Files
supabase/apps/studio/components/interfaces/Settings/Logs/Logs.UpdateSavedQueryModal.tsx
T
Jonathan Summers-Muir 972773ca87 [Dashboard] Chore: update Modal component to use new components (#26844)
* init

* add more examples

* update modal

* update modals

* more modals updated

* update modal

* Update NewAccessTokenButton.tsx

* Update NewAccessTokenButton.tsx

* fix: issue with scale on dialog opening. chore: added bg-dialog color

* fix modals

* add deprecation notices

* revert bg

* revert

* Update Modal.tsx

* Update PITRSelection.tsx

* update dialog docs

* fix: issue with payment method modal

* update terminal instructions

* update padding defaults
2024-06-05 10:06:55 +00:00

72 lines
1.8 KiB
TypeScript

import { Button, Form, Input, Modal } from 'ui'
type SavedQuery = { name: string; description: string | null }
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="small"
>
<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>
)
}