Skip to content

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

feat: branch migration statuses (#21809)

Alaister Young643611fe3769
diff --git a/apps/studio/components/interfaces/Auth/Policies/PolicyTableRow/index.tsx b/apps/studio/components/interfaces/Auth/Policies/PolicyTableRow/index.tsx
index 121a5a46a7a..b2dc06136fb 100644
--- a/apps/studio/components/interfaces/Auth/Policies/PolicyTableRow/index.tsx
+++ b/apps/studio/components/interfaces/Auth/Policies/PolicyTableRow/index.tsx
@@ -3,7 +3,7 @@ import { noop } from 'lodash'
import { AlertDescription_Shadcn_, AlertTitle_Shadcn_, Alert_Shadcn_ } from 'ui'
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
-import { WarningIcon } from 'components/ui/Icons'
+import { WarningIcon } from 'ui-patterns/Icons/StatusIcons'
import Panel from 'components/ui/Panel'
import { useDatabasePoliciesQuery } from 'data/database-policies/database-policies-query'
import PolicyRow from './PolicyRow'
diff --git a/apps/studio/components/interfaces/BranchManagement/BranchManagement.tsx b/apps/studio/components/interfaces/BranchManagement/BranchManagement.tsx
index cfc761e5ed3..89a4ac4dbc5 100644
--- a/apps/studio/components/interfaces/BranchManagement/BranchManagement.tsx
+++ b/apps/studio/components/interfaces/BranchManagement/BranchManagement.tsx
@@ -68,7 +68,25 @@ const BranchManagement = () => {
isLoading: isLoadingBranches,
isError: isErrorBranches,
isSuccess: isSuccessBranches,
- } = useBranchesQuery({ projectRef })
+ } = useBranchesQuery(
+ { projectRef },
+ {
+ refetchInterval(data) {
+ if (
+ data?.some(
+ (branch) =>
+ branch.status === 'CREATING_PROJECT' ||
+ branch.status === 'RUNNING_MIGRATIONS' ||
+ branch.status === 'MIGRATIONS_FAILED'
+ )
+ ) {
+ return 1000 * 3 // 3 seconds
+ }
+
+ return false
+ },
+ }
+ )
const [[mainBranch], previewBranchesUnsorted] = partition(branches, (branch) => branch.is_default)
const previewBranches = previewBranchesUnsorted.sort((a, b) =>
new Date(a.updated_at) < new Date(b.updated_at) ? 1 : -1
diff --git a/apps/studio/components/interfaces/BranchManagement/BranchPanels.tsx b/apps/studio/components/interfaces/BranchManagement/BranchPanels.tsx
index 0e5690f8c9e..27566b81a47 100644
--- a/apps/studio/components/interfaces/BranchManagement/BranchPanels.tsx
+++ b/apps/studio/components/interfaces/BranchManagement/BranchPanels.tsx
@@ -103,7 +103,7 @@ export const BranchRow = ({
const { data } = useBranchQuery(
{ projectRef, id: branch.id },
{
- enabled: inView,
+ enabled: branch.status === 'CREATING_PROJECT' && inView,
refetchInterval(data) {
if (data?.status !== 'ACTIVE_HEALTHY') {
return 1000 * 3 // 3 seconds
@@ -128,7 +128,11 @@ export const BranchRow = ({
</Link>
</Button>
{isActive && <Badge color="slate">Current</Badge>}
- {data?.status !== undefined && <BranchStatusBadge status={data.status} />}
+ <BranchStatusBadge
+ status={
+ branch.status === 'CREATING_PROJECT' ? data?.status ?? branch.status : branch.status
+ }
+ />
<p className="text-xs text-foreground-lighter">
{daysFromNow > 1 ? `Updated on ${formattedUpdatedAt}` : `Updated ${formattedTimeFromNow}`}
</p>
diff --git a/apps/studio/components/interfaces/BranchManagement/BranchStatusBadge.tsx b/apps/studio/components/interfaces/BranchManagement/BranchStatusBadge.tsx
index 247e91f0037..c08b1669fc4 100644
--- a/apps/studio/components/interfaces/BranchManagement/BranchStatusBadge.tsx
+++ b/apps/studio/components/interfaces/BranchManagement/BranchStatusBadge.tsx
@@ -1,16 +1,28 @@
-import { WarningIcon } from 'components/ui/Icons'
import type { BranchData } from 'data/branches/branch-query'
-import { ClockIcon } from 'lucide-react'
-import { Badge } from 'ui'
+import type { Branch } from 'data/branches/branches-query'
+import { Badge_Shadcn_ } from 'ui'
+import { StatusIcon } from 'ui-patterns/Icons/StatusIcons'
-type Status = BranchData['status']
+type Status = Branch['status'] | BranchData['status']
export interface BranchStatusBadgeProps {
status: Status
}
-const UNHEALTHY_STATUES: Status[] = ['ACTIVE_UNHEALTHY', 'INIT_FAILED', 'UNKNOWN']
-const WAITING_STATUSES: Status[] = ['COMING_UP', 'GOING_DOWN', 'PAUSING', 'RESTORING', 'UPGRADING']
+const UNHEALTHY_STATUES: Status[] = [
+ 'ACTIVE_UNHEALTHY',
+ 'INIT_FAILED',
+ 'UNKNOWN',
+ 'MIGRATIONS_FAILED',
+]
+const WAITING_STATUSES: Status[] = [
+ 'COMING_UP',
+ 'GOING_DOWN',
+ 'PAUSING',
+ 'RESTORING',
+ 'UPGRADING',
+ 'RUNNING_MIGRATIONS',
+]
const STATUS_TO_LABEL: Record<Status, string> = {
ACTIVE_HEALTHY: 'Healthy',
@@ -24,10 +36,14 @@ const STATUS_TO_LABEL: Record<Status, string> = {
REMOVED: 'Removed',
RESTORING: 'Restoring',
UPGRADING: 'Upgrading',
+ CREATING_PROJECT: 'Creating project',
+ RUNNING_MIGRATIONS: 'Running migrations',
+ MIGRATIONS_FAILED: 'Migrations failed',
+ MIGRATIONS_PASSED: 'Migrations applied successfully',
}
const BranchStatusBadge = ({ status }: BranchStatusBadgeProps) => {
- if (status === 'ACTIVE_HEALTHY') {
+ if (status === 'ACTIVE_HEALTHY' || status === 'MIGRATIONS_PASSED') {
return null
}
@@ -35,11 +51,12 @@ const BranchStatusBadge = ({ status }: BranchStatusBadgeProps) => {
const isWaiting = WAITING_STATUSES.includes(status)
return (
- <Badge color={isUnhealthy ? 'red' : 'slate'} className="flex items-center gap-1.5">
- {isUnhealthy && <WarningIcon className="w-3 h-3" />}
- {isWaiting && <ClockIcon size={12} />}
- <span>{STATUS_TO_LABEL[status]}</span>
- </Badge>
+ <Badge_Shadcn_ variant={isUnhealthy ? 'destructive' : 'default'} className="gap-1.5">
+ {(isUnhealthy || isWaiting) && (
+ <StatusIcon variant={isUnhealthy ? 'destructive' : 'default'} hideBackground />
+ )}
+ {STATUS_TO_LABEL[status]}
+ </Badge_Shadcn_>
)
}
diff --git a/apps/studio/components/interfaces/Integrations/IntegrationConnection.tsx b/apps/studio/components/interfaces/Integrations/IntegrationConnection.tsx
index 3c3f1fd8474..78122f739a7 100644
--- a/apps/studio/components/interfaces/Integrations/IntegrationConnection.tsx
+++ b/apps/studio/components/interfaces/Integrations/IntegrationConnection.tsx
@@ -23,7 +23,7 @@ import {
IntegrationConnection,
IntegrationConnectionProps,
} from 'components/interfaces/Integrations/IntegrationPanels'
-import { WarningIcon } from 'components/ui/Icons'
+import { WarningIcon } from 'ui-patterns/Icons/StatusIcons'
import { useIntegrationsVercelConnectionSyncEnvsMutation } from 'data/integrations/integrations-vercel-connection-sync-envs-mutation'
import type { IntegrationProjectConnection } from 'data/integrations/integrations.types'
import { useProjectsQuery } from 'data/projects/projects-query'
diff --git a/apps/studio/components/interfaces/Settings/Addons/ComputeInstanceSidePanel.tsx b/apps/studio/components/interfaces/Settings/Addons/ComputeInstanceSidePanel.tsx
index dbf847aa52f..44f64dc52b2 100644
--- a/apps/studio/components/interfaces/Settings/Addons/ComputeInstanceSidePanel.tsx
+++ b/apps/studio/components/interfaces/Settings/Addons/ComputeInstanceSidePanel.tsx
@@ -22,7 +22,7 @@ import {
} from 'ui'
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
-import { WarningIcon } from 'components/ui/Icons'
+import { WarningIcon } from 'ui-patterns/Icons/StatusIcons'
import { setProjectStatus } from 'data/projects/projects-query'
import { useReadReplicasQuery } from 'data/read-replicas/replicas-query'
import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'
diff --git a/apps/studio/components/interfaces/Settings/Addons/PITRSidePanel.tsx b/apps/studio/components/interfaces/Settings/Addons/PITRSidePanel.tsx
index 86c5cba401e..7037ac0f5fd 100644
--- a/apps/studio/components/interfaces/Settings/Addons/PITRSidePanel.tsx
+++ b/apps/studio/components/interfaces/Settings/Addons/PITRSidePanel.tsx
@@ -14,7 +14,7 @@ import Telemetry from 'lib/telemetry'
import { useTheme } from 'next-themes'
import { subscriptionHasHipaaAddon } from 'components/interfaces/Billing/Subscription/Subscription.utils'
-import { CriticalIcon, WarningIcon } from 'components/ui/Icons'
+import { CriticalIcon, WarningIcon } from 'ui-patterns/Icons/StatusIcons'
import { useReadReplicasQuery } from 'data/read-replicas/replicas-query'
import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'
import type { AddonVariantId } from 'data/subscriptions/types'
diff --git a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DeployNewReplicaPanel.tsx b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DeployNewReplicaPanel.tsx
index 582000c01ea..b086d9244ea 100644
--- a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DeployNewReplicaPanel.tsx
+++ b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DeployNewReplicaPanel.tsx
@@ -11,7 +11,7 @@ import {
SidePanel,
} from 'ui'
-import { WarningIcon } from 'components/ui/Icons'
+import { WarningIcon } from 'ui-patterns/Icons/StatusIcons'
import { Region, useReadReplicaSetUpMutation } from 'data/read-replicas/replica-setup-mutation'
import { useReadReplicasQuery } from 'data/read-replicas/replicas-query'
import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'
diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationRow.tsx b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationRow.tsx
index 355bf61de16..a423c544eea 100644
--- a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationRow.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationRow.tsx
@@ -8,7 +8,7 @@ import { useInView } from 'react-intersection-observer'
import { Button, IconArchive, IconExternalLink } from 'ui'
import { Markdown } from 'components/interfaces/Markdown'
-import { CriticalIcon, WarningIcon } from 'components/ui/Icons'
+import { CriticalIcon, WarningIcon } from 'ui-patterns/Icons/StatusIcons'
import type { ItemRenderer } from 'components/ui/InfiniteList'
import { Notification, NotificationData } from 'data/notifications/notifications-v2-query'
import { ProjectInfo } from 'data/projects/projects-query'
diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsFilter.tsx b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsFilter.tsx
index be5040a631e..4f3360fdcff 100644
--- a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsFilter.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsFilter.tsx
@@ -18,7 +18,7 @@ import {
} from 'ui'
import { CommandGroup } from '@ui/components/shadcn/ui/command'
-import { CriticalIcon, WarningIcon } from 'components/ui/Icons'
+import { CriticalIcon, WarningIcon } from 'ui-patterns/Icons/StatusIcons'
import { useOrganizationsQuery } from 'data/organizations/organizations-query'
import { useProjectsQuery } from 'data/projects/projects-query'
import { useNotificationsStateSnapshot } from 'state/notifications'
diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsPopover.tsx b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsPopover.tsx
index b3c47c85b3a..36c83ea74c9 100644
--- a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsPopover.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsPopover.tsx
@@ -14,7 +14,7 @@ import {
} from 'ui'
import AlertError from 'components/ui/AlertError'
-import { CriticalIcon, WarningIcon } from 'components/ui/Icons'
+import { CriticalIcon, WarningIcon } from 'ui-patterns/Icons/StatusIcons'
import InfiniteList from 'components/ui/InfiniteList'
import ShimmeringLoader, { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'
import { useNotificationsArchiveAllMutation } from 'data/notifications/notifications-v2-archive-all-mutation'
diff --git a/apps/studio/components/layouts/SQLEditorLayout/SQLEditorMenu.tsx b/apps/studio/components/layouts/SQLEditorLayout/SQLEditorMenu.tsx
index 5b7c4e60c91..a12de5934fd 100644
--- a/apps/studio/components/layouts/SQLEditorLayout/SQLEditorMenu.tsx
+++ b/apps/studio/components/layouts/SQLEditorLayout/SQLEditorMenu.tsx
@@ -31,7 +31,7 @@ import {
import { untitledSnippetTitle } from 'components/interfaces/SQLEditor/SQLEditor.constants'
import { createSqlSnippetSkeleton } from 'components/interfaces/SQLEditor/SQLEditor.utils'
-import { WarningIcon } from 'components/ui/Icons'
+import { WarningIcon } from 'ui-patterns/Icons/StatusIcons'
import { useContentDeleteMutation } from 'data/content/content-delete-mutation'
import { SqlSnippet, useSqlSnippetsQuery } from 'data/content/sql-snippets-query'
import { useCheckPermissions, useSelectedProject, useStore } from 'hooks'
diff --git a/apps/studio/components/ui/AISettingsModal.tsx b/apps/studio/components/ui/AISettingsModal.tsx
index 5bf8c5c6e0a..8daf70a72e9 100644
--- a/apps/studio/components/ui/AISettingsModal.tsx
+++ b/apps/studio/components/ui/AISettingsModal.tsx
@@ -12,7 +12,7 @@ import {
import { useLocalStorageQuery, useSelectedOrganization } from 'hooks'
import { IS_PLATFORM, LOCAL_STORAGE_KEYS, OPT_IN_TAGS } from 'lib/constants'
import { useAppStateSnapshot } from 'state/app-state'
-import { WarningIcon } from './Icons'
+import { WarningIcon } from 'ui-patterns/Icons/StatusIcons'
const AISettingsModal = () => {
const snap = useAppStateSnapshot()
diff --git a/apps/studio/components/ui/Icons.tsx b/apps/studio/components/ui/Icons.tsx
deleted file mode 100644
index 56d82de565b..00000000000
--- a/apps/studio/components/ui/Icons.tsx
+++ /dev/null
@@ -1,33 +0,0 @@
-export const CriticalIcon = ({ className }: { className?: string }) => {
- return (
- <svg
- xmlns="http://www.w3.org/2000/svg"
- viewBox="0 0 22 20"
- className={`w-4 h-4 p-0.5 text-destructive-200 bg-destructive-600 rounded ${className}`}
- fill="currentColor"
- >
- <path
- fill-rule="evenodd"
- clip-rule="evenodd"
- d="M8.15137 1.95117C9.30615 -0.0488281 12.1943 -0.0488281 13.3481 1.95117L20.7031 14.6992C21.8574 16.6992 20.4131 19.1992 18.104 19.1992H3.39502C1.08594 19.1992 -0.356933 16.6992 0.797364 14.6992L8.15137 1.95117ZM11.7666 16.0083C11.4971 16.2778 11.1313 16.4292 10.75 16.4292C10.3687 16.4292 10.0029 16.2778 9.7334 16.0083C9.46387 15.7388 9.3125 15.373 9.3125 14.9917C9.3125 14.9307 9.31641 14.8706 9.32373 14.811C9.33545 14.7197 9.35547 14.6304 9.38379 14.5439L9.41406 14.4609C9.48584 14.2803 9.59375 14.1147 9.7334 13.9751C10.0029 13.7056 10.3687 13.5542 10.75 13.5542C11.1313 13.5542 11.4971 13.7056 11.7666 13.9751C12.0361 14.2446 12.1875 14.6104 12.1875 14.9917C12.1875 15.373 12.0361 15.7388 11.7666 16.0083ZM10.75 4.69971C11.0317 4.69971 11.3022 4.81152 11.5015 5.01074C11.7007 5.20996 11.8125 5.48047 11.8125 5.76221V11.0747C11.8125 11.3564 11.7007 11.627 11.5015 11.8262C11.3022 12.0254 11.0317 12.1372 10.75 12.1372C10.4683 12.1372 10.1978 12.0254 9.99854 11.8262C9.79932 11.627 9.6875 11.3564 9.6875 11.0747V5.76221C9.6875 5.48047 9.79932 5.20996 9.99854 5.01074C10.1978 4.81152 10.4683 4.69971 10.75 4.69971Z"
- />
- </svg>
- )
-}
-
-export const WarningIcon = ({ className }: { className?: string }) => {
- return (
- <svg
- xmlns="http://www.w3.org/2000/svg"
- viewBox="0 0 21 20"
- className={`w-4 h-4 p-0.5 text-warning-200 bg-warning-600 rounded ${className}`}
- fill="currentColor"
- >
- <path
- fill-rule="evenodd"
- clip-rule="evenodd"
- d="M0.625 9.8252C0.625 4.44043 4.99023 0.0751953 10.375 0.0751953C15.7598 0.0751953 20.125 4.44043 20.125 9.8252C20.125 15.21 15.7598 19.5752 10.375 19.5752C4.99023 19.5752 0.625 15.21 0.625 9.8252ZM9.3584 4.38135C9.45117 4.28857 9.55518 4.20996 9.66699 4.14648C9.88086 4.02539 10.1245 3.96045 10.375 3.96045C10.5845 3.96045 10.7896 4.00586 10.9766 4.09229C11.1294 4.1626 11.2705 4.26025 11.3916 4.38135C11.6611 4.65088 11.8125 5.0166 11.8125 5.39795C11.8125 5.5249 11.7959 5.6499 11.7637 5.77002C11.6987 6.01172 11.5718 6.23438 11.3916 6.41455C11.1221 6.68408 10.7563 6.83545 10.375 6.83545C9.99365 6.83545 9.62793 6.68408 9.3584 6.41455C9.08887 6.14502 8.9375 5.7793 8.9375 5.39795C8.9375 5.29492 8.94873 5.19287 8.97021 5.09375C9.02783 4.82568 9.16162 4.57812 9.3584 4.38135ZM10.375 15.6899C10.0933 15.6899 9.82275 15.5781 9.62354 15.3789C9.42432 15.1797 9.3125 14.9092 9.3125 14.6274V9.31494C9.3125 9.0332 9.42432 8.7627 9.62354 8.56348C9.82275 8.36426 10.0933 8.25244 10.375 8.25244C10.6567 8.25244 10.9272 8.36426 11.1265 8.56348C11.3257 8.7627 11.4375 9.0332 11.4375 9.31494V14.6274C11.4375 14.7944 11.3979 14.9575 11.3242 15.104C11.2739 15.2046 11.2075 15.2979 11.1265 15.3789C10.9272 15.5781 10.6567 15.6899 10.375 15.6899Z"
- />
- </svg>
- )
-}
diff --git a/packages/ui-patterns/Icons/StatusIcons.stories.tsx b/packages/ui-patterns/Icons/StatusIcons.stories.tsx
new file mode 100644
index 00000000000..19e698b9f64
--- /dev/null
+++ b/packages/ui-patterns/Icons/StatusIcons.stories.tsx
@@ -0,0 +1,100 @@
+import { StoryObj } from '@storybook/react'
+import { Badge_Shadcn_ } from 'ui'
+import { StatusIcon } from './StatusIcons'
+
+// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
+export default {
+ title: 'Icons/StatusIcon',
+ component: StatusIcon,
+ parameters: {
+ // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
+ layout: 'centered',
+ },
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
+ tags: ['autodocs'],
+ // More on argTypes: https://storybook.js.org/docs/api/argtypes
+ argTypes: {},
+}
+
+// export default meta
+
+// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
+// export const Primary = {
+// args: {
+// size: 'small',
+// // visible: true,
+// },
+// }
+
+type Story = StoryObj<typeof StatusIcon>
+
+export const Default: Story = {
+ args: {
+ variant: 'default',
+ },
+ /**
+ * πŸ‘‡ To avoid linting issues, it is recommended to use a function with a capitalized name.
+ * If you are not concerned with linting, you may use an arrow function.
+ */
+ render: function Render(args) {
+ return <StatusIcon {...args} />
+ },
+}
+
+export const Destructive: Story = {
+ args: {
+ variant: 'destructive',
+ },
+ /**
+ * πŸ‘‡ To avoid linting issues, it is recommended to use a function with a capitalized name.
+ * If you are not concerned with linting, you may use an arrow function.
+ */
+ render: function Render(args) {
+ return <StatusIcon {...args} />
+ },
+}
+
+export const Warning: Story = {
+ args: {
+ variant: 'warning',
+ },
+ /**
+ * πŸ‘‡ To avoid linting issues, it is recommended to use a function with a capitalized name.
+ * If you are not concerned with linting, you may use an arrow function.
+ */
+ render: function Render(args) {
+ return <StatusIcon {...args} />
+ },
+}
+
+export const withNoBackground: Story = {
+ args: {
+ variant: 'default',
+ hideBackground: true,
+ },
+ /**
+ * πŸ‘‡ To avoid linting issues, it is recommended to use a function with a capitalized name.
+ * If you are not concerned with linting, you may use an arrow function.
+ */
+ render: function Render(args) {
+ return <StatusIcon {...args} />
+ },
+}
+
+export const InsideBadge: Story = {
+ args: {
+ variant: 'destructive',
+ },
+ /**
+ * πŸ‘‡ To avoid linting issues, it is recommended to use a function with a capitalized name.
+ * If you are not concerned with linting, you may use an arrow function.
+ */
+ render: function Render(args) {
+ return (
+ <Badge_Shadcn_ variant={'destructive'} className="flex gap-1">
+ <StatusIcon {...args} hideBackground />
+ Caution
+ </Badge_Shadcn_>
+ )
+ },
+}
diff --git a/packages/ui-patterns/Icons/StatusIcons.tsx b/packages/ui-patterns/Icons/StatusIcons.tsx
new file mode 100644
index 00000000000..b38da610a0f
--- /dev/null
+++ b/packages/ui-patterns/Icons/StatusIcons.tsx
@@ -0,0 +1,104 @@
+import { SVGProps, forwardRef } from 'react'
+import { cn } from 'ui'
+
+export interface StatusIconProps {
+ hideBackground?: boolean
+}
+
+export const StatusIcon = forwardRef<
+ HTMLOrSVGElement,
+ React.ComponentPropsWithoutRef<'svg'> & {
+ variant: 'success' | 'warning' | 'destructive' | 'default'
+ } & StatusIconProps
+>(({ variant = 'default', ...props }, ref) => {
+ let Icon: React.ElementType | undefined
+ if (variant === 'warning') {
+ Icon = WarningIcon
+ } else if (variant === 'destructive') {
+ Icon = CriticalIcon
+ } else {
+ Icon = InfoIcon
+ }
+
+ return Icon ? <Icon ref={ref} {...props} /> : null
+})
+
+const InfoIcon: React.FC<SVGProps<SVGSVGElement> & StatusIconProps> = ({
+ hideBackground = false,
+ ...props
+}) => {
+ return (
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 16 16"
+ fill="currentColor"
+ {...props}
+ className={cn(
+ !hideBackground
+ ? 'w-4 h-4 p-0.5 bg-foreground-lighter text-background-surface-200 rounded'
+ : 'w-3 h-3 text-foreground-lighter',
+ props.className
+ )}
+ >
+ <path
+ fill-rule="evenodd"
+ d="M15 8A7 7 0 1 1 1 8a7 7 0 0 1 14 0ZM9 5a1 1 0 1 1-2 0 1 1 0 0 1 2 0ZM6.75 8a.75.75 0 0 0 0 1.5h.75v1.75a.75.75 0 0 0 1.5 0v-2.5A.75.75 0 0 0 8.25 8h-1.5Z"
+ clip-rule="evenodd"
+ />
+ </svg>
+ )
+}
+
+const CriticalIcon: React.FC<SVGProps<SVGSVGElement> & StatusIconProps> = ({
+ hideBackground = false,
+ ...props
+}) => {
+ return (
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 16 16"
+ fill="currentColor"
+ {...props}
+ className={cn(
+ !hideBackground
+ ? 'w-4 h-4 p-0.5 bg-destructive-600 text-destructive-200 rounded'
+ : 'w-3 h-3 text-destructive-600',
+ props.className
+ )}
+ >
+ <path
+ fill-rule="evenodd"
+ d="M6.701 2.25c.577-1 2.02-1 2.598 0l5.196 9a1.5 1.5 0 0 1-1.299 2.25H2.804a1.5 1.5 0 0 1-1.3-2.25l5.197-9ZM8 4a.75.75 0 0 1 .75.75v3a.75.75 0 1 1-1.5 0v-3A.75.75 0 0 1 8 4Zm0 8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"
+ clip-rule="evenodd"
+ />
+ </svg>
+ )
+}
+
+const WarningIcon: React.FC<SVGProps<SVGSVGElement> & StatusIconProps> = ({
+ hideBackground = false,
+ ...props
+}) => {
+ return (
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 16 16"
+ fill="currentColor"
+ {...props}
+ className={cn(
+ !hideBackground
+ ? 'w-4 h-4 p-0.5 bg-warning-600 text-warning-200 rounded'
+ : 'w-3 h-3 text-warning-600',
+ props.className
+ )}
+ >
+ <path
+ fill-rule="evenodd"
+ d="M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14ZM8 4a.75.75 0 0 1 .75.75v3a.75.75 0 0 1-1.5 0v-3A.75.75 0 0 1 8 4Zm0 8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"
+ clip-rule="evenodd"
+ />
+ </svg>
+ )
+}
+
+export { WarningIcon, CriticalIcon }
diff --git a/packages/ui/index.tsx b/packages/ui/index.tsx
index d6c92f6e803..ad320595e23 100644
--- a/packages/ui/index.tsx
+++ b/packages/ui/index.tsx
@@ -85,6 +85,8 @@ export * from './src/components/shadcn/ui/use-toast'
export * from './src/components/shadcn/ui/toast'
export * from './src/components/shadcn/ui/toaster'
+export { Badge as Badge_Shadcn_ } from './src/components/shadcn/ui/badge'
+
export {
Command as Command_Shadcn_,
CommandDialog as CommandDialog_Shadcn_,
diff --git a/packages/ui/src/components/Badge/Badge.tsx b/packages/ui/src/components/Badge/Badge.tsx
index af526dc7747..8b36ec177ea 100644
--- a/packages/ui/src/components/Badge/Badge.tsx
+++ b/packages/ui/src/components/Badge/Badge.tsx
@@ -1,5 +1,6 @@
import { AvailableColors } from '../../lib/constants'
import styleHandler from '../../lib/theme/styleHandler'
+import { cn } from '../../lib/utils'
interface Props {
color?: AvailableColors
@@ -24,7 +25,7 @@ function Badge({ color = 'brand', children, size, dot, className }: Props) {
}
return (
- <span className={classes.join(' ')}>
+ <span className={cn(classes)}>
{dot && (
<svg
className={`${__styles.dot} ${__styles.color[color]}`}
diff --git a/packages/ui/src/components/shadcn/ui/badge.tsx b/packages/ui/src/components/shadcn/ui/badge.tsx
index bbda227ed1a..84d5568b71a 100644
--- a/packages/ui/src/components/shadcn/ui/badge.tsx
+++ b/packages/ui/src/components/shadcn/ui/badge.tsx
@@ -4,33 +4,18 @@ import * as React from 'react'
import { cn } from '../../../lib/utils/cn'
const badgeVariants = cva(
- 'inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-opacity-10',
+ 'inline-flex items-center px-2.5 py-0.5 rounded-full text-xs bg-opacity-10',
{
variants: {
variant: {
default: 'bg-surface-200 text-foreground-light border border-strong',
- brand: 'bg-brand-200 text-brand-primary border border-brand-400',
+ warning: 'bg-warning text-warning-600 border border-warning-500',
+ success: 'bg-brand text-brand-600 border border-brand-500',
+ destructive: 'bg-destructive text-destructive-600 border border-destructive-500',
+ brand: 'bg-brand text-brand-600 border border-brand-500',
secondary:
'bg-secondary hover:bg-secondary/80 border-transparent text-secondary-foreground',
- destructive: 'bg-destructive-400 text-destructive border border-destructive-300',
- outline: 'bg-transparent text border border-foreground',
- scale: 'bg-background text-foreground-light border border-strong',
- tomato: `bg-tomato-200 text-tomato-1100 border border-tomato-700`,
- red: `bg-red-200 text-red-1100 border border-red-700`,
- crimson: `bg-crimson-200 text-crimson-1100 border border-crimson-700`,
- pink: `bg-pink-200 text-pink-1100 border border-pink-700`,
- purple: `bg-purple-200 text-purple-1100 border border-purple-700`,
- violet: `bg-violet-200 text-violet-1100 border border-violet-700`,
- indigo: `bg-indigo-200 text-indigo-1100 border border-indigo-700`,
- blue: `bg-blue-200 text-blue-1100 border border-blue-700`,
- green: `bg-brand-500 text-brand-600 border border-brand-400`,
- grass: `bg-grass-200 text-grass-1100 border border-grass-700`,
- orange: `bg-orange-200 text-orange-1100 border border-orange-700`,
- yellow: `bg-yellow-200 text-yellow-1100 border border-yellow-700`,
- amber: `bg-amber-200 text-amber-1100 border border-amber-700`,
- gold: `bg-gold-200 text-gold-1100 border border-gold-700`,
- gray: `bg-gray-200 text-gray-1100 border border-gray-700`,
- slate: `bg-slate-200 text-slate-1100 border border-slate-700`,
+ outline: 'bg-transparent text border border-foreground-muted',
},
size: {
small: 'px-2.5 py-0.5 text-xs',
@@ -46,39 +31,6 @@ const badgeVariants = cva(
},
}
)
-// const badgeVariants = cva(
-// 'inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-opacity-10',
-// {
-// variants: {
-// variant: {
-// size: {
-// large: 'px-3 py-0.5 rounded-full text-sm',
-// },
-// dot: '-ml-0.5 mr-1.5 h-2 w-2 rounded-full',
-// color: {
-// brand: 'bg-brand-200 text-brand-600 border border-brand-400',
-// scale: 'bg-background text-foreground-light border border-strong',
-// tomato: `bg-tomato-200 text-tomato-1100 border border-tomato-700`,
-// red: `bg-red-200 text-red-1100 border border-red-700`,
-// crimson: `bg-crimson-200 text-crimson-1100 border border-crimson-700`,
-// pink: `bg-pink-200 text-pink-1100 border border-pink-700`,
-// purple: `bg-purple-200 text-purple-1100 border border-purple-700`,
-// violet: `bg-violet-200 text-violet-1100 border border-violet-700`,
-// indigo: `bg-indigo-200 text-indigo-1100 border border-indigo-700`,
-// blue: `bg-blue-200 text-blue-1100 border border-blue-700`,
-// green: `bg-opacity-10 bg-brand-500 text-brand-600 border border-brand-500`,
-// grass: `bg-grass-200 text-grass-1100 border border-grass-700`,
-// orange: `bg-orange-200 text-orange-1100 border border-orange-700`,
-// yellow: `bg-yellow-200 text-yellow-1100 border border-yellow-700`,
-// amber: `bg-amber-200 text-amber-1100 border border-amber-700`,
-// gold: `bg-gold-200 text-gold-1100 border border-gold-700`,
-// gray: `bg-gray-200 text-gray-1100 border border-gray-700`,
-// slate: `bg-slate-200 text-slate-1100 border border-slate-700`,
-// },
-// },
-// },
-// }
-// )
export interface BadgeProps
extends React.HTMLAttributes<HTMLDivElement>,