mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-20 00:46:01 +00:00
refactor
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import ModalBase from './ModalBase';
|
||||
import { FormTextField, FormSubmit, FormButton, FormCheckboxField } from '../utility/forms';
|
||||
import { FormTextField, FormSubmit, FormButton, FormCheckboxField, FormFieldTemplate } from '../utility/forms';
|
||||
import ModalHeader from './ModalHeader';
|
||||
import ModalContent from './ModalContent';
|
||||
import ModalFooter from './ModalFooter';
|
||||
@@ -8,7 +8,6 @@ import { FormProvider, useForm } from '../utility/FormProvider';
|
||||
import axios from '../utility/axios';
|
||||
import uuidv1 from 'uuid/v1';
|
||||
import { FontIcon } from '../icons';
|
||||
import { FormFieldTemplateDefault } from '../utility/formStyle';
|
||||
|
||||
function FontIconPreview() {
|
||||
const { values } = useForm();
|
||||
@@ -93,9 +92,9 @@ export default function FavoriteModal({ modalState, editingData = undefined, sav
|
||||
<ModalContent>
|
||||
<FormTextField label="Title" name="title" focused />
|
||||
<FormTextField label="Icon" name="icon" />
|
||||
<FormFieldTemplateDefault label="Icon preview" type="icon">
|
||||
<FormFieldTemplate label="Icon preview" type="icon">
|
||||
<FontIconPreview />
|
||||
</FormFieldTemplateDefault>
|
||||
</FormFieldTemplate>
|
||||
<FormCheckboxField label="Show in toolbar" name="showInToolbar" />
|
||||
<FormCheckboxField label="Open on startup" name="openOnStartup" />
|
||||
</ModalContent>
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import React from 'react';
|
||||
import ModalBase from './ModalBase';
|
||||
import { FormTextField, FormSubmit, FormArchiveFolderSelect } from '../utility/forms';
|
||||
import { FormTextField, FormSubmit, FormArchiveFolderSelect, FormFieldTemplate } from '../utility/forms';
|
||||
import styled from 'styled-components';
|
||||
import ModalHeader from './ModalHeader';
|
||||
import ModalContent from './ModalContent';
|
||||
import ModalFooter from './ModalFooter';
|
||||
import { FormProvider } from '../utility/FormProvider';
|
||||
import { FormFieldTemplateDefault } from '../utility/formStyle';
|
||||
|
||||
const SelectWrapper = styled.div`
|
||||
width: 150px;
|
||||
@@ -25,11 +24,11 @@ export default function SaveArchiveModal({ file = 'new-table', folder = 'default
|
||||
<ModalHeader modalState={modalState}>Save to archive</ModalHeader>
|
||||
<FormProvider initialValues={{ file, folder }}>
|
||||
<ModalContent>
|
||||
<FormFieldTemplateDefault label="Folder" type="select">
|
||||
<FormFieldTemplate label="Folder" type="select">
|
||||
<SelectWrapper>
|
||||
<FormArchiveFolderSelect name="folder" />
|
||||
</SelectWrapper>
|
||||
</FormFieldTemplateDefault>
|
||||
</FormFieldTemplate>
|
||||
<FormTextField label="File name" name="file" />
|
||||
</ModalContent>
|
||||
<ModalFooter>
|
||||
|
||||
@@ -15,6 +15,14 @@ import axios from './axios';
|
||||
import useTheme from '../theme/useTheme';
|
||||
import { useForm, useFormFieldTemplate } from './FormProvider';
|
||||
|
||||
export function FormFieldTemplate({ label, children, type }) {
|
||||
const FieldTemplate = useFormFieldTemplate();
|
||||
return (
|
||||
<FieldTemplate label={label} type={type}>
|
||||
{children}
|
||||
</FieldTemplate>
|
||||
);
|
||||
}
|
||||
|
||||
export function FormTextFieldRaw({ name, focused = false, ...other }) {
|
||||
const { values, setFieldValue } = useForm();
|
||||
|
||||
@@ -14,9 +14,7 @@ import { getDefaultFileFormat } from '../utility/fileformats';
|
||||
import getElectron from '../utility/getElectron';
|
||||
import AboutModal from '../modals/AboutModal';
|
||||
import useOpenNewTab from '../utility/useOpenNewTab';
|
||||
import axios from '../utility/axios';
|
||||
import tabs from '../tabs';
|
||||
import uuidv1 from 'uuid/v1';
|
||||
import FavoriteModal from '../modals/FavoriteModal';
|
||||
|
||||
const ToolbarContainer = styled.div`
|
||||
@@ -84,28 +82,6 @@ export default function ToolBar({ toolbarPortalRef }) {
|
||||
|
||||
const addToFavorite = () => {
|
||||
showModal((modalState) => <FavoriteModal modalState={modalState} savingTab={currentTab} />);
|
||||
// const tabdata = {};
|
||||
|
||||
// const re = new RegExp(`tabdata_(.*)_${currentTab.tabid}`);
|
||||
// for (const key in localStorage) {
|
||||
// const match = key.match(re);
|
||||
// if (!match) continue;
|
||||
// if (match[1] == 'editor') continue;
|
||||
// tabdata[match[1]] = JSON.parse(localStorage.getItem(key));
|
||||
// }
|
||||
|
||||
// axios.post('files/save', {
|
||||
// folder: 'favorites',
|
||||
// file: uuidv1(),
|
||||
// format: 'json',
|
||||
// data: {
|
||||
// title: currentTab.title,
|
||||
// icon: currentTab.icon,
|
||||
// props: currentTab.props,
|
||||
// tabComponent: currentTab.tabComponent,
|
||||
// tabdata,
|
||||
// },
|
||||
// });
|
||||
};
|
||||
|
||||
function openTabFromButton(page) {
|
||||
|
||||
Reference in New Issue
Block a user