|
| 1 | +/** |
| 2 | + @license |
| 3 | + Copyright (c) 2015-2026 Lablup Inc. All rights reserved. |
| 4 | + */ |
| 5 | +import ReplicaStatusTag from './ReplicaStatusTag'; |
| 6 | +import type { Meta, StoryObj } from '@storybook/react-vite'; |
| 7 | + |
| 8 | +/** |
| 9 | + * ReplicaStatusTag displays the health/lifecycle state of a deployment replica |
| 10 | + * using the BAI design system semantic colors and an optional tooltip. |
| 11 | + * |
| 12 | + * Health states: HEALTHY, UNHEALTHY, DEGRADED, NOT_CHECKED |
| 13 | + * Lifecycle states: PROVISIONING, TERMINATING, TERMINATED |
| 14 | + */ |
| 15 | +const meta: Meta<typeof ReplicaStatusTag> = { |
| 16 | + title: 'Components/ReplicaStatusTag', |
| 17 | + component: ReplicaStatusTag, |
| 18 | + tags: ['autodocs'], |
| 19 | + parameters: { |
| 20 | + layout: 'centered', |
| 21 | + reactDocgen: false, |
| 22 | + docs: { |
| 23 | + description: { |
| 24 | + component: ` |
| 25 | +**ReplicaStatusTag** visualises the current state of a deployment replica. |
| 26 | +
|
| 27 | +## Status → color mapping |
| 28 | +
|
| 29 | +| Status | Color | Processing | Notes | |
| 30 | +|----------------|-------------|------------|--------------------------------------------| |
| 31 | +| HEALTHY | success | no | Replica is healthy and serving traffic. | |
| 32 | +| UNHEALTHY | error | no | Replica confirmed unhealthy. | |
| 33 | +| DEGRADED | warning | no | Health checker cannot reach replica. | |
| 34 | +| NOT_CHECKED | (outline) | no | Within initial delay period. | |
| 35 | +| PROVISIONING | info | yes | Replica is being provisioned. | |
| 36 | +| TERMINATING | warning | yes | Replica is being terminated. | |
| 37 | +| TERMINATED | default | no | Replica has been terminated. | |
| 38 | +
|
| 39 | +When \`showTooltip\` is \`true\` (default), a tooltip explaining the state is |
| 40 | +rendered on hover. Set \`showTooltip={false}\` to render just the badge. |
| 41 | + `, |
| 42 | + }, |
| 43 | + }, |
| 44 | + }, |
| 45 | + argTypes: { |
| 46 | + status: { |
| 47 | + control: { type: 'select' }, |
| 48 | + options: [ |
| 49 | + 'HEALTHY', |
| 50 | + 'UNHEALTHY', |
| 51 | + 'DEGRADED', |
| 52 | + 'NOT_CHECKED', |
| 53 | + 'PROVISIONING', |
| 54 | + 'TERMINATING', |
| 55 | + 'TERMINATED', |
| 56 | + ], |
| 57 | + description: 'Replica health or lifecycle state.', |
| 58 | + }, |
| 59 | + showTooltip: { |
| 60 | + control: { type: 'boolean' }, |
| 61 | + description: |
| 62 | + 'Whether to wrap the badge in a tooltip explaining the state.', |
| 63 | + table: { |
| 64 | + type: { summary: 'boolean' }, |
| 65 | + defaultValue: { summary: 'true' }, |
| 66 | + }, |
| 67 | + }, |
| 68 | + }, |
| 69 | +}; |
| 70 | + |
| 71 | +export default meta; |
| 72 | +type Story = StoryObj<typeof ReplicaStatusTag>; |
| 73 | + |
| 74 | +/** |
| 75 | + * HEALTHY — success (green) dot with tooltip. |
| 76 | + */ |
| 77 | +export const Healthy: Story = { |
| 78 | + name: 'Basic', |
| 79 | + args: { |
| 80 | + status: 'HEALTHY', |
| 81 | + }, |
| 82 | + parameters: { |
| 83 | + docs: { |
| 84 | + description: { |
| 85 | + story: |
| 86 | + 'Healthy replica: success (green) dot with an explanatory tooltip on hover.', |
| 87 | + }, |
| 88 | + }, |
| 89 | + }, |
| 90 | +}; |
| 91 | + |
| 92 | +/** |
| 93 | + * UNHEALTHY — error (red) dot. |
| 94 | + */ |
| 95 | +export const Unhealthy: Story = { |
| 96 | + args: { |
| 97 | + status: 'UNHEALTHY', |
| 98 | + }, |
| 99 | + parameters: { |
| 100 | + docs: { |
| 101 | + description: { |
| 102 | + story: |
| 103 | + 'Unhealthy replica after consecutive health check failures. Excluded from the Active Pool.', |
| 104 | + }, |
| 105 | + }, |
| 106 | + }, |
| 107 | +}; |
| 108 | + |
| 109 | +/** |
| 110 | + * DEGRADED — warning (orange) dot. |
| 111 | + */ |
| 112 | +export const Degraded: Story = { |
| 113 | + args: { |
| 114 | + status: 'DEGRADED', |
| 115 | + }, |
| 116 | + parameters: { |
| 117 | + docs: { |
| 118 | + description: { |
| 119 | + story: |
| 120 | + 'Degraded replica. The health checker cannot reach this replica and it is temporarily excluded from the Active Pool.', |
| 121 | + }, |
| 122 | + }, |
| 123 | + }, |
| 124 | +}; |
| 125 | + |
| 126 | +/** |
| 127 | + * NOT_CHECKED — outline-only dot indicating an unknown/indeterminate state. |
| 128 | + */ |
| 129 | +export const NotChecked: Story = { |
| 130 | + args: { |
| 131 | + status: 'NOT_CHECKED', |
| 132 | + }, |
| 133 | + parameters: { |
| 134 | + docs: { |
| 135 | + description: { |
| 136 | + story: |
| 137 | + 'Replica within the initial delay period, awaiting the first health check. Renders as an outline-only dot to indicate an indeterminate state.', |
| 138 | + }, |
| 139 | + }, |
| 140 | + }, |
| 141 | +}; |
| 142 | + |
| 143 | +/** |
| 144 | + * PROVISIONING — info (blue) dot with processing animation. |
| 145 | + */ |
| 146 | +export const Provisioning: Story = { |
| 147 | + args: { |
| 148 | + status: 'PROVISIONING', |
| 149 | + }, |
| 150 | + parameters: { |
| 151 | + docs: { |
| 152 | + description: { |
| 153 | + story: |
| 154 | + 'Replica is being provisioned. Uses info (blue) color with a ripple animation to signal an in-progress transition.', |
| 155 | + }, |
| 156 | + }, |
| 157 | + }, |
| 158 | +}; |
| 159 | + |
| 160 | +/** |
| 161 | + * TERMINATING — warning (orange) dot with processing animation. |
| 162 | + */ |
| 163 | +export const Terminating: Story = { |
| 164 | + args: { |
| 165 | + status: 'TERMINATING', |
| 166 | + }, |
| 167 | + parameters: { |
| 168 | + docs: { |
| 169 | + description: { |
| 170 | + story: |
| 171 | + 'Replica is being terminated. Uses warning color with a ripple animation.', |
| 172 | + }, |
| 173 | + }, |
| 174 | + }, |
| 175 | +}; |
| 176 | + |
| 177 | +/** |
| 178 | + * TERMINATED — default (grey) dot. |
| 179 | + */ |
| 180 | +export const Terminated: Story = { |
| 181 | + args: { |
| 182 | + status: 'TERMINATED', |
| 183 | + }, |
| 184 | + parameters: { |
| 185 | + docs: { |
| 186 | + description: { |
| 187 | + story: |
| 188 | + 'Replica has been terminated. Rendered with the neutral default (grey) color.', |
| 189 | + }, |
| 190 | + }, |
| 191 | + }, |
| 192 | +}; |
| 193 | + |
| 194 | +/** |
| 195 | + * Same HEALTHY badge but with the tooltip disabled. |
| 196 | + */ |
| 197 | +export const WithoutTooltip: Story = { |
| 198 | + args: { |
| 199 | + status: 'HEALTHY', |
| 200 | + showTooltip: false, |
| 201 | + }, |
| 202 | + parameters: { |
| 203 | + docs: { |
| 204 | + description: { |
| 205 | + story: |
| 206 | + 'Renders the badge without the explanatory tooltip. Useful in dense tables where the status column header already describes the state.', |
| 207 | + }, |
| 208 | + }, |
| 209 | + }, |
| 210 | +}; |
0 commit comments