Skip to content

Commit ef02eb6

Browse files
realtime: Add Allow Public Access toggle back to Realtime Configuration (supabase#36708)
* realtime: Add Allow Public Access toggle back to Realtime Configuration * Smol fix --------- Co-authored-by: Joshen Lim <[email protected]>
1 parent 5cb2ce1 commit ef02eb6

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

apps/studio/components/interfaces/Realtime/RealtimeSettings.tsx

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ import {
2929
FormField_Shadcn_,
3030
FormMessage_Shadcn_,
3131
Input_Shadcn_,
32+
Switch,
3233
} from 'ui'
3334
import { Admonition } from 'ui-patterns'
35+
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
3436

3537
const formId = 'realtime-configuration-form'
3638

@@ -70,25 +72,22 @@ export const RealtimeSettings = () => {
7072
// max_channels_per_client: z.coerce.number().min(1).max(10000),
7173
// max_joins_per_second: z.coerce.number().min(1).max(5000),
7274

73-
// [Filipe] This field is temporarily hidden from the UI
74-
// allow_public: z.boolean(),
75+
allow_public: z.boolean(),
7576
})
7677

7778
const form = useForm<z.infer<typeof FormSchema>>({
7879
resolver: zodResolver(FormSchema),
7980
defaultValues: {
8081
...REALTIME_DEFAULT_CONFIG,
81-
// [Filipe] This field is temporarily hidden from the UI
82-
// allow_public: !REALTIME_DEFAULT_CONFIG.private_only,
82+
allow_public: !REALTIME_DEFAULT_CONFIG.private_only,
8383
},
8484
})
8585

8686
const onSubmit: SubmitHandler<z.infer<typeof FormSchema>> = (data) => {
8787
if (!projectRef) return console.error('Project ref is required')
8888
updateRealtimeConfig({
8989
ref: projectRef,
90-
// [Filipe] This field is temporarily hidden from the UI
91-
// private_only: !data.allow_public,
90+
private_only: !data.allow_public,
9291
connection_pool: data.connection_pool,
9392
max_concurrent_users: data.max_concurrent_users,
9493
})
@@ -97,10 +96,9 @@ export const RealtimeSettings = () => {
9796
useEffect(() => {
9897
// [Joshen] Temp typed with any - API typing marks all the properties as nullable,
9998
// but checked with Filipe that they're not supposed to
100-
// [Filipe] This field is temporarily hidden from the UI
101-
// if (data) form.reset({ ...data, allow_public: !data.private_only } as any)
102-
103-
if (data) form.reset({ ...data } as any)
99+
if (isSuccess) {
100+
form.reset({ ...data, allow_public: !data.private_only } as any)
101+
}
104102
}, [isSuccess])
105103

106104
return (
@@ -111,10 +109,7 @@ export const RealtimeSettings = () => {
111109
<AlertError error={error} subject="Failed to retrieve realtime settings" />
112110
) : (
113111
<Card>
114-
{/*
115-
[Filipe] We're hidding this field until we implement a 'kill all sockets` on change to be triggered in realtime server
116-
*/}
117-
{/* <CardContent>
112+
<CardContent>
118113
<FormField_Shadcn_
119114
control={form.control}
120115
name="allow_public"
@@ -141,7 +136,7 @@ export const RealtimeSettings = () => {
141136
</FormSection>
142137
)}
143138
/>
144-
</CardContent> */}
139+
</CardContent>
145140
<CardContent>
146141
<FormField_Shadcn_
147142
control={form.control}

0 commit comments

Comments
 (0)