{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "settings-04",
  "description": "Connected and available integrations in tabs, one row each with what it does, its status and a prompt for ones that need reconnecting.",
  "registryDependencies": [
    "button",
    "tabs",
    "https://www.dashboardblocks.com/r/radix/block-state.json",
    "https://www.dashboardblocks.com/r/radix/brand-logos.json",
    "https://www.dashboardblocks.com/r/radix/format.json",
    "https://www.dashboardblocks.com/r/radix/tag.json",
    "https://www.dashboardblocks.com/r/radix/settings.json",
    "https://www.dashboardblocks.com/r/radix/team.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/settings/settings-04.tsx",
      "content": "'use client'\n\nimport {\n  BlockStateProvider,\n  BlockStateRows,\n  type BlockStateProps,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport {\n  BigQueryLogo,\n  GitHubLogo,\n  MicrosoftTeamsLogo,\n  PagerDutyLogo,\n  SlackLogo,\n  StripeLogo,\n} from '@/registry/components/dashboardblocks/brand-logos'\nimport {\n  ConnectionRow,\n  type ConnectionStatus,\n} from '@/registry/components/dashboardblocks/settings'\nimport { Tag } from '@/registry/components/dashboardblocks/tag'\nimport { getAvatarColor } from '@/registry/components/dashboardblocks/team'\nimport { IconPlaceholder } from '@/registry/icons/icon-placeholder'\nimport { formatNumber } from '@/registry/lib/dashboardblocks/format'\nimport { type ReactNode, useState } from 'react'\n\nimport { Button } from '@/components/ui/button'\nimport { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'\n\nimport { cn } from '@/lib/utils'\n\ninterface Integration {\n  category: string\n  description: string\n  detail?: string\n  id: string\n  logo?: ReactNode\n  name: string\n  status: ConnectionStatus\n}\n\ninterface Settings4Props extends BlockStateProps {\n  description: string\n  /** Leave out, or pass none, to show the empty state. */\n  integrations?: Integration[]\n  onConfigure?: (id: string) => void\n  onConnect?: (id: string) => void\n  onDisconnect?: (id: string) => void\n  title: string\n}\n\nconst exampleProps: Settings4Props = {\n  description: 'Send alerts and reports to the tools your team already uses.',\n  integrations: [\n    {\n      category: 'Messaging',\n      description: 'Post alerts and weekly summaries to channels.',\n      detail: 'Posting to #alerts',\n      id: 'slack',\n      logo: <SlackLogo />,\n      name: 'Slack',\n      status: 'connected',\n    },\n    {\n      category: 'Data',\n      description: 'Sync tables on a schedule for dashboards.',\n      detail: 'Credentials expired 2 days ago',\n      id: 'bigquery',\n      logo: <BigQueryLogo />,\n      name: 'BigQuery',\n      status: 'error',\n    },\n    {\n      category: 'Developer',\n      description: 'Mark deploys on charts and link incidents to commits.',\n      detail: 'Paused by Liam Carter',\n      id: 'github',\n      logo: <GitHubLogo />,\n      name: 'GitHub',\n      status: 'paused',\n    },\n    {\n      category: 'Incidents',\n      description: 'Page the on-call engineer when a critical alert fires.',\n      id: 'pagerduty',\n      logo: <PagerDutyLogo />,\n      name: 'PagerDuty',\n      status: 'disconnected',\n    },\n    {\n      category: 'Payments',\n      description: 'Import revenue, refunds and subscriptions.',\n      detail: 'Last sync 12 minutes ago',\n      id: 'stripe',\n      logo: <StripeLogo />,\n      name: 'Stripe',\n      status: 'connected',\n    },\n    {\n      category: 'Messaging',\n      description: 'Send alerts to a team channel.',\n      id: 'teams',\n      logo: <MicrosoftTeamsLogo />,\n      name: 'Microsoft Teams',\n      status: 'disconnected',\n    },\n  ],\n  title: 'Integrations',\n}\n\ntype Filter = 'all' | 'connected' | 'available'\n\nconst needsAttention = (item: Integration) =>\n  item.status === 'error' || item.status === 'revoked'\n\nconst Settings4 = (props: Settings4Props) => {\n  const {\n    description,\n    onConfigure,\n    onConnect,\n    onDisconnect,\n    errorMessage,\n    status,\n    title,\n  } = props\n  const [integrations, setIntegrations] = useState(props.integrations ?? [])\n  const ready = !status && integrations.length > 0\n  const [filter, setFilter] = useState<Filter>('all')\n\n  const setStatus = (id: string, status: ConnectionStatus) =>\n    setIntegrations((current) =>\n      current.map((item) =>\n        item.id === id ? { ...item, status, detail: undefined } : item,\n      ),\n    )\n\n  const connected = integrations.filter((item) => item.status !== 'disconnected')\n  const views: {\n    empty: string\n    items: Integration[]\n    label: string\n    value: Filter\n  }[] = [\n    {\n      empty: 'No integrations.',\n      items: integrations,\n      label: 'All',\n      value: 'all',\n    },\n    {\n      empty: 'Nothing connected yet.',\n      items: connected,\n      label: 'Connected',\n      value: 'connected',\n    },\n    {\n      empty: 'Everything is connected.',\n      items: integrations.filter((item) => item.status === 'disconnected'),\n      label: 'Available',\n      value: 'available',\n    },\n  ]\n\n  const attention = integrations.filter(needsAttention).length\n\n  return (\n    <BlockStateProvider\n      errorMessage={errorMessage}\n      state={getBlockState(status, integrations)}\n    >\n      <section className='@container flex flex-col gap-3'>\n        <header className='flex flex-col gap-0.5'>\n          <h2 className='font-semibold tracking-tight'>{title}</h2>\n          <p className='text-muted-foreground text-sm'>\n            {description}\n            {ready && (\n              <>\n                {' '}\n                {connected.length} of {integrations.length} connected\n                {attention > 0 &&\n                  `, ${attention} ${attention === 1 ? 'needs' : 'need'} attention`}\n                .\n              </>\n            )}\n          </p>\n        </header>\n        <Tabs value={filter} onValueChange={(value) => setFilter(value as Filter)}>\n          <TabsList>\n            {views.map((view) => (\n              <TabsTrigger key={view.value} value={view.value}>\n                {view.label}\n                {ready && view.value !== 'all' && view.items.length > 0 && (\n                  <Tag>{formatNumber(view.items.length)}</Tag>\n                )}\n              </TabsTrigger>\n            ))}\n          </TabsList>\n          {views.map((view) => (\n            <TabsContent key={view.value} value={view.value} className='mt-2'>\n              {!ready ? (\n                <div className='border-t'>\n                  <BlockStateRows rows={4} />\n                </div>\n              ) : view.items.length === 0 ? (\n                <p className='text-muted-foreground border-t py-8 text-center text-sm'>\n                  {view.empty}\n                </p>\n              ) : (\n                <ul className='flex flex-col divide-y border-t'>\n                  {view.items.map((item) => (\n                    <li key={item.id}>\n                      <ConnectionRow\n                        className='py-2.5'\n                        description={item.description}\n                        logo={\n                          <span\n                            aria-hidden\n                            className={cn(\n                              'flex size-8 shrink-0 items-center justify-center rounded-md text-sm font-semibold [&_svg]:size-4',\n                              !item.logo && getAvatarColor(item.name),\n                              item.logo && 'border',\n                            )}\n                          >\n                            {item.logo ?? item.name[0]}\n                          </span>\n                        }\n                        name={item.name}\n                        status={item.status}\n                        actions={\n                          item.status === 'disconnected' ? (\n                            <Button\n                              variant='outline'\n                              size='sm'\n                              aria-label={`Connect ${item.name}`}\n                              onClick={() => {\n                                setStatus(item.id, 'connected')\n                                onConnect?.(item.id)\n                              }}\n                            >\n                              <IconPlaceholder\n                                lucide='PlugIcon'\n                                tabler='IconPlugConnected'\n                                hugeicons='Plug01Icon'\n                                phosphor='PlugsConnectedIcon'\n                                remixicon='RiPlugLine'\n                                data-icon='inline-start'\n                              />\n                              Connect\n                            </Button>\n                          ) : (\n                            <>\n                              <Button\n                                variant='ghost'\n                                size='sm'\n                                aria-label={`Disconnect ${item.name}`}\n                                onClick={() => {\n                                  setStatus(item.id, 'disconnected')\n                                  onDisconnect?.(item.id)\n                                }}\n                              >\n                                <IconPlaceholder\n                                  lucide='UnplugIcon'\n                                  tabler='IconPlugConnectedX'\n                                  hugeicons='UnplugIcon'\n                                  phosphor='PlugsIcon'\n                                  remixicon='RiLinkUnlink'\n                                  data-icon='inline-start'\n                                />\n                                Disconnect\n                              </Button>\n                              <Button\n                                variant={needsAttention(item) ? 'default' : 'outline'}\n                                size='sm'\n                                aria-label={`${needsAttention(item) ? 'Reconnect' : 'Configure'} ${item.name}`}\n                                onClick={() => {\n                                  if (needsAttention(item))\n                                    setStatus(item.id, 'connected')\n                                  onConfigure?.(item.id)\n                                }}\n                              >\n                                {needsAttention(item) ? (\n                                  <>\n                                    <IconPlaceholder\n                                      lucide='RefreshCwIcon'\n                                      tabler='IconRefresh'\n                                      hugeicons='RefreshIcon'\n                                      phosphor='ArrowClockwiseIcon'\n                                      remixicon='RiRefreshLine'\n                                      data-icon='inline-start'\n                                    />\n                                    Reconnect\n                                  </>\n                                ) : (\n                                  'Configure'\n                                )}\n                              </Button>\n                            </>\n                          )\n                        }\n                      >\n                        {item.detail && (\n                          <span\n                            className={cn(\n                              'text-muted-foreground text-sm',\n                              needsAttention(item) && 'text-red-700 dark:text-red-400',\n                            )}\n                          >\n                            {item.detail}\n                          </span>\n                        )}\n                      </ConnectionRow>\n                    </li>\n                  ))}\n                </ul>\n              )}\n            </TabsContent>\n          ))}\n        </Tabs>\n      </section>\n    </BlockStateProvider>\n  )\n}\n\nexport {\n  Settings4,\n  exampleProps as settings4ExampleProps,\n  type Integration,\n  type Settings4Props,\n}\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/settings/settings-04.tsx"
    }
  ],
  "meta": {
    "shows": "Connected and available integrations in tabs, one row each with what it does, its status and a prompt for ones that need reconnecting.",
    "size": "half",
    "usedWith": [
      "settings-05",
      "settings-02"
    ],
    "component": "Settings4",
    "props": "{ description: string; integrations?: { category: string; description: string; detail?: string; id: string; logo?: ReactNode; name: string; status: \"error\" | \"connected\" | \"disconnected\" | \"importing\" | \"paused\" | \"revoked\" }[]; onConfigure?: (id: string) => void; onConnect?: (id: string) => void; onDisconnect?: (id: string) => void; title: string; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
