Skip to content

armgit / AiSOC

Public Imported from GitHub
0

Open-source AI Security Operations Center: alert fusion, LLM-agent triage, MITRE ATT&CK investigation, and a replayable decision ledger for every agent step. Self-hostable, runs with no API keys, MIT licensed. Ships an MCP server for Claude, Cursor and Continue.

feat(web): WS-F5 — empty-state polish across list views

Beenu Arora474ecceec396
diff --git a/apps/web/src/components/alerts/AlertsView.tsx b/apps/web/src/components/alerts/AlertsView.tsx
index 37552766a..3f62cdf8c 100644
--- a/apps/web/src/components/alerts/AlertsView.tsx
+++ b/apps/web/src/components/alerts/AlertsView.tsx
@@ -8,6 +8,8 @@ import { alertsApi, type Alert, type AlertFilters, type ConfidenceLabel } from '
import { clsx } from 'clsx';
import { formatDistanceToNow } from 'date-fns';
import { EntityRiskQueue } from './EntityRiskQueue';
+import { EmptyState, EmptyStateIcons } from '@/components/ui/EmptyState';
+import { ErrorState } from '@/components/ui/ErrorState';
// Wave 1 of the AiSOC v6 capability roadmap. The "entities" tab renders the
// rolled-up Risk-Based Alerting queue — alerts contribute time-decayed risk
@@ -379,12 +381,41 @@ function AlertsTable({
<div className="w-6 h-6 border-2 border-blue-500 border-t-transparent rounded-full animate-spin" />
</div>
) : error ? (
- <div className="flex items-center justify-center h-32 text-red-400 text-sm">
- Failed to load alerts
+ <div className="p-4">
+ <ErrorState
+ title="Couldn't load alerts"
+ description="The alerts feed didn't respond. Check the API service or try again."
+ error={error}
+ />
</div>
) : alerts.length === 0 ? (
- <div className="flex flex-col items-center justify-center h-32 text-gray-500">
- <p className="text-sm">No alerts found</p>
+ <div className="p-4">
+ {/*
+ WS-F5 — distinguish "no data at all" from "filtered out". The
+ filter-aware copy is the difference between an analyst thinking
+ "the system is broken" and "I should clear my filters".
+ */}
+ {filters.severity || filters.status ? (
+ <EmptyState
+ icon={EmptyStateIcons.search}
+ title="No alerts match these filters"
+ description="Try clearing the severity or status filter to widen the search."
+ action={
+ <button
+ onClick={() => onFilterChange({ page: 1, pageSize: filters.pageSize ?? 25 })}
+ className="text-xs px-3 py-1.5 rounded-md border border-blue-500/40 bg-blue-500/10 text-blue-300 hover:bg-blue-500/20 transition-colors"
+ >
+ Clear filters
+ </button>
+ }
+ />
+ ) : (
+ <EmptyState
+ icon={EmptyStateIcons.alert}
+ title="No alerts yet"
+ description="Once a connector ingests events that trip a detection, alerts will appear here. Connect a data source from Settings → Connectors to start streaming."
+ />
+ )}
</div>
) : (
<div>
diff --git a/apps/web/src/components/audit/AuditLogView.tsx b/apps/web/src/components/audit/AuditLogView.tsx
index 87a14af18..4e661f252 100644
--- a/apps/web/src/components/audit/AuditLogView.tsx
+++ b/apps/web/src/components/audit/AuditLogView.tsx
@@ -2,6 +2,8 @@
import { useState, useCallback } from 'react';
import useSWR from 'swr';
+import { EmptyState, EmptyStateIcons } from '@/components/ui/EmptyState';
+import { ErrorState } from '@/components/ui/ErrorState';
interface AuditEvent {
id: string;
@@ -156,13 +158,47 @@ export function AuditLogView() {
{/* Table */}
<div className="bg-gray-800/50 rounded-lg border border-gray-700 shadow-sm overflow-hidden">
{error && !data && (
- <div className="p-8 text-center text-red-500 text-sm">
- Failed to load audit log.
+ <div className="p-4">
+ <ErrorState
+ title="Couldn't load audit log"
+ description="The audit log service didn't respond. Check the API or try again."
+ error={error}
+ />
</div>
)}
{data && data.items.length === 0 && !isLoading && (
- <div className="p-8 text-center text-gray-400 text-sm">
- No audit events found.
+ // WS-F5 — audit log is *required* by SOC2/HIPAA so a true "empty"
+ // tenant is rare. Most empty paths here are filter-misses; surface
+ // a clear path back to the unfiltered view.
+ <div className="p-4">
+ {search || actionFilter || resourceFilter ? (
+ <EmptyState
+ icon={EmptyStateIcons.search}
+ title="No audit events match these filters"
+ description="Try widening the search, clearing the action/resource filter, or jumping to a different time window."
+ action={
+ <button
+ onClick={() => {
+ setSearch('');
+ setActionFilter('');
+ setResourceFilter('');
+ setPage(1);
+ }}
+ className="text-xs px-3 py-1.5 rounded-md border border-indigo-500/40 bg-indigo-500/10 text-indigo-300 hover:bg-indigo-500/20 transition-colors"
+ >
+ Clear filters
+ </button>
+ }
+ className="bg-transparent py-8"
+ />
+ ) : (
+ <EmptyState
+ icon={EmptyStateIcons.audit}
+ title="No audit events yet"
+ description="Every authenticated action — case updates, rule edits, connector changes, role grants — is logged here. Events will start appearing as analysts use the platform."
+ className="bg-transparent py-8"
+ />
+ )}
</div>
)}
{data && data.items.length > 0 && (
diff --git a/apps/web/src/components/cases/CasesView.tsx b/apps/web/src/components/cases/CasesView.tsx
index 31ded8638..9de121f0b 100644
--- a/apps/web/src/components/cases/CasesView.tsx
+++ b/apps/web/src/components/cases/CasesView.tsx
@@ -7,6 +7,7 @@ import toast from 'react-hot-toast';
import { casesApi, type Case, type CasesResponse } from '@/lib/api';
import { clsx } from 'clsx';
import { format } from 'date-fns';
+import { EmptyState, EmptyStateIcons } from '@/components/ui/EmptyState';
// ─── Mock Data ────────────────────────────────────────────────────────────────
@@ -247,9 +248,34 @@ export function CasesView({ initialCases }: CasesViewProps = {}) {
<div className="w-6 h-6 border-2 border-blue-500/30 border-t-blue-500 rounded-full animate-spin" />
</div>
) : cases.length === 0 ? (
- <div className="flex flex-col items-center justify-center h-48 text-gray-600">
- <p className="text-sm">No cases found</p>
- </div>
+ // WS-F5 — distinguish "filter miss" from "no cases ever". The former
+ // gets a "clear filters" CTA; the latter explains what cases are and
+ // where they come from so a brand-new tenant doesn't think it's broken.
+ statusFilter !== 'all' || severityFilter !== 'all' || search ? (
+ <EmptyState
+ icon={EmptyStateIcons.search}
+ title="No cases match these filters"
+ description="Try clearing the status, severity, or search filter to widen the view."
+ action={
+ <button
+ onClick={() => {
+ setStatusFilter('all');
+ setSeverityFilter('all');
+ setSearch('');
+ }}
+ className="text-xs px-3 py-1.5 rounded-md border border-blue-500/40 bg-blue-500/10 text-blue-300 hover:bg-blue-500/20 transition-colors"
+ >
+ Clear filters
+ </button>
+ }
+ />
+ ) : (
+ <EmptyState
+ icon={EmptyStateIcons.case}
+ title="No cases yet"
+ description="Cases bundle related alerts, evidence, and analyst notes into a single investigation. Promote alerts to a case from the Alerts tab, or click ‘New Case’ to start a manual investigation."
+ />
+ )
) : (
<div className="grid grid-cols-1 gap-3">
{cases.map((c) => <CaseCard key={c.id} c={c} />)}
diff --git a/apps/web/src/components/cases/InvestigationLedger.tsx b/apps/web/src/components/cases/InvestigationLedger.tsx
index 570640be3..f53a202e9 100644
--- a/apps/web/src/components/cases/InvestigationLedger.tsx
+++ b/apps/web/src/components/cases/InvestigationLedger.tsx
@@ -382,9 +382,17 @@ export function InvestigationLedger({
Couldn&apos;t load events: {String(eventsError)}
</p>
) : filteredEvents.length === 0 ? (
- <p className="p-4 text-xs text-slate-500">
- No events yet. {isLive && 'Waiting for the agent to emit its first step…'}
- </p>
+ <div className="p-3">
+ <EmptyState
+ title={isLive ? 'Waiting for the agent…' : 'No events recorded'}
+ description={
+ isLive
+ ? 'The agent is still planning. Steps will stream in here as soon as it makes its first decision.'
+ : 'This run has no events that match the active filters. Clear filters or pick a different run from the toolbar.'
+ }
+ className="bg-transparent py-8"
+ />
+ </div>
) : (
<ol className="max-h-[640px] space-y-1 overflow-y-auto p-1">
{filteredEvents.map((evt) => (
diff --git a/apps/web/src/components/compliance/FrameworkView.tsx b/apps/web/src/components/compliance/FrameworkView.tsx
index 2c7fc8b54..2b7173123 100644
--- a/apps/web/src/components/compliance/FrameworkView.tsx
+++ b/apps/web/src/components/compliance/FrameworkView.tsx
@@ -3,6 +3,7 @@
import useSWR, { mutate } from 'swr';
import { useState } from 'react';
import { ComplianceHeatmap } from './ComplianceHeatmap';
+import { EmptyState, EmptyStateIcons } from '@/components/ui/EmptyState';
interface Evidence {
id: string;
@@ -241,9 +242,25 @@ export function FrameworkView({ framework }: Props) {
{/* Controls list */}
<div className="space-y-2">
{filtered.length === 0 && (
- <div className="text-gray-400 text-sm py-8 text-center">
- No controls match the current filter.
- </div>
+ // WS-F5 — controls come from a static framework definition, so
+ // an "empty" view here is *always* a filter miss. Give the
+ // analyst a clear path back to the full list.
+ <EmptyState
+ icon={EmptyStateIcons.search}
+ title="No controls match the current filter"
+ description="Try a different status filter, or clear it to see every control in the framework."
+ action={
+ filterStatus !== 'all' ? (
+ <button
+ onClick={() => setFilterStatus('all')}
+ className="text-xs px-3 py-1.5 rounded-md border border-blue-500/40 bg-blue-500/10 text-blue-300 hover:bg-blue-500/20 transition-colors"
+ >
+ Show all controls
+ </button>
+ ) : undefined
+ }
+ className="bg-transparent py-8"
+ />
)}
{filtered.map((cwev) => {
const isExpanded = expandedId === cwev.control.id;
diff --git a/apps/web/src/components/marketplace/MarketplaceView.tsx b/apps/web/src/components/marketplace/MarketplaceView.tsx
index c4a6dd5bf..dbb04a8fa 100644
--- a/apps/web/src/components/marketplace/MarketplaceView.tsx
+++ b/apps/web/src/components/marketplace/MarketplaceView.tsx
@@ -3,6 +3,8 @@
import { useCallback, useMemo, useState } from 'react';
import useSWR from 'swr';
import clsx from 'clsx';
+import { EmptyState, EmptyStateIcons } from '@/components/ui/EmptyState';
+import { ErrorState } from '@/components/ui/ErrorState';
// ── Types ────────────────────────────────────────────────────────────────────
@@ -946,23 +948,30 @@ export function MarketplaceView() {
)}
{error && (
- <div className="rounded-lg border border-red-700/40 bg-red-900/20 p-4 text-sm text-red-300">
- Failed to load marketplace data. Make sure{' '}
- <code className="text-red-200">/marketplace/index.json</code> is served
- as a static file. Run <code className="text-red-200">pnpm marketplace:build</code> to regenerate it.
- </div>
+ <ErrorState
+ title="Couldn't load marketplace"
+ description="Make sure /marketplace/index.json is served as a static file. Run `pnpm marketplace:build` to regenerate it."
+ error={error}
+ />
)}
{!isLoading && !error && items.length === 0 && (
- <div className="flex flex-col items-center justify-center py-20 text-zinc-500">
- <p className="text-sm">No items match your filters.</p>
- <button
- onClick={clearFilters}
- className="mt-2 text-xs text-zinc-400 underline hover:text-zinc-200"
- >
- Clear filters
- </button>
- </div>
+ // WS-F5 — marketplace ships with a non-empty index by default, so
+ // the only realistic empty state here is a filter-miss.
+ <EmptyState
+ icon={EmptyStateIcons.search}
+ title="No marketplace items match your filters"
+ description="Try a different category or clear your filters to see all 50+ playbooks, detections, and plugins."
+ action={
+ <button
+ onClick={clearFilters}
+ className="text-xs px-3 py-1.5 rounded-md border border-blue-500/40 bg-blue-500/10 text-blue-300 hover:bg-blue-500/20 transition-colors"
+ >
+ Clear filters
+ </button>
+ }
+ className="bg-transparent py-12"
+ />
)}
{!isLoading && !error && items.length > 0 && (
diff --git a/apps/web/src/components/playbooks/PlaybooksView.tsx b/apps/web/src/components/playbooks/PlaybooksView.tsx
index 27b2bff82..96038106d 100644
--- a/apps/web/src/components/playbooks/PlaybooksView.tsx
+++ b/apps/web/src/components/playbooks/PlaybooksView.tsx
@@ -13,6 +13,7 @@ import useSWR from 'swr';
import clsx from 'clsx';
import type { Playbook, PlaybookRun } from './types';
import { PlaybooksGallery } from './PlaybooksGallery';
+import { EmptyState, EmptyStateIcons } from '@/components/ui/EmptyState';
const fetcher = (url: string) =>
fetch(url).then((r) => {
@@ -43,10 +44,14 @@ function RunHistoryTab() {
</div>
);
if (!data || data.length === 0)
+ // WS-F5 — fresh tenants haven't run anything yet; nudge toward the editor.
return (
- <div className="flex flex-col items-center py-20 text-gray-700">
- <div className="text-gray-500">No playbook runs yet. Trigger a dry run from the editor.</div>
- </div>
+ <EmptyState
+ icon={EmptyStateIcons.ledger}
+ title="No playbook runs yet"
+ description="Run history shows up after you trigger a playbook — either manually from the editor's dry-run button, or automatically when an alert matches a playbook trigger."
+ className="bg-transparent py-12"
+ />
);
return (
<div className="space-y-2">
@@ -252,10 +257,29 @@ function CommunityPlaybooksTab() {
)}
{!loading && !error && items.length === 0 && (
- <div className="flex flex-col items-center justify-center py-16 text-zinc-500 text-sm">
- <p>No community playbooks found.</p>
- <p className="text-xs mt-1">Be the first to submit one!</p>
- </div>
+ // WS-F5 — community playbooks come from the marketplace index. If
+ // search is active we treat it as a filter-miss; otherwise it's an
+ // index-not-built state.
+ <EmptyState
+ icon={EmptyStateIcons.search}
+ title={search ? 'No community playbooks match your search' : 'No community playbooks indexed yet'}
+ description={
+ search
+ ? 'Try a different search term, or browse the full catalog by clearing the search.'
+ : 'Run `pnpm marketplace:build` to regenerate the community index, or check that /marketplace/index.json is being served.'
+ }
+ action={
+ search ? (
+ <button
+ onClick={() => { setSearch(''); load('', sortBy, 1); }}
+ className="text-xs px-3 py-1.5 rounded-md border border-blue-500/40 bg-blue-500/10 text-blue-300 hover:bg-blue-500/20 transition-colors"
+ >
+ Clear search
+ </button>
+ ) : undefined
+ }
+ className="bg-transparent py-12"
+ />
)}
{!loading && items.length > 0 && (
@@ -432,18 +456,31 @@ export function PlaybooksView() {
)}
{!isLoading && !error && (!data || data.length === 0) && (
- <div className="flex flex-col items-center justify-center py-20 text-center">
- <div className="text-lg font-medium text-gray-400 mb-2">No playbooks yet</div>
- <div className="text-sm text-gray-600 mb-6">
- Create a playbook to automate your SOC response workflows
- </div>
- <Link
- href="/playbooks/new"
- className="px-4 py-2 rounded-lg bg-blue-600 hover:bg-blue-500 text-white text-sm transition-colors"
- >
- Create your first playbook
- </Link>
- </div>
+ // WS-F5 — first-run experience. Push toward both "create your own"
+ // and "browse the community" so analysts don't have to start from
+ // a blank YAML file.
+ <EmptyState
+ icon={EmptyStateIcons.ledger}
+ title="No playbooks yet"
+ description="Playbooks automate your SOC response — isolate hosts, enrich IOCs, page on-call, post to Slack. Start from a community template or write your own from scratch."
+ action={
+ <div className="flex items-center gap-2">
+ <Link
+ href="/playbooks/new"
+ className="px-3 py-1.5 rounded-md bg-blue-600 hover:bg-blue-500 text-white text-xs font-medium transition-colors"
+ >
+ Create your first playbook
+ </Link>
+ <button
+ onClick={() => setTab('community')}
+ className="text-xs px-3 py-1.5 rounded-md border border-zinc-700 bg-zinc-800/40 text-zinc-300 hover:bg-zinc-800 transition-colors"
+ >
+ Browse community
+ </button>
+ </div>
+ }
+ className="bg-transparent py-16"
+ />
)}
{data && data.length > 0 && <PlaybooksGallery playbooks={data} />}
diff --git a/apps/web/src/components/threat-intel/ThreatIntelView.tsx b/apps/web/src/components/threat-intel/ThreatIntelView.tsx
index e6a71f424..36114c859 100644
--- a/apps/web/src/components/threat-intel/ThreatIntelView.tsx
+++ b/apps/web/src/components/threat-intel/ThreatIntelView.tsx
@@ -10,6 +10,7 @@ import {
} from '@/lib/api';
import { clsx } from 'clsx';
import { format } from 'date-fns';
+import { EmptyState, EmptyStateIcons } from '@/components/ui/EmptyState';
// ─── Mock Data ────────────────────────────────────────────────────────────────
// Static timestamps avoid SSR/client hydration mismatches (React error #418)
@@ -327,9 +328,36 @@ export function ThreatIntelView() {
<span className="text-xs text-gray-500">{indicators.length} indicators</span>
</div>
{indicators.length === 0 ? (
- <div className="flex flex-col items-center justify-center h-32 text-gray-600">
- <p className="text-sm">No indicators found</p>
- </div>
+ // WS-F5 — TI feeds rarely have a true "no IOCs ever" state in
+ // practice (the OT feed alone seeds dozens), so the most common
+ // empty path here is a filter-miss. Both copies still steer the
+ // analyst back to a useful action.
+ typeFilter !== 'all' || search ? (
+ <EmptyState
+ icon={EmptyStateIcons.search}
+ title="No indicators match these filters"
+ description="Try a different IOC type or clear the search to see the full feed."
+ action={
+ <button
+ onClick={() => {
+ setTypeFilter('all');
+ setSearch('');
+ }}
+ className="text-xs px-3 py-1.5 rounded-md border border-blue-500/40 bg-blue-500/10 text-blue-300 hover:bg-blue-500/20 transition-colors"
+ >
+ Clear filters
+ </button>
+ }
+ className="bg-transparent py-8"
+ />
+ ) : (
+ <EmptyState
+ icon={EmptyStateIcons.shield}
+ title="No threat intel ingested yet"
+ description="Connect a TI feed (MISP, OTX, AbuseIPDB, GreyNoise, internal STIX/TAXII) from Settings → Connectors to start enriching alerts with reputation context."
+ className="bg-transparent py-8"
+ />
+ )
) : (
<div>
{indicators.map((ioc) => <IOCRow key={ioc.id} ioc={ioc} />)}
diff --git a/apps/web/src/components/ui/EmptyState.test.tsx b/apps/web/src/components/ui/EmptyState.test.tsx
new file mode 100644
index 000000000..4f66c600d
--- /dev/null
+++ b/apps/web/src/components/ui/EmptyState.test.tsx
@@ -0,0 +1,111 @@
+import { describe, expect, it } from 'vitest';
+import { render, screen } from '@testing-library/react';
+
+import { EmptyState, EmptyStateIcons } from './EmptyState';
+
+// WS-F5 — guard the contract that a few dozen list views now depend on:
+// 1. The "default" variant renders an action when one is provided.
+// 2. The "planned-v1.1" variant *suppresses* actions and shows a badge,
+// because deferred features must not advertise outbound links.
+// 3. Icons render with `aria-hidden` so screen readers skip them and
+// announce the title instead.
+
+describe('EmptyState', () => {
+ it('renders title, description, and action for the default variant', () => {
+ render(
+ <EmptyState
+ title="No alerts yet"
+ description="Connect a data source to start streaming."
+ action={<button>Connect</button>}
+ />,
+ );
+
+ expect(screen.getByRole('status')).toBeInTheDocument();
+ expect(screen.getByRole('heading', { name: /no alerts yet/i })).toBeInTheDocument();
+ expect(screen.getByText(/connect a data source/i)).toBeInTheDocument();
+ expect(screen.getByRole('button', { name: /connect/i })).toBeInTheDocument();
+ });
+
+ it('renders without description or action when omitted', () => {
+ render(<EmptyState title="Nothing to see" />);
+
+ expect(screen.getByRole('heading', { name: /nothing to see/i })).toBeInTheDocument();
+ expect(screen.queryByRole('button')).not.toBeInTheDocument();
+ });
+
+ it('shows the "Planned for v1.1" badge for the planned-v1.1 variant', () => {
+ render(
+ <EmptyState
+ title="Saved views are coming"
+ description="Filter+column presets land in v1.1."
+ variant="planned-v1.1"
+ />,
+ );
+
+ expect(screen.getByText(/planned for v1\.1/i)).toBeInTheDocument();
+ expect(screen.getByRole('heading', { name: /saved views are coming/i })).toBeInTheDocument();
+ });
+
+ it('suppresses actions for the planned-v1.1 variant', () => {
+ // Per the WS-F5 plan: deferred features show "planned for v1.1" copy with
+ // NO outbound links. Even if a caller passes an action, we drop it.
+ render(
+ <EmptyState
+ title="Replayable timeline"
+ description="Coming soon."
+ variant="planned-v1.1"
+ action={<a href="/somewhere">Should be hidden</a>}
+ />,
+ );
+
+ expect(screen.queryByRole('link', { name: /should be hidden/i })).not.toBeInTheDocument();
+ });
+
+ it('honors a custom badge label on planned-v1.1', () => {
+ render(
+ <EmptyState
+ title="Custom"
+ variant="planned-v1.1"
+ badge="Coming Q3"
+ />,
+ );
+
+ expect(screen.getByText(/coming q3/i)).toBeInTheDocument();
+ // Default label should not also show.
+ expect(screen.queryByText(/planned for v1\.1/i)).not.toBeInTheDocument();
+ });
+
+ it('does not render the badge on the default variant', () => {
+ render(
+ <EmptyState
+ title="Default with badge prop"
+ variant="default"
+ badge="Should not appear"
+ />,
+ );
+
+ expect(screen.queryByText(/should not appear/i)).not.toBeInTheDocument();
+ });
+
+ it('exports a stable set of empty-state icons', () => {
+ // These icons are referenced from many list views; this test guards
+ // against an accidental rename or removal during a refactor.
+ const expected = ['alert', 'case', 'search', 'shield', 'audit', 'marketplace', 'ledger'] as const;
+ for (const key of expected) {
+ expect(EmptyStateIcons[key]).toBeTruthy();
+ }
+ });
+
+ it('marks SVG icons as aria-hidden so titles drive announcements', () => {
+ const { container } = render(
+ <EmptyState
+ icon={EmptyStateIcons.alert}
+ title="No alerts"
+ />,
+ );
+
+ const svg = container.querySelector('svg');
+ expect(svg).not.toBeNull();
+ expect(svg).toHaveAttribute('aria-hidden', 'true');
+ });
+});
diff --git a/apps/web/src/components/ui/EmptyState.tsx b/apps/web/src/components/ui/EmptyState.tsx
index a80d26e23..9f2069d73 100644
--- a/apps/web/src/components/ui/EmptyState.tsx
+++ b/apps/web/src/components/ui/EmptyState.tsx
@@ -1,38 +1,158 @@
import { clsx } from 'clsx';
import type { ReactNode } from 'react';
+// WS-F5 — empty-state polish across list views.
+// Two variants:
+// - "default": filtered/no-data states with optional CTA
+// - "planned-v1.1": deferred features that should NOT advertise an
+// outbound link (per plan: "deferred features show 'planned for v1.1'
+// copy with NO outbound links"). The amber accent + badge make it
+// visually obvious this isn't a bug or a misconfiguration.
+type EmptyStateVariant = 'default' | 'planned-v1.1';
+
interface EmptyStateProps {
icon?: ReactNode;
title: string;
description?: string;
action?: ReactNode;
className?: string;
+ variant?: EmptyStateVariant;
+ /**
+ * Override the default badge text. Only renders for non-default variants.
+ * Defaults to "Planned for v1.1" for the planned-v1.1 variant.
+ */
+ badge?: string;
}
+const VARIANT_STYLES: Record<EmptyStateVariant, {
+ container: string;
+ iconWrap: string;
+ badge: string;
+ badgeLabel: string;
+}> = {
+ default: {
+ container:
+ 'border-gray-800 bg-gray-900/30',
+ iconWrap:
+ 'bg-gray-800/60 text-blue-400',
+ badge: '',
+ badgeLabel: '',
+ },
+ 'planned-v1.1': {
+ container:
+ 'border-amber-500/30 bg-amber-500/[0.04]',
+ iconWrap:
+ 'bg-amber-500/10 text-amber-300',
+ badge:
+ 'inline-flex items-center gap-1 rounded-full border border-amber-500/30 bg-amber-500/10 px-2.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-amber-300',
+ badgeLabel: 'Planned for v1.1',
+ },
+};
+
/**
* Friendly placeholder shown when a list/section has no data yet.
*
- * Always pair with a clear `action` so users can do *something* — a link
- * to docs, a "Connect data source" button, or a way to seed demo data.
+ * Pair with a clear `action` so users can do *something* — a link to
+ * docs, a "Connect data source" button, or a way to seed demo data —
+ * UNLESS the variant is "planned-v1.1", in which case the action
+ * should be omitted (deferred features don't advertise outbound links).
*/
-export function EmptyState({ icon, title, description, action, className }: EmptyStateProps) {
+export function EmptyState({
+ icon,
+ title,
+ description,
+ action,
+ className,
+ variant = 'default',
+ badge,
+}: EmptyStateProps) {
+ const styles = VARIANT_STYLES[variant];
+ const badgeText = badge ?? styles.badgeLabel;
+ const showBadge = variant !== 'default' && badgeText.length > 0;
+
return (
<div
className={clsx(
- 'flex flex-col items-center justify-center rounded-xl border border-dashed border-gray-800 bg-gray-900/30 px-6 py-12 text-center',
+ 'flex flex-col items-center justify-center rounded-xl border border-dashed px-6 py-12 text-center',
+ styles.container,
className,
)}
+ role="status"
>
{icon && (
- <div className="mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-gray-800/60 text-blue-400">
+ <div
+ className={clsx(
+ 'mb-4 flex h-12 w-12 items-center justify-center rounded-full',
+ styles.iconWrap,
+ )}
+ >
{icon}
</div>
)}
+ {showBadge && <span className={clsx('mb-3', styles.badge)}>{badgeText}</span>}
<h3 className="text-base font-semibold text-gray-100">{title}</h3>
{description && (
<p className="mt-1 max-w-md text-sm text-gray-500">{description}</p>
)}
- {action && <div className="mt-5">{action}</div>}
+ {action && variant === 'default' && <div className="mt-5">{action}</div>}
</div>
);
}
+
+// ─── Shared empty-state icons ────────────────────────────────────────────────
+//
+// Lightweight inline SVGs sized for the EmptyState icon slot (h-12 w-12 wrap,
+// the SVG itself uses h-6 w-6 inside). Keeping them here avoids pulling in a
+// full icon library just for empty states and ensures consistent sizing /
+// stroke weight across views.
+
+const baseIconProps = {
+ className: 'h-6 w-6',
+ fill: 'none' as const,
+ viewBox: '0 0 24 24',
+ stroke: 'currentColor' as const,
+ strokeWidth: 1.75,
+ strokeLinecap: 'round' as const,
+ strokeLinejoin: 'round' as const,
+};
+
+export const EmptyStateIcons = {
+ alert: (
+ <svg {...baseIconProps} aria-hidden="true">
+ <path d="M12 9v3.75m9-.75a9 9 0 11-18 0 9 9 0 0118 0zm-9 3.75h.008v.008H12v-.008z" />
+ </svg>
+ ),
+ case: (
+ <svg {...baseIconProps} aria-hidden="true">
+ <path d="M2.25 7.125C2.25 6.504 2.754 6 3.375 6h17.25c.621 0 1.125.504 1.125 1.125v9.75c0 .621-.504 1.125-1.125 1.125H3.375A1.125 1.125 0 012.25 16.875v-9.75z" />
+ <path d="M9 6V4.875C9 4.254 9.504 3.75 10.125 3.75h3.75c.621 0 1.125.504 1.125 1.125V6" />
+ </svg>
+ ),
+ search: (
+ <svg {...baseIconProps} aria-hidden="true">
+ <path d="M21 21l-4.35-4.35m0 0A7.5 7.5 0 1010.5 18a7.5 7.5 0 006.15-1.35z" />
+ </svg>
+ ),
+ shield: (
+ <svg {...baseIconProps} aria-hidden="true">
+ <path d="M12 2.25l7.5 3.375v5.25c0 4.5-3.375 8.25-7.5 9-4.125-.75-7.5-4.5-7.5-9V5.625L12 2.25z" />
+ <path d="M9.75 12l1.5 1.5L15 9.75" />
+ </svg>
+ ),
+ audit: (
+ <svg {...baseIconProps} aria-hidden="true">
+ <path d="M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z" />
+ </svg>
+ ),
+ marketplace: (
+ <svg {...baseIconProps} aria-hidden="true">
+ <path d="M2.25 3h1.386c.51 0 .955.343 1.087.835l.383 1.437M7.5 14.25a3 3 0 00-3 3h15.75M7.5 14.25l-1.299-6.486a1.125 1.125 0 011.103-1.347h13.392c.717 0 1.255.66 1.11 1.363l-1.298 6.348a1.125 1.125 0 01-1.103.872H8.603a1.125 1.125 0 01-1.103-.75z" />
+ <path d="M16.5 19.5a1.5 1.5 0 11-3 0 1.5 1.5 0 013 0zM10.5 19.5a1.5 1.5 0 11-3 0 1.5 1.5 0 013 0z" />
+ </svg>
+ ),
+ ledger: (
+ <svg {...baseIconProps} aria-hidden="true">
+ <path d="M3.75 6h16.5M3.75 12h16.5M3.75 18h16.5" />
+ </svg>
+ ),
+};