import { Meta, StoryObj } from '@storybook/react-webpack5';
import {
Layers,
AlertCircle,
Database,
Plus,
RefreshCw,
Shield,
Trash2,
} from 'lucide-react';
import KubernetesLogo from '@/assets/ico/vendor/kubernetes.svg';
import DockerLogo from '@/assets/ico/vendor/docker.svg';
import PodmanLogo from '@/assets/ico/vendor/podman.svg';
import { ResourceDetailHeader } from './ResourceDetailHeader';
import { ActionBarButton } from './ActionBarButton';
import { ActionBarShell } from './ActionBarShell';
import { HeaderStats } from './HeaderStats';
import { ResourceStatBlock } from './ResourceStatBlock';
// Mirrors the env-group platform breakdown used by GroupHeader on
// feat/R8S-813. Vertical stack of engine-icon + count + name rows so
// mixed-platform groups stay scannable in the right column.
const platformBreakdown = (
3 Kubernetes
1 Docker
1 Podman
);
const meta: Meta = {
title: 'Design System/ResourceDetailHeader',
component: ResourceDetailHeader,
tags: ['autodocs'],
};
export default meta;
type Story = StoryObj;
/**
* Demonstrates the optional `actionBar` slot.
*
* Wrap content in `` to get the standard bottom-segment
* styling (rounded bottom, border, tint). Children inside the shell
* naturally split left/right because `ActionBarShell` is `justify-between`.
* Pass a custom element to `actionBar` directly if you need a different
* layout.
*/
export const ActionBar: Story = {
args: {
isLoading: false,
title: 'Production Cluster',
icon: ,
iconBackgroundClassName: 'bg-blue-3 th-dark:bg-blue-9',
subtitleLabel: 'Environment Group',
description: 'Resource detail header with the action bar slot in use',
},
render: (args) => (
{}}
data-cy="action-bar-add-environments"
>
Add Environments
{}}
data-cy="action-bar-sync"
>
Sync
{}}
data-cy="action-bar-delete"
>
Delete
}
/>
),
};
/**
* Demonstrates the optional `rightInfo` slot with `HeaderStats` and
* `ResourceStatBlock` — the standard pattern for showing health/status cards
* on the right of the header.
*/
export const StatBlocks: Story = {
args: {
isLoading: false,
title: 'orders-api',
icon: ,
iconBackgroundClassName: 'bg-blue-3 th-dark:bg-blue-9',
subtitleLabel: 'GitOps Source',
description: 'Synced from origin/main · 14 services',
rightInfo: (
Sync Status
Synced
Last reconciled 2 min ago
Health
3/3
),
},
};
/**
* The full env-group detail-header pattern, mirroring how GroupHeader uses
* `ResourceDetailHeader` in the environment-group ItemView: a vertical
* platform breakdown stat block, a centred policies count stat block, and
* a borderless Refresh / Add environments / Delete action bar.
*/
export const WithStatBlocksAndActionBar: Story = {
args: {
isLoading: false,
title: 'Production Cluster',
icon: ,
iconBackgroundClassName: 'bg-blue-3 th-dark:bg-blue-9',
subtitleLabel: 'Environment Group',
description: 'Main production environment group',
},
render: (args) => (
Environments
{platformBreakdown}
}>
Policies
3
}
actionBar={
{}}
data-cy="combined-example-refresh"
>
Refresh
{}}
data-cy="combined-example-add"
>
Add environments
{}}
data-cy="combined-example-delete"
>
Delete
}
/>
),
};
export const Default: Story = {
args: {
isLoading: false,
title: 'Production Cluster',
icon: ,
iconBackgroundClassName: 'bg-blue-3 th-dark:bg-blue-9',
subtitleLabel: 'Environment Group',
description: 'Main production environment group',
},
};
export const WithBadge: Story = {
args: {
...Default.args,
badge: (
Multi-platform
),
},
};
export const MinimalUsage: Story = {
args: {
isLoading: false,
title: 'Simple Group',
icon: ,
},
};
export const LoadingState: Story = {
args: {
isLoading: true,
title: 'Loading...',
icon: ,
},
};
export const ErrorState: Story = {
args: {
isLoading: false,
errorMessage: 'Failed to load group details',
title: '',
icon: ,
},
};
export const CustomIconBackground: Story = {
args: {
...Default.args,
icon: ,
iconBackgroundClassName: 'bg-warning-3 th-dark:bg-warning-10',
},
};
export const LongTitle: Story = {
args: {
...Default.args,
title:
'Very Long Environment Group Name That Might Wrap to Multiple Lines in Some Contexts',
description:
'This group contains multiple types of container engines including Docker, Kubernetes, and Podman installations',
},
};
export const EnvironmentGroup: Story = {
args: {
isLoading: false,
title: 'Production Cluster',
icon: ,
iconBackgroundClassName: 'bg-blue-3 th-dark:bg-blue-9',
subtitleLabel: 'Environment Group',
description: 'Main production environment group',
},
render: (args) => (
{}}
data-cy="add-environments-button"
>
Add Environments
{}}
data-cy="delete-environment-group-button"
>
Delete
}
/>
),
};