@wallarm-org/design-system 4.10.0-rc-feat-parser.1 → 4.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/components/Badge/generateBadgeVariants.js +9 -28
- package/dist/components/Checkbox/CheckboxGroup.d.ts +2 -1
- package/dist/components/Checkbox/CheckboxGroup.js +16 -13
- package/dist/components/CodeSnippet/internal/FoldToggle.js +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.d.ts +0 -2
- package/dist/components/DropdownMenu/DropdownMenu.js +71 -84
- package/dist/components/DropdownMenu/DropdownMenuItemDescription.js +1 -1
- package/dist/components/FilterInput/hooks/useFilterInputAutocomplete/useFilterInputAutocomplete.js +1 -1
- package/dist/components/Radio/RadioGroup.d.ts +2 -1
- package/dist/components/Radio/RadioGroup.js +16 -13
- package/dist/components/SimpleCharts/Chart/classes.js +1 -1
- package/dist/components/SimpleCharts/HorizontalBarStack/classes.js +1 -1
- package/dist/components/SimpleCharts/Metric/classes.d.ts +2 -2
- package/dist/components/SimpleCharts/Metric/classes.js +2 -2
- package/dist/components/Table/TableBody/TableBodyCell.js +4 -1
- package/dist/guidelines/patterns/complex-drawer.md +1084 -0
- package/dist/guidelines/patterns/confirmation-dialogs.md +3 -11
- package/dist/guidelines/patterns/detail-drawer.md +31 -13
- package/dist/guidelines/patterns/empty-states.md +6 -5
- package/dist/guidelines/patterns/entity-table.md +25 -29
- package/dist/guidelines/patterns/feedback-toasts.md +3 -11
- package/dist/guidelines/patterns/resource-list-page.md +14 -16
- package/dist/guidelines/rules.md +6 -5
- package/dist/guidelines/templates/ai-assistant.md +1133 -0
- package/dist/guidelines/templates/api-inventory.md +905 -0
- package/dist/guidelines/templates/attack-events.md +2722 -0
- package/dist/guidelines/templates/incident-detail.md +2085 -0
- package/dist/guidelines/templates/integrations-settings.md +836 -0
- package/dist/guidelines/templates/page-states.md +798 -0
- package/dist/guidelines/templates/rule-editor.md +886 -0
- package/dist/guidelines/templates/security-dashboard.md +681 -0
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -2
- package/dist/metadata/components.json +20 -108
- package/dist/metadata/guidelines.json +1204 -37
- package/dist/theme/tokens.test.ts +52 -0
- package/package.json +1 -4
- package/dist/components/Rules/PointSelector/KeyboardShortcutsDialog.d.ts +0 -14
- package/dist/components/Rules/PointSelector/KeyboardShortcutsDialog.js +0 -209
- package/dist/components/Rules/PointSelector/MatchStep.d.ts +0 -15
- package/dist/components/Rules/PointSelector/MatchStep.js +0 -186
- package/dist/components/Rules/PointSelector/MenuFooterHints.d.ts +0 -16
- package/dist/components/Rules/PointSelector/MenuFooterHints.js +0 -177
- package/dist/components/Rules/PointSelector/PointPreview.d.ts +0 -10
- package/dist/components/Rules/PointSelector/PointPreview.js +0 -88
- package/dist/components/Rules/PointSelector/PointSelector.d.ts +0 -17
- package/dist/components/Rules/PointSelector/PointSelector.js +0 -937
- package/dist/components/Rules/PointSelector/PointSelectorEmptyState.d.ts +0 -12
- package/dist/components/Rules/PointSelector/PointSelectorEmptyState.js +0 -173
- package/dist/components/Rules/PointSelector/PointSelectorError.d.ts +0 -31
- package/dist/components/Rules/PointSelector/PointSelectorError.js +0 -275
- package/dist/components/Rules/PointSelector/PointSelectorInput.d.ts +0 -20
- package/dist/components/Rules/PointSelector/PointSelectorInput.js +0 -130
- package/dist/components/Rules/PointSelector/PointSelectorMenu.d.ts +0 -31
- package/dist/components/Rules/PointSelector/PointSelectorMenu.js +0 -317
- package/dist/components/Rules/PointSelector/PointSelectorSkeleton.d.ts +0 -8
- package/dist/components/Rules/PointSelector/PointSelectorSkeleton.js +0 -73
- package/dist/components/Rules/PointSelector/SampleRequest.d.ts +0 -14
- package/dist/components/Rules/PointSelector/SampleRequest.js +0 -116
- package/dist/components/Rules/PointSelector/StepMenu.d.ts +0 -40
- package/dist/components/Rules/PointSelector/StepMenu.js +0 -210
- package/dist/components/Rules/PointSelector/VersionWarning.d.ts +0 -26
- package/dist/components/Rules/PointSelector/VersionWarning.js +0 -231
- package/dist/components/Rules/PointSelector/WhereBar.d.ts +0 -48
- package/dist/components/Rules/PointSelector/WhereBar.js +0 -263
- package/dist/components/Rules/PointSelector/classes.d.ts +0 -28
- package/dist/components/Rules/PointSelector/classes.js +0 -22
- package/dist/components/Rules/PointSelector/index.d.ts +0 -20
- package/dist/components/Rules/PointSelector/index.js +0 -18
- package/dist/components/Rules/PointSelector/liftLayer.d.ts +0 -8
- package/dist/components/Rules/PointSelector/liftLayer.js +0 -4
- package/dist/components/Rules/PointSelector/sampleValue.d.ts +0 -6
- package/dist/components/Rules/PointSelector/sampleValue.js +0 -51
- package/dist/components/Rules/PointSelector/sdkBridge.d.ts +0 -508
- package/dist/components/Rules/PointSelector/sdkBridge.js +0 -339
- package/dist/components/Rules/PointSelector/types.d.ts +0 -304
- package/dist/components/Rules/PointSelector/types.js +0 -0
- package/dist/components/Rules/PointSelector/usePointSelector.d.ts +0 -161
- package/dist/components/Rules/PointSelector/usePointSelector.js +0 -1088
- package/dist/components/Rules/RuleBuilder/ActionEditor/ActionEditor.d.ts +0 -28
- package/dist/components/Rules/RuleBuilder/ActionEditor/ActionEditor.js +0 -208
- package/dist/components/Rules/RuleBuilder/ActionEditor/ActionFields.d.ts +0 -23
- package/dist/components/Rules/RuleBuilder/ActionEditor/ActionFields.js +0 -950
- package/dist/components/Rules/RuleBuilder/ActionEditor/ActionTargetPicker.d.ts +0 -21
- package/dist/components/Rules/RuleBuilder/ActionEditor/ActionTargetPicker.js +0 -110
- package/dist/components/Rules/RuleBuilder/ActionEditor/ActionTypeSelect.d.ts +0 -20
- package/dist/components/Rules/RuleBuilder/ActionEditor/ActionTypeSelect.js +0 -31
- package/dist/components/Rules/RuleBuilder/ActionEditor/AttackTypeField.d.ts +0 -23
- package/dist/components/Rules/RuleBuilder/ActionEditor/AttackTypeField.js +0 -131
- package/dist/components/Rules/RuleBuilder/ActionEditor/classes.d.ts +0 -17
- package/dist/components/Rules/RuleBuilder/ActionEditor/classes.js +0 -14
- package/dist/components/Rules/RuleBuilder/ActionEditor/index.d.ts +0 -6
- package/dist/components/Rules/RuleBuilder/ActionEditor/index.js +0 -6
- package/dist/components/Rules/RuleBuilder/ConditionTree/AddConditionMenu.d.ts +0 -24
- package/dist/components/Rules/RuleBuilder/ConditionTree/AddConditionMenu.js +0 -245
- package/dist/components/Rules/RuleBuilder/ConditionTree/AttackCondition.d.ts +0 -15
- package/dist/components/Rules/RuleBuilder/ConditionTree/AttackCondition.js +0 -691
- package/dist/components/Rules/RuleBuilder/ConditionTree/ConditionCard.d.ts +0 -19
- package/dist/components/Rules/RuleBuilder/ConditionTree/ConditionCard.js +0 -72
- package/dist/components/Rules/RuleBuilder/ConditionTree/ConditionTree.d.ts +0 -27
- package/dist/components/Rules/RuleBuilder/ConditionTree/ConditionTree.js +0 -407
- package/dist/components/Rules/RuleBuilder/ConditionTree/FieldCondition.d.ts +0 -14
- package/dist/components/Rules/RuleBuilder/ConditionTree/FieldCondition.js +0 -269
- package/dist/components/Rules/RuleBuilder/ConditionTree/GroupCondition.d.ts +0 -25
- package/dist/components/Rules/RuleBuilder/ConditionTree/GroupCondition.js +0 -99
- package/dist/components/Rules/RuleBuilder/ConditionTree/SampleCondition.d.ts +0 -14
- package/dist/components/Rules/RuleBuilder/ConditionTree/SampleCondition.js +0 -118
- package/dist/components/Rules/RuleBuilder/ConditionTree/SignalCondition.d.ts +0 -14
- package/dist/components/Rules/RuleBuilder/ConditionTree/SignalCondition.js +0 -446
- package/dist/components/Rules/RuleBuilder/ConditionTree/TagCondition.d.ts +0 -14
- package/dist/components/Rules/RuleBuilder/ConditionTree/TagCondition.js +0 -266
- package/dist/components/Rules/RuleBuilder/ConditionTree/classes.d.ts +0 -35
- package/dist/components/Rules/RuleBuilder/ConditionTree/classes.js +0 -57
- package/dist/components/Rules/RuleBuilder/ConditionTree/index.d.ts +0 -15
- package/dist/components/Rules/RuleBuilder/ConditionTree/index.js +0 -10
- package/dist/components/Rules/RuleBuilder/RuleBuilder.d.ts +0 -67
- package/dist/components/Rules/RuleBuilder/RuleBuilder.js +0 -366
- package/dist/components/Rules/RuleBuilder/Summary/ActionSummary.d.ts +0 -32
- package/dist/components/Rules/RuleBuilder/Summary/ActionSummary.js +0 -420
- package/dist/components/Rules/RuleBuilder/Summary/ConditionSummary.d.ts +0 -27
- package/dist/components/Rules/RuleBuilder/Summary/ConditionSummary.js +0 -446
- package/dist/components/Rules/RuleBuilder/Summary/index.d.ts +0 -7
- package/dist/components/Rules/RuleBuilder/Summary/index.js +0 -2
- package/dist/components/Rules/RuleBuilder/classes.d.ts +0 -19
- package/dist/components/Rules/RuleBuilder/classes.js +0 -18
- package/dist/components/Rules/RuleBuilder/index.d.ts +0 -55
- package/dist/components/Rules/RuleBuilder/index.js +0 -11
- package/dist/components/Rules/RuleBuilder/models/actionModel.d.ts +0 -31
- package/dist/components/Rules/RuleBuilder/models/actionModel.js +0 -276
- package/dist/components/Rules/RuleBuilder/models/conditionModel.d.ts +0 -95
- package/dist/components/Rules/RuleBuilder/models/conditionModel.js +0 -418
- package/dist/components/Rules/RuleBuilder/models/index.d.ts +0 -3
- package/dist/components/Rules/RuleBuilder/models/index.js +0 -3
- package/dist/components/Rules/RuleBuilder/models/validation.d.ts +0 -176
- package/dist/components/Rules/RuleBuilder/models/validation.js +0 -242
- package/dist/components/Rules/RuleBuilder/shared/ChoiceSelect.d.ts +0 -27
- package/dist/components/Rules/RuleBuilder/shared/ChoiceSelect.js +0 -92
- package/dist/components/Rules/RuleBuilder/shared/index.d.ts +0 -1
- package/dist/components/Rules/RuleBuilder/shared/index.js +0 -1
- package/dist/components/Rules/RuleBuilder/types.d.ts +0 -384
- package/dist/components/Rules/RuleBuilder/types.js +0 -0
- package/dist/components/Rules/RuleBuilder/utils/constants.d.ts +0 -65
- package/dist/components/Rules/RuleBuilder/utils/constants.js +0 -356
- package/dist/components/Rules/RuleBuilder/utils/extractBindings.d.ts +0 -48
- package/dist/components/Rules/RuleBuilder/utils/extractBindings.js +0 -42
- package/dist/components/Rules/RuleBuilder/utils/helpers.d.ts +0 -92
- package/dist/components/Rules/RuleBuilder/utils/helpers.js +0 -54
- package/dist/components/Rules/RuleBuilder/utils/index.d.ts +0 -2
- package/dist/components/Rules/RuleBuilder/utils/index.js +0 -2
|
@@ -0,0 +1,798 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Page states
|
|
3
|
+
description: Use when a list page must handle every state it goes through, from loading and first use to no results, load errors, read-only access and partial failure.
|
|
4
|
+
components: [Page, PageHeader, PageHeaderGroup, PageTitle, PageDescription, PageActions, PageToolbar, PageContent, Button, SearchInput, SegmentedTabs, SegmentedTabsList, SegmentedTabsTrigger, NumericBadge, Table, TableEmptyState, EmptyState, EmptyStateIllustration, EmptyStateMessage, EmptyStateTitle, EmptyStateDescription, EmptyStateActions, EmptyStateLink, Alert, AlertIcon, AlertContent, AlertTitle, AlertDescription, AlertControls, Tooltip, TooltipTrigger, TooltipContent, Badge, Avatar, Code, Ip, FormatDateTime, DropdownMenu, VStack]
|
|
5
|
+
keywords: [page states, loading, skeleton, empty, first use, no results, error, failed to load, try again, read only, no permission, partial failure, degraded, api tokens, list page]
|
|
6
|
+
order: 80
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Page states
|
|
10
|
+
|
|
11
|
+
One API tokens list page in every state it goes through. The header, toolbar and columns never change between stories, so the only difference is the state itself.
|
|
12
|
+
|
|
13
|
+
## What it shows
|
|
14
|
+
|
|
15
|
+
- The [Resource list page](../patterns/resource-list-page.md) frame, with one story per list state.
|
|
16
|
+
- An [Entity table](../patterns/entity-table.md) of API tokens with the row menu in the master cell.
|
|
17
|
+
- Loading, first use, no results and a failed list from [Empty states](../patterns/empty-states.md); the failed list is the same composition as the Patterns/Error states `Default` story.
|
|
18
|
+
- Two states no pattern covers: read-only access (a disabled create action with a tooltip, no row menu, an info `Alert`) and partial failure (a warning `Alert` over the rows that did load).
|
|
19
|
+
- A "Copy token ID" toast from [Feedback toasts](../patterns/feedback-toasts.md).
|
|
20
|
+
|
|
21
|
+
## Examples
|
|
22
|
+
|
|
23
|
+
Data: search, status tabs and the row menu all work.
|
|
24
|
+
|
|
25
|
+
Data: one create action in the header, search and status tabs with counts in the toolbar, and
|
|
26
|
+
the token table. Hover a row and the `…` row menu appears in the name (master) cell, through
|
|
27
|
+
`meta.renderMenuAction` on the first column. "Copy token ID" reports through one toast with a
|
|
28
|
+
stable id, so repeated copies update it instead of stacking.
|
|
29
|
+
|
|
30
|
+
```tsx story=Default
|
|
31
|
+
import { useState } from 'react';
|
|
32
|
+
import { Button } from '@wallarm-org/design-system/Button';
|
|
33
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuItemText, DropdownMenuSeparator, DropdownMenuTrigger } from '@wallarm-org/design-system/DropdownMenu';
|
|
34
|
+
import { EmptyState, EmptyStateActions, EmptyStateDescription, EmptyStateIllustration, EmptyStateMessage, EmptyStateTitle } from '@wallarm-org/design-system/EmptyState';
|
|
35
|
+
import { Ellipsis, FilterX, SearchX } from '@wallarm-org/design-system/icons';
|
|
36
|
+
import { NumericBadge } from '@wallarm-org/design-system/NumericBadge';
|
|
37
|
+
import { Page, PageActions, PageContent, PageDescription, PageHeader, PageHeaderGroup, PageTitle, PageToolbar } from '@wallarm-org/design-system/Page';
|
|
38
|
+
import { SearchInput } from '@wallarm-org/design-system/SearchInput';
|
|
39
|
+
import { SegmentedTabs, SegmentedTabsList, SegmentedTabsTrigger } from '@wallarm-org/design-system/SegmentedTabs';
|
|
40
|
+
import { type TableColumnDef, type TableRow, Table, TableEmptyState } from '@wallarm-org/design-system/Table';
|
|
41
|
+
import { useToast } from '@wallarm-org/design-system/Toast';
|
|
42
|
+
|
|
43
|
+
export const Default = () => {
|
|
44
|
+
const toast = useToast();
|
|
45
|
+
const [query, setQuery] = useState('');
|
|
46
|
+
const [status, setStatus] = useState('all');
|
|
47
|
+
|
|
48
|
+
const renderRowMenu = (row: TableRow<ApiToken>) => {
|
|
49
|
+
const token = row.original;
|
|
50
|
+
const handleCopyId = async () => {
|
|
51
|
+
try {
|
|
52
|
+
await navigator.clipboard.writeText(token.id);
|
|
53
|
+
toast.create({ id: 'copy-token-id', title: 'Token ID copied', type: 'default' });
|
|
54
|
+
} catch {
|
|
55
|
+
toast.create({ id: 'copy-token-id', title: 'Copy failed', type: 'error' });
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const handleRotate = () => onRotateToken(token);
|
|
59
|
+
const handleRevoke = () => onRevokeToken(token);
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<DropdownMenu data-testid='api-tokens-row-menu'>
|
|
63
|
+
<DropdownMenuTrigger asChild>
|
|
64
|
+
<Button
|
|
65
|
+
variant='ghost'
|
|
66
|
+
color='neutral'
|
|
67
|
+
size='small'
|
|
68
|
+
aria-label={`Actions for ${token.name}`}
|
|
69
|
+
data-testid={`api-tokens-actions-${token.id}`}
|
|
70
|
+
>
|
|
71
|
+
<Ellipsis />
|
|
72
|
+
</Button>
|
|
73
|
+
</DropdownMenuTrigger>
|
|
74
|
+
<DropdownMenuContent>
|
|
75
|
+
<DropdownMenuItem onSelect={handleCopyId}>
|
|
76
|
+
<DropdownMenuItemText>Copy token ID</DropdownMenuItemText>
|
|
77
|
+
</DropdownMenuItem>
|
|
78
|
+
<DropdownMenuItem onSelect={handleRotate}>
|
|
79
|
+
<DropdownMenuItemText>Rotate secret</DropdownMenuItemText>
|
|
80
|
+
</DropdownMenuItem>
|
|
81
|
+
<DropdownMenuSeparator />
|
|
82
|
+
<DropdownMenuItem variant='destructive' onSelect={handleRevoke}>
|
|
83
|
+
<DropdownMenuItemText>Revoke token</DropdownMenuItemText>
|
|
84
|
+
</DropdownMenuItem>
|
|
85
|
+
</DropdownMenuContent>
|
|
86
|
+
</DropdownMenu>
|
|
87
|
+
);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const columns: TableColumnDef<ApiToken>[] = [
|
|
91
|
+
{ ...NAME_COLUMN, meta: { renderMenuAction: renderRowMenu } },
|
|
92
|
+
...DATA_COLUMNS,
|
|
93
|
+
];
|
|
94
|
+
|
|
95
|
+
const matching = TOKENS.filter(token => matchesSearch(token, query));
|
|
96
|
+
const counts = countByStatus(matching);
|
|
97
|
+
const rows = status === 'all' ? matching : matching.filter(token => token.status === status);
|
|
98
|
+
|
|
99
|
+
const handleReset = () => {
|
|
100
|
+
setQuery('');
|
|
101
|
+
setStatus('all');
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<Page name='settings-api-tokens' fullSize fixedHeight data-testid='api-tokens-page'>
|
|
106
|
+
<PageHeader>
|
|
107
|
+
<PageHeaderGroup className='flex-1'>
|
|
108
|
+
<PageTitle>API tokens</PageTitle>
|
|
109
|
+
<PageDescription>
|
|
110
|
+
Tokens let scripts, CI pipelines and integrations call the Wallarm API on behalf of your
|
|
111
|
+
organization.
|
|
112
|
+
</PageDescription>
|
|
113
|
+
</PageHeaderGroup>
|
|
114
|
+
<PageActions>
|
|
115
|
+
<Button size='medium' onClick={onCreateToken} data-testid='api-tokens-create'>
|
|
116
|
+
Create token
|
|
117
|
+
</Button>
|
|
118
|
+
</PageActions>
|
|
119
|
+
</PageHeader>
|
|
120
|
+
|
|
121
|
+
<PageToolbar>
|
|
122
|
+
<SearchInput
|
|
123
|
+
value={query}
|
|
124
|
+
onChange={setQuery}
|
|
125
|
+
placeholder='Search name or prefix'
|
|
126
|
+
className='w-[320px]'
|
|
127
|
+
data-testid='api-tokens-search'
|
|
128
|
+
/>
|
|
129
|
+
<SegmentedTabs value={status} onChange={setStatus} data-testid='api-tokens-status-tabs'>
|
|
130
|
+
<SegmentedTabsList>
|
|
131
|
+
<SegmentedTabsTrigger value='all'>
|
|
132
|
+
All <NumericBadge>{counts.all}</NumericBadge>
|
|
133
|
+
</SegmentedTabsTrigger>
|
|
134
|
+
<SegmentedTabsTrigger value='active'>
|
|
135
|
+
Active <NumericBadge>{counts.active}</NumericBadge>
|
|
136
|
+
</SegmentedTabsTrigger>
|
|
137
|
+
<SegmentedTabsTrigger value='expiring'>
|
|
138
|
+
Expiring soon <NumericBadge>{counts.expiring}</NumericBadge>
|
|
139
|
+
</SegmentedTabsTrigger>
|
|
140
|
+
<SegmentedTabsTrigger value='expired'>
|
|
141
|
+
Expired <NumericBadge>{counts.expired}</NumericBadge>
|
|
142
|
+
</SegmentedTabsTrigger>
|
|
143
|
+
</SegmentedTabsList>
|
|
144
|
+
</SegmentedTabs>
|
|
145
|
+
</PageToolbar>
|
|
146
|
+
|
|
147
|
+
<PageContent>
|
|
148
|
+
<Table
|
|
149
|
+
aria-label='API tokens'
|
|
150
|
+
data={rows}
|
|
151
|
+
columns={columns}
|
|
152
|
+
getRowId={getTokenId}
|
|
153
|
+
data-testid='api-tokens-table'
|
|
154
|
+
>
|
|
155
|
+
<TableEmptyState>
|
|
156
|
+
<EmptyState type='collection-empty' data-testid='api-tokens-no-results'>
|
|
157
|
+
<EmptyStateIllustration>
|
|
158
|
+
<SearchX />
|
|
159
|
+
</EmptyStateIllustration>
|
|
160
|
+
<EmptyStateMessage>
|
|
161
|
+
<EmptyStateTitle>No results found</EmptyStateTitle>
|
|
162
|
+
<EmptyStateDescription>
|
|
163
|
+
No tokens match your search or status.
|
|
164
|
+
</EmptyStateDescription>
|
|
165
|
+
</EmptyStateMessage>
|
|
166
|
+
<EmptyStateActions>
|
|
167
|
+
<Button size='medium' variant='outline' color='neutral' onClick={handleReset}>
|
|
168
|
+
<FilterX />
|
|
169
|
+
Reset filters
|
|
170
|
+
</Button>
|
|
171
|
+
</EmptyStateActions>
|
|
172
|
+
</EmptyState>
|
|
173
|
+
</TableEmptyState>
|
|
174
|
+
</Table>
|
|
175
|
+
</PageContent>
|
|
176
|
+
</Page>
|
|
177
|
+
);
|
|
178
|
+
};
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
First load: skeleton rows, tabs without counts.
|
|
182
|
+
|
|
183
|
+
First load: the real header and toolbar with skeleton rows under the column headers. Counts are
|
|
184
|
+
unknown yet, so the tabs drop their badges.
|
|
185
|
+
|
|
186
|
+
```tsx story=Loading
|
|
187
|
+
import { useState } from 'react';
|
|
188
|
+
import { Button } from '@wallarm-org/design-system/Button';
|
|
189
|
+
import { Page, PageActions, PageContent, PageDescription, PageHeader, PageHeaderGroup, PageTitle, PageToolbar } from '@wallarm-org/design-system/Page';
|
|
190
|
+
import { SearchInput } from '@wallarm-org/design-system/SearchInput';
|
|
191
|
+
import { SegmentedTabs, SegmentedTabsList, SegmentedTabsTrigger } from '@wallarm-org/design-system/SegmentedTabs';
|
|
192
|
+
import { Table } from '@wallarm-org/design-system/Table';
|
|
193
|
+
|
|
194
|
+
export const Loading = () => {
|
|
195
|
+
const [query, setQuery] = useState('');
|
|
196
|
+
const [status, setStatus] = useState('all');
|
|
197
|
+
|
|
198
|
+
return (
|
|
199
|
+
<Page name='settings-api-tokens' fullSize fixedHeight data-testid='api-tokens-page'>
|
|
200
|
+
<PageHeader>
|
|
201
|
+
<PageHeaderGroup className='flex-1'>
|
|
202
|
+
<PageTitle>API tokens</PageTitle>
|
|
203
|
+
<PageDescription>
|
|
204
|
+
Tokens let scripts, CI pipelines and integrations call the Wallarm API on behalf of your
|
|
205
|
+
organization.
|
|
206
|
+
</PageDescription>
|
|
207
|
+
</PageHeaderGroup>
|
|
208
|
+
<PageActions>
|
|
209
|
+
<Button size='medium' onClick={onCreateToken} data-testid='api-tokens-create'>
|
|
210
|
+
Create token
|
|
211
|
+
</Button>
|
|
212
|
+
</PageActions>
|
|
213
|
+
</PageHeader>
|
|
214
|
+
|
|
215
|
+
<PageToolbar>
|
|
216
|
+
<SearchInput
|
|
217
|
+
value={query}
|
|
218
|
+
onChange={setQuery}
|
|
219
|
+
placeholder='Search name or prefix'
|
|
220
|
+
className='w-[320px]'
|
|
221
|
+
data-testid='api-tokens-search'
|
|
222
|
+
/>
|
|
223
|
+
<SegmentedTabs value={status} onChange={setStatus} data-testid='api-tokens-status-tabs'>
|
|
224
|
+
<SegmentedTabsList>
|
|
225
|
+
<SegmentedTabsTrigger value='all'>All</SegmentedTabsTrigger>
|
|
226
|
+
<SegmentedTabsTrigger value='active'>Active</SegmentedTabsTrigger>
|
|
227
|
+
<SegmentedTabsTrigger value='expiring'>Expiring soon</SegmentedTabsTrigger>
|
|
228
|
+
<SegmentedTabsTrigger value='expired'>Expired</SegmentedTabsTrigger>
|
|
229
|
+
</SegmentedTabsList>
|
|
230
|
+
</SegmentedTabs>
|
|
231
|
+
</PageToolbar>
|
|
232
|
+
|
|
233
|
+
<PageContent>
|
|
234
|
+
<Table
|
|
235
|
+
aria-label='API tokens'
|
|
236
|
+
data={[]}
|
|
237
|
+
columns={COLUMNS}
|
|
238
|
+
getRowId={getTokenId}
|
|
239
|
+
isLoading
|
|
240
|
+
data-testid='api-tokens-table'
|
|
241
|
+
/>
|
|
242
|
+
</PageContent>
|
|
243
|
+
</Page>
|
|
244
|
+
);
|
|
245
|
+
};
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
Nothing yet: the header keeps the create action, so the empty state only links to the docs.
|
|
249
|
+
|
|
250
|
+
First use: nothing exists yet. The header keeps the one create action, so the empty state has
|
|
251
|
+
no button of its own, only an illustration that names the entity and a link to the docs.
|
|
252
|
+
|
|
253
|
+
```tsx story=Empty
|
|
254
|
+
import { useState } from 'react';
|
|
255
|
+
import { Button } from '@wallarm-org/design-system/Button';
|
|
256
|
+
import { EmptyState, EmptyStateDescription, EmptyStateIllustration, EmptyStateLink, EmptyStateMessage, EmptyStateTitle } from '@wallarm-org/design-system/EmptyState';
|
|
257
|
+
import { KeyRound } from '@wallarm-org/design-system/icons';
|
|
258
|
+
import { NumericBadge } from '@wallarm-org/design-system/NumericBadge';
|
|
259
|
+
import { Page, PageActions, PageContent, PageDescription, PageHeader, PageHeaderGroup, PageTitle, PageToolbar } from '@wallarm-org/design-system/Page';
|
|
260
|
+
import { SearchInput } from '@wallarm-org/design-system/SearchInput';
|
|
261
|
+
import { SegmentedTabs, SegmentedTabsList, SegmentedTabsTrigger } from '@wallarm-org/design-system/SegmentedTabs';
|
|
262
|
+
import { Table, TableEmptyState } from '@wallarm-org/design-system/Table';
|
|
263
|
+
|
|
264
|
+
export const Empty = () => {
|
|
265
|
+
const [query, setQuery] = useState('');
|
|
266
|
+
const [status, setStatus] = useState('all');
|
|
267
|
+
|
|
268
|
+
return (
|
|
269
|
+
<Page name='settings-api-tokens' fullSize fixedHeight data-testid='api-tokens-page'>
|
|
270
|
+
<PageHeader>
|
|
271
|
+
<PageHeaderGroup className='flex-1'>
|
|
272
|
+
<PageTitle>API tokens</PageTitle>
|
|
273
|
+
<PageDescription>
|
|
274
|
+
Tokens let scripts, CI pipelines and integrations call the Wallarm API on behalf of your
|
|
275
|
+
organization.
|
|
276
|
+
</PageDescription>
|
|
277
|
+
</PageHeaderGroup>
|
|
278
|
+
<PageActions>
|
|
279
|
+
<Button size='medium' onClick={onCreateToken} data-testid='api-tokens-create'>
|
|
280
|
+
Create token
|
|
281
|
+
</Button>
|
|
282
|
+
</PageActions>
|
|
283
|
+
</PageHeader>
|
|
284
|
+
|
|
285
|
+
<PageToolbar>
|
|
286
|
+
<SearchInput
|
|
287
|
+
value={query}
|
|
288
|
+
onChange={setQuery}
|
|
289
|
+
placeholder='Search name or prefix'
|
|
290
|
+
className='w-[320px]'
|
|
291
|
+
data-testid='api-tokens-search'
|
|
292
|
+
/>
|
|
293
|
+
<SegmentedTabs value={status} onChange={setStatus} data-testid='api-tokens-status-tabs'>
|
|
294
|
+
<SegmentedTabsList>
|
|
295
|
+
<SegmentedTabsTrigger value='all'>
|
|
296
|
+
All <NumericBadge>0</NumericBadge>
|
|
297
|
+
</SegmentedTabsTrigger>
|
|
298
|
+
<SegmentedTabsTrigger value='active'>
|
|
299
|
+
Active <NumericBadge>0</NumericBadge>
|
|
300
|
+
</SegmentedTabsTrigger>
|
|
301
|
+
<SegmentedTabsTrigger value='expiring'>
|
|
302
|
+
Expiring soon <NumericBadge>0</NumericBadge>
|
|
303
|
+
</SegmentedTabsTrigger>
|
|
304
|
+
<SegmentedTabsTrigger value='expired'>
|
|
305
|
+
Expired <NumericBadge>0</NumericBadge>
|
|
306
|
+
</SegmentedTabsTrigger>
|
|
307
|
+
</SegmentedTabsList>
|
|
308
|
+
</SegmentedTabs>
|
|
309
|
+
</PageToolbar>
|
|
310
|
+
|
|
311
|
+
<PageContent>
|
|
312
|
+
<Table
|
|
313
|
+
aria-label='API tokens'
|
|
314
|
+
data={[]}
|
|
315
|
+
columns={COLUMNS}
|
|
316
|
+
getRowId={getTokenId}
|
|
317
|
+
data-testid='api-tokens-table'
|
|
318
|
+
>
|
|
319
|
+
<TableEmptyState>
|
|
320
|
+
<EmptyState type='collection-empty' data-testid='api-tokens-empty-state'>
|
|
321
|
+
<EmptyStateIllustration>
|
|
322
|
+
<KeyRound />
|
|
323
|
+
</EmptyStateIllustration>
|
|
324
|
+
<EmptyStateMessage>
|
|
325
|
+
<EmptyStateTitle>No API tokens yet</EmptyStateTitle>
|
|
326
|
+
<EmptyStateDescription>
|
|
327
|
+
Create a token to call the Wallarm API from scripts, CI pipelines and Terraform.
|
|
328
|
+
</EmptyStateDescription>
|
|
329
|
+
</EmptyStateMessage>
|
|
330
|
+
<EmptyStateLink href='#'>How API tokens work</EmptyStateLink>
|
|
331
|
+
</EmptyState>
|
|
332
|
+
</TableEmptyState>
|
|
333
|
+
</Table>
|
|
334
|
+
</PageContent>
|
|
335
|
+
</Page>
|
|
336
|
+
);
|
|
337
|
+
};
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
Search matched nothing: "Reset filters" clears the search.
|
|
341
|
+
|
|
342
|
+
Search matched nothing: the typed value stays, counts drop to zero, and the empty state offers
|
|
343
|
+
"Reset filters", never a create action.
|
|
344
|
+
|
|
345
|
+
```tsx story=NoResults
|
|
346
|
+
import { useState } from 'react';
|
|
347
|
+
import { Button } from '@wallarm-org/design-system/Button';
|
|
348
|
+
import { EmptyState, EmptyStateActions, EmptyStateDescription, EmptyStateIllustration, EmptyStateMessage, EmptyStateTitle } from '@wallarm-org/design-system/EmptyState';
|
|
349
|
+
import { FilterX, SearchX } from '@wallarm-org/design-system/icons';
|
|
350
|
+
import { NumericBadge } from '@wallarm-org/design-system/NumericBadge';
|
|
351
|
+
import { Page, PageActions, PageContent, PageDescription, PageHeader, PageHeaderGroup, PageTitle, PageToolbar } from '@wallarm-org/design-system/Page';
|
|
352
|
+
import { SearchInput } from '@wallarm-org/design-system/SearchInput';
|
|
353
|
+
import { SegmentedTabs, SegmentedTabsList, SegmentedTabsTrigger } from '@wallarm-org/design-system/SegmentedTabs';
|
|
354
|
+
import { Table, TableEmptyState } from '@wallarm-org/design-system/Table';
|
|
355
|
+
|
|
356
|
+
export const NoResults = () => {
|
|
357
|
+
const [query, setQuery] = useState('okta-scim');
|
|
358
|
+
const [status, setStatus] = useState('all');
|
|
359
|
+
|
|
360
|
+
const matching = TOKENS.filter(token => matchesSearch(token, query));
|
|
361
|
+
const counts = countByStatus(matching);
|
|
362
|
+
const rows = status === 'all' ? matching : matching.filter(token => token.status === status);
|
|
363
|
+
|
|
364
|
+
const handleReset = () => {
|
|
365
|
+
setQuery('');
|
|
366
|
+
setStatus('all');
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
return (
|
|
370
|
+
<Page name='settings-api-tokens' fullSize fixedHeight data-testid='api-tokens-page'>
|
|
371
|
+
<PageHeader>
|
|
372
|
+
<PageHeaderGroup className='flex-1'>
|
|
373
|
+
<PageTitle>API tokens</PageTitle>
|
|
374
|
+
<PageDescription>
|
|
375
|
+
Tokens let scripts, CI pipelines and integrations call the Wallarm API on behalf of your
|
|
376
|
+
organization.
|
|
377
|
+
</PageDescription>
|
|
378
|
+
</PageHeaderGroup>
|
|
379
|
+
<PageActions>
|
|
380
|
+
<Button size='medium' onClick={onCreateToken} data-testid='api-tokens-create'>
|
|
381
|
+
Create token
|
|
382
|
+
</Button>
|
|
383
|
+
</PageActions>
|
|
384
|
+
</PageHeader>
|
|
385
|
+
|
|
386
|
+
<PageToolbar>
|
|
387
|
+
<SearchInput
|
|
388
|
+
value={query}
|
|
389
|
+
onChange={setQuery}
|
|
390
|
+
placeholder='Search name or prefix'
|
|
391
|
+
className='w-[320px]'
|
|
392
|
+
data-testid='api-tokens-search'
|
|
393
|
+
/>
|
|
394
|
+
<SegmentedTabs value={status} onChange={setStatus} data-testid='api-tokens-status-tabs'>
|
|
395
|
+
<SegmentedTabsList>
|
|
396
|
+
<SegmentedTabsTrigger value='all'>
|
|
397
|
+
All <NumericBadge>{counts.all}</NumericBadge>
|
|
398
|
+
</SegmentedTabsTrigger>
|
|
399
|
+
<SegmentedTabsTrigger value='active'>
|
|
400
|
+
Active <NumericBadge>{counts.active}</NumericBadge>
|
|
401
|
+
</SegmentedTabsTrigger>
|
|
402
|
+
<SegmentedTabsTrigger value='expiring'>
|
|
403
|
+
Expiring soon <NumericBadge>{counts.expiring}</NumericBadge>
|
|
404
|
+
</SegmentedTabsTrigger>
|
|
405
|
+
<SegmentedTabsTrigger value='expired'>
|
|
406
|
+
Expired <NumericBadge>{counts.expired}</NumericBadge>
|
|
407
|
+
</SegmentedTabsTrigger>
|
|
408
|
+
</SegmentedTabsList>
|
|
409
|
+
</SegmentedTabs>
|
|
410
|
+
</PageToolbar>
|
|
411
|
+
|
|
412
|
+
<PageContent>
|
|
413
|
+
<Table
|
|
414
|
+
aria-label='API tokens'
|
|
415
|
+
data={rows}
|
|
416
|
+
columns={COLUMNS}
|
|
417
|
+
getRowId={getTokenId}
|
|
418
|
+
data-testid='api-tokens-table'
|
|
419
|
+
>
|
|
420
|
+
<TableEmptyState>
|
|
421
|
+
<EmptyState type='collection-empty' data-testid='api-tokens-no-results'>
|
|
422
|
+
<EmptyStateIllustration>
|
|
423
|
+
<SearchX />
|
|
424
|
+
</EmptyStateIllustration>
|
|
425
|
+
<EmptyStateMessage>
|
|
426
|
+
<EmptyStateTitle>No results found</EmptyStateTitle>
|
|
427
|
+
<EmptyStateDescription>
|
|
428
|
+
No tokens match your search or status.
|
|
429
|
+
</EmptyStateDescription>
|
|
430
|
+
</EmptyStateMessage>
|
|
431
|
+
<EmptyStateActions>
|
|
432
|
+
<Button
|
|
433
|
+
size='medium'
|
|
434
|
+
variant='outline'
|
|
435
|
+
color='neutral'
|
|
436
|
+
onClick={handleReset}
|
|
437
|
+
data-testid='api-tokens-reset'
|
|
438
|
+
>
|
|
439
|
+
<FilterX />
|
|
440
|
+
Reset filters
|
|
441
|
+
</Button>
|
|
442
|
+
</EmptyStateActions>
|
|
443
|
+
</EmptyState>
|
|
444
|
+
</TableEmptyState>
|
|
445
|
+
</Table>
|
|
446
|
+
</PageContent>
|
|
447
|
+
</Page>
|
|
448
|
+
);
|
|
449
|
+
};
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
The list failed to load: `EmptyState` with "Try again" in place of the rows.
|
|
453
|
+
|
|
454
|
+
The list failed to load: header, toolbar and column headers stay, and the Patterns/Error states
|
|
455
|
+
`EmptyState` with "Try again" takes the place of the rows. Retrying shows skeleton rows, then
|
|
456
|
+
the data.
|
|
457
|
+
|
|
458
|
+
```tsx story=LoadError
|
|
459
|
+
import { useState } from 'react';
|
|
460
|
+
import { Button } from '@wallarm-org/design-system/Button';
|
|
461
|
+
import { EmptyState, EmptyStateActions, EmptyStateDescription, EmptyStateIllustration, EmptyStateMessage, EmptyStateTitle } from '@wallarm-org/design-system/EmptyState';
|
|
462
|
+
import { CloudOff, RefreshCcw } from '@wallarm-org/design-system/icons';
|
|
463
|
+
import { NumericBadge } from '@wallarm-org/design-system/NumericBadge';
|
|
464
|
+
import { Page, PageActions, PageContent, PageDescription, PageHeader, PageHeaderGroup, PageTitle, PageToolbar } from '@wallarm-org/design-system/Page';
|
|
465
|
+
import { SearchInput } from '@wallarm-org/design-system/SearchInput';
|
|
466
|
+
import { SegmentedTabs, SegmentedTabsList, SegmentedTabsTrigger } from '@wallarm-org/design-system/SegmentedTabs';
|
|
467
|
+
import { Table, TableEmptyState } from '@wallarm-org/design-system/Table';
|
|
468
|
+
|
|
469
|
+
export const LoadError = () => {
|
|
470
|
+
const [query, setQuery] = useState('');
|
|
471
|
+
const [status, setStatus] = useState('all');
|
|
472
|
+
const [load, setLoad] = useState<'error' | 'loading' | 'ready'>('error');
|
|
473
|
+
|
|
474
|
+
const matching = TOKENS.filter(token => matchesSearch(token, query));
|
|
475
|
+
const counts = countByStatus(matching);
|
|
476
|
+
const isReady = load === 'ready';
|
|
477
|
+
const rows = status === 'all' ? matching : matching.filter(token => token.status === status);
|
|
478
|
+
|
|
479
|
+
const handleRetry = () => {
|
|
480
|
+
onRetry();
|
|
481
|
+
setLoad('loading');
|
|
482
|
+
setTimeout(() => setLoad('ready'), 800);
|
|
483
|
+
};
|
|
484
|
+
|
|
485
|
+
return (
|
|
486
|
+
<Page name='settings-api-tokens' fullSize fixedHeight data-testid='api-tokens-page'>
|
|
487
|
+
<PageHeader>
|
|
488
|
+
<PageHeaderGroup className='flex-1'>
|
|
489
|
+
<PageTitle>API tokens</PageTitle>
|
|
490
|
+
<PageDescription>
|
|
491
|
+
Tokens let scripts, CI pipelines and integrations call the Wallarm API on behalf of your
|
|
492
|
+
organization.
|
|
493
|
+
</PageDescription>
|
|
494
|
+
</PageHeaderGroup>
|
|
495
|
+
<PageActions>
|
|
496
|
+
<Button size='medium' onClick={onCreateToken} data-testid='api-tokens-create'>
|
|
497
|
+
Create token
|
|
498
|
+
</Button>
|
|
499
|
+
</PageActions>
|
|
500
|
+
</PageHeader>
|
|
501
|
+
|
|
502
|
+
<PageToolbar>
|
|
503
|
+
<SearchInput
|
|
504
|
+
value={query}
|
|
505
|
+
onChange={setQuery}
|
|
506
|
+
placeholder='Search name or prefix'
|
|
507
|
+
className='w-[320px]'
|
|
508
|
+
data-testid='api-tokens-search'
|
|
509
|
+
/>
|
|
510
|
+
<SegmentedTabs value={status} onChange={setStatus} data-testid='api-tokens-status-tabs'>
|
|
511
|
+
<SegmentedTabsList>
|
|
512
|
+
<SegmentedTabsTrigger value='all'>
|
|
513
|
+
All {isReady && <NumericBadge>{counts.all}</NumericBadge>}
|
|
514
|
+
</SegmentedTabsTrigger>
|
|
515
|
+
<SegmentedTabsTrigger value='active'>
|
|
516
|
+
Active {isReady && <NumericBadge>{counts.active}</NumericBadge>}
|
|
517
|
+
</SegmentedTabsTrigger>
|
|
518
|
+
<SegmentedTabsTrigger value='expiring'>
|
|
519
|
+
Expiring soon {isReady && <NumericBadge>{counts.expiring}</NumericBadge>}
|
|
520
|
+
</SegmentedTabsTrigger>
|
|
521
|
+
<SegmentedTabsTrigger value='expired'>
|
|
522
|
+
Expired {isReady && <NumericBadge>{counts.expired}</NumericBadge>}
|
|
523
|
+
</SegmentedTabsTrigger>
|
|
524
|
+
</SegmentedTabsList>
|
|
525
|
+
</SegmentedTabs>
|
|
526
|
+
</PageToolbar>
|
|
527
|
+
|
|
528
|
+
<PageContent>
|
|
529
|
+
<Table
|
|
530
|
+
aria-label='API tokens'
|
|
531
|
+
data={isReady ? rows : []}
|
|
532
|
+
columns={COLUMNS}
|
|
533
|
+
getRowId={getTokenId}
|
|
534
|
+
isLoading={load === 'loading'}
|
|
535
|
+
data-testid='api-tokens-table'
|
|
536
|
+
>
|
|
537
|
+
{load === 'error' && (
|
|
538
|
+
<TableEmptyState>
|
|
539
|
+
<EmptyState data-testid='api-tokens-error'>
|
|
540
|
+
<EmptyStateIllustration>
|
|
541
|
+
<CloudOff />
|
|
542
|
+
</EmptyStateIllustration>
|
|
543
|
+
<EmptyStateMessage>
|
|
544
|
+
<EmptyStateTitle>Couldn't load API tokens</EmptyStateTitle>
|
|
545
|
+
<EmptyStateDescription>
|
|
546
|
+
The server didn't respond in time. Your tokens keep working; try again in a
|
|
547
|
+
moment.
|
|
548
|
+
</EmptyStateDescription>
|
|
549
|
+
</EmptyStateMessage>
|
|
550
|
+
<EmptyStateActions>
|
|
551
|
+
<Button
|
|
552
|
+
size='medium'
|
|
553
|
+
variant='outline'
|
|
554
|
+
color='neutral'
|
|
555
|
+
onClick={handleRetry}
|
|
556
|
+
data-testid='api-tokens-retry'
|
|
557
|
+
>
|
|
558
|
+
<RefreshCcw />
|
|
559
|
+
Try again
|
|
560
|
+
</Button>
|
|
561
|
+
</EmptyStateActions>
|
|
562
|
+
</EmptyState>
|
|
563
|
+
</TableEmptyState>
|
|
564
|
+
)}
|
|
565
|
+
</Table>
|
|
566
|
+
</PageContent>
|
|
567
|
+
</Page>
|
|
568
|
+
);
|
|
569
|
+
};
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
Read-only access: the list stays, every write action goes.
|
|
573
|
+
|
|
574
|
+
Read-only access: the list stays fully visible, the create action is disabled with a tooltip
|
|
575
|
+
that names who can create tokens, the row menu is gone, and an info `Alert` explains
|
|
576
|
+
the state for as long as it holds.
|
|
577
|
+
|
|
578
|
+
```tsx story=NoPermission
|
|
579
|
+
import { useState } from 'react';
|
|
580
|
+
import { Alert, AlertContent, AlertDescription, AlertIcon, AlertTitle } from '@wallarm-org/design-system/Alert';
|
|
581
|
+
import { Button } from '@wallarm-org/design-system/Button';
|
|
582
|
+
import { NumericBadge } from '@wallarm-org/design-system/NumericBadge';
|
|
583
|
+
import { Page, PageActions, PageContent, PageDescription, PageHeader, PageHeaderGroup, PageTitle, PageToolbar } from '@wallarm-org/design-system/Page';
|
|
584
|
+
import { SearchInput } from '@wallarm-org/design-system/SearchInput';
|
|
585
|
+
import { SegmentedTabs, SegmentedTabsList, SegmentedTabsTrigger } from '@wallarm-org/design-system/SegmentedTabs';
|
|
586
|
+
import { VStack } from '@wallarm-org/design-system/Stack';
|
|
587
|
+
import { Table } from '@wallarm-org/design-system/Table';
|
|
588
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from '@wallarm-org/design-system/Tooltip';
|
|
589
|
+
|
|
590
|
+
export const NoPermission = () => {
|
|
591
|
+
const [query, setQuery] = useState('');
|
|
592
|
+
const [status, setStatus] = useState('all');
|
|
593
|
+
|
|
594
|
+
const matching = TOKENS.filter(token => matchesSearch(token, query));
|
|
595
|
+
const counts = countByStatus(matching);
|
|
596
|
+
const rows = status === 'all' ? matching : matching.filter(token => token.status === status);
|
|
597
|
+
|
|
598
|
+
return (
|
|
599
|
+
<Page name='settings-api-tokens' fullSize fixedHeight data-testid='api-tokens-page'>
|
|
600
|
+
<PageHeader>
|
|
601
|
+
<PageHeaderGroup className='flex-1'>
|
|
602
|
+
<PageTitle>API tokens</PageTitle>
|
|
603
|
+
<PageDescription>
|
|
604
|
+
Tokens let scripts, CI pipelines and integrations call the Wallarm API on behalf of your
|
|
605
|
+
organization.
|
|
606
|
+
</PageDescription>
|
|
607
|
+
</PageHeaderGroup>
|
|
608
|
+
<PageActions>
|
|
609
|
+
<Tooltip>
|
|
610
|
+
<TooltipTrigger asChild>
|
|
611
|
+
<span>
|
|
612
|
+
<Button size='medium' disabled data-testid='api-tokens-create'>
|
|
613
|
+
Create token
|
|
614
|
+
</Button>
|
|
615
|
+
</span>
|
|
616
|
+
</TooltipTrigger>
|
|
617
|
+
<TooltipContent>Only administrators can create tokens.</TooltipContent>
|
|
618
|
+
</Tooltip>
|
|
619
|
+
</PageActions>
|
|
620
|
+
</PageHeader>
|
|
621
|
+
|
|
622
|
+
<PageToolbar>
|
|
623
|
+
<SearchInput
|
|
624
|
+
value={query}
|
|
625
|
+
onChange={setQuery}
|
|
626
|
+
placeholder='Search name or prefix'
|
|
627
|
+
className='w-[320px]'
|
|
628
|
+
data-testid='api-tokens-search'
|
|
629
|
+
/>
|
|
630
|
+
<SegmentedTabs value={status} onChange={setStatus} data-testid='api-tokens-status-tabs'>
|
|
631
|
+
<SegmentedTabsList>
|
|
632
|
+
<SegmentedTabsTrigger value='all'>
|
|
633
|
+
All <NumericBadge>{counts.all}</NumericBadge>
|
|
634
|
+
</SegmentedTabsTrigger>
|
|
635
|
+
<SegmentedTabsTrigger value='active'>
|
|
636
|
+
Active <NumericBadge>{counts.active}</NumericBadge>
|
|
637
|
+
</SegmentedTabsTrigger>
|
|
638
|
+
<SegmentedTabsTrigger value='expiring'>
|
|
639
|
+
Expiring soon <NumericBadge>{counts.expiring}</NumericBadge>
|
|
640
|
+
</SegmentedTabsTrigger>
|
|
641
|
+
<SegmentedTabsTrigger value='expired'>
|
|
642
|
+
Expired <NumericBadge>{counts.expired}</NumericBadge>
|
|
643
|
+
</SegmentedTabsTrigger>
|
|
644
|
+
</SegmentedTabsList>
|
|
645
|
+
</SegmentedTabs>
|
|
646
|
+
</PageToolbar>
|
|
647
|
+
|
|
648
|
+
<PageContent>
|
|
649
|
+
<VStack gap={12} align='stretch'>
|
|
650
|
+
<Alert color='info' data-testid='api-tokens-read-only'>
|
|
651
|
+
<AlertIcon />
|
|
652
|
+
<AlertContent>
|
|
653
|
+
<AlertTitle>You have read-only access</AlertTitle>
|
|
654
|
+
<AlertDescription>
|
|
655
|
+
Ask an administrator to create, rotate or revoke tokens for you.
|
|
656
|
+
</AlertDescription>
|
|
657
|
+
</AlertContent>
|
|
658
|
+
</Alert>
|
|
659
|
+
<Table
|
|
660
|
+
aria-label='API tokens'
|
|
661
|
+
data={rows}
|
|
662
|
+
columns={READ_COLUMNS}
|
|
663
|
+
getRowId={getTokenId}
|
|
664
|
+
data-testid='api-tokens-table'
|
|
665
|
+
/>
|
|
666
|
+
</VStack>
|
|
667
|
+
</PageContent>
|
|
668
|
+
</Page>
|
|
669
|
+
);
|
|
670
|
+
};
|
|
671
|
+
```
|
|
672
|
+
|
|
673
|
+
Usage data failed for some rows: a warning, an em dash in the affected cells.
|
|
674
|
+
|
|
675
|
+
Partial failure: the tokens loaded but their usage data did not. A warning `Alert` says what is
|
|
676
|
+
missing and offers "Retry"; the affected cells show the em dash instead of hiding rows.
|
|
677
|
+
|
|
678
|
+
```tsx story=PartialFailure
|
|
679
|
+
import { useState } from 'react';
|
|
680
|
+
import { Alert, AlertContent, AlertControls, AlertDescription, AlertIcon, AlertTitle } from '@wallarm-org/design-system/Alert';
|
|
681
|
+
import { Button } from '@wallarm-org/design-system/Button';
|
|
682
|
+
import { RefreshCcw } from '@wallarm-org/design-system/icons';
|
|
683
|
+
import { NumericBadge } from '@wallarm-org/design-system/NumericBadge';
|
|
684
|
+
import { Page, PageActions, PageContent, PageDescription, PageHeader, PageHeaderGroup, PageTitle, PageToolbar } from '@wallarm-org/design-system/Page';
|
|
685
|
+
import { SearchInput } from '@wallarm-org/design-system/SearchInput';
|
|
686
|
+
import { SegmentedTabs, SegmentedTabsList, SegmentedTabsTrigger } from '@wallarm-org/design-system/SegmentedTabs';
|
|
687
|
+
import { VStack } from '@wallarm-org/design-system/Stack';
|
|
688
|
+
import { Table } from '@wallarm-org/design-system/Table';
|
|
689
|
+
|
|
690
|
+
export const PartialFailure = () => {
|
|
691
|
+
const [query, setQuery] = useState('');
|
|
692
|
+
const [status, setStatus] = useState('all');
|
|
693
|
+
const [usageLoaded, setUsageLoaded] = useState(false);
|
|
694
|
+
|
|
695
|
+
const tokens = usageLoaded
|
|
696
|
+
? TOKENS
|
|
697
|
+
: TOKENS.map(token =>
|
|
698
|
+
USAGE_UNAVAILABLE.includes(token.id)
|
|
699
|
+
? { ...token, lastUsedAt: null, lastUsedIp: null, lastUsedCountry: null }
|
|
700
|
+
: token,
|
|
701
|
+
);
|
|
702
|
+
const matching = tokens.filter(token => matchesSearch(token, query));
|
|
703
|
+
const counts = countByStatus(matching);
|
|
704
|
+
const rows = status === 'all' ? matching : matching.filter(token => token.status === status);
|
|
705
|
+
|
|
706
|
+
const handleRetry = () => {
|
|
707
|
+
onRetry();
|
|
708
|
+
setUsageLoaded(true);
|
|
709
|
+
};
|
|
710
|
+
|
|
711
|
+
return (
|
|
712
|
+
<Page name='settings-api-tokens' fullSize fixedHeight data-testid='api-tokens-page'>
|
|
713
|
+
<PageHeader>
|
|
714
|
+
<PageHeaderGroup className='flex-1'>
|
|
715
|
+
<PageTitle>API tokens</PageTitle>
|
|
716
|
+
<PageDescription>
|
|
717
|
+
Tokens let scripts, CI pipelines and integrations call the Wallarm API on behalf of your
|
|
718
|
+
organization.
|
|
719
|
+
</PageDescription>
|
|
720
|
+
</PageHeaderGroup>
|
|
721
|
+
<PageActions>
|
|
722
|
+
<Button size='medium' onClick={onCreateToken} data-testid='api-tokens-create'>
|
|
723
|
+
Create token
|
|
724
|
+
</Button>
|
|
725
|
+
</PageActions>
|
|
726
|
+
</PageHeader>
|
|
727
|
+
|
|
728
|
+
<PageToolbar>
|
|
729
|
+
<SearchInput
|
|
730
|
+
value={query}
|
|
731
|
+
onChange={setQuery}
|
|
732
|
+
placeholder='Search name or prefix'
|
|
733
|
+
className='w-[320px]'
|
|
734
|
+
data-testid='api-tokens-search'
|
|
735
|
+
/>
|
|
736
|
+
<SegmentedTabs value={status} onChange={setStatus} data-testid='api-tokens-status-tabs'>
|
|
737
|
+
<SegmentedTabsList>
|
|
738
|
+
<SegmentedTabsTrigger value='all'>
|
|
739
|
+
All <NumericBadge>{counts.all}</NumericBadge>
|
|
740
|
+
</SegmentedTabsTrigger>
|
|
741
|
+
<SegmentedTabsTrigger value='active'>
|
|
742
|
+
Active <NumericBadge>{counts.active}</NumericBadge>
|
|
743
|
+
</SegmentedTabsTrigger>
|
|
744
|
+
<SegmentedTabsTrigger value='expiring'>
|
|
745
|
+
Expiring soon <NumericBadge>{counts.expiring}</NumericBadge>
|
|
746
|
+
</SegmentedTabsTrigger>
|
|
747
|
+
<SegmentedTabsTrigger value='expired'>
|
|
748
|
+
Expired <NumericBadge>{counts.expired}</NumericBadge>
|
|
749
|
+
</SegmentedTabsTrigger>
|
|
750
|
+
</SegmentedTabsList>
|
|
751
|
+
</SegmentedTabs>
|
|
752
|
+
</PageToolbar>
|
|
753
|
+
|
|
754
|
+
<PageContent>
|
|
755
|
+
<VStack gap={12} align='stretch'>
|
|
756
|
+
{!usageLoaded && (
|
|
757
|
+
<Alert color='warning' data-testid='api-tokens-partial-failure'>
|
|
758
|
+
<AlertIcon />
|
|
759
|
+
<AlertContent>
|
|
760
|
+
<AlertTitle>Usage data is missing for 3 tokens</AlertTitle>
|
|
761
|
+
<AlertDescription>
|
|
762
|
+
The usage service didn't respond. Tokens and their scopes are up to date.
|
|
763
|
+
</AlertDescription>
|
|
764
|
+
</AlertContent>
|
|
765
|
+
<AlertControls>
|
|
766
|
+
<Button
|
|
767
|
+
variant='secondary'
|
|
768
|
+
color='neutral'
|
|
769
|
+
size='small'
|
|
770
|
+
onClick={handleRetry}
|
|
771
|
+
data-testid='api-tokens-retry'
|
|
772
|
+
>
|
|
773
|
+
<RefreshCcw />
|
|
774
|
+
Retry
|
|
775
|
+
</Button>
|
|
776
|
+
</AlertControls>
|
|
777
|
+
</Alert>
|
|
778
|
+
)}
|
|
779
|
+
<Table
|
|
780
|
+
aria-label='API tokens'
|
|
781
|
+
data={rows}
|
|
782
|
+
columns={COLUMNS}
|
|
783
|
+
getRowId={getTokenId}
|
|
784
|
+
data-testid='api-tokens-table'
|
|
785
|
+
/>
|
|
786
|
+
</VStack>
|
|
787
|
+
</PageContent>
|
|
788
|
+
</Page>
|
|
789
|
+
);
|
|
790
|
+
};
|
|
791
|
+
```
|
|
792
|
+
|
|
793
|
+
## Related
|
|
794
|
+
|
|
795
|
+
- [Resource list page](../patterns/resource-list-page.md)
|
|
796
|
+
- [Empty states](../patterns/empty-states.md)
|
|
797
|
+
- [Entity table](../patterns/entity-table.md)
|
|
798
|
+
- [Feedback toasts](../patterns/feedback-toasts.md)
|