From 159bda6df4be8e6a4e1a2f3f0517469470096b95 Mon Sep 17 00:00:00 2001 From: Jonathan Summers-Muir Date: Mon, 24 Jun 2024 12:10:53 +0800 Subject: [PATCH] more panels --- .../[project]/[config]/page-render.tsx | 18 +++++ .../settings/[project]/[config]/page.tsx | 10 +++ .../src/app/[org]/settings/account/page.tsx | 0 .../src/app/[org]/settings/layout.tsx | 1 - .../[org]/settings/settings-menu-children.tsx | 70 +++++++++++++++++++ .../[org]/settings/settings-menu-panel.tsx | 13 ++-- .../src/app/[org]/side-nav-menu-icon.tsx | 4 +- .../table-editor/table-editor-items-panel.tsx | 26 ++++++- .../studio-prototype/src/config/settings.json | 62 ++++++++++++++++ apps/studio-prototype/src/hooks/use-config.ts | 2 + 10 files changed, 192 insertions(+), 14 deletions(-) create mode 100644 apps/studio-prototype/src/app/[org]/settings/[project]/[config]/page-render.tsx create mode 100644 apps/studio-prototype/src/app/[org]/settings/[project]/[config]/page.tsx create mode 100644 apps/studio-prototype/src/app/[org]/settings/account/page.tsx create mode 100644 apps/studio-prototype/src/app/[org]/settings/settings-menu-children.tsx create mode 100644 apps/studio-prototype/src/config/settings.json diff --git a/apps/studio-prototype/src/app/[org]/settings/[project]/[config]/page-render.tsx b/apps/studio-prototype/src/app/[org]/settings/[project]/[config]/page-render.tsx new file mode 100644 index 00000000000..ee0d6d70db7 --- /dev/null +++ b/apps/studio-prototype/src/app/[org]/settings/[project]/[config]/page-render.tsx @@ -0,0 +1,18 @@ +'use client' + +import { useParams, usePathname } from 'next/navigation' +import { cn } from 'ui' + +export default function PageRender() { + const { org, config } = useParams() + const pathname = usePathname() + + return ( +
+ + {org} {config} {pathname} + +
+
+ ) +} diff --git a/apps/studio-prototype/src/app/[org]/settings/[project]/[config]/page.tsx b/apps/studio-prototype/src/app/[org]/settings/[project]/[config]/page.tsx new file mode 100644 index 00000000000..a79b427717b --- /dev/null +++ b/apps/studio-prototype/src/app/[org]/settings/[project]/[config]/page.tsx @@ -0,0 +1,10 @@ +import PageRender from './page-render' + +export default function SettingsProjectPage() { + return ( +
+ +
+
+ ) +} diff --git a/apps/studio-prototype/src/app/[org]/settings/account/page.tsx b/apps/studio-prototype/src/app/[org]/settings/account/page.tsx new file mode 100644 index 00000000000..e69de29bb2d diff --git a/apps/studio-prototype/src/app/[org]/settings/layout.tsx b/apps/studio-prototype/src/app/[org]/settings/layout.tsx index e2611c58282..0f241f56475 100644 --- a/apps/studio-prototype/src/app/[org]/settings/layout.tsx +++ b/apps/studio-prototype/src/app/[org]/settings/layout.tsx @@ -8,7 +8,6 @@ export default function TableEditorLayout({ return (
-
{children}
diff --git a/apps/studio-prototype/src/app/[org]/settings/settings-menu-children.tsx b/apps/studio-prototype/src/app/[org]/settings/settings-menu-children.tsx new file mode 100644 index 00000000000..f0bc4506e60 --- /dev/null +++ b/apps/studio-prototype/src/app/[org]/settings/settings-menu-children.tsx @@ -0,0 +1,70 @@ +import React from 'react' + +import settingsData from '@/src/config/settings.json' +import { ScrollArea, ScrollBar } from 'ui' +import { useConfig } from '@/src/hooks/use-config' + +const SettingsMenuChildren: React.FC = () => { + const [config] = useConfig() + + const { organization, project } = config + + const getBasePath = (section: string) => { + switch (section) { + case 'PROJECT_SETTINGS': + return `/${organization}/settings/${project}` + case 'ORGANIZATION_SETTINGS': + return `/${organization}/settings` + case 'ACCOUNT_SETTINGS': + return `/${organization}/settings/account` + default: + return '' + } + } + + const renderItems = (items: any[], basePath: string) => { + return items.map((item) => ( +
  • + + {item.label} + + {item.items && ( + + )} +
  • + )) + } + + return ( + + + + + ) +} + +export default SettingsMenuChildren diff --git a/apps/studio-prototype/src/app/[org]/settings/settings-menu-panel.tsx b/apps/studio-prototype/src/app/[org]/settings/settings-menu-panel.tsx index cba37455a93..9b0075fdc14 100644 --- a/apps/studio-prototype/src/app/[org]/settings/settings-menu-panel.tsx +++ b/apps/studio-prototype/src/app/[org]/settings/settings-menu-panel.tsx @@ -2,28 +2,25 @@ import { useParams, usePathname } from 'next/navigation' import { cn } from 'ui' +import SettingsMenuChildren from './settings-menu-children' export default function SettingsMenuPanel() { const { org } = useParams() const pathname = usePathname() - const isActive = pathname === `/${org}/settings` + const isActive = pathname.startsWith(`/${org}/settings`) return (
    - items panel +
    ) } diff --git a/apps/studio-prototype/src/app/[org]/side-nav-menu-icon.tsx b/apps/studio-prototype/src/app/[org]/side-nav-menu-icon.tsx index 528e767dadb..7604ebb5a54 100644 --- a/apps/studio-prototype/src/app/[org]/side-nav-menu-icon.tsx +++ b/apps/studio-prototype/src/app/[org]/side-nav-menu-icon.tsx @@ -7,9 +7,7 @@ import { cn } from 'ui' export default function SideNavMenuIcon({ product }: { product: any }) { const { org } = useParams() const pathname = usePathname() - const isActive = pathname === `/${org}${product.href}` - - console.log('pathname', pathname) + const isActive = pathname.startsWith(`/${org}${product.href}`) return ( - items panel +
    + hello world
    ) } diff --git a/apps/studio-prototype/src/config/settings.json b/apps/studio-prototype/src/config/settings.json new file mode 100644 index 00000000000..66e6f1ba975 --- /dev/null +++ b/apps/studio-prototype/src/config/settings.json @@ -0,0 +1,62 @@ +{ + "PROJECT_SETTINGS": { + "metadata": { + "base_path": "/project" + }, + "items": [ + { "label": "General", "key": "general", "href": "/general" }, + { "label": "Infrastructure", "key": "infrastructure", "href": "/infrastructure" }, + { "label": "Integrations", "key": "integrations", "href": "/integrations" }, + { "label": "Add ons", "key": "add_ons", "href": "/add-ons" }, + { "label": "Vault", "key": "vault", "href": "/vault" }, + { "label": "Database", "key": "database", "href": "/database" }, + { + "label": "Authentication", + "key": "authentication", + "href": "/authentication", + "items": [ + { "label": "General", "key": "auth_general", "href": "/authentication/general" }, + { "label": "Providers", "key": "providers", "href": "/authentication/providers" }, + { "label": "Rate Limits", "key": "rate_limits", "href": "/authentication/rate-limits" }, + { + "label": "Email templates", + "key": "email_templates", + "href": "/authentication/email-templates" + }, + { + "label": "URL configuration", + "key": "url_configuration", + "href": "/authentication/url-configuration" + }, + { "label": "Hooks", "key": "hooks", "href": "/authentication/hooks" } + ] + }, + { "label": "Storage", "key": "storage", "href": "/storage" }, + { "label": "Edge Functions", "key": "edge_functions", "href": "/edge-functions" }, + { "label": "Realtime", "key": "realtime", "href": "/realtime" }, + { "label": "Branching", "key": "branching", "href": "/branching" } + ] + }, + "ORGANIZATION_SETTINGS": { + "items": [ + { "label": "General", "key": "general", "href": "/general" }, + { "label": "Subscription plan", "key": "subscription_plan", "href": "/subscription-plan" }, + { "label": "Team", "key": "team", "href": "/team" }, + { "label": "Integrations", "key": "integrations", "href": "/integrations" }, + { "label": "Billing", "key": "billing", "href": "/billing" }, + { "label": "Usage", "key": "usage", "href": "/usage" }, + { "label": "Invoices", "key": "invoices", "href": "/invoices" }, + { "label": "OAuth apps", "key": "oauth_apps", "href": "/oauth-apps" }, + { "label": "Audit logs", "key": "audit_logs", "href": "/audit-logs" }, + { "label": "Legal documents", "key": "legal_documents", "href": "/legal-documents" } + ] + }, + "ACCOUNT_SETTINGS": { + "items": [ + { "label": "General", "key": "general", "href": "/general" }, + { "label": "Access tokens", "key": "access_tokens", "href": "/access-tokens" }, + { "label": "Security", "key": "security", "href": "/security" }, + { "label": "Audit logs", "key": "audit_logs", "href": "/audit-logs" } + ] + } +} diff --git a/apps/studio-prototype/src/hooks/use-config.ts b/apps/studio-prototype/src/hooks/use-config.ts index 209ed875f47..04f7943f6ff 100644 --- a/apps/studio-prototype/src/hooks/use-config.ts +++ b/apps/studio-prototype/src/hooks/use-config.ts @@ -4,11 +4,13 @@ import { atomWithStorage } from 'jotai/utils' type Config = { radius: number organization?: string + project?: string } const configAtom = atomWithStorage('config', { radius: 0.5, organization: 'Summers-Muir', + project: 'Sonsing', }) export function useConfig() {