Skip to content

Commit a4928ef

Browse files
dnywhjoshenlim
andauthored
chore(studio): security notification emails announcements (supabase#40366)
* announcement * fix link * Minor clean up --------- Co-authored-by: Joshen Lim <[email protected]>
1 parent e08d1f7 commit a4928ef

File tree

9 files changed

+86
-20
lines changed

9 files changed

+86
-20
lines changed

apps/studio/components/interfaces/App/FeaturePreview/FeaturePreview.constants.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { LOCAL_STORAGE_KEYS } from 'common'
33
export const FEATURE_PREVIEWS = [
44
{
55
key: LOCAL_STORAGE_KEYS.UI_PREVIEW_SECURITY_NOTIFICATIONS,
6-
name: 'Security notification templates',
7-
discussionsUrl: undefined,
6+
name: 'Security notification emails',
7+
discussionsUrl: 'https://github.com/orgs/supabase/discussions/40349',
88
isNew: true,
99
isPlatformOnly: true,
1010
},

apps/studio/components/interfaces/App/FeaturePreview/SecurityNotificationsPreview.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ import Image from 'next/image'
33
import { useParams } from 'common'
44
import { InlineLink } from 'components/ui/InlineLink'
55
import { BASE_PATH } from 'lib/constants'
6-
import { useIsSecurityNotificationsEnabled } from './FeaturePreviewContext'
76

87
export const SecurityNotificationsPreview = () => {
98
const { ref } = useParams()
10-
const isSecurityNotificationsEnabled = useIsSecurityNotificationsEnabled()
119

1210
return (
1311
<div className="text-sm text-foreground-light">
@@ -21,11 +19,7 @@ export const SecurityNotificationsPreview = () => {
2119
<div className="space-y-2 !mt-4">
2220
<p className=" mb-4">
2321
Try out our expanded set of{' '}
24-
<InlineLink
25-
href={`/project/${ref ?? '_'}/auth/${isSecurityNotificationsEnabled ? 'email' : 'templates'}`}
26-
>
27-
email templates
28-
</InlineLink>{' '}
22+
<InlineLink href={`/project/${ref ?? '_'}/auth/templates`}>email templates</InlineLink>{' '}
2923
with support for security-related notifications.
3024
</p>
3125
<p className="text-foreground">Enabling this preview will:</p>
@@ -37,8 +31,7 @@ export const SecurityNotificationsPreview = () => {
3731
<p>
3832
These changes are necessary to support incoming security-related notification templates.
3933
Given that the list of our email templates is doubling in size, this change requires some
40-
wider interface changes. Ones that we think make for a clearer experience overall. Win
41-
win!
34+
wider interface changes. Ones that we think make for a clearer experience overall.
4235
</p>
4336
</div>
4437
</div>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { DOCS_URL } from 'lib/constants'
66
import { Button } from 'ui'
77
import { Admonition } from 'ui-patterns/admonition'
88

9-
export function EmailRateLimitsAlert() {
9+
export const EmailRateLimitsAlert = () => {
1010
const { ref } = useParams()
1111

1212
return (

apps/studio/components/interfaces/Auth/EmailRateLimitsAlert/index.tsx

Lines changed: 0 additions & 3 deletions
This file was deleted.

apps/studio/components/interfaces/Auth/EmailTemplates/EmailTemplates.tsx

Lines changed: 75 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
import { zodResolver } from '@hookform/resolvers/zod'
22
import { PermissionAction } from '@supabase/shared-types/out/constants'
3-
import { ChevronRight } from 'lucide-react'
3+
import { ChevronRight, ExternalLink, X } from 'lucide-react'
44
import Link from 'next/link'
55
import { useEffect } from 'react'
66
import { useForm } from 'react-hook-form'
77
import { toast } from 'sonner'
88
import { 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'
1112
import { useIsSecurityNotificationsEnabled } from 'components/interfaces/App/FeaturePreview/FeaturePreviewContext'
1213
import { ScaffoldSection, ScaffoldSectionTitle } from 'components/layouts/Scaffold'
1314
import AlertError from 'components/ui/AlertError'
15+
import { InlineLink } from 'components/ui/InlineLink'
1416
import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'
1517
import { useAuthConfigQuery } from 'data/auth/auth-config-query'
1618
import { useAuthConfigUpdateMutation } from 'data/auth/auth-config-update-mutation'
1719
import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions'
20+
import { useLocalStorageQuery } from 'hooks/misc/useLocalStorage'
21+
import { DOCS_URL } from 'lib/constants'
1822
import {
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'
3241
import { TEMPLATES_SCHEMAS } from '../AuthTemplatesValidation'
33-
import EmailRateLimitsAlert from '../EmailRateLimitsAlert'
42+
import { EmailRateLimitsAlert } from '../EmailRateLimitsAlert'
3443
import { slugifyTitle } from './EmailTemplates.utils'
3544
import { 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+
5366
export 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>

apps/studio/components/interfaces/SQLEditor/UtilityPanel/ChartConfig.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ export const ChartConfig = ({
206206
<Tooltip>
207207
<TooltipTrigger
208208
onClick={() => setAcknowledged(true)}
209-
className="absolute top-3 right-3 opacity-0 group-hover:opacity-100 transition-opacity"
209+
className="absolute top-3 right-3 opacity-30 group-hover:opacity-100 transition-opacity"
210210
>
211211
<X size={14} className="text-foreground-light" />
212212
</TooltipTrigger>

apps/studio/pages/project/[ref]/auth/templates/[templateId].tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ const RedirectToTemplates = () => {
234234
<ScaffoldSection isFullWidth>
235235
{/* Only show title if there is an another section above */}
236236
{showConfigurationSection && (
237-
<ScaffoldSectionTitle className="mb-4">Contents</ScaffoldSectionTitle>
237+
<ScaffoldSectionTitle className="mb-4">Content</ScaffoldSectionTitle>
238238
)}
239239
<Card>
240240
<TemplateEditor template={template} />
103 KB
Loading

packages/common/constants/local-storage.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ export const LOCAL_STORAGE_KEYS = {
4040
SQL_EDITOR_SECTION_STATE: (ref: string) => `sql-editor-section-state-${ref}`,
4141
SQL_EDITOR_SORT: (ref: string) => `sql-editor-sort-${ref}`,
4242

43+
// Key to track if the user has acknowledged the security notifications preview
44+
SECURITY_NOTIFICATIONS_ACKNOWLEDGED: (ref: string) =>
45+
`security-notifications-acknowledged-${ref}`,
46+
4347
LOG_EXPLORER_SPLIT_SIZE: 'supabase_log-explorer-split-size',
4448
GRAPHIQL_RLS_BYPASS_WARNING: 'graphiql-rls-bypass-warning-dismissed',
4549
CLS_DIFF_WARNING: 'cls-diff-warning-dismissed',

0 commit comments

Comments
 (0)