From 09ae9038eccc6bb028a21355c40ff9b654830ed9 Mon Sep 17 00:00:00 2001 From: Francesco Sansalvadore Date: Mon, 15 Dec 2025 18:33:58 +0100 Subject: [PATCH] chore(studio): realtime settings form patterns (#41275) --- .../interfaces/Realtime/RealtimeSettings.tsx | 533 ++++++++---------- .../pages/project/[ref]/realtime/settings.tsx | 4 +- 2 files changed, 233 insertions(+), 304 deletions(-) diff --git a/apps/studio/components/interfaces/Realtime/RealtimeSettings.tsx b/apps/studio/components/interfaces/Realtime/RealtimeSettings.tsx index 43b57533bf0..f235598abe9 100644 --- a/apps/studio/components/interfaces/Realtime/RealtimeSettings.tsx +++ b/apps/studio/components/interfaces/Realtime/RealtimeSettings.tsx @@ -8,7 +8,6 @@ import * as z from 'zod' import { useParams } from 'common' import AlertError from 'components/ui/AlertError' -import { FormSection, FormSectionContent, FormSectionLabel } from 'components/ui/Forms/FormSection' import { ToggleSpendCapButton } from 'components/ui/ToggleSpendCapButton' import { UpgradePlanButton } from 'components/ui/UpgradePlanButton' import { useDatabasePoliciesQuery } from 'data/database-policies/database-policies-query' @@ -31,6 +30,7 @@ import { FormField_Shadcn_, FormMessage_Shadcn_, Input_Shadcn_, + PrePostTab, Switch, } from 'ui' import { Admonition } from 'ui-patterns' @@ -155,67 +155,58 @@ export const RealtimeSettings = () => { ) : ( - + ( - Enable Realtime service} - > - + - - - field.onChange(!checked)} - disabled={!canUpdateConfig} - /> - - - - {(isRealtimeDisabled || isDisablingRealtime || isEnablingRealtime) && ( - -
-
-
- {isDisablingRealtime - ? 'Realtime service will be disabled' - : isEnablingRealtime - ? 'Realtime service will be re-enabled' - : isRealtimeDisabled - ? 'Realtime service is disabled' - : null} -
-

- {isDisablingRealtime - ? 'Clients will no longer be able to connect to your project’s realtime service once saved' - : isEnablingRealtime - ? "Clients will be able to connect to your project's realtime service again once saved" - : isRealtimeDisabled - ? 'You will need to enable it to continue using Realtime' - : null} -

-
-
-
- )} -
-
+ + field.onChange(!checked)} + disabled={!canUpdateConfig} + /> + + + + )} /> + {(isRealtimeDisabled || isDisablingRealtime || isEnablingRealtime) && ( + +
+
+
+ {isDisablingRealtime + ? 'Realtime service will be disabled' + : isEnablingRealtime + ? 'Realtime service will be re-enabled' + : isRealtimeDisabled + ? 'Realtime service is disabled' + : null} +
+

+ {isDisablingRealtime + ? 'Clients will no longer be able to connect to your project’s realtime service once saved' + : isEnablingRealtime + ? "Clients will be able to connect to your project's realtime service again once saved" + : isRealtimeDisabled + ? 'You will need to enable it to continue using Realtime' + : null} +

+
+
+
+ )}
{!suspend && ( @@ -225,59 +216,50 @@ export const RealtimeSettings = () => { control={form.control} name="allow_public" render={({ field }) => ( - Channel restrictions} - > - + - - - - - + + + + - {isSuccessPolicies && - !hasRealtimeMessagesPolicies && - !allow_public && - !isRealtimeDisabled && ( - -

- Private mode is {isSettingToPrivate ? 'being ' : ''} - enabled, but no RLS policies exists on the{' '} - - realtime.messages - {' '} - table. No messages will be received by users. -

+ {isSuccessPolicies && + !hasRealtimeMessagesPolicies && + !allow_public && + !isRealtimeDisabled && ( + +

+ Private mode is {isSettingToPrivate ? 'being ' : ''} + enabled, but no RLS policies exists on the{' '} + + realtime.messages + {' '} + table. No messages will be received by users. +

- - - } - /> - )} -
-
+ + + } + /> + )} + )} />
@@ -286,41 +268,32 @@ export const RealtimeSettings = () => { control={form.control} name="connection_pool" render={({ field }) => ( - - Realtime Authorization uses this database pool to check client - access -

- } - > - Database connection pool size - - } - > - + <> + - + + + - - {!!maxConn && field.value > maxConn.maxConnections * 0.5 && ( - - )} - -
+ + {!!maxConn && field.value > maxConn.maxConnections * 0.5 && ( + + )} + )} /> @@ -329,221 +302,177 @@ export const RealtimeSettings = () => { control={form.control} name="max_concurrent_users" render={({ field }) => ( - - Sets maximum number of concurrent clients that can connect to your - Realtime service -

- } - > - Max concurrent clients - - } + - - + + - - - -
+ + + )} /> - + ( - - Sets maximum number of events per second that can be sent to your - Realtime service -

- } - > - Max events per second - - } + - - + + - - - {isSuccessOrganization && !isUsageBillingEnabled && ( - -
-
-
- Spend cap needs to be disabled to configure this value -
-

- {isFreePlan - ? 'Upgrade to the Pro plan first to disable spend cap' - : 'You may adjust this setting in the organization billing settings'} -

-
-
- {isFreePlan ? ( - - ) : ( - - )} -
-
-
- )} -
-
+ + + )} /> + {isSuccessOrganization && !isUsageBillingEnabled && ( + +
+
+
+ Spend cap needs to be disabled to configure this value +
+

+ {isFreePlan + ? 'Upgrade to the Pro plan first to disable spend cap' + : 'You may adjust this setting in the organization billing settings'} +

+
+
+ {isFreePlan ? ( + + ) : ( + + )} +
+
+
+ )}
- + ( - - Sets maximum number of presence events per second that can be sent - to your Realtime service -

- } - > - Max presence events per second - - } + - - + + - - - {isSuccessOrganization && !isUsageBillingEnabled && ( - -
-
-
- Spend cap needs to be disabled to configure this value -
-

- {isFreePlan - ? 'Upgrade to the Pro plan first to disable spend cap' - : 'You may adjust this setting in the organization billing settings'} -

-
-
- {isFreePlan ? ( - - ) : ( - - )} -
-
-
- )} -
-
+ + + )} /> + {isSuccessOrganization && !isUsageBillingEnabled && ( + +
+
+
+ Spend cap needs to be disabled to configure this value +
+

+ {isFreePlan + ? 'Upgrade to the Pro plan first to disable spend cap' + : 'You may adjust this setting in the organization billing settings'} +

+
+
+ {isFreePlan ? ( + + ) : ( + + )} +
+
+
+ )}
- + ( - - Sets maximum number of payload size in KB that can be sent to your - Realtime service -

- } - > - Max payload size in KB - - } + - - + + - - - {isSuccessOrganization && !isUsageBillingEnabled && ( - -
-
-
- Spend cap needs to be disabled to configure this value -
-

- {isFreePlan - ? 'Upgrade to the Pro plan first to disable spend cap' - : 'You may adjust this setting in the organization billing settings'} -

-
-
- {isFreePlan ? ( - - ) : ( - - )} -
-
-
- )} -
-
+ + + )} /> + {isSuccessOrganization && !isUsageBillingEnabled && ( + +
+
+
+ Spend cap needs to be disabled to configure this value +
+

+ {isFreePlan + ? 'Upgrade to the Pro plan first to disable spend cap' + : 'You may adjust this setting in the organization billing settings'} +

+
+
+ {isFreePlan ? ( + + ) : ( + + )} +
+
+
+ )}
)} diff --git a/apps/studio/pages/project/[ref]/realtime/settings.tsx b/apps/studio/pages/project/[ref]/realtime/settings.tsx index 4c0e1ee4385..6994c2dd1aa 100644 --- a/apps/studio/pages/project/[ref]/realtime/settings.tsx +++ b/apps/studio/pages/project/[ref]/realtime/settings.tsx @@ -18,7 +18,7 @@ import { PageSection, PageSectionContent } from 'ui-patterns/PageSection' const RealtimeSettingsPage: NextPageWithLayout = () => { return ( <> - + Realtime Settings @@ -31,7 +31,7 @@ const RealtimeSettingsPage: NextPageWithLayout = () => { - +