11import { zodResolver } from '@hookform/resolvers/zod'
22import { PermissionAction } from '@supabase/shared-types/out/constants'
3- import { ChevronRight } from 'lucide-react'
3+ import { ChevronRight , ExternalLink , X } from 'lucide-react'
44import Link from 'next/link'
55import { useEffect } from 'react'
66import { useForm } from 'react-hook-form'
77import { toast } from 'sonner'
88import { z } from 'zod'
99
10- import { useParams } from 'common'
10+ import { LOCAL_STORAGE_KEYS , useParams } from 'common'
11+ import { FEATURE_PREVIEWS } from 'components/interfaces/App/FeaturePreview/FeaturePreview.constants'
1112import { useIsSecurityNotificationsEnabled } from 'components/interfaces/App/FeaturePreview/FeaturePreviewContext'
1213import { ScaffoldSection , ScaffoldSectionTitle } from 'components/layouts/Scaffold'
1314import AlertError from 'components/ui/AlertError'
15+ import { InlineLink } from 'components/ui/InlineLink'
1416import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'
1517import { useAuthConfigQuery } from 'data/auth/auth-config-query'
1618import { useAuthConfigUpdateMutation } from 'data/auth/auth-config-update-mutation'
1719import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions'
20+ import { useLocalStorageQuery } from 'hooks/misc/useLocalStorage'
21+ import { DOCS_URL } from 'lib/constants'
1822import {
23+ Badge ,
1924 Button ,
2025 Card ,
2126 CardContent ,
@@ -28,9 +33,13 @@ import {
2833 TabsContent_Shadcn_ ,
2934 TabsList_Shadcn_ ,
3035 TabsTrigger_Shadcn_ ,
36+ Tooltip ,
37+ TooltipContent ,
38+ TooltipTrigger ,
3139} from 'ui'
40+ import { Admonition } from 'ui-patterns'
3241import { TEMPLATES_SCHEMAS } from '../AuthTemplatesValidation'
33- import EmailRateLimitsAlert from '../EmailRateLimitsAlert'
42+ import { EmailRateLimitsAlert } from '../EmailRateLimitsAlert'
3443import { slugifyTitle } from './EmailTemplates.utils'
3544import { TemplateEditor } from './TemplateEditor'
3645
@@ -50,6 +59,10 @@ const NotificationsFormSchema = z.object({
5059 ) ,
5160} )
5261
62+ const SECURITY_NOTIFICATIONS_DISCUSSIONS_URL = FEATURE_PREVIEWS . find (
63+ ( f ) => f . key === LOCAL_STORAGE_KEYS . UI_PREVIEW_SECURITY_NOTIFICATIONS
64+ ) ?. discussionsUrl
65+
5366export const EmailTemplates = ( ) => {
5467 const { ref : projectRef } = useParams ( )
5568 const isSecurityNotificationsEnabled = useIsSecurityNotificationsEnabled ( )
@@ -58,6 +71,11 @@ export const EmailTemplates = () => {
5871 'custom_config_gotrue'
5972 )
6073
74+ const [ acknowledged , setAcknowledged ] = useLocalStorageQuery (
75+ LOCAL_STORAGE_KEYS . SECURITY_NOTIFICATIONS_ACKNOWLEDGED ( projectRef ?? '' ) ,
76+ false
77+ )
78+
6179 const {
6280 data : authConfig ,
6381 error : authConfigError ,
@@ -161,6 +179,60 @@ export const EmailTemplates = () => {
161179
162180 < div >
163181 < ScaffoldSectionTitle className = "mb-4" > Security</ ScaffoldSectionTitle >
182+ { ! acknowledged && (
183+ < Admonition showIcon = { false } type = "tip" className = "relative mb-6" >
184+ < Tooltip >
185+ < TooltipTrigger
186+ onClick = { ( ) => setAcknowledged ( true ) }
187+ className = "absolute top-3 right-3 opacity-30 hover:opacity-100 transition-opacity"
188+ >
189+ < X size = { 14 } className = "text-foreground-light" />
190+ </ TooltipTrigger >
191+ < TooltipContent side = "bottom" > Dismiss</ TooltipContent >
192+ </ Tooltip >
193+ < div className = "flex flex-col md:flex-row md:items-center gap-y-2 md:gap-x-8 justify-between px-2 py-1" >
194+ < div className = "flex flex-col gap-y-0.5" >
195+ < div className = "flex flex-col gap-y-2 items-start" >
196+ < Badge variant = "success" className = "-ml-0.5" >
197+ NEW
198+ </ Badge >
199+ < p className = "text-sm" >
200+ Notify users about security-sensitive actions on their accounts
201+ </ p >
202+ </ div >
203+ < p className = "text-sm text-foreground-lighter text-balance" >
204+ We’ve expanded our email templates to handle security-sensitive actions.
205+ The list of templates will continue to grow as our feature-set changes
206+ { SECURITY_NOTIFICATIONS_DISCUSSIONS_URL && (
207+ < >
208+ { ' ' }
209+ and as we{ ' ' }
210+ < InlineLink
211+ href = { SECURITY_NOTIFICATIONS_DISCUSSIONS_URL }
212+ target = "_blank"
213+ >
214+ gather feedback
215+ </ InlineLink > { ' ' }
216+ from our community
217+ </ >
218+ ) }
219+ .
220+ </ p >
221+ </ div >
222+ < Button
223+ asChild
224+ type = "default"
225+ icon = { < ExternalLink strokeWidth = { 1.5 } /> }
226+ className = "mt-2"
227+ >
228+ < Link href = { `${ DOCS_URL } /guides/auth/auth-email-templates` } target = "_blank" >
229+ Docs
230+ </ Link >
231+ </ Button >
232+ </ div >
233+ </ Admonition >
234+ ) }
235+
164236 < Form_Shadcn_ { ...notificationsForm } >
165237 < form onSubmit = { notificationsForm . handleSubmit ( onSubmit ) } className = "space-y-4" >
166238 < Card >
0 commit comments