mirror of
https://github.com/supabase/supabase.git
synced 2026-05-06 14:05:05 +08:00
format
This commit is contained in:
@@ -172,7 +172,9 @@ describe('TemplateEditor reset to default', () => {
|
||||
|
||||
it('resets the template through the dedicated reset endpoint after confirmation', async () => {
|
||||
const user = userEvent.setup()
|
||||
resetTemplateMock.mockImplementation((_vars, callbacks) => callbacks?.onSuccess?.(resetAuthConfig))
|
||||
resetTemplateMock.mockImplementation((_vars, callbacks) =>
|
||||
callbacks?.onSuccess?.(resetAuthConfig)
|
||||
)
|
||||
|
||||
renderTemplateEditor({ hasCustomBody: true })
|
||||
|
||||
@@ -195,7 +197,9 @@ describe('TemplateEditor reset to default', () => {
|
||||
|
||||
it('does not reset through the auth config update payload', async () => {
|
||||
const user = userEvent.setup()
|
||||
resetTemplateMock.mockImplementation((_vars, callbacks) => callbacks?.onSuccess?.(resetAuthConfig))
|
||||
resetTemplateMock.mockImplementation((_vars, callbacks) =>
|
||||
callbacks?.onSuccess?.(resetAuthConfig)
|
||||
)
|
||||
|
||||
renderTemplateEditor({ hasCustomBody: true })
|
||||
|
||||
@@ -210,9 +214,15 @@ describe('TemplateEditor reset to default', () => {
|
||||
|
||||
it('uses the reset response as the new editor state', async () => {
|
||||
const user = userEvent.setup()
|
||||
resetTemplateMock.mockImplementation((_vars, callbacks) => callbacks?.onSuccess?.(resetAuthConfig))
|
||||
resetTemplateMock.mockImplementation((_vars, callbacks) =>
|
||||
callbacks?.onSuccess?.(resetAuthConfig)
|
||||
)
|
||||
|
||||
renderTemplateEditor({ body: '<p>Custom body</p>', hasCustomBody: true, hasCustomSubject: true })
|
||||
renderTemplateEditor({
|
||||
body: '<p>Custom body</p>',
|
||||
hasCustomBody: true,
|
||||
hasCustomSubject: true,
|
||||
})
|
||||
|
||||
await user.click(screen.getByRole('button', { name: 'Reset template' }))
|
||||
const dialog = await screen.findByRole('alertdialog')
|
||||
|
||||
@@ -122,13 +122,16 @@ export const TemplateEditor = ({ template }: TemplateEditorProps) => {
|
||||
|
||||
const spamRules = (validationResult?.rules ?? []).filter((rule) => rule.score > 0)
|
||||
|
||||
const getFormValuesFromConfig = useCallback((config: AuthConfigResponse | undefined) => {
|
||||
const result: { [x: string]: string } = {}
|
||||
Object.keys(properties).forEach((key) => {
|
||||
result[key] = ((config && config[key as keyof typeof config]) ?? '') as string
|
||||
})
|
||||
return result
|
||||
}, [properties])
|
||||
const getFormValuesFromConfig = useCallback(
|
||||
(config: AuthConfigResponse | undefined) => {
|
||||
const result: { [x: string]: string } = {}
|
||||
Object.keys(properties).forEach((key) => {
|
||||
result[key] = ((config && config[key as keyof typeof config]) ?? '') as string
|
||||
})
|
||||
return result
|
||||
},
|
||||
[properties]
|
||||
)
|
||||
|
||||
const INITIAL_VALUES = useMemo(() => {
|
||||
return getFormValuesFromConfig(authConfig)
|
||||
@@ -434,8 +437,8 @@ export const TemplateEditor = ({ template }: TemplateEditorProps) => {
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>Reset template to default</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
This will remove your custom subject line and body content. The default
|
||||
template content will be used instead.
|
||||
This will remove your custom subject line and email body content. The
|
||||
default values will be used instead.
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
||||
import { toast } from 'sonner'
|
||||
|
||||
import { authKeys } from './keys'
|
||||
import type { ProjectAuthConfigData } from './auth-config-query'
|
||||
import { authKeys } from './keys'
|
||||
import type { components } from '@/data/api'
|
||||
import { handleError, patch } from '@/data/fetchers'
|
||||
import { lintKeys } from '@/data/lint/keys'
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
||||
import { toast } from 'sonner'
|
||||
|
||||
import { authKeys } from './keys'
|
||||
import type { ProjectAuthConfigData } from './auth-config-query'
|
||||
import { authKeys } from './keys'
|
||||
import { handleError, post } from '@/data/fetchers'
|
||||
import { lintKeys } from '@/data/lint/keys'
|
||||
import type { ResponseError, UseCustomMutationOptions } from '@/types'
|
||||
|
||||
Reference in New Issue
Block a user