Skip to content

Commit efdf6d1

Browse files
authored
Fix auth hooks, enabled state in panel doesnt match hook state if disabled (supabase#43326)
## Context If an auth hook is disabled, clicking "Configure hook" will incorrectly show the enable toggle as true <img width="1095" height="265" alt="image" src="https://github.com/user-attachments/assets/72b4104c-658d-44fd-baca-1102aefc3fb3" /> <img width="737" height="216" alt="image" src="https://github.com/user-attachments/assets/73e4e8cb-7c03-440e-8f36-a7431b0ea051" /> Was due to the `enabled` value being default to `true` in the `useEffect` ## To test - Just verify that the enable toggle in the panel matches the auth hook's enabled state
1 parent 81415c6 commit efdf6d1

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

apps/studio/components/interfaces/Auth/Hooks/CreateHookSheet.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
import { zodResolver } from '@hookform/resolvers/zod'
2-
import randomBytes from 'randombytes'
3-
import { useEffect, useMemo } from 'react'
4-
import { SubmitHandler, useForm } from 'react-hook-form'
5-
import { toast } from 'sonner'
6-
import * as z from 'zod'
7-
82
import { useParams } from 'common'
93
import { convertArgumentTypes } from 'components/interfaces/Database/Functions/Functions.utils'
104
import CodeEditor from 'components/ui/CodeEditor/CodeEditor'
@@ -16,11 +10,15 @@ import { useAuthHooksUpdateMutation } from 'data/auth/auth-hooks-update-mutation
1610
import { executeSql } from 'data/sql/execute-sql-query'
1711
import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
1812
import { DOCS_URL } from 'lib/constants'
13+
import randomBytes from 'randombytes'
14+
import { useEffect, useMemo } from 'react'
15+
import { SubmitHandler, useForm } from 'react-hook-form'
16+
import { toast } from 'sonner'
1917
import {
2018
Button,
19+
Form_Shadcn_,
2120
FormControl_Shadcn_,
2221
FormField_Shadcn_,
23-
Form_Shadcn_,
2422
Input_Shadcn_,
2523
RadioGroupStacked,
2624
RadioGroupStackedItem,
@@ -35,7 +33,9 @@ import {
3533
} from 'ui'
3634
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
3735
import { InfoTooltip } from 'ui-patterns/info-tooltip'
38-
import { HOOKS_DEFINITIONS, HOOK_DEFINITION_TITLE, Hook } from './hooks.constants'
36+
import * as z from 'zod'
37+
38+
import { Hook, HOOK_DEFINITION_TITLE, HOOKS_DEFINITIONS } from './hooks.constants'
3939
import { extractMethod, getRevokePermissionStatements, isValidHook } from './hooks.utils'
4040

4141
interface CreateHookSheetProps {
@@ -239,7 +239,7 @@ export const CreateHookSheet = ({
239239

240240
form.reset({
241241
hookType: definition.title,
242-
enabled: authConfig?.[definition.enabledKey] || true,
242+
enabled: isCreating ? true : authConfig?.[definition.enabledKey],
243243
selectedType: values.type,
244244
httpsValues: {
245245
url: (values.type === 'https' && values.url) || '',

0 commit comments

Comments
 (0)