Skip to content

⭐️⭐️⭐️ Open-source, self-hosted alternative to Linear and Plane. Project management and issue tracking where teams and AI agents work side by side to plan and ship products.

1.8 KB
Raw Blame
import { BadgeDollarSign, Clock3, Coins, Info, LayoutTemplate, ShieldCheck } from 'lucide-react';
import { useTranslations } from 'next-intl';
import { useWorkspaceSections } from '@/cloud';
import type { WorkspaceSummary } from '@/lib/api/endpoints/workspaces';
import { WORKSPACE_SECTION_GROUPS, type WorkspaceSection } from '../types/workspaceSection';
import { useWorkspaceQuery } from '@/services/workspaces.service';

// Grouped in menu order, so the first entry, the page a workspace opens on
// (WorkspaceFirstSection), is the first of the top group.
// Only the workspace's owner and its admins open them (WorkspaceLayout), and both read
// what the agents spent, keep its project templates and set the model prices it is costed at.
export function useWorkspaceSettingsSections(workspace: WorkspaceSummary): WorkspaceSection[] {
  const t = useTranslations('teams.workspace');
  const tSections = useTranslations('teams.sections');
  const detail = useWorkspaceQuery(workspace.id).data;
  const sections = useWorkspaceSections(workspace, [
    { id: 'queue', label: t('queue.title'), icon: Clock3, group: 'overview' },
    { id: 'agent-usage', label: t('agentUsage.title'), icon: Coins, group: 'overview' },
    {
      id: 'templates',
      label: tSections('templates.title'),
      icon: LayoutTemplate,
      group: 'overview',
    },
    { id: 'info', label: t('general'), icon: Info, group: 'settings' },
    {
      id: 'managers',
      label: t('managers.title'),
      icon: ShieldCheck,
      group: 'settings',
      badge: detail && String(detail.managerCount),
    },
    { id: 'model-prices', label: t('modelPrices.title'), icon: BadgeDollarSign, group: 'settings' },
  ]);
  return WORKSPACE_SECTION_GROUPS.flatMap((group) =>
    sections.filter((section) => section.group === group),
  );
}