Skip to content

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

fix: auth provider form for sms is invalid when using sms hook (#44820)

Gildas Garcia73f678c73085
diff --git a/apps/studio/components/interfaces/Auth/AuthProvidersForm/FormField.tsx b/apps/studio/components/interfaces/Auth/AuthProvidersForm/FormField.tsx
index 3993465467a..c1626730f6b 100644
--- a/apps/studio/components/interfaces/Auth/AuthProvidersForm/FormField.tsx
+++ b/apps/studio/components/interfaces/Auth/AuthProvidersForm/FormField.tsx
@@ -40,6 +40,7 @@ interface FormFieldProps {
control: Control
hasAccess: boolean
disabled?: boolean
+ readOnly?: boolean
}
const FormField = ({
@@ -50,6 +51,7 @@ const FormField = ({
control,
hasAccess,
disabled: disabledProp,
+ readOnly,
}: FormFieldProps) => {
const { description: originalDescription } = properties
let description = originalDescription
@@ -95,7 +97,7 @@ const FormField = ({
<FormField_Shadcn_
control={control}
name={name}
- disabled={disabled}
+ disabled={disabled || readOnly}
render={({ field }) => (
<FormItemLayout
layout="horizontal"
@@ -160,9 +162,16 @@ const FormField = ({
>
<FormControl_Shadcn_ className="col-span-6">
{properties.isSecret ? (
- <DataInput {...field} id={name} size="small" copy reveal />
+ <DataInput
+ {...field}
+ id={name}
+ size="small"
+ copy
+ reveal
+ readOnly={readOnly}
+ />
) : (
- <Input_Shadcn_ {...field} id={name} />
+ <Input_Shadcn_ {...field} id={name} readOnly={readOnly} />
)}
</FormControl_Shadcn_>
</FormItemLayout>
@@ -198,6 +207,7 @@ const FormField = ({
rows={4}
placeholder="Enter multi-line text"
className="resize-none"
+ readOnly={readOnly}
/>
</FormControl_Shadcn_>
</FormItemLayout>
@@ -234,6 +244,7 @@ const FormField = ({
id={name}
type="number"
onChange={(e) => field.onChange(Number(e.target.value))}
+ readOnly={readOnly}
/>
<InputGroupAddon align="inline-end">
<ReactMarkdown unwrapDisallowed disallowedElements={['p']}>
@@ -246,6 +257,7 @@ const FormField = ({
{...field}
id={name}
type="number"
+ readOnly={readOnly}
onChange={(e) => field.onChange(Number(e.target.value))}
/>
)}
@@ -265,7 +277,7 @@ const FormField = ({
<FormField_Shadcn_
control={control}
name={name}
- disabled={disabled}
+ disabled={disabled || readOnly}
render={({ field }) => (
<FormItemLayout
layout="horizontal"
@@ -308,7 +320,7 @@ const FormField = ({
<FormField_Shadcn_
control={control}
name={name}
- disabled={disabled}
+ disabled={disabled || readOnly}
render={({ field }) => (
<FormItemLayout
layout="horizontal"
diff --git a/apps/studio/components/interfaces/Auth/AuthProvidersForm/ProviderForm.tsx b/apps/studio/components/interfaces/Auth/AuthProvidersForm/ProviderForm.tsx
index 93a4e13ccca..a4f22ba4e50 100644
--- a/apps/studio/components/interfaces/Auth/AuthProvidersForm/ProviderForm.tsx
+++ b/apps/studio/components/interfaces/Auth/AuthProvidersForm/ProviderForm.tsx
@@ -110,8 +110,12 @@ export const ProviderForm = ({ config, provider, isActive }: ProviderFormProps)
)
const INITIAL_VALUES = useMemo(() => {
+ // This check will always be true but let us avoid adding an eslint disable comment on unused memo dependencies
+ // which could hide real issues in the future.
+ // Adding the provider in the memo dependencies ensures the INITIAL_VALUES is properly applied
+ if (!provider) return
return getValuesForProvider(config)
- }, [config, getValuesForProvider])
+ }, [config, getValuesForProvider, provider])
const onSubmit = (values: any) => {
const payload = { ...values }
@@ -230,7 +234,7 @@ export const ProviderForm = ({ config, provider, isActive }: ProviderFormProps)
name={x}
properties={provider.properties[x]}
control={form.control}
- disabled={shouldDisableField(x) || !canUpdateConfig}
+ readOnly={shouldDisableField(x) || !canUpdateConfig}
hasAccess={hasAccess}
/>
)