| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- import type { Meta, StoryObj } from '@storybook/react-vite';
- import { InputNumber, Space } from 'antd';
- import {
- CloudServerOutlined,
- DashboardOutlined,
- DesktopOutlined,
- SafetyOutlined,
- ThunderboltOutlined,
- } from '@ant-design/icons';
- import { NotificationLayout } from './NotificationLayout';
- import { NotificationCard } from './NotificationCard';
- import { NotificationEvent } from './NotificationEvent';
- import { NotificationHeader } from './NotificationHeader';
- const noop = () => undefined;
- function OutboundGroup() {
- return (
- <NotificationCard
- icon={<CloudServerOutlined />}
- title="Outbound"
- extra={
- <NotificationHeader
- count={1}
- total={2}
- allSelected={false}
- indeterminate
- onToggleAll={noop}
- />
- }
- >
- <Space orientation="vertical" size={8} style={{ width: '100%' }}>
- <NotificationEvent label="Outbound went down" checked onToggle={noop} />
- <NotificationEvent label="Outbound recovered" checked={false} onToggle={noop} />
- </Space>
- </NotificationCard>
- );
- }
- function XrayGroup() {
- return (
- <NotificationCard
- icon={<ThunderboltOutlined />}
- title="Xray"
- extra={
- <NotificationHeader
- count={1}
- total={1}
- allSelected
- indeterminate={false}
- onToggleAll={noop}
- />
- }
- >
- <Space orientation="vertical" size={8} style={{ width: '100%' }}>
- <NotificationEvent label="Xray crashed" checked onToggle={noop} />
- </Space>
- </NotificationCard>
- );
- }
- function NodeGroup() {
- return (
- <NotificationCard
- icon={<DesktopOutlined />}
- title="Nodes"
- extra={
- <NotificationHeader
- count={0}
- total={2}
- allSelected={false}
- indeterminate={false}
- onToggleAll={noop}
- />
- }
- >
- <Space orientation="vertical" size={8} style={{ width: '100%' }}>
- <NotificationEvent label="Node went offline" checked={false} onToggle={noop} />
- <NotificationEvent label="Node back online" checked={false} onToggle={noop} />
- </Space>
- </NotificationCard>
- );
- }
- function SystemGroup() {
- return (
- <NotificationCard
- icon={<DashboardOutlined />}
- title="System"
- extra={
- <NotificationHeader
- count={2}
- total={2}
- allSelected
- indeterminate={false}
- onToggleAll={noop}
- />
- }
- >
- <Space orientation="vertical" size={8} style={{ width: '100%' }}>
- <NotificationEvent label="CPU usage above threshold (%)" checked onToggle={noop}>
- <InputNumber
- size="small"
- min={0}
- max={100}
- defaultValue={80}
- aria-label="CPU usage threshold percent"
- style={{ width: 80 }}
- />
- </NotificationEvent>
- <NotificationEvent label="Memory usage above threshold (%)" checked onToggle={noop}>
- <InputNumber
- size="small"
- min={0}
- max={100}
- defaultValue={90}
- aria-label="Memory usage threshold percent"
- style={{ width: 80 }}
- />
- </NotificationEvent>
- </Space>
- </NotificationCard>
- );
- }
- function SecurityGroup() {
- return (
- <NotificationCard
- icon={<SafetyOutlined />}
- title="Security"
- extra={
- <NotificationHeader
- count={1}
- total={1}
- allSelected
- indeterminate={false}
- onToggleAll={noop}
- />
- }
- >
- <Space orientation="vertical" size={8} style={{ width: '100%' }}>
- <NotificationEvent label="Panel login attempt" checked onToggle={noop} />
- </Space>
- </NotificationCard>
- );
- }
- const meta = {
- title: 'UI/Notifications/NotificationLayout',
- component: NotificationLayout,
- tags: ['autodocs'],
- parameters: {
- layout: 'padded',
- docs: {
- description: {
- component:
- 'Responsive auto-fit grid (min 260px columns) that arranges notification event-group cards; the Telegram and email notification tabs on the settings page render their groups inside it.',
- },
- },
- },
- argTypes: {
- children: { description: 'Grid items, typically one NotificationCard per event group.' },
- },
- } satisfies Meta<typeof NotificationLayout>;
- export default meta;
- type Story = StoryObj<typeof meta>;
- export const AllEventGroups: Story = {
- args: {
- children: (
- <>
- <OutboundGroup />
- <XrayGroup />
- <NodeGroup />
- <SystemGroup />
- <SecurityGroup />
- </>
- ),
- },
- };
- export const TwoGroups: Story = {
- args: {
- children: (
- <>
- <SystemGroup />
- <SecurityGroup />
- </>
- ),
- },
- };
- export const SingleGroup: Story = {
- args: {
- children: <OutboundGroup />,
- },
- };
|