diff --git a/.changeset/team-settings-sidebar.md b/.changeset/team-settings-sidebar.md new file mode 100644 index 0000000000..14757dab35 --- /dev/null +++ b/.changeset/team-settings-sidebar.md @@ -0,0 +1,8 @@ +--- +'@hyperdx/app': patch +--- + +feat: team settings now has a sidebar with one page per setting and a search +box that also finds individual settings, such as "Parallelize queries when +possible", and jumps to them. API keys and organization API keys share one page. +Old `?tab=` links redirect to the new pages. diff --git a/packages/app/src/OnboardingChecklist/onboardingTasks.ts b/packages/app/src/OnboardingChecklist/onboardingTasks.ts index 5646f68adc..1716079796 100644 --- a/packages/app/src/OnboardingChecklist/onboardingTasks.ts +++ b/packages/app/src/OnboardingChecklist/onboardingTasks.ts @@ -36,8 +36,7 @@ export const PRODUCT_TASKS: Record< mcp: { title: 'Connect the MCP server', description: 'Query your data from an AI agent', - // /team alone lands on the Data tab (TeamPage falls back to tabs[0]). - href: '/team?tab=api-agents#team-api-agents-mcp-server', + href: '/team?tab=mcp', }, }; diff --git a/packages/app/src/OnboardingChecklist/useOnboardingCompletion.ts b/packages/app/src/OnboardingChecklist/useOnboardingCompletion.ts index 386fbf819f..5eb5340ec4 100644 --- a/packages/app/src/OnboardingChecklist/useOnboardingCompletion.ts +++ b/packages/app/src/OnboardingChecklist/useOnboardingCompletion.ts @@ -117,7 +117,7 @@ export function useOnboardingCompletion( description: 'Set up your database connection', isComplete: hasConnections, isLoading: isConnectionsLoading, - href: hasConnections ? undefined : '/team', + href: hasConnections ? undefined : '/team?tab=connections', }, { id: 'sources', @@ -125,7 +125,7 @@ export function useOnboardingCompletion( description: 'Configure where your data comes from', isComplete: hasSources, isLoading: isSourcesLoading, - href: hasSources ? undefined : '/team', + href: hasSources ? undefined : '/team?tab=sources', }, { id: 'data', diff --git a/packages/app/src/TeamPage.tsx b/packages/app/src/TeamPage.tsx index f4391b5b68..d93d71d0a3 100644 --- a/packages/app/src/TeamPage.tsx +++ b/packages/app/src/TeamPage.tsx @@ -2,27 +2,17 @@ import { ReactNode, useCallback, useEffect, useState } from 'react'; import Head from 'next/head'; import { useRouter } from 'next/router'; import { SubmitHandler, useForm } from 'react-hook-form'; +import { Badge } from '@clickhouse/click-ui'; import { - Box, + Anchor, Button, Center, - Container, Group, Loader, - Stack, - Tabs, TextInput, } from '@mantine/core'; import { notifications } from '@mantine/notifications'; -import { - IconAdjustmentsHorizontal, - IconApi, - IconDatabase, - IconPencil, - IconPlug, - IconShieldLock, - IconUsers, -} from '@tabler/icons-react'; +import { IconExternalLink, IconPencil } from '@tabler/icons-react'; import { PageHeader } from './components/PageHeader'; import ApiKeysSection from './components/TeamSettings/ApiKeysSection'; @@ -32,61 +22,54 @@ import IntegrationsSection from './components/TeamSettings/IntegrationsSection'; import McpServerSection from './components/TeamSettings/McpServerSection'; import OrgApiKeysSection from './components/TeamSettings/OrgApiKeysSection'; import SecurityPoliciesSection from './components/TeamSettings/SecurityPoliciesSection'; +import { + resolveSettingsPage, + SETTINGS_PAGES, + SettingsPageId, +} from './components/TeamSettings/settingsPages'; import SourcesSection from './components/TeamSettings/SourcesSection'; import TeamMembersSection from './components/TeamSettings/TeamMembersSection'; import TeamQueryConfigSection from './components/TeamSettings/TeamQueryConfigSection'; +import TeamSettingsNav from './components/TeamSettings/TeamSettingsNav'; +import { useScrollToSetting } from './components/TeamSettings/useScrollToSetting'; import api from './api'; import { usePageTitle } from './brand'; -import { IS_IAC_EXPORT_ENABLED, IS_LOCAL_MODE } from './config'; +import { IS_LOCAL_MODE } from './config'; import { APP_CONTENT_SCROLL_CONTAINER_ID, withAppNav } from './layout'; -type TeamTab = { - value: string; - label: string; - icon: ReactNode; - sections: { - id: string; - // Always a function of whether this tab is the visible one. Mantine `Tabs` - // keeps every panel mounted, so a section that fetches on mount would - // otherwise do so on every Team Settings visit. Uniform rather than a - // `ReactNode | fn` union: the union let a bare `
` be passed where - // the closure form was needed, silently reinstating the eager fetch. - content: (active: boolean) => ReactNode; - }[]; -}; - -function TeamTabContent({ - sections, - active, -}: { - sections: TeamTab['sections']; - active: boolean; -}) { - // Deep links like `?tab=api-agents#team-api-agents-mcp-server` (spotlight, - // onboarding) land before the team has loaded, so Next's own hash scroll - // finds no element. - const { asPath } = useRouter(); - const hash = asPath.split('#')[1]; - const scrollTargetId = - active && sections.some(section => section.id === hash) ? hash : null; - useEffect(() => { - if (!scrollTargetId) return; - requestAnimationFrame(() => { - document - .getElementById(scrollTargetId) - ?.scrollIntoView({ behavior: 'smooth', block: 'start' }); - }); - }, [scrollTargetId]); +import styles from './components/TeamSettings/TeamSettings.module.scss'; - return ( - - {sections.map(section => ( - - {section.content(active)} - - ))} - - ); +function renderSettingsPage( + id: SettingsPageId, + allowedAuthMethods: string[], +): ReactNode { + switch (id) { + case 'sources': + return ; + case 'connections': + return ; + case 'query-settings': + return ; + case 'members': + return ; + case 'security-policies': + return ( + + ); + case 'webhooks': + return ; + case 'api-keys': + return ( + + {/* Org keys are stored by the API, which local mode doesn't run. */} + {!IS_LOCAL_MODE && } + + ); + case 'mcp': + return ; + case 'terraform': + return ; + } } export default function TeamPage() { @@ -128,169 +111,66 @@ export default function TeamPage() { [refetchTeam, setTeamName], ); - const tabs: TeamTab[] = [ - { - value: 'data', - label: 'Data', - icon: , - sections: [ - { - id: 'team-data-sources', - content: () => , - }, - { - id: 'team-data-connections', - content: () => , - }, - ], - }, - { - value: 'team', - label: 'Members', - icon: , - sections: [ - { - id: 'team-members', - content: () => , - }, - ], - }, - ...(hasAllowedAuthMethods - ? [ - { - value: 'access', - label: 'Access', - icon: , - sections: [ - { - id: 'team-access-security-policies', - content: () => ( - - ), - }, - ], - }, - ] - : []), - { - value: 'api-agents', - label: 'API & Agents', - icon: , - sections: [ - { - id: 'team-api-agents-api-keys', - content: () => , - }, - // Org keys are stored by the API, which local mode doesn't run. - ...(IS_LOCAL_MODE - ? [] - : [ - { - id: 'team-api-agents-org-api-keys', - content: () => , - }, - ]), - { - id: 'team-api-agents-mcp-server', - content: () => , - }, - ...(IS_IAC_EXPORT_ENABLED - ? [ - { - id: 'team-api-agents-iac', - content: (active: boolean) => ( - - ), - }, - ] - : []), - ], - }, - { - value: 'integrations', - label: 'Integrations', - icon: , - sections: [ - { - id: 'team-integrations-webhooks', - content: () => , - }, - ], - }, - { - value: 'advanced', - label: 'Query Settings', - icon: , - sections: [ - { - id: 'team-advanced-query-settings', - content: () => , - }, - ], - }, - ]; - + const pages = SETTINGS_PAGES.filter( + page => !page.requiresAuthPolicy || hasAllowedAuthMethods, + ); const queryTab = typeof router.query.tab === 'string' ? router.query.tab : null; - const activeTab = tabs.some(tab => tab.value === queryTab) - ? queryTab - : tabs[0]?.value; + // asPath carries the hash on the client; the server render never sees it. + const hash = router.asPath.split('#')[1] ?? ''; + const { id: activeId, legacyAnchor } = resolveSettingsPage( + pages, + queryTab, + hash, + ); + const activePage = pages.find(page => page.id === activeId); + const [jumpNonce, setJumpNonce] = useState(0); + // Start waiting for the field only once the team has loaded and the page renders. + useScrollToSetting( + team != null && activePage?.items?.some(item => item.anchor === hash) + ? hash + : null, + jumpNonce, + ); + // Rewrite old and missing `?tab=` values to the page being shown. Waits for + // the team so a security policies link isn't redirected before it loads. useEffect(() => { - if (!router.isReady || !activeTab || queryTab === activeTab) { - return; - } - - // Preserve any hash (e.g. `#source-` deep links consumed by - // SourcesList) — this replace only normalizes the `tab` param and - // must not strip other parts of the URL. - const hash = window.location.hash.slice(1); + if (!router.isReady || team == null) return; + if (queryTab === activeId && !legacyAnchor) return; void router.replace( { pathname: router.pathname, - query: { - ...router.query, - tab: activeTab, - }, - hash: hash || undefined, + query: { ...router.query, tab: activeId }, + // Keep anchors pages consume themselves, like SourcesList's `#source-`. + hash: legacyAnchor ? undefined : hash || undefined, }, undefined, + { shallow: true, scroll: false }, + ); + }, [activeId, hash, legacyAnchor, queryTab, router, team]); + + const selectPage = (id: SettingsPageId, anchor?: string) => { + if (anchor) { + // A new hash re-runs the jump on its own; only a repeat pick needs the nonce. + if (anchor === hash && id === activeId) setJumpNonce(n => n + 1); + } else if (id === activeId) { + return; + } else { + document + .getElementById(APP_CONTENT_SCROLL_CONTAINER_ID) + ?.scrollTo({ top: 0 }); + } + void router.push( { - shallow: true, - scroll: false, + pathname: router.pathname, + query: { ...router.query, tab: id }, + hash: anchor, }, + undefined, + { shallow: true, scroll: false }, ); - }, [activeTab, queryTab, router]); - - const handleTabChange = useCallback( - (value: string | null) => { - if (!value || value === activeTab) { - return; - } - - document.getElementById(APP_CONTENT_SCROLL_CONTAINER_ID)?.scrollTo({ - top: 0, - }); - - void router.replace( - { - pathname: router.pathname, - query: { - ...router.query, - tab: value, - }, - }, - undefined, - { - shallow: true, - scroll: false, - }, - ); - }, - [activeTab, router], - ); + }; return (
@@ -363,38 +243,54 @@ export default function TeamPage() { )}
-
- - {isLoading && ( -
- -
- )} - {!isLoading && team != null && ( - - - {tabs.map(tab => ( - - {tab.label} - - ))} - - {tabs.map(tab => ( - - - - ))} - - )} -
-
+ {isLoading && ( +
+ +
+ )} + {!isLoading && team != null && activePage != null && ( +
+ +
+
+

+ {activePage.label} + {activePage.badge && ( + + )} +

+

{activePage.description}

+ {activePage.links && ( + + {activePage.links.map(link => ( + + + {link.label} + + + + ))} + + )} +
+ {renderSettingsPage(activeId, allowedAuthMethods)} +
+
+ )} ); } diff --git a/packages/app/src/__tests__/Spotlights.test.tsx b/packages/app/src/__tests__/Spotlights.test.tsx index ae55cfb697..0c1056c85a 100644 --- a/packages/app/src/__tests__/Spotlights.test.tsx +++ b/packages/app/src/__tests__/Spotlights.test.tsx @@ -127,11 +127,17 @@ describe('useSpotlightActions', () => { await userEvent.click(await screen.findByRole('button', { name })); }; - it('opens the anchored team settings section', async () => { - await selectSpotlightAction('mcp', /MCP server/); + it('opens the team settings page', async () => { + await selectSpotlightAction('mcp', /AI agents/); + + expect(mockPush).toHaveBeenCalledWith('/team?tab=mcp'); + }); + + it('opens a setting inside a team settings page', async () => { + await selectSpotlightAction('parallelize', /Parallelize queries/); expect(mockPush).toHaveBeenCalledWith( - '/team?tab=api-agents#team-api-agents-mcp-server', + '/team?tab=query-settings#setting-parallelizeWhenPossible', ); }); diff --git a/packages/app/src/components/TeamSettings/ApiKeysSection.tsx b/packages/app/src/components/TeamSettings/ApiKeysSection.tsx index 8348622a98..99ce261f0a 100644 --- a/packages/app/src/components/TeamSettings/ApiKeysSection.tsx +++ b/packages/app/src/components/TeamSettings/ApiKeysSection.tsx @@ -1,11 +1,15 @@ -import { Separator } from '@clickhouse/click-ui'; -import { Box, Button, Card, Group, Text } from '@mantine/core'; +import { ReactNode } from 'react'; +import { Box, Button, Stack } from '@mantine/core'; import { notifications } from '@mantine/notifications'; import api from '@/api'; import { RevealSnippet } from '@/components/RevealSnippet/RevealSnippet'; import { useConfirm } from '@/useConfirm'; +import { SettingsRow } from './SettingsBlock'; + +import styles from './TeamSettings.module.scss'; + // The reveal Input fills its container, so cap its width here at the parent. const KEY_FIELD_MAX_WIDTH = 420; @@ -31,7 +35,8 @@ function APIKeyCopyButton({ ); } -export default function ApiKeysSection() { +/** `children` renders below the team's single keys. */ +export default function ApiKeysSection({ children }: { children?: ReactNode }) { const { data: team, refetch: refetchTeam } = api.useTeam(); const { data: me, isLoading: isLoadingMe } = api.useMe(); const rotateTeamApiKey = api.useRotateTeamApiKey(); @@ -108,12 +113,13 @@ export default function ApiKeysSection() { }; return ( - - API keys - - - Ingestion API key - + +
+ {team?.apiKey && ( - Rotate API key + Rotate key )} - - - {!isLoadingMe && me != null && ( - - - Personal API access key - - - - - - - - - )} - + + {!isLoadingMe && me != null && ( + + + + + + + )} +
+ {children} +
); } diff --git a/packages/app/src/components/TeamSettings/ConnectionsSection.tsx b/packages/app/src/components/TeamSettings/ConnectionsSection.tsx index 5c6d7db9d9..ed7bb7b617 100644 --- a/packages/app/src/components/TeamSettings/ConnectionsSection.tsx +++ b/packages/app/src/components/TeamSettings/ConnectionsSection.tsx @@ -16,8 +16,6 @@ export default function ConnectionsSection() { return ( - Connections - {connections?.map(connection => ( diff --git a/packages/app/src/components/TeamSettings/IacMigrationSection.tsx b/packages/app/src/components/TeamSettings/IacMigrationSection.tsx index 57ffb400aa..183cc3ec4f 100644 --- a/packages/app/src/components/TeamSettings/IacMigrationSection.tsx +++ b/packages/app/src/components/TeamSettings/IacMigrationSection.tsx @@ -1,5 +1,4 @@ import { useMemo, useState } from 'react'; -import { Badge, Separator } from '@clickhouse/click-ui'; import { buildImportFile, collectImportableResources, @@ -8,16 +7,7 @@ import { type IacResourceType, providerEndpoint, } from '@hyperdx/common-utils/dist/iac'; -import { - Alert, - Box, - Button, - Card, - Checkbox, - Group, - Stack, - Text, -} from '@mantine/core'; +import { Alert, Box, Button, Card, Checkbox, Stack, Text } from '@mantine/core'; import { IconDownload } from '@tabler/icons-react'; import api from '@/api'; @@ -228,11 +218,6 @@ export default function IacMigrationSection({ return ( - - Export to Terraform - - - Download a Terraform import file for this team's resources. Add diff --git a/packages/app/src/components/TeamSettings/IntegrationsSection.tsx b/packages/app/src/components/TeamSettings/IntegrationsSection.tsx index 8a64c0497e..18cf9f2379 100644 --- a/packages/app/src/components/TeamSettings/IntegrationsSection.tsx +++ b/packages/app/src/components/TeamSettings/IntegrationsSection.tsx @@ -1,13 +1,10 @@ -import { Separator } from '@clickhouse/click-ui'; -import { Box, Card, Stack, Text } from '@mantine/core'; +import { Box, Card, Stack } from '@mantine/core'; import WebhooksSection from './WebhooksSection'; export default function IntegrationsSection() { return ( - Integrations - diff --git a/packages/app/src/components/TeamSettings/McpServerSection.tsx b/packages/app/src/components/TeamSettings/McpServerSection.tsx index 741f839081..4674d0b45f 100644 --- a/packages/app/src/components/TeamSettings/McpServerSection.tsx +++ b/packages/app/src/components/TeamSettings/McpServerSection.tsx @@ -1,32 +1,14 @@ import { useMemo } from 'react'; -import { Separator } from '@clickhouse/click-ui'; -import { Box, Card, Text } from '@mantine/core'; +import { Box, Card } from '@mantine/core'; import api from '@/api'; import { type DeploymentShape } from '@/components/ClickStackOnboarding/installSnippets'; import McpInstallPanel from '@/components/ClickStackOnboarding/McpInstallPanel'; /** - * Renders the "Connect your AI Agents" section on the Team - * Settings page (Integrations tab). Self-managed OSS deployments - * mount the MCP server at `/api/mcp` with the per-user - * access key as bearer; the MCP server resolves the active team - * from the token, so the install snippet doesn't need to encode - * tenant context on the client. - * - * Structure mirrors `IntegrationsSection.tsx` and - * `ApiKeysSection.tsx`: outer `` with a `` - * header and ``, then a single `` wrapping the - * install panel. No subtitle below the header so the visual - * rhythm matches the rest of the Integrations tab. - * - * Auth gating matches `ApiKeysSection`: render nothing until `me` - * resolves with a non-empty access key. `MeApiResponseSchema` - * declares `accessKey` as `z.string()`, and the User model - * generates one on account creation, so the empty-key branch is - * defensive against a state the schema disallows; we still skip - * mounting the panel in that case rather than rendering a snippet - * with an empty bearer. + * MCP install snippet for the AI agents settings page. Self-managed deployments + * mount the server at `/api/mcp` with the user's access key as bearer, + * and the server resolves the team from that token. */ export default function McpServerSection() { const { data: me, isLoading: isLoadingMe } = api.useMe(); @@ -45,8 +27,6 @@ export default function McpServerSection() { return ( - Connect your AI Agents - diff --git a/packages/app/src/components/TeamSettings/OrgApiKeysSection.tsx b/packages/app/src/components/TeamSettings/OrgApiKeysSection.tsx index 999d8a133e..b2a62f1d47 100644 --- a/packages/app/src/components/TeamSettings/OrgApiKeysSection.tsx +++ b/packages/app/src/components/TeamSettings/OrgApiKeysSection.tsx @@ -1,8 +1,9 @@ import { useEffect, useState } from 'react'; -import { Badge, Separator } from '@clickhouse/click-ui'; +import { Badge } from '@clickhouse/click-ui'; import type { OrgApiKeyApiResponse } from '@hyperdx/common-utils/dist/types'; -import { Box, Button, Card, Group, Table, Text } from '@mantine/core'; +import { Box, Button, Card, Table, Text } from '@mantine/core'; import { notifications } from '@mantine/notifications'; +import { IconPlus } from '@tabler/icons-react'; import api from '@/api'; import EmptyState from '@/components/EmptyState'; @@ -12,6 +13,7 @@ import { useConfirm } from '@/useConfirm'; import { useFormatTime } from '@/useFormatTime'; import CreateOrgApiKeyModal from './CreateOrgApiKeyModal'; +import SettingsBlock from './SettingsBlock'; // A minute tick is close enough for flipping the Expired badge. const EXPIRY_TICK_MS = 60_000; @@ -112,52 +114,59 @@ export default function OrgApiKeysSection() { const now = useNow(); const [isCreateOpen, setIsCreateOpen] = useState(false); const keys = data?.data ?? []; + const createButton = ( + + ); return ( - - - Organization API keys - - Keys owned by the team. + 0 ? createButton : undefined} + > + {isError ? ( + + Couldn't load organization API keys - - - - - {isError ? ( - - Couldn't load organization API keys - - ) : !isLoading && keys.length === 0 ? ( - - ) : ( - - - - - Description - Created by - Created - Last used - Expires - - - - - {keys.map(apiKey => ( - - ))} - -
-
- )} + ) : !isLoading && keys.length === 0 ? ( + + {createButton} + + ) : ( + + + + + Description + Created by + Created + Last used + Expires + + + + + {keys.map(apiKey => ( + + ))} + +
+
+ )} + setIsCreateOpen(false)} diff --git a/packages/app/src/components/TeamSettings/SecurityPoliciesSection.tsx b/packages/app/src/components/TeamSettings/SecurityPoliciesSection.tsx index 7fa77a3be4..9d8d64897d 100644 --- a/packages/app/src/components/TeamSettings/SecurityPoliciesSection.tsx +++ b/packages/app/src/components/TeamSettings/SecurityPoliciesSection.tsx @@ -1,4 +1,3 @@ -import { Separator } from '@clickhouse/click-ui'; import { Box, Card, Text } from '@mantine/core'; export default function SecurityPoliciesSection({ @@ -8,8 +7,6 @@ export default function SecurityPoliciesSection({ }) { return ( - Security Policies - Team members can only authenticate via{' '} diff --git a/packages/app/src/components/TeamSettings/SettingsBlock.tsx b/packages/app/src/components/TeamSettings/SettingsBlock.tsx new file mode 100644 index 0000000000..10b5ea71c5 --- /dev/null +++ b/packages/app/src/components/TeamSettings/SettingsBlock.tsx @@ -0,0 +1,63 @@ +import { ReactNode } from 'react'; +import { Group, Stack, Text, Title } from '@mantine/core'; + +import styles from './TeamSettings.module.scss'; + +/** A titled group inside a settings page, for pages that hold more than one thing. */ +export default function SettingsBlock({ + id, + title, + description, + actions, + children, +}: { + id?: string; + title: string; + description: ReactNode; + actions?: ReactNode; + children: ReactNode; +}) { + return ( + + + + + {title} + + + {description} + + + {actions} + + {children} + + ); +} + +/** One setting in a bordered list: what it is on the left, its control on the right. */ +export function SettingsRow({ + id, + title, + description, + children, +}: { + id?: string; + title: string; + description: ReactNode; + children: ReactNode; +}) { + return ( +
+ + + {title} + + + {description} + + +
{children}
+
+ ); +} diff --git a/packages/app/src/components/TeamSettings/SourcesSection.tsx b/packages/app/src/components/TeamSettings/SourcesSection.tsx index a7e7fdc259..f6a11e0bf7 100644 --- a/packages/app/src/components/TeamSettings/SourcesSection.tsx +++ b/packages/app/src/components/TeamSettings/SourcesSection.tsx @@ -1,13 +1,10 @@ -import { Separator } from '@clickhouse/click-ui'; -import { Box, Text } from '@mantine/core'; +import { Box } from '@mantine/core'; import { SourcesList } from '@/components/Sources/SourcesList'; export default function SourcesSection() { return ( - Sources - - Team Members - diff --git a/packages/app/src/components/TeamSettings/TeamQueryConfigSection.tsx b/packages/app/src/components/TeamSettings/TeamQueryConfigSection.tsx index 80907a47d1..b2e3310e69 100644 --- a/packages/app/src/components/TeamSettings/TeamQueryConfigSection.tsx +++ b/packages/app/src/components/TeamSettings/TeamQueryConfigSection.tsx @@ -1,8 +1,6 @@ import { useCallback, useState } from 'react'; import { SubmitHandler, useForm } from 'react-hook-form'; -import { Separator } from '@clickhouse/click-ui'; import { DEFAULT_METADATA_MAX_ROWS_TO_READ } from '@hyperdx/common-utils/dist/core/metadata'; -import { type TeamClickHouseSettings } from '@hyperdx/common-utils/dist/types'; import { Box, Button, @@ -26,10 +24,12 @@ import { DEFAULT_SEARCH_ROW_LIMIT, } from '@/defaults'; +import { QUERY_SETTINGS, querySettingAnchor } from './settingsPages'; + type ClickhouseSettingType = 'number' | 'boolean'; interface ClickhouseSettingFormProps { - settingKey: keyof TeamClickHouseSettings; + settingKey: keyof typeof QUERY_SETTINGS; label: string; tooltip?: string; type: ClickhouseSettingType; @@ -155,7 +155,7 @@ function ClickhouseSettingForm({ const isCustomValue = currentValue !== undefined; return ( - + {label} {tooltip && ( @@ -281,13 +281,11 @@ export default function TeamQueryConfigSection() { return ( - ClickHouse Client Settings - (value ? 'Exact' : 'All')} /> (value ? 'Disabled' : 'Enabled')} /> (value ? 'Enabled' : 'Disabled')} diff --git a/packages/app/src/components/TeamSettings/TeamSettings.module.scss b/packages/app/src/components/TeamSettings/TeamSettings.module.scss new file mode 100644 index 0000000000..0ce505812e --- /dev/null +++ b/packages/app/src/components/TeamSettings/TeamSettings.module.scss @@ -0,0 +1,224 @@ +$header-height: 60px; +$nav-width: 224px; + +.layout { + display: grid; + grid-template-columns: $nav-width minmax(0, 1fr); + gap: 40px; + align-items: start; + padding: 24px var(--mantine-spacing-xl) 64px; + max-width: 1280px; +} + +.nav { + display: flex; + flex-direction: column; + gap: 4px; + position: sticky; + top: calc(#{$header-height} + 24px); + max-height: calc(100vh - #{$header-height} - 48px); + overflow-y: auto; +} + +.navSelect { + display: none; +} + +.navGroup { + display: flex; + flex-direction: column; + gap: 2px; + margin-top: 16px; +} + +.navGroupLabel { + color: var(--color-text-muted); + font-size: 12px; + font-weight: 500; + padding: 0 8px 4px; +} + +.navItem { + display: flex; + align-items: center; + gap: 8px; + height: 32px; + padding-inline: 8px; + border-radius: 4px; + color: var(--color-text-sidenav-link); + font-size: 14px; + text-decoration: none; + transition: background-color 150ms ease-out; + + &:hover { + background: var(--color-bg-sidenav-link-active); + color: var(--color-text-sidenav-link-active); + } + + &:focus-visible { + outline: 2px solid var(--click-global-color-outline-default); + outline-offset: -2px; + } + + &[data-active] { + background: var(--color-bg-sidenav-link-active); + color: var(--color-text-sidenav-link-active); + font-weight: 500; + } +} + +.navSubItem { + display: block; + padding: 4px 8px 4px 32px; + border-radius: 4px; + color: var(--color-text-muted); + font-size: 13px; + line-height: 1.35; + text-decoration: none; + transition: background-color 150ms ease-out; + + &:hover { + background: var(--color-bg-sidenav-link-active); + color: var(--color-text-sidenav-link-active); + } + + &:focus-visible { + outline: 2px solid var(--click-global-color-outline-default); + outline-offset: -2px; + } +} + +.navItemIcon { + display: inline-flex; + flex-shrink: 0; + color: var(--color-text-muted); + + .navItem[data-active] & { + color: inherit; + } +} + +.navItemLabel { + flex: 1; + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.navEmpty { + color: var(--color-text-muted); + font-size: 13px; + margin: 12px 8px 0; + overflow-wrap: anywhere; +} + +.content { + min-width: 0; + max-width: 960px; + + /* Keep a setting reached from search clear of the sticky page header. */ + [id^='setting-'] { + scroll-margin-top: calc(#{$header-height} + 24px); + } +} + +/* Briefly marks the setting a search result jumped to. */ +.highlighted { + border-radius: 4px; + animation: highlight 1.6s ease-out; +} + +@keyframes highlight { + 0%, + 40% { + background-color: var(--color-bg-sidenav-link-active); + box-shadow: 0 0 0 6px var(--color-bg-sidenav-link-active); + } + + 100% { + background-color: transparent; + box-shadow: 0 0 0 6px transparent; + } +} + +@media (prefers-reduced-motion: reduce) { + .highlighted { + animation: none; + outline: 2px solid var(--click-global-color-outline-default); + } +} + +.pageHeading { + display: flex; + flex-direction: column; + gap: 4px; + margin-bottom: 24px; +} + +.pageTitle { + display: flex; + align-items: center; + gap: 8px; + margin: 0; + font-size: 18px; + font-weight: 500; + line-height: 1.3; +} + +.pageDescription { + color: var(--color-text-muted); + font-size: 14px; + margin: 0; + max-width: 70ch; +} + +.rowList { + border: 1px solid var(--color-border); + border-radius: 4px; +} + +.row { + display: grid; + grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); + gap: 24px; + align-items: center; + padding: 16px 20px; + + & + & { + border-top: 1px solid var(--color-border); + } +} + +.rowControl { + display: flex; + align-items: center; + justify-content: flex-end; + gap: 8px; + min-width: 0; +} + +@media (width <= 860px) { + .row { + grid-template-columns: minmax(0, 1fr); + gap: 12px; + } + + .rowControl { + justify-content: flex-start; + } + + .layout { + grid-template-columns: minmax(0, 1fr); + gap: 24px; + padding-inline: var(--mantine-spacing-md); + } + + .nav { + display: none; + } + + .navSelect { + display: block; + } +} diff --git a/packages/app/src/components/TeamSettings/TeamSettingsNav.tsx b/packages/app/src/components/TeamSettings/TeamSettingsNav.tsx new file mode 100644 index 0000000000..f410f47d38 --- /dev/null +++ b/packages/app/src/components/TeamSettings/TeamSettingsNav.tsx @@ -0,0 +1,137 @@ +import { Fragment, useState } from 'react'; +import Link from 'next/link'; +import { CloseButton, Select, TextInput } from '@mantine/core'; +import { IconSearch } from '@tabler/icons-react'; + +import { + matchSettingsPage, + SETTINGS_GROUPS, + SettingsPage, + SettingsPageId, +} from './settingsPages'; + +import styles from './TeamSettings.module.scss'; + +function settingsPageHref(id: SettingsPageId, anchor?: string) { + return { pathname: '/team', query: { tab: id }, hash: anchor }; +} + +// Leave cmd/ctrl/shift-click to the browser so they still open a new tab. +const isPlainClick = (e: React.MouseEvent) => + !(e.metaKey || e.ctrlKey || e.shiftKey); + +export default function TeamSettingsNav({ + pages, + activeId, + onSelect, +}: { + pages: SettingsPage[]; + activeId: SettingsPageId; + onSelect: (id: SettingsPageId, anchor?: string) => void; +}) { + const [query, setQuery] = useState(''); + const matches = pages + .map(page => ({ page, ...matchSettingsPage(page, query) })) + .filter(match => match.visible); + + return ( + <> +