Skip to content

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

Chore/prepare org nav rollout (#35175)

Joshen Lim6794f4c6ebb6
diff --git a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsx b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsx
index 5a8a0221444..d4d4b770dfa 100644
--- a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsx
+++ b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsx
@@ -1,5 +1,7 @@
import { noop } from 'lodash'
+import { FeatureFlagContext } from 'common'
+import { useFlag } from 'hooks/ui/useFlag'
import { IS_PLATFORM, LOCAL_STORAGE_KEYS } from 'lib/constants'
import { EMPTY_OBJ } from 'lib/void'
import { PropsWithChildren, createContext, useContext, useEffect, useState } from 'react'
@@ -15,7 +17,7 @@ export const FEATURE_PREVIEWS = [
key: LOCAL_STORAGE_KEYS.UI_NEW_LAYOUT_PREVIEW,
name: 'Layout Update for Organizations',
content: <LayoutUpdatePreview />,
- discussionsUrl: 'https://github.com/orgs/supabase/discussions/18038',
+ discussionsUrl: 'https://github.com/orgs/supabase/discussions/33670',
isNew: false,
isPlatformOnly: true,
},
@@ -72,6 +74,19 @@ const FeaturePreviewContext = createContext<FeaturePreviewContextType>({
export const useFeaturePreviewContext = () => useContext(FeaturePreviewContext)
export const FeaturePreviewContextProvider = ({ children }: PropsWithChildren<{}>) => {
+ const { hasLoaded } = useContext(FeatureFlagContext)
+ const enableNewLayoutPreview = useFlag('newLayoutPreview')
+
+ // [Joshen] Similar logic to feature flagging previews, we can use flags to default opt in previews
+ const isDefaultOptIn = (feature: (typeof FEATURE_PREVIEWS)[number]) => {
+ switch (feature.key) {
+ case LOCAL_STORAGE_KEYS.UI_NEW_LAYOUT_PREVIEW:
+ return enableNewLayoutPreview
+ default:
+ return false
+ }
+ }
+
const [flags, setFlags] = useState(() =>
FEATURE_PREVIEWS.reduce((a, b) => {
return { ...a, [b.key]: false }
@@ -82,11 +97,16 @@ export const FeaturePreviewContextProvider = ({ children }: PropsWithChildren<{}
if (typeof window !== 'undefined') {
setFlags(
FEATURE_PREVIEWS.reduce((a, b) => {
- return { ...a, [b.key]: localStorage.getItem(b.key) === 'true' }
+ const defaultOptIn = isDefaultOptIn(b)
+ const localStorageValue = localStorage.getItem(b.key)
+ return {
+ ...a,
+ [b.key]: !localStorageValue ? defaultOptIn : localStorageValue === 'true',
+ }
}, {})
)
}
- }, [])
+ }, [hasLoaded])
const value = {
flags,
diff --git a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewModal.tsx b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewModal.tsx
index 71862a31f93..5f78dde3e6b 100644
--- a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewModal.tsx
+++ b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewModal.tsx
@@ -5,7 +5,6 @@ import { useEffect } from 'react'
import { useParams } from 'common'
import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'
-import { useFlag } from 'hooks/ui/useFlag'
import { IS_PLATFORM, LOCAL_STORAGE_KEYS } from 'lib/constants'
import { useAppStateSnapshot } from 'state/app-state'
import { removeTabsByEditor } from 'state/tabs'
@@ -19,12 +18,9 @@ const FeaturePreviewModal = () => {
const featurePreviewContext = useFeaturePreviewContext()
const { mutate: sendEvent } = useSendEventMutation()
- const enableNewLayoutPreview = useFlag('newLayoutPreview')
-
+ // [Joshen] Use this if we want to feature flag previews
function isReleasedToPublic(feature: (typeof FEATURE_PREVIEWS)[number]) {
switch (feature.key) {
- case LOCAL_STORAGE_KEYS.UI_NEW_LAYOUT_PREVIEW:
- return enableNewLayoutPreview
default:
return true
}
diff --git a/apps/studio/components/interfaces/App/FeaturePreview/LayoutUpdatePreview.tsx b/apps/studio/components/interfaces/App/FeaturePreview/LayoutUpdatePreview.tsx
index 0c143b92305..be462dde866 100644
--- a/apps/studio/components/interfaces/App/FeaturePreview/LayoutUpdatePreview.tsx
+++ b/apps/studio/components/interfaces/App/FeaturePreview/LayoutUpdatePreview.tsx
@@ -1,5 +1,10 @@
-import { BASE_PATH } from 'lib/constants'
+import { ButtonTooltip } from 'components/ui/ButtonTooltip'
+import { useLocalStorageQuery } from 'hooks/misc/useLocalStorage'
+import { BASE_PATH, LOCAL_STORAGE_KEYS } from 'lib/constants'
+import { ExternalLink, X } from 'lucide-react'
import Image from 'next/image'
+import { Alert_Shadcn_, AlertDescription_Shadcn_, AlertTitle_Shadcn_, Badge, Button } from 'ui'
+import { useIsNewLayoutEnabled } from './FeaturePreviewContext'
export const LayoutUpdatePreview = () => {
return (
@@ -37,3 +42,48 @@ export const LayoutUpdatePreview = () => {
</div>
)
}
+
+export const LayoutUpdateBanner = () => {
+ const newLayoutPreview = useIsNewLayoutEnabled()
+ const [newLayoutPreviewState] = useLocalStorageQuery(LOCAL_STORAGE_KEYS.UI_NEW_LAYOUT_PREVIEW, '')
+ const [newLayoutAcknowledged, setNewLayoutAcknowledged] = useLocalStorageQuery(
+ LOCAL_STORAGE_KEYS.NEW_LAYOUT_NOTICE_ACKNOWLEDGED,
+ false
+ )
+ const isDefaultOptedInNewLayout = newLayoutPreview && newLayoutPreviewState === ''
+
+ if (!isDefaultOptedInNewLayout || newLayoutAcknowledged) return null
+
+ return (
+ <Alert_Shadcn_ className="mb-4 relative">
+ <AlertTitle_Shadcn_>
+ <Badge variant="brand" className="mr-2">
+ NEW
+ </Badge>
+ Dashboard layout has been updated!
+ </AlertTitle_Shadcn_>
+ <AlertDescription_Shadcn_>
+ We've updated the dashboard layout to make it easier to find and manage your organization
+ settings.
+ </AlertDescription_Shadcn_>
+ <AlertDescription_Shadcn_ className="mt-4 flex items-center gap-x-2">
+ <Button asChild type="default" icon={<ExternalLink />}>
+ <a
+ target="_blank"
+ rel="noreferrer noopener"
+ href="https://github.com/orgs/supabase/discussions/33670"
+ >
+ View announcement
+ </a>
+ </Button>
+ </AlertDescription_Shadcn_>
+ <ButtonTooltip
+ type="text"
+ icon={<X />}
+ className="absolute top-2 right-2 px-1"
+ onClick={() => setNewLayoutAcknowledged(true)}
+ tooltip={{ content: { side: 'bottom', text: 'Dismiss' } }}
+ />
+ </Alert_Shadcn_>
+ )
+}
diff --git a/apps/studio/lib/constants/index.ts b/apps/studio/lib/constants/index.ts
index ac4f7e22636..01897488056 100644
--- a/apps/studio/lib/constants/index.ts
+++ b/apps/studio/lib/constants/index.ts
@@ -53,7 +53,7 @@ export const LOCAL_STORAGE_KEYS = {
UI_SQL_EDITOR_TABS: 'supabase-ui-sql-editor-tabs',
UI_NEW_LAYOUT_PREVIEW: 'supabase-ui-new-layout-preview',
- SQL_SCRATCH_PAD_BANNER_ACKNOWLEDGED: 'supabase-sql-scratch-pad-banner-acknowledged',
+ NEW_LAYOUT_NOTICE_ACKNOWLEDGED: 'new-layout-notice-acknowledge',
DASHBOARD_HISTORY: (ref: string) => `dashboard-history-${ref}`,
@@ -72,7 +72,6 @@ export const LOCAL_STORAGE_KEYS = {
GRAPHIQL_RLS_BYPASS_WARNING: 'graphiql-rls-bypass-warning-dismissed',
CLS_DIFF_WARNING: 'cls-diff-warning-dismissed',
CLS_SELECT_STAR_WARNING: 'cls-select-star-warning-dismissed',
- PROJECT_LINT_IGNORE_LIST: 'supabase-project-lint-ignore-list',
QUERY_PERF_SHOW_BOTTOM_SECTION: 'supabase-query-perf-show-bottom-section',
// Key to track account deletion requests
ACCOUNT_DELETION_REQUEST: 'supabase-account-deletion-request',
@@ -82,8 +81,6 @@ export const LOCAL_STORAGE_KEYS = {
LAST_SIGN_IN_METHOD: 'supabase-last-sign-in-method',
// Key to track the last selected schema. The project ref is intentionally put at the end for easier search in the browser console.
LAST_SELECTED_SCHEMA: (ref: string) => `last-selected-schema-${ref}`,
- // Key to show a warning on the SQL Editor AI Assistant that the org hasn't opted-in to sending anon data
- SHOW_AI_NOT_OPTIMIZED_WARNING: (ref: string) => `supabase-show-ai-not-optimized-${ref}`,
// Track position of nodes for schema visualizer
SCHEMA_VISUALIZER_POSITIONS: (ref: string, schemaId: number) =>
`schema-visualizer-positions-${ref}-${schemaId}`,
@@ -92,9 +89,7 @@ export const LOCAL_STORAGE_KEYS = {
GITHUB_AUTHORIZATION_STATE: 'supabase-github-authorization-state',
// Notice banner keys
FLY_POSTGRES_DEPRECATION_WARNING: 'fly-postgres-deprecation-warning-dismissed',
-
AUTH_USERS_COLUMNS_CONFIGURATION: (ref: string) => `supabase-auth-users-columns-${ref}`,
- STORAGE_BUCKETS_COLUMN_CONFIG: (ref: string) => `supabase-storage-buckets-columns-${ref}`,
// api keys view switcher for new and legacy api keys
API_KEYS_VIEW: (ref: string) => `supabase-api-keys-view-${ref}`,
diff --git a/apps/studio/pages/org/[slug]/index.tsx b/apps/studio/pages/org/[slug]/index.tsx
index 044935bcd8e..2cccccb89fd 100644
--- a/apps/studio/pages/org/[slug]/index.tsx
+++ b/apps/studio/pages/org/[slug]/index.tsx
@@ -3,6 +3,7 @@ import { useEffect, useState } from 'react'
import { useParams } from 'common'
import { useIsNewLayoutEnabled } from 'components/interfaces/App/FeaturePreview/FeaturePreviewContext'
+import { LayoutUpdateBanner } from 'components/interfaces/App/FeaturePreview/LayoutUpdatePreview'
import { ProjectList } from 'components/interfaces/Home/ProjectList'
import HomePageActions from 'components/interfaces/HomePageActions'
import DefaultLayout from 'components/layouts/DefaultLayout'
@@ -37,12 +38,15 @@ const ProjectsPage: NextPageWithLayout = () => {
return (
<ScaffoldContainerLegacy>
<div>
+ <LayoutUpdateBanner />
+
<HomePageActions
search={search}
setSearch={setSearch}
filterStatus={filterStatus}
setFilterStatus={setFilterStatus}
/>
+
<div className="my-6 space-y-8">
<ProjectList
filterToSlug
diff --git a/apps/studio/pages/organizations.tsx b/apps/studio/pages/organizations.tsx
index e4ed10f37d8..ad939867035 100644
--- a/apps/studio/pages/organizations.tsx
+++ b/apps/studio/pages/organizations.tsx
@@ -2,6 +2,7 @@ import { Boxes } from 'lucide-react'
import { useRouter } from 'next/router'
import { useEffect } from 'react'
+import { LayoutUpdateBanner } from 'components/interfaces/App/FeaturePreview/LayoutUpdatePreview'
import AppLayout from 'components/layouts/AppLayout/AppLayout'
import DefaultLayout from 'components/layouts/DefaultLayout'
import { ScaffoldContainerLegacy, ScaffoldTitle } from 'components/layouts/Scaffold'
@@ -27,6 +28,7 @@ const OrganizationsPage: NextPageWithLayout = () => {
return (
<>
<ScaffoldContainerLegacy>
+ <LayoutUpdateBanner />
<ScaffoldTitle>Your Organizations</ScaffoldTitle>
</ScaffoldContainerLegacy>
<ScaffoldContainerLegacy>
diff --git a/packages/common/feature-flags.tsx b/packages/common/feature-flags.tsx
index a715439a88b..f79131f2fea 100644
--- a/packages/common/feature-flags.tsx
+++ b/packages/common/feature-flags.tsx
@@ -33,7 +33,7 @@ export type FeatureFlagContextType = {
hasLoaded?: boolean
}
-const FeatureFlagContext = createContext<FeatureFlagContextType>({
+export const FeatureFlagContext = createContext<FeatureFlagContextType>({
API_URL: undefined,
configcat: {},
posthog: {},