fleet/frontend/components/TabNav/TabNav.stories.tsx
jacobshandling 166e5ed663
UI: Batch script run detail page (#32333)
## For #31226 

New features:
- Dynamic header for each possible state of a batch script run: Started,
Scheduled, and Finished (corresponds to tabs at
`/controls/scripts/progress`
- Unique tabs for each possible status of hosts targeted by a batch
script run: Ran, Errored, Pending, Incompatible, Canceled.
- Within each tab, sortable, paginated host results with output preview
and execution time.
- View script/run details, cancel a batch, view manage hosts page
filtered for the script batch run and a status.
- Global script batch runs activities and and Scripts progress rows now
navigate to this details page.

Cleanups and improvements:
- Expand tab count badge options using “alert”/“pending” variants across
hosts, policies, and query results.
- Misc cleanups and improvements


![ezgif-1438d4041f694f](https://github.com/user-attachments/assets/2d93127b-dea4-4ca6-abcc-7c888b2e0b93)


- [x] Changes file added for user-visible changes in `changes/`,


- [x] Updated automated tests - new tests tracked for follow-up work
- [x] QA'd all new/changed functionality manually

---------

Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
2025-08-29 09:37:05 -06:00

93 lines
2.3 KiB
TypeScript

import React, { useState } from "react";
import { Meta, StoryObj } from "@storybook/react";
import { Tab, Tabs, TabList, TabPanel } from "react-tabs";
import TabText from "components/TabText";
import TabNav from "./TabNav";
const meta: Meta<typeof TabNav> = {
component: TabNav,
title: "Components/TabNav",
parameters: {
backgrounds: {
default: "light",
values: [
{
name: "light",
value: "#ffffff",
},
{
name: "dark",
value: "#333333",
},
],
},
},
};
export default meta;
type Story = StoryObj<typeof TabNav>;
export const Default: Story = {
render: () => {
const [selectedTabIndex, setSelectedTabIndex] = useState(0);
const platformSubNav = [
{ name: <TabText>Basic tab</TabText>, type: "type1" },
{ name: <TabText>Basic tab 2</TabText>, type: "type2" },
{
name: <TabText>Disabled tab</TabText>,
type: "type3",
disabled: true,
},
{ name: <TabText count={3}>Tab with count</TabText>, type: "type4" },
{
name: (
<TabText count={20} countVariant="alert">
Tab with error count
</TabText>
),
type: "type5",
},
];
const renderPanel = (type: string) => {
switch (type) {
case "type1":
return <div>Content for Tab 1</div>;
case "type2":
return <div>Content for Tab 2</div>;
case "type3":
return <div>Content for Tab 3</div>;
case "type4":
return <div>Content for Tab 4</div>;
case "type5":
return <div>Content for Tab 5</div>;
default:
return null;
}
};
return (
<TabNav>
<Tabs
onSelect={(index) => setSelectedTabIndex(index)}
selectedIndex={selectedTabIndex}
>
<TabList>
{platformSubNav.map((navItem) => (
<Tab disabled={navItem.disabled}>
<TabText>{navItem.name}</TabText>
</Tab>
))}
</TabList>
{platformSubNav.map((navItem) => (
<TabPanel key={navItem.type}>
<div>{renderPanel(navItem.type)}</div>
</TabPanel>
))}
</Tabs>
</TabNav>
);
},
};