Skip to content

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

chore: migrate realtime `Modal` to `Dialog` (#46284)

Gildas Garcia6b7f2f27defc
diff --git a/apps/studio/components/interfaces/Realtime/Inspector/ChooseChannelPopover.tsx b/apps/studio/components/interfaces/Realtime/Inspector/ChooseChannelPopover.tsx
index 5171ac96264..706fd5513c2 100644
--- a/apps/studio/components/interfaces/Realtime/Inspector/ChooseChannelPopover.tsx
+++ b/apps/studio/components/interfaces/Realtime/Inspector/ChooseChannelPopover.tsx
@@ -11,7 +11,10 @@ import {
FormField,
FormItem,
FormLabel,
- Input,
+ InputGroup,
+ InputGroupAddon,
+ InputGroupButton,
+ InputGroupInput,
Popover,
PopoverContent,
PopoverTrigger,
@@ -140,25 +143,25 @@ export const ChooseChannelPopover = ({
<FormItem className="flex flex-col gap-y-2">
<div className="flex flex-col gap-y-1">
<label className="text-foreground text-xs">Name of channel</label>
- <div className="flex flex-row">
+ <InputGroup>
<FormControl>
- <Input
+ <InputGroupInput
{...field}
autoComplete="off"
className="rounded-r-none text-xs px-2.5 py-1 h-auto"
placeholder="Enter a channel name"
/>
</FormControl>
-
- <Button
- type="primary"
- className="rounded-l-none"
- disabled={form.getValues().channel.length === 0}
- onClick={() => onSubmit()}
- >
- Listen to channel
- </Button>
- </div>
+ <InputGroupAddon align="inline-end">
+ <InputGroupButton
+ type="primary"
+ disabled={form.getValues().channel.length === 0}
+ onClick={() => onSubmit()}
+ >
+ Listen to channel
+ </InputGroupButton>
+ </InputGroupAddon>
+ </InputGroup>
</div>
<FormDescription className="text-xs text-foreground-lighter">
The channel you initialize with the Supabase Realtime client. Learn more
diff --git a/apps/studio/components/interfaces/Realtime/Inspector/SendMessageModal.tsx b/apps/studio/components/interfaces/Realtime/Inspector/SendMessageModal.tsx
index cee116fd3ba..41c0adcd491 100644
--- a/apps/studio/components/interfaces/Realtime/Inspector/SendMessageModal.tsx
+++ b/apps/studio/components/interfaces/Realtime/Inspector/SendMessageModal.tsx
@@ -1,5 +1,15 @@
import { useEffect, useState } from 'react'
-import { Input, Modal } from 'ui'
+import {
+ Button,
+ Dialog,
+ DialogContent,
+ DialogFooter,
+ DialogHeader,
+ DialogSection,
+ DialogSectionSeparator,
+ DialogTitle,
+ Input,
+} from 'ui'
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
import CodeEditor from '@/components/ui/CodeEditor/CodeEditor'
@@ -32,47 +42,58 @@ export const SendMessageModal = ({
}, [visible])
return (
- <Modal
- size="medium"
- alignFooter="right"
- header="Broadcast a message to all clients"
- visible={visible}
- loading={false}
- onCancel={onSelectCancel}
- onConfirm={() => {
- const payload = tryParseJson(values.payload)
- if (payload === undefined) {
- setError('Please provide a valid JSON')
- } else {
- onSelectConfirm({ ...values, payload })
- }
- }}
- >
- <Modal.Content className="flex flex-col gap-y-4">
- <FormItemLayout label="Message name" layout="vertical" isReactForm={false}>
- <Input
- size="small"
- value={values.message}
- onChange={(v) => setValues({ ...values, message: v.target.value })}
- />
- </FormItemLayout>
+ <Dialog open={visible} onOpenChange={onSelectCancel}>
+ <DialogContent>
+ <DialogHeader>
+ <DialogTitle>Broadcast a message to all clients</DialogTitle>
+ </DialogHeader>
+ <DialogSectionSeparator />
+ <DialogSection>
+ <div className="flex flex-col gap-y-4">
+ <FormItemLayout label="Message name" layout="vertical" isReactForm={false}>
+ <Input
+ size="small"
+ value={values.message}
+ onChange={(v) => setValues({ ...values, message: v.target.value })}
+ />
+ </FormItemLayout>
- <div className="flex flex-col gap-y-2">
- <FormItemLayout label="Message payload" layout="vertical" isReactForm={false}>
- <CodeEditor
- id="message-payload"
- language="json"
- className="mb-0! h-32 overflow-hidden rounded-sm border"
- onInputChange={(e: string | undefined) =>
- setValues({ ...values, payload: e ?? '{}' })
+ <div className="flex flex-col gap-y-2">
+ <FormItemLayout label="Message payload" layout="vertical" isReactForm={false}>
+ <CodeEditor
+ id="message-payload"
+ language="json"
+ className="mb-0! h-32 overflow-hidden rounded-sm border"
+ onInputChange={(e: string | undefined) =>
+ setValues({ ...values, payload: e ?? '{}' })
+ }
+ options={{ wordWrap: 'off', contextmenu: false }}
+ value={values.payload}
+ />
+ {error !== undefined && <p className="text-sm text-red-900">{error}</p>}
+ </FormItemLayout>
+ </div>
+ </div>
+ </DialogSection>
+ <DialogFooter>
+ <Button onClick={onSelectCancel} type="default">
+ Cancel
+ </Button>
+ <Button
+ onClick={() => {
+ const payload = tryParseJson(values.payload)
+ if (payload === undefined) {
+ setError('Please provide a valid JSON')
+ } else {
+ onSelectConfirm({ ...values, payload })
}
- options={{ wordWrap: 'off', contextmenu: false }}
- value={values.payload}
- />
- {error !== undefined && <p className="text-sm text-red-900">{error}</p>}
- </FormItemLayout>
- </div>
- </Modal.Content>
- </Modal>
+ }}
+ type="primary"
+ >
+ Confirm
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
)
}