Skip to content

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

Chore/styling spam banner (#30280)

Jonathan Summers-Muir73c7b3fb8190
diff --git a/apps/studio/components/interfaces/Auth/EmailTemplates/EmailTemplates.tsx b/apps/studio/components/interfaces/Auth/EmailTemplates/EmailTemplates.tsx
index 9217586f363..9bced7ff316 100644
--- a/apps/studio/components/interfaces/Auth/EmailTemplates/EmailTemplates.tsx
+++ b/apps/studio/components/interfaces/Auth/EmailTemplates/EmailTemplates.tsx
@@ -5,7 +5,7 @@ import { FormHeader } from 'components/ui/Forms/FormHeader'
import { FormPanel } from 'components/ui/Forms/FormPanel'
import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'
import { useAuthConfigQuery } from 'data/auth/auth-config-query'
-import { Tabs } from 'ui'
+import { Tabs, Tabs_Shadcn_, TabsContent_Shadcn_, TabsList_Shadcn_, TabsTrigger_Shadcn_ } from 'ui'
import { TEMPLATES_SCHEMAS } from '../AuthTemplatesValidation'
import EmailRateLimitsAlert from '../EmailRateLimitsAlert'
import TemplateEditor from './TemplateEditor'
@@ -42,27 +42,31 @@ const EmailTemplates = () => {
{isLoading && <GenericSkeletonLoader />}
{isSuccess && (
<FormPanel>
- <Tabs
- scrollable
- size="small"
- type="underlined"
- listClassNames="px-8 pt-4"
- defaultActiveId={TEMPLATES_SCHEMAS[0].title.trim().replace(/\s+/g, '-')}
- >
+ <Tabs_Shadcn_ defaultValue={TEMPLATES_SCHEMAS[0].title.trim().replace(/\s+/g, '-')}>
+ <TabsList_Shadcn_ className="px-8 pt-2 gap-5">
+ {TEMPLATES_SCHEMAS.map((template) => {
+ return (
+ <TabsTrigger_Shadcn_ value={template.title.trim().replace(/\s+/g, '-')}>
+ {template.title}
+ </TabsTrigger_Shadcn_>
+ )
+ })}
+ </TabsList_Shadcn_>
+
{TEMPLATES_SCHEMAS.map((template) => {
const panelId = template.title.trim().replace(/\s+/g, '-')
return (
- <Tabs.Panel id={panelId} label={template.title} key={panelId}>
+ <TabsContent_Shadcn_ value={panelId} key={panelId}>
{builtInSMTP ? (
<div className="mx-8">
<EmailRateLimitsAlert />
</div>
) : null}
<TemplateEditor key={template.title} template={template} />
- </Tabs.Panel>
+ </TabsContent_Shadcn_>
)
})}
- </Tabs>
+ </Tabs_Shadcn_>
</FormPanel>
)}
</div>
diff --git a/apps/studio/components/interfaces/Auth/EmailTemplates/SpamValidation.tsx b/apps/studio/components/interfaces/Auth/EmailTemplates/SpamValidation.tsx
index b50808295dd..670921a211e 100644
--- a/apps/studio/components/interfaces/Auth/EmailTemplates/SpamValidation.tsx
+++ b/apps/studio/components/interfaces/Auth/EmailTemplates/SpamValidation.tsx
@@ -1,5 +1,3 @@
-import { Check } from 'lucide-react'
-
import { Markdown } from 'components/interfaces/Markdown'
import InformationBox from 'components/ui/InformationBox'
import { ValidateSpamResponse } from 'data/auth/validate-spam-mutation'
@@ -14,13 +12,13 @@ interface SpamValidationProps {
// are hence not visualized in the UI
export const SpamValidation = ({ validationResult }: SpamValidationProps) => {
- const spamRules = (validationResult?.rules ?? []).filter((rule) => rule.score > 0)
+ const spamRules = (validationResult?.rules ?? []).filter((rule) => rule.score >= 0)
const hasSpamWarning = spamRules.length > 0
return (
<InformationBox
- className={cn('mb-2', hasSpamWarning && '!bg-alternative')}
- icon={hasSpamWarning ? <WarningIcon /> : <Check size={16} className="text-brand" />}
+ className={cn('mb-2', hasSpamWarning && '!bg-alternative/75', '!px-0', 'rounded-t-none')}
+ icon={hasSpamWarning && <WarningIcon />}
title={
hasSpamWarning
? 'Email has a high probability of being marked as spam and deliverability may be affected'
@@ -39,15 +37,15 @@ export const SpamValidation = ({ validationResult }: SpamValidationProps) => {
<Table>
<TableHeader>
<TableRow>
- <TableHead>Warning</TableHead>
- <TableHead>Description</TableHead>
+ <TableHead className="h-10">Warning</TableHead>
+ <TableHead className="h-10">Description</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{spamRules.map((rule) => (
<TableRow key={rule.name}>
- <TableCell>{rule.name}</TableCell>
- <TableCell>{rule.desc}</TableCell>
+ <TableCell className="py-2.5">{rule.name}</TableCell>
+ <TableCell className="py-2.5">{rule.desc}</TableCell>
</TableRow>
))}
</TableBody>
diff --git a/apps/studio/components/interfaces/Auth/EmailTemplates/TemplateEditor.tsx b/apps/studio/components/interfaces/Auth/EmailTemplates/TemplateEditor.tsx
index bd30ff54ea6..f26e612eb74 100644
--- a/apps/studio/components/interfaces/Auth/EmailTemplates/TemplateEditor.tsx
+++ b/apps/studio/components/interfaces/Auth/EmailTemplates/TemplateEditor.tsx
@@ -10,14 +10,21 @@ import CodeEditor from 'components/ui/CodeEditor/CodeEditor'
import { FormActions } from 'components/ui/Forms/FormActions'
import { FormSection, FormSectionContent, FormSectionLabel } from 'components/ui/Forms/FormSection'
import InformationBox from 'components/ui/InformationBox'
+import { useAuthConfigQuery } from 'data/auth/auth-config-query'
import { useAuthConfigUpdateMutation } from 'data/auth/auth-config-update-mutation'
import { useValidateSpamMutation, ValidateSpamResponse } from 'data/auth/validate-spam-mutation'
import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'
import type { FormSchema } from 'types'
-import { Form, Input, Tabs } from 'ui'
+import {
+ Form,
+ Input,
+ Tabs_Shadcn_,
+ TabsContent_Shadcn_,
+ TabsList_Shadcn_,
+ TabsTrigger_Shadcn_,
+} from 'ui'
import { Admonition } from 'ui-patterns'
import { SpamValidation } from './SpamValidation'
-import { useAuthConfigQuery } from 'data/auth/auth-config-query'
interface TemplateEditorProps {
template: FormSchema
@@ -157,6 +164,14 @@ const TemplateEditor = ({ template }: TemplateEditorProps) => {
</ReactMarkdown>
) : null
}
+ onChange={(e) => {
+ if (projectRef) {
+ debounceValidateSpam({
+ projectRef,
+ template: { subject: e.target.value, content: bodyValue },
+ })
+ }
+ }}
disabled={!canUpdateConfig}
/>
</div>
@@ -184,33 +199,41 @@ const TemplateEditor = ({ template }: TemplateEditorProps) => {
}
/>
</div>
- <Tabs defaultActiveId="source" type="underlined" size="tiny">
- <Tabs.Panel id="source" icon={<Code size={14} />} label="Source">
- <SpamValidation validationResult={validationResult} />
- <div className="relative h-96">
- <CodeEditor
- id="code-id"
- language="html"
- isReadOnly={!canUpdateConfig}
- className="!mb-0 h-96 overflow-hidden rounded border"
- onInputChange={(e: string | undefined) => {
- setBodyValue(e ?? '')
- if (bodyValue !== e) setHasUnsavedChanges(true)
+ <Tabs_Shadcn_ defaultValue="source">
+ <TabsList_Shadcn_ className="gap-3">
+ <TabsTrigger_Shadcn_ value="source" className="gap-2">
+ <Code size={14} />
+ Source
+ </TabsTrigger_Shadcn_>
+ <TabsTrigger_Shadcn_ value="preview" className="gap-2">
+ <Monitor size={14} />
+ Preview
+ </TabsTrigger_Shadcn_>
+ </TabsList_Shadcn_>
+ <TabsContent_Shadcn_ value="source" className="-space-y-px">
+ <CodeEditor
+ id="code-id"
+ language="html"
+ isReadOnly={!canUpdateConfig}
+ className="!mb-0 relative h-96 overflow-hidden rounded border rounded-b-none"
+ onInputChange={(e: string | undefined) => {
+ setBodyValue(e ?? '')
+ if (bodyValue !== e) setHasUnsavedChanges(true)
- if (projectRef) {
- const [subjectKey] = Object.keys(values)
- debounceValidateSpam({
- projectRef,
- template: { subject: values[subjectKey], content: e ?? '' },
- })
- }
- }}
- options={{ wordWrap: 'on', contextmenu: false }}
- value={bodyValue}
- />
- </div>
- </Tabs.Panel>
- <Tabs.Panel id="preview" icon={<Monitor size={14} />} label="Preview">
+ if (projectRef) {
+ const [subjectKey] = Object.keys(values)
+ debounceValidateSpam({
+ projectRef,
+ template: { subject: values[subjectKey], content: e ?? '' },
+ })
+ }
+ }}
+ options={{ wordWrap: 'on', contextmenu: false }}
+ value={bodyValue}
+ />
+ <SpamValidation validationResult={validationResult} />
+ </TabsContent_Shadcn_>
+ <TabsContent_Shadcn_ value="preview">
<Admonition
type="default"
title="The preview may differ slightly from the actual rendering in the email client"
@@ -220,8 +243,8 @@ const TemplateEditor = ({ template }: TemplateEditorProps) => {
title={id}
srcDoc={bodyValue}
/>
- </Tabs.Panel>
- </Tabs>
+ </TabsContent_Shadcn_>
+ </Tabs_Shadcn_>
</>
)}
<div className="col-span-12 flex w-full">
diff --git a/apps/studio/components/ui/InformationBox.tsx b/apps/studio/components/ui/InformationBox.tsx
index 4bcfc2e4116..702d832fecb 100644
--- a/apps/studio/components/ui/InformationBox.tsx
+++ b/apps/studio/components/ui/InformationBox.tsx
@@ -1,6 +1,6 @@
import { ExternalLink, Maximize2, Minimize2 } from 'lucide-react'
import Link from 'next/link'
-import { ReactNode, useState } from 'react'
+import { ReactNode, useState, forwardRef } from 'react'
import { Button } from 'ui'
@@ -17,71 +17,79 @@ interface InformationBoxProps {
block?: boolean
}
-const InformationBox = ({
- icon,
- title,
- description,
- url,
- urlLabel = 'Read more',
- defaultVisibility = false,
- hideCollapse = false,
- button,
- className = '',
- block = false,
-}: InformationBoxProps) => {
- const [isExpanded, setIsExpanded] = useState<boolean>(defaultVisibility)
+const InformationBox = forwardRef<HTMLDivElement, InformationBoxProps>(
+ (
+ {
+ icon,
+ title,
+ description,
+ url,
+ urlLabel = 'Read more',
+ defaultVisibility = false,
+ hideCollapse = false,
+ button,
+ className = '',
+ block = false,
+ },
+ ref
+ ) => {
+ const [isExpanded, setIsExpanded] = useState<boolean>(defaultVisibility)
- return (
- <div
- className={`${block ? 'block w-full' : ''}
- block w-full rounded border bg-surface-200 py-3 ${className}`}
- >
- <div className="flex flex-col px-4">
- <div className="flex items-center justify-between">
- <div className="flex w-full space-x-3 items-center">
- {icon && <span className="text-foreground-lighter">{icon}</span>}
- <div className="flex-grow">
- <h5 className="text-sm text-foreground">{title}</h5>
+ return (
+ <div
+ ref={ref}
+ role="alert"
+ className={`${block ? 'block w-full' : ''}
+ block w-full rounded-md border bg-surface-300/25 py-3 ${className}`}
+ >
+ <div className="flex flex-col px-4">
+ <div className="flex items-center justify-between">
+ <div className="flex w-full space-x-3 items-center">
+ {icon && <span className="text-foreground-lighter">{icon}</span>}
+ <div className="flex-grow">
+ <h5 className="text-sm text-foreground">{title}</h5>
+ </div>
</div>
+ {description && !hideCollapse ? (
+ <div
+ className="cursor-pointer text-foreground-lighter"
+ onClick={() => setIsExpanded(!isExpanded)}
+ >
+ {isExpanded ? (
+ <Minimize2 size={14} strokeWidth={1.5} />
+ ) : (
+ <Maximize2 size={14} strokeWidth={1.5} />
+ )}
+ </div>
+ ) : null}
</div>
- {description && !hideCollapse ? (
+ {(description || url || button) && (
<div
- className="cursor-pointer text-foreground-lighter"
- onClick={() => setIsExpanded(!isExpanded)}
+ className={`flex flex-col space-y-3 overflow-hidden transition-all ${
+ isExpanded ? 'mt-3' : ''
+ }`}
+ style={{ maxHeight: isExpanded ? 500 : 0 }}
>
- {isExpanded ? (
- <Minimize2 size={14} strokeWidth={1.5} />
- ) : (
- <Maximize2 size={14} strokeWidth={1.5} />
+ <div className="text-foreground-light text-sm">{description}</div>
+
+ {url && (
+ <div>
+ <Button asChild type="default" icon={<ExternalLink />}>
+ <Link href={url} target="_blank" rel="noreferrer">
+ {urlLabel}
+ </Link>
+ </Button>
+ </div>
)}
+
+ {button && <div>{button}</div>}
</div>
- ) : null}
+ )}
</div>
- {(description || url || button) && (
- <div
- className={`flex flex-col space-y-3 overflow-hidden transition-all ${
- isExpanded ? 'mt-3' : ''
- }`}
- style={{ maxHeight: isExpanded ? 500 : 0 }}
- >
- <div className="text-foreground-light text-sm">{description}</div>
-
- {url && (
- <div>
- <Button asChild type="default" icon={<ExternalLink />}>
- <Link href={url} target="_blank" rel="noreferrer">
- {urlLabel}
- </Link>
- </Button>
- </div>
- )}
-
- {button && <div>{button}</div>}
- </div>
- )}
</div>
- </div>
- )
-}
+ )
+ }
+)
+InformationBox.displayName = 'InformationBox'
export default InformationBox
diff --git a/packages/ui/src/components/StatusIcon.tsx b/packages/ui/src/components/StatusIcon.tsx
index bb21335a5ce..10fdfc12a27 100644
--- a/packages/ui/src/components/StatusIcon.tsx
+++ b/packages/ui/src/components/StatusIcon.tsx
@@ -17,6 +17,8 @@ export const StatusIcon = forwardRef<
Icon = WarningIcon
} else if (variant === 'destructive') {
Icon = CriticalIcon
+ } else if (variant === 'success') {
+ Icon = CheckIcon
} else {
Icon = InfoIcon
}
@@ -102,4 +104,32 @@ const WarningIcon: React.FC<SVGProps<SVGSVGElement> & StatusIconProps> = ({
)
}
-export { CriticalIcon, InfoIcon, WarningIcon }
+const CheckIcon: React.FC<SVGProps<SVGSVGElement> & StatusIconProps> = ({
+ hideBackground = false,
+ ...props
+}) => {
+ return (
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ {...props}
+ className={cn(
+ !hideBackground
+ ? 'w-4 h-4 p-0.5 bg-foreground text-background rounded'
+ : 'w-3 h-3 text-success-600',
+ props.className
+ )}
+ >
+ <path
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth={3}
+ d="m4.5 12.75 6 6 9-13.5"
+ />
+ </svg>
+ )
+}
+
+export { CriticalIcon, InfoIcon, WarningIcon, CheckIcon }