Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

chore: update SQL rename modal

Jonathan Summers-Muirc24ff33de026
diff --git a/studio/components/layouts/SQLEditorLayout/SQLEditorMenuOld.tsx b/studio/components/layouts/SQLEditorLayout/SQLEditorMenuOld.tsx
index 3ac56b42485..f577ba27304 100644
--- a/studio/components/layouts/SQLEditorLayout/SQLEditorMenuOld.tsx
+++ b/studio/components/layouts/SQLEditorLayout/SQLEditorMenuOld.tsx
@@ -15,6 +15,7 @@ import {
IconTrash,
IconChevronDown,
Loading,
+ Modal,
} from '@supabase/ui'
import { IS_PLATFORM } from 'lib/constants'
@@ -22,7 +23,6 @@ import { useStore } from 'hooks'
import { useProjectContentStore } from 'stores/projectContentStore'
import { useSqlStore, TAB_TYPES } from 'localStores/sqlEditor/SqlEditorStore'
-import Modal from 'components/to-be-cleaned/ModalsDeprecated/Modal'
import { confirmAlert } from 'components/to-be-cleaned/ModalsDeprecated/ConfirmModal'
import RenameQuery from 'components/to-be-cleaned/SqlEditor/RenameQuery'
import { createSqlSnippet } from 'components/to-be-cleaned/SqlEditor/SqlEditor.utils'
@@ -96,11 +96,13 @@ const DropdownMenu = observer(({ tabInfo }: { tabInfo: any }) => {
<Button as="span" type="text" style={{ padding: '3px' }} />
)}
- {/* @ts-ignore */}
- <Modal open={renameModalOpen} handleCloseEvent={onCloseRenameModal}>
- {/* @ts-ignore */}
- <RenameQuery tabId={tabId} onComplete={onCloseRenameModal} />
- </Modal>
+ <RenameQuery
+ // @ts-ignore -- @mildtomato not sure what is wrong here
+ visible={renameModalOpen}
+ onCancel={onCloseRenameModal}
+ tabId={tabId}
+ onComplete={onCloseRenameModal}
+ />
</div>
)
})
@@ -163,42 +165,36 @@ const SideBarContent = observer(() => {
: queries.filter((tab: any) => tab.name.includes(filterString))
return (
- <div className="mt-8">
- <Menu>
+ <div className="mt-6">
+ <Menu type="pills">
{IS_PLATFORM && (
- <div className="my-4 px-3 space-y-1">
- <Menu.Misc>
- <Button
- block
- className="mx-1"
- icon={<IconPlus />}
- type="text"
- style={{ justifyContent: 'start' }}
- onClick={() => handleNewQuery()}
- loading={loadingNewQuery}
- >
- New query
- </Button>
- </Menu.Misc>
- <Menu.Misc>
- <Input
- icon={<IconSearch size="tiny" />}
- className="sbui-input-no-border mx-1"
- placeholder="Search"
- onChange={(e) => setFilterString(e.target.value)}
- value={filterString}
- size="tiny"
- actions={
- filterString && (
- <IconX
- size={'tiny'}
- className="cursor-pointer mr-2"
- onClick={() => setFilterString('')}
- />
- )
- }
- />
- </Menu.Misc>
+ <div className="my-4 px-3 space-y-1 mx-3">
+ <Button
+ block
+ icon={<IconPlus />}
+ type="default"
+ style={{ justifyContent: 'start' }}
+ onClick={() => handleNewQuery()}
+ loading={loadingNewQuery}
+ >
+ New query
+ </Button>
+ <Input
+ icon={<IconSearch size="tiny" />}
+ placeholder="Search"
+ onChange={(e) => setFilterString(e.target.value)}
+ value={filterString}
+ size="tiny"
+ actions={
+ filterString && (
+ <IconX
+ size={'tiny'}
+ className="cursor-pointer mr-2"
+ onClick={() => setFilterString('')}
+ />
+ )
+ }
+ />
</div>
)}
diff --git a/studio/components/to-be-cleaned/ModalsDeprecated/TextConfirmModal.js b/studio/components/to-be-cleaned/ModalsDeprecated/TextConfirmModal.js
index f6e5b6d5534..6158dff956e 100644
--- a/studio/components/to-be-cleaned/ModalsDeprecated/TextConfirmModal.js
+++ b/studio/components/to-be-cleaned/ModalsDeprecated/TextConfirmModal.js
@@ -1,5 +1,5 @@
import { useState, useEffect } from 'react'
-import { Modal, Button, Typography, IconAlertCircle, Divider, Input } from '@supabase/ui'
+import { Modal, Button, Typography, IconAlertCircle, Divider, Input, Alert } from '@supabase/ui'
export default function TextConfirmModal({
title,
@@ -26,10 +26,10 @@ export default function TextConfirmModal({
<Modal
size="small"
visible={visible}
- title={title}
+ header={title}
customFooter={
<>
- <div className="space-x-2 w-full">
+ <div className="w-full">
<Button
danger
disabled={confirmValue != confirmString}
@@ -48,32 +48,33 @@ export default function TextConfirmModal({
onCancel={onCancel}
closable
>
- <div className="w-full">
+ <div className="w-full py-4">
<div className="space-y-4">
{alert && (
- <div className="block w-full bg-yellow-500 bg-opacity-5 p-3 border border-yellow-500 border-opacity-50 rounded">
- <div className="flex space-x-3">
- <div>
- <IconAlertCircle className="text-yellow-500" size="large" />
- </div>
- <Typography.Text type="warning">{alert}</Typography.Text>
- </div>
- </div>
+ <Modal.Content>
+ <Alert variant="warning" withIcon title={alert} />
+ </Modal.Content>
)}
- <Typography.Text className="block">
- <p className="mb-2 text-sm">{text}</p>
- </Typography.Text>
- <Divider light />
- <Typography.Text className="block">
- <p className="text-sm">
- Type <span className="dark:text-white font-medium">{confirmString}</span> to confirm.
- </p>
- </Typography.Text>
- <Input
- value={confirmValue}
- onChange={(e) => setConfirmValue(e.target.value)}
- placeholder={confirmPlaceholder}
- />
+ <Modal.Content>
+ <Typography.Text className="block">
+ <p className="mb-2 text-sm">{text}</p>
+ </Typography.Text>
+ </Modal.Content>
+ <Modal.Seperator />
+ <Modal.Content>
+ <Input
+ label={
+ <>
+ <span>
+ Type <span className="text-scale-1200">{confirmString}</span> to confirm.
+ </span>
+ </>
+ }
+ value={confirmValue}
+ onChange={(e) => setConfirmValue(e.target.value)}
+ placeholder={confirmPlaceholder}
+ />
+ </Modal.Content>
</div>
</div>
</Modal>
diff --git a/studio/components/to-be-cleaned/SqlEditor/RenameQuery.js b/studio/components/to-be-cleaned/SqlEditor/RenameQuery.js
index 7b9c2c0ec32..824cbe458c7 100644
--- a/studio/components/to-be-cleaned/SqlEditor/RenameQuery.js
+++ b/studio/components/to-be-cleaned/SqlEditor/RenameQuery.js
@@ -1,14 +1,13 @@
import React from 'react'
import { observer } from 'mobx-react-lite'
import { useRouter } from 'next/router'
-import { AutoField } from 'uniforms-bootstrap4'
-import SchemaFormPanel from 'components/to-be-cleaned/forms/SchemaFormPanel'
import { useStore } from 'hooks'
import { useSqlStore } from 'localStores/sqlEditor/SqlEditorStore'
import { useProjectContentStore } from 'stores/projectContentStore'
+import { Button, Form, Input, Modal } from '@supabase/ui'
-const RenameQuery = observer(({ tabId, onComplete }) => {
+const RenameQuery = observer(({ tabId, onComplete, visible, onCancel }) => {
const { ui } = useStore()
const router = useRouter()
@@ -50,33 +49,49 @@ const RenameQuery = observer(({ tabId, onComplete }) => {
}
}
- function onCancel() {
- if (onComplete) onComplete()
- }
-
return (
- <SchemaFormPanel
- title="Rename"
- schema={{
- properties: {
- name: { title: 'Name', type: 'string' },
- desc: { title: 'Description', type: 'string' },
- },
- required: ['name'],
- type: 'object',
- }}
- model={model}
- onSubmit={onRename}
- onReset={onCancel}
- >
- <AutoField
- name="name"
- inputRef={(x) => x?.focus()}
- showInlineError
- errorMessage="Please enter a query name"
- />
- <AutoField name="desc" placeholder="Describe query" />
- </SchemaFormPanel>
+ <Modal visible={visible} onCancel={onCancel} hideFooter header="Rename" size="small">
+ <Form
+ onReset={onCancel}
+ validateOnBlur
+ initialValues={{
+ name: model ? model.name : '',
+ description: model ? model.desc : '',
+ }}
+ validate={(values) => {
+ const errors = {}
+ if (!values.name) errors.name = 'Please enter a query name'
+ return errors
+ }}
+ onSubmit={async (values, { setSubmitting }) => {
+ setSubmitting(true)
+ await onRename(values)
+ setSubmitting(false)
+ }}
+ >
+ {({ isSubmitting }) => (
+ <div className="py-4 space-y-4">
+ <Modal.Content>
+ <Input label="Name" id="name" name="name" />
+ </Modal.Content>
+ <Modal.Content>
+ <Input label="Description" id="desc" placeholder="Describe query" />
+ </Modal.Content>
+ <Modal.Seperator />
+ <Modal.Content>
+ <div className="flex items-center justify-end gap-2">
+ <Button htmlType="reset" type="default" onClick={onCancel}>
+ Cancel
+ </Button>
+ <Button htmlType="submit" loading={isSubmitting}>
+ Rename query
+ </Button>
+ </div>
+ </Modal.Content>
+ </div>
+ )}
+ </Form>
+ </Modal>
)
})
diff --git a/studio/components/to-be-cleaned/Storage/DeleteBucketModal.tsx b/studio/components/to-be-cleaned/Storage/DeleteBucketModal.tsx
index 8e8747a5b88..c77379a24e7 100644
--- a/studio/components/to-be-cleaned/Storage/DeleteBucketModal.tsx
+++ b/studio/components/to-be-cleaned/Storage/DeleteBucketModal.tsx
@@ -1,5 +1,5 @@
import { FC, useEffect, useState } from 'react'
-import { Modal, Button, Input, Space, Typography } from '@supabase/ui'
+import TextConfirmModal from '../ModalsDeprecated/TextConfirmModal'
interface Props {
visible: boolean
@@ -28,43 +28,18 @@ const DeleteBucketModal: FC<Props> = ({
}
return (
- <Modal
+ <TextConfirmModal
visible={visible}
title={`Confirm deletion of ${bucket.name}`}
- description="Are you sure you want to delete the selected bucket? This action cannot be undone."
- size="small"
- customFooter={
- <Space>
- <Button type="secondary" onClick={onSelectCancel}>
- Cancel
- </Button>
- <Button
- type="primary"
- danger
- loading={deleting}
- onClick={onConfirmDelete}
- disabled={bucket.name !== validationInput}
- >
- {deleting ? 'Deleting' : 'Delete'}
- </Button>
- </Space>
- }
- >
- <div className="w-full">
- <p className="mb-2 text-sm">
- <Typography.Text>
- Please type <span className="font-bold">{bucket.name}</span> to confirm
- </Typography.Text>
- </p>
- <Input
- autoFocus
- type="text"
- className="w-full"
- value={validationInput}
- onChange={(event) => setValidationInput(event.target.value)}
- />
- </div>
- </Modal>
+ confirmPlaceholder="Type in name of bucket"
+ onConfirm={onConfirmDelete}
+ onCancel={onSelectCancel}
+ confirmString={bucket.name}
+ loading={deleting}
+ text={`This will delete your bucket called ${bucket.name}.`}
+ alert="You cannot recover this bucket once it is deleted!"
+ confirmLabel={`Delete bucket ${bucket.name}`}
+ />
)
}