mirror of
https://github.com/supabase/supabase.git
synced 2026-10-08 02:45:07 +03:00
* ui redesign * when on a saved query and clicking save, it updates existing query * fix styles in create dropdown, sticky search * fix update type err * fix payload type in logs content update * fix bug with navigation when clicking dropdown items * use same dialog ui patterns * cleanup unused stuff * rm unused component * truncate sidebar element labels * align end in dropdowns, fix zindex issue w expandable sidebar * add empty state to queries section * top left of the screen
72 lines
1.8 KiB
TypeScript
72 lines
1.8 KiB
TypeScript
import { Button, Form, Input, Modal } from 'ui'
|
|
|
|
type SavedQuery = { name: string; description?: string }
|
|
|
|
export interface UpdateSavedQueryProps {
|
|
visible: boolean
|
|
onCancel: () => void
|
|
onSubmit: (newValues: SavedQuery) => void
|
|
initialValues: SavedQuery
|
|
}
|
|
|
|
export const UpdateSavedQueryModal = ({
|
|
visible,
|
|
onCancel,
|
|
onSubmit,
|
|
initialValues,
|
|
}: UpdateSavedQueryProps) => {
|
|
function validate(values: SavedQuery) {
|
|
const errors: Partial<SavedQuery> = {}
|
|
|
|
if (!values.name) {
|
|
errors.name = 'Required'
|
|
}
|
|
|
|
return errors
|
|
}
|
|
|
|
return (
|
|
<Modal
|
|
visible={visible}
|
|
onCancel={onCancel}
|
|
hideFooter
|
|
header="Update saved query"
|
|
size="medium"
|
|
>
|
|
<Form
|
|
onReset={onCancel}
|
|
validateOnBlur
|
|
initialValues={initialValues}
|
|
validate={validate}
|
|
onSubmit={onSubmit}
|
|
>
|
|
{({ isSubmitting }: { isSubmitting: boolean }) => (
|
|
<>
|
|
<Modal.Content>
|
|
<Input label="Name" id="name" name="name" />
|
|
</Modal.Content>
|
|
<Modal.Content>
|
|
<Input.TextArea
|
|
label="Description"
|
|
id="description"
|
|
placeholder="Describe query"
|
|
size="medium"
|
|
textAreaClassName="resize-none"
|
|
/>
|
|
</Modal.Content>
|
|
<Modal.Separator />
|
|
<Modal.Content className="flex items-center justify-end gap-2">
|
|
<Button htmlType="reset" type="default" onClick={onCancel} disabled={isSubmitting}>
|
|
Cancel
|
|
</Button>
|
|
<Button htmlType="submit" loading={isSubmitting} disabled={isSubmitting}>
|
|
Save query
|
|
</Button>
|
|
</Modal.Content>
|
|
</>
|
|
)}
|
|
</Form>
|
|
</Modal>
|
|
)
|
|
}
|