mirror of
https://github.com/supabase/supabase.git
synced 2026-06-21 21:12:49 +08:00
* add log explorer query deletion, align table vertically, fix longer descriptions breaking table layout * undo change in logsexplorer indexts, rm unused import * add update query feature * use IconMoreVertical in users table * add err handler and loading button while deleting a query * disable save btn while saving new query * fix tiny nit --------- Co-authored-by: Alaister Young <a@alaisteryoung.com>
74 lines
1.9 KiB
TypeScript
74 lines
1.9 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 }) => (
|
|
<div className="space-y-4 py-4">
|
|
<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>
|
|
<div 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>
|
|
</div>
|
|
</Modal.Content>
|
|
</div>
|
|
)}
|
|
</Form>
|
|
</Modal>
|
|
)
|
|
}
|