mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 00:16:00 +00:00
saved sql files
This commit is contained in:
38
packages/web/src/modals/SaveSqlFileModal.js
Normal file
38
packages/web/src/modals/SaveSqlFileModal.js
Normal file
@@ -0,0 +1,38 @@
|
||||
import React from 'react';
|
||||
import axios from '../utility/axios';
|
||||
import ModalBase from './ModalBase';
|
||||
import { FormRow, FormButton, FormTextField, FormSelectField, FormSubmit } from '../utility/forms';
|
||||
import { TextField } from '../utility/inputs';
|
||||
import { Formik, Form } from 'formik';
|
||||
import { useSetSavedSqlFiles } from '../utility/globalState';
|
||||
// import FormikForm from '../utility/FormikForm';
|
||||
|
||||
export default function SaveSqlFileModal({ storageKey, modalState, name, onSave = undefined }) {
|
||||
const setSavedSqlFiles = useSetSavedSqlFiles();
|
||||
const handleSubmit = async (values) => {
|
||||
const { name } = values;
|
||||
setSavedSqlFiles((files) => [
|
||||
...files.filter((x) => x.storageKey != storageKey),
|
||||
{
|
||||
name,
|
||||
storageKey,
|
||||
},
|
||||
]);
|
||||
modalState.close();
|
||||
if (onSave) onSave(name);
|
||||
};
|
||||
return (
|
||||
<ModalBase modalState={modalState}>
|
||||
<h2>Save SQL file</h2>
|
||||
<Formik onSubmit={handleSubmit} initialValues={{ name }}>
|
||||
<Form>
|
||||
<FormTextField label="File name" name="name" />
|
||||
|
||||
<FormRow>
|
||||
<FormSubmit text="Save" />
|
||||
</FormRow>
|
||||
</Form>
|
||||
</Formik>
|
||||
</ModalBase>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user