mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-28 01:26:01 +00:00
refactor
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ModalBase from './ModalBase';
|
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 ModalHeader from './ModalHeader';
|
||||||
import ModalContent from './ModalContent';
|
import ModalContent from './ModalContent';
|
||||||
import ModalFooter from './ModalFooter';
|
import ModalFooter from './ModalFooter';
|
||||||
@@ -8,7 +8,6 @@ import { FormProvider, useForm } from '../utility/FormProvider';
|
|||||||
import axios from '../utility/axios';
|
import axios from '../utility/axios';
|
||||||
import uuidv1 from 'uuid/v1';
|
import uuidv1 from 'uuid/v1';
|
||||||
import { FontIcon } from '../icons';
|
import { FontIcon } from '../icons';
|
||||||
import { FormFieldTemplateDefault } from '../utility/formStyle';
|
|
||||||
|
|
||||||
function FontIconPreview() {
|
function FontIconPreview() {
|
||||||
const { values } = useForm();
|
const { values } = useForm();
|
||||||
@@ -93,9 +92,9 @@ export default function FavoriteModal({ modalState, editingData = undefined, sav
|
|||||||
<ModalContent>
|
<ModalContent>
|
||||||
<FormTextField label="Title" name="title" focused />
|
<FormTextField label="Title" name="title" focused />
|
||||||
<FormTextField label="Icon" name="icon" />
|
<FormTextField label="Icon" name="icon" />
|
||||||
<FormFieldTemplateDefault label="Icon preview" type="icon">
|
<FormFieldTemplate label="Icon preview" type="icon">
|
||||||
<FontIconPreview />
|
<FontIconPreview />
|
||||||
</FormFieldTemplateDefault>
|
</FormFieldTemplate>
|
||||||
<FormCheckboxField label="Show in toolbar" name="showInToolbar" />
|
<FormCheckboxField label="Show in toolbar" name="showInToolbar" />
|
||||||
<FormCheckboxField label="Open on startup" name="openOnStartup" />
|
<FormCheckboxField label="Open on startup" name="openOnStartup" />
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ModalBase from './ModalBase';
|
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 styled from 'styled-components';
|
||||||
import ModalHeader from './ModalHeader';
|
import ModalHeader from './ModalHeader';
|
||||||
import ModalContent from './ModalContent';
|
import ModalContent from './ModalContent';
|
||||||
import ModalFooter from './ModalFooter';
|
import ModalFooter from './ModalFooter';
|
||||||
import { FormProvider } from '../utility/FormProvider';
|
import { FormProvider } from '../utility/FormProvider';
|
||||||
import { FormFieldTemplateDefault } from '../utility/formStyle';
|
|
||||||
|
|
||||||
const SelectWrapper = styled.div`
|
const SelectWrapper = styled.div`
|
||||||
width: 150px;
|
width: 150px;
|
||||||
@@ -25,11 +24,11 @@ export default function SaveArchiveModal({ file = 'new-table', folder = 'default
|
|||||||
<ModalHeader modalState={modalState}>Save to archive</ModalHeader>
|
<ModalHeader modalState={modalState}>Save to archive</ModalHeader>
|
||||||
<FormProvider initialValues={{ file, folder }}>
|
<FormProvider initialValues={{ file, folder }}>
|
||||||
<ModalContent>
|
<ModalContent>
|
||||||
<FormFieldTemplateDefault label="Folder" type="select">
|
<FormFieldTemplate label="Folder" type="select">
|
||||||
<SelectWrapper>
|
<SelectWrapper>
|
||||||
<FormArchiveFolderSelect name="folder" />
|
<FormArchiveFolderSelect name="folder" />
|
||||||
</SelectWrapper>
|
</SelectWrapper>
|
||||||
</FormFieldTemplateDefault>
|
</FormFieldTemplate>
|
||||||
<FormTextField label="File name" name="file" />
|
<FormTextField label="File name" name="file" />
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
<ModalFooter>
|
<ModalFooter>
|
||||||
|
|||||||
@@ -15,6 +15,14 @@ import axios from './axios';
|
|||||||
import useTheme from '../theme/useTheme';
|
import useTheme from '../theme/useTheme';
|
||||||
import { useForm, useFormFieldTemplate } from './FormProvider';
|
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 }) {
|
export function FormTextFieldRaw({ name, focused = false, ...other }) {
|
||||||
const { values, setFieldValue } = useForm();
|
const { values, setFieldValue } = useForm();
|
||||||
|
|||||||
@@ -14,9 +14,7 @@ import { getDefaultFileFormat } from '../utility/fileformats';
|
|||||||
import getElectron from '../utility/getElectron';
|
import getElectron from '../utility/getElectron';
|
||||||
import AboutModal from '../modals/AboutModal';
|
import AboutModal from '../modals/AboutModal';
|
||||||
import useOpenNewTab from '../utility/useOpenNewTab';
|
import useOpenNewTab from '../utility/useOpenNewTab';
|
||||||
import axios from '../utility/axios';
|
|
||||||
import tabs from '../tabs';
|
import tabs from '../tabs';
|
||||||
import uuidv1 from 'uuid/v1';
|
|
||||||
import FavoriteModal from '../modals/FavoriteModal';
|
import FavoriteModal from '../modals/FavoriteModal';
|
||||||
|
|
||||||
const ToolbarContainer = styled.div`
|
const ToolbarContainer = styled.div`
|
||||||
@@ -84,28 +82,6 @@ export default function ToolBar({ toolbarPortalRef }) {
|
|||||||
|
|
||||||
const addToFavorite = () => {
|
const addToFavorite = () => {
|
||||||
showModal((modalState) => <FavoriteModal modalState={modalState} savingTab={currentTab} />);
|
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) {
|
function openTabFromButton(page) {
|
||||||
|
|||||||
Reference in New Issue
Block a user