@wallarm-org/design-system 4.9.0 → 4.10.0

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.
Files changed (28) hide show
  1. package/README.md +1 -1
  2. package/dist/components/Badge/generateBadgeVariants.js +9 -28
  3. package/dist/components/CodeSnippet/internal/FoldToggle.js +1 -1
  4. package/dist/components/SimpleCharts/Chart/classes.js +1 -1
  5. package/dist/components/SimpleCharts/HorizontalBarStack/classes.js +1 -1
  6. package/dist/components/SimpleCharts/Metric/classes.d.ts +2 -2
  7. package/dist/components/SimpleCharts/Metric/classes.js +2 -2
  8. package/dist/components/Table/TableBody/TableBodyCell.js +4 -1
  9. package/dist/guidelines/patterns/complex-drawer.md +1084 -0
  10. package/dist/guidelines/patterns/confirmation-dialogs.md +3 -11
  11. package/dist/guidelines/patterns/detail-drawer.md +31 -13
  12. package/dist/guidelines/patterns/empty-states.md +6 -5
  13. package/dist/guidelines/patterns/entity-table.md +25 -29
  14. package/dist/guidelines/patterns/feedback-toasts.md +3 -11
  15. package/dist/guidelines/patterns/resource-list-page.md +14 -16
  16. package/dist/guidelines/rules.md +6 -5
  17. package/dist/guidelines/templates/ai-assistant.md +1133 -0
  18. package/dist/guidelines/templates/api-inventory.md +905 -0
  19. package/dist/guidelines/templates/attack-events.md +2722 -0
  20. package/dist/guidelines/templates/incident-detail.md +2085 -0
  21. package/dist/guidelines/templates/integrations-settings.md +836 -0
  22. package/dist/guidelines/templates/page-states.md +798 -0
  23. package/dist/guidelines/templates/rule-editor.md +886 -0
  24. package/dist/guidelines/templates/security-dashboard.md +681 -0
  25. package/dist/metadata/components.json +10 -10
  26. package/dist/metadata/guidelines.json +1204 -37
  27. package/dist/theme/tokens.test.ts +52 -0
  28. package/package.json +1 -1
@@ -0,0 +1,905 @@
1
+ ---
2
+ title: API inventory
3
+ description: Use when building an API discovery screen with a host and endpoint tree beside an inspector showing risk, sensitive data, traffic and parameters.
4
+ components: [Page, PageHeader, PageHeaderGroup, PageTitle, PageDescription, PageActions, PageToolbar, PageContent, Button, SearchInput, SegmentedTabs, SegmentedTabsList, SegmentedTabsTrigger, NumericBadge, ResizablePanelGroup, ResizablePanel, ResizableHandle, ScrollArea, ScrollAreaViewport, ScrollAreaContent, ScrollAreaScrollbar, TreeView, TreeViewItem, HttpMethod, ParameterPath, ResponseCode, Badge, Tag, Attribute, AttributeLabel, AttributeValue, Heading, Text, HStack, VStack, Separator, Tabs, TabsList, TabsTrigger, TabsContent, Table, DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuItemText, DropdownMenuSeparator, Tooltip, TooltipTrigger, TooltipContent, FormatNumber, FormatDateTime, Skeleton, EmptyState, EmptyStateIllustration, EmptyStateMessage, EmptyStateTitle, EmptyStateDescription, EmptyStateActions]
5
+ keywords: [api inventory, api discovery, endpoints, hosts, tree, split view, master detail, inspector, resizable, risk score, sensitive data, pii, parameters, http method, parameter path, status codes, attack surface]
6
+ order: 30
7
+ ---
8
+
9
+ # API inventory
10
+
11
+ An API discovery screen: every host and endpoint found in traffic sits in a tree on the left, and the selected endpoint opens in an inspector on the right. It is a master-detail layout inside one `Page`, split by `ResizablePanelGroup` instead of a drawer, because the reader moves through many endpoints in a row.
12
+
13
+ ## What it shows
14
+
15
+ - The [Resource list page](../patterns/resource-list-page.md) frame, with the split in place of the `Table` in `PageContent`.
16
+ - A resizable split: a bordered `rounded-12` frame with no padding of its own, each panel scrolling on its own `ScrollArea`.
17
+ - `TreeView` as the master list: hosts are branches with a `NumericBadge`, endpoints are selectable rows with `HttpMethod`, the path and a risk score trailing on the right.
18
+ - The inspector is the [Detail drawer](../patterns/detail-drawer.md) composition in a panel instead of a `Drawer`. Nothing selected is the [Complex drawer](../patterns/complex-drawer.md) detail pane: centred secondary text.
19
+ - Domain primitives: `ParameterPath` for where a parameter lives, `ResponseCode` for status codes, `Badge` colors for risk and sensitive data, `FormatNumber` and `FormatDateTime` for traffic and timestamps.
20
+ - No results and a failed load in the tree follow [Empty states](../patterns/empty-states.md).
21
+
22
+ ## Examples
23
+
24
+ An endpoint open in the inspector; search, tabs and host rows all work.
25
+
26
+ The whole screen with an endpoint open. Search and the status tabs filter the tree; hosts
27
+ expand and collapse; selecting an endpoint fills the inspector with its risk, sensitive data,
28
+ traffic and a parameters table built from `ParameterPath`. Drag the handle to resize.
29
+
30
+ ```tsx story=Default
31
+ import { useState } from 'react';
32
+ import { Attribute, AttributeLabel, AttributeValue } from '@wallarm-org/design-system/Attribute';
33
+ import { Badge } from '@wallarm-org/design-system/Badge';
34
+ import { Button } from '@wallarm-org/design-system/Button';
35
+ import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuItemText, DropdownMenuSeparator, DropdownMenuTrigger } from '@wallarm-org/design-system/DropdownMenu';
36
+ import { EmptyState, EmptyStateActions, EmptyStateDescription, EmptyStateIllustration, EmptyStateMessage, EmptyStateTitle } from '@wallarm-org/design-system/EmptyState';
37
+ import { FormatDateTime } from '@wallarm-org/design-system/FormatDateTime';
38
+ import { FormatNumber } from '@wallarm-org/design-system/FormatNumber';
39
+ import { Heading } from '@wallarm-org/design-system/Heading';
40
+ import { HttpMethod } from '@wallarm-org/design-system/HttpMethod';
41
+ import { ChevronDown, ChevronsDownUp, ChevronsUpDown, Download, FilterX, Globe, SearchX } from '@wallarm-org/design-system/icons';
42
+ import { NumericBadge } from '@wallarm-org/design-system/NumericBadge';
43
+ import { Page, PageActions, PageContent, PageDescription, PageHeader, PageHeaderGroup, PageTitle, PageToolbar } from '@wallarm-org/design-system/Page';
44
+ import { ParameterPath } from '@wallarm-org/design-system/ParameterPath';
45
+ import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from '@wallarm-org/design-system/Resizable';
46
+ import { ResponseCode } from '@wallarm-org/design-system/ResponseCode';
47
+ import { ScrollArea, ScrollAreaContent, ScrollAreaScrollbar, ScrollAreaViewport } from '@wallarm-org/design-system/ScrollArea';
48
+ import { SearchInput } from '@wallarm-org/design-system/SearchInput';
49
+ import { SegmentedTabs, SegmentedTabsList, SegmentedTabsTrigger } from '@wallarm-org/design-system/SegmentedTabs';
50
+ import { Separator } from '@wallarm-org/design-system/Separator';
51
+ import { HStack, VStack } from '@wallarm-org/design-system/Stack';
52
+ import { type TableCellContext, type TableColumnDef, Table } from '@wallarm-org/design-system/Table';
53
+ import { Tabs, TabsContent, TabsList, TabsTrigger } from '@wallarm-org/design-system/Tabs';
54
+ import { Tag } from '@wallarm-org/design-system/Tag';
55
+ import { Text } from '@wallarm-org/design-system/Text';
56
+ import { Tooltip, TooltipContent, TooltipTrigger } from '@wallarm-org/design-system/Tooltip';
57
+ import { TreeView, TreeViewItem } from '@wallarm-org/design-system/TreeView';
58
+
59
+ export const Default = () => {
60
+ const [query, setQuery] = useState('');
61
+ const [status, setStatus] = useState('all');
62
+ const [openIds, setOpenIds] = useState<string[]>(HOST_IDS);
63
+ const [selectedId, setSelectedId] = useState<string | null>('pay-cards-post');
64
+ const [tab, setTab] = useState('parameters');
65
+
66
+ const search = query.trim().toLowerCase();
67
+ const matchesSearch = (host: ApiHost, endpoint: Endpoint) =>
68
+ host.host.includes(search) || endpoint.path.toLowerCase().includes(search);
69
+ const searched = HOSTS.map(host => ({
70
+ ...host,
71
+ endpoints: host.endpoints.filter(endpoint => matchesSearch(host, endpoint)),
72
+ }));
73
+ const counts = {
74
+ all: searched.flatMap(host => host.endpoints).length,
75
+ sensitive: searched.flatMap(host => host.endpoints).filter(e => e.sensitive.length > 0).length,
76
+ new: searched.flatMap(host => host.endpoints).filter(e => e.isNew).length,
77
+ };
78
+ const visibleHosts = searched
79
+ .map(host => ({
80
+ ...host,
81
+ endpoints: host.endpoints.filter(
82
+ endpoint =>
83
+ status === 'all' ||
84
+ (status === 'sensitive' && endpoint.sensitive.length > 0) ||
85
+ (status === 'new' && endpoint.isNew),
86
+ ),
87
+ }))
88
+ .filter(host => host.endpoints.length > 0);
89
+
90
+ const visibleEndpointCount = visibleHosts.flatMap(host => host.endpoints).length;
91
+
92
+ const endpoint = ALL_ENDPOINTS.find(item => item.id === selectedId) ?? null;
93
+ const risk = endpoint ? getRisk(endpoint.risk) : null;
94
+
95
+ const toggleHost = (id: string) =>
96
+ setOpenIds(prev => (prev.includes(id) ? prev.filter(v => v !== id) : [...prev, id]));
97
+ // Hosts are branches: a click on a host row toggles it instead of selecting it.
98
+ const handleSelectionChange = (ids: string[]) => {
99
+ const [id] = ids;
100
+ if (id && HOST_IDS.includes(id)) {
101
+ toggleHost(id);
102
+ return;
103
+ }
104
+ setSelectedId(id ?? null);
105
+ setTab('parameters');
106
+ };
107
+ const handleHostOpenChange = (id: string) => () => toggleHost(id);
108
+ const handleExpandAll = () => setOpenIds(HOST_IDS);
109
+ const handleCollapseAll = () => setOpenIds([]);
110
+ // A new search reopens every host so matches are never hidden in a collapsed branch.
111
+ const handleSearchChange = (value: string) => {
112
+ setQuery(value);
113
+ setOpenIds(HOST_IDS);
114
+ };
115
+ const handleReset = () => {
116
+ setQuery('');
117
+ setStatus('all');
118
+ };
119
+ const handleViewRequests = () => onViewRequests(endpoint);
120
+ const handleMarkReviewed = () => onMarkReviewed(endpoint);
121
+ const handleAddToPolicy = () => onAddToPolicy(endpoint);
122
+ const handleHide = () => onHideEndpoint(endpoint);
123
+
124
+ const renderParameter = ({ row }: TableCellContext<Parameter, unknown>) => (
125
+ <ParameterPath segments={row.original.segments} />
126
+ );
127
+ const renderRequired = ({ row }: TableCellContext<Parameter, unknown>) =>
128
+ row.original.required ? 'Required' : 'Optional';
129
+ const renderSensitive = ({ row }: TableCellContext<Parameter, unknown>) =>
130
+ row.original.sensitive ? (
131
+ <Badge type='secondary' color={SENSITIVE_COLOR[row.original.sensitive]}>
132
+ {row.original.sensitive}
133
+ </Badge>
134
+ ) : (
135
+ '—'
136
+ );
137
+ const renderCode = ({ row }: TableCellContext<EndpointResponse, unknown>) => (
138
+ <ResponseCode code={row.original.code} />
139
+ );
140
+ const renderShare = ({ row }: TableCellContext<EndpointResponse, unknown>) => (
141
+ <FormatNumber value={row.original.share} type='percent' />
142
+ );
143
+
144
+ const parameterColumns: TableColumnDef<Parameter>[] = [
145
+ { id: 'parameter', header: 'Parameter', size: 300, cell: renderParameter },
146
+ { accessorKey: 'type', header: 'Type', size: 120 },
147
+ { id: 'required', header: 'Presence', size: 120, cell: renderRequired },
148
+ { id: 'sensitive', header: 'Sensitive data', size: 160, cell: renderSensitive },
149
+ ];
150
+ const responseColumns: TableColumnDef<EndpointResponse>[] = [
151
+ { id: 'code', header: 'Status', size: 160, cell: renderCode },
152
+ { id: 'share', header: 'Share of responses', size: 200, cell: renderShare },
153
+ ];
154
+
155
+ return (
156
+ <Page name='api-inventory' fullSize fixedHeight data-testid='api-inventory-page'>
157
+ <PageHeader>
158
+ <PageHeaderGroup className='flex-1'>
159
+ <PageTitle>API inventory</PageTitle>
160
+ <PageDescription>
161
+ Hosts and endpoints discovered from live traffic, with the parameters and sensitive data
162
+ each one carries.
163
+ </PageDescription>
164
+ </PageHeaderGroup>
165
+ <PageActions>
166
+ <Button variant='secondary' color='neutral' size='medium' onClick={onExport}>
167
+ <Download />
168
+ Export
169
+ </Button>
170
+ <Button size='medium' onClick={onUploadSpec} data-testid='api-inventory-upload'>
171
+ Upload specification
172
+ </Button>
173
+ </PageActions>
174
+ </PageHeader>
175
+
176
+ <PageToolbar>
177
+ <SearchInput
178
+ value={query}
179
+ onChange={handleSearchChange}
180
+ placeholder='Search host or path'
181
+ className='w-[320px]'
182
+ data-testid='api-inventory-search'
183
+ />
184
+ <SegmentedTabs value={status} onChange={setStatus} data-testid='api-inventory-status'>
185
+ <SegmentedTabsList>
186
+ <SegmentedTabsTrigger value='all'>
187
+ All <NumericBadge>{counts.all}</NumericBadge>
188
+ </SegmentedTabsTrigger>
189
+ <SegmentedTabsTrigger value='sensitive'>
190
+ Sensitive data <NumericBadge>{counts.sensitive}</NumericBadge>
191
+ </SegmentedTabsTrigger>
192
+ <SegmentedTabsTrigger value='new'>
193
+ New <NumericBadge>{counts.new}</NumericBadge>
194
+ </SegmentedTabsTrigger>
195
+ </SegmentedTabsList>
196
+ </SegmentedTabs>
197
+ </PageToolbar>
198
+
199
+ <PageContent>
200
+ <div className='h-full overflow-hidden rounded-12 border border-border-primary'>
201
+ <ResizablePanelGroup data-testid='api-inventory-split'>
202
+ <ResizablePanel id='tree' defaultSize='32%' minSize='22%' maxSize='50%'>
203
+ <div className='flex h-full flex-col'>
204
+ <HStack justify='between' align='center' className='h-40 shrink-0 px-12'>
205
+ <Text size='xs' weight='medium' color='secondary'>
206
+ {pluralize(visibleHosts.length, 'host')} ·{' '}
207
+ {pluralize(visibleEndpointCount, 'endpoint')}
208
+ </Text>
209
+ <HStack gap={2}>
210
+ <Tooltip>
211
+ <TooltipTrigger asChild>
212
+ <Button
213
+ variant='ghost'
214
+ color='neutral'
215
+ size='small'
216
+ aria-label='Expand all hosts'
217
+ onClick={handleExpandAll}
218
+ >
219
+ <ChevronsUpDown />
220
+ </Button>
221
+ </TooltipTrigger>
222
+ <TooltipContent>Expand all</TooltipContent>
223
+ </Tooltip>
224
+ <Tooltip>
225
+ <TooltipTrigger asChild>
226
+ <Button
227
+ variant='ghost'
228
+ color='neutral'
229
+ size='small'
230
+ aria-label='Collapse all hosts'
231
+ onClick={handleCollapseAll}
232
+ >
233
+ <ChevronsDownUp />
234
+ </Button>
235
+ </TooltipTrigger>
236
+ <TooltipContent>Collapse all</TooltipContent>
237
+ </Tooltip>
238
+ </HStack>
239
+ </HStack>
240
+ <Separator />
241
+ <ScrollArea className='min-h-0 flex-1'>
242
+ <ScrollAreaViewport>
243
+ <ScrollAreaContent className='min-w-0! py-4'>
244
+ {visibleHosts.length > 0 ? (
245
+ <TreeView
246
+ selectable
247
+ selectedIds={selectedId ? [selectedId] : []}
248
+ onSelectionChange={handleSelectionChange}
249
+ aria-label='Hosts and endpoints'
250
+ data-testid='api-inventory-tree'
251
+ >
252
+ {visibleHosts.map(host => (
253
+ <TreeViewItem
254
+ key={host.id}
255
+ id={host.id}
256
+ open={openIds.includes(host.id)}
257
+ onOpenChange={handleHostOpenChange(host.id)}
258
+ data-testid={`api-inventory-host-${host.id}`}
259
+ >
260
+ <Globe />
261
+ {host.host}
262
+ <NumericBadge>{host.endpoints.length}</NumericBadge>
263
+ {host.endpoints.map(item => (
264
+ <TreeViewItem
265
+ key={item.id}
266
+ id={item.id}
267
+ data-testid={`api-inventory-endpoint-${item.id}`}
268
+ >
269
+ <span className='flex w-64 shrink-0'>
270
+ <HttpMethod method={item.method} size='small' />
271
+ </span>
272
+ {item.path}
273
+ <Badge
274
+ variant='dotted'
275
+ type='text-color'
276
+ size='small'
277
+ color={getRisk(item.risk).color}
278
+ >
279
+ {item.risk.toFixed(1)}
280
+ </Badge>
281
+ </TreeViewItem>
282
+ ))}
283
+ </TreeViewItem>
284
+ ))}
285
+ </TreeView>
286
+ ) : (
287
+ <div className='flex justify-center py-48'>
288
+ <EmptyState
289
+ type='collection-empty'
290
+ data-testid='api-inventory-no-results'
291
+ >
292
+ <EmptyStateIllustration>
293
+ <SearchX />
294
+ </EmptyStateIllustration>
295
+ <EmptyStateMessage>
296
+ <EmptyStateTitle>No results found</EmptyStateTitle>
297
+ <EmptyStateDescription>
298
+ Nothing matches your search or status.
299
+ </EmptyStateDescription>
300
+ </EmptyStateMessage>
301
+ <EmptyStateActions>
302
+ <Button
303
+ size='medium'
304
+ variant='outline'
305
+ color='neutral'
306
+ onClick={handleReset}
307
+ >
308
+ <FilterX />
309
+ Reset filters
310
+ </Button>
311
+ </EmptyStateActions>
312
+ </EmptyState>
313
+ </div>
314
+ )}
315
+ </ScrollAreaContent>
316
+ </ScrollAreaViewport>
317
+ <ScrollAreaScrollbar />
318
+ </ScrollArea>
319
+ </div>
320
+ </ResizablePanel>
321
+
322
+ <ResizableHandle />
323
+
324
+ <ResizablePanel id='inspector' defaultSize='68%' minSize='40%'>
325
+ {endpoint && risk ? (
326
+ <ScrollArea className='h-full' data-testid='api-inventory-inspector'>
327
+ <ScrollAreaViewport>
328
+ <ScrollAreaContent className='min-w-0!'>
329
+ <HStack
330
+ justify='between'
331
+ align='start'
332
+ gap={16}
333
+ className='px-24 pt-20 pb-16'
334
+ >
335
+ <VStack gap={6} className='min-w-0'>
336
+ <HStack gap={8} align='center'>
337
+ <HttpMethod method={endpoint.method} size='large' />
338
+ <Heading
339
+ as='h2'
340
+ size='lg'
341
+ weight='medium'
342
+ truncate
343
+ data-testid='api-inventory-title'
344
+ >
345
+ {endpoint.path}
346
+ </Heading>
347
+ </HStack>
348
+ <HStack gap={6} align='center'>
349
+ <Text size='sm' color='secondary'>
350
+ {HOST_BY_ENDPOINT.get(endpoint.id)}
351
+ </Text>
352
+ {endpoint.isNew && (
353
+ <Badge type='secondary' color='blue' size='small'>
354
+ New
355
+ </Badge>
356
+ )}
357
+ </HStack>
358
+ </VStack>
359
+ <DropdownMenu>
360
+ <DropdownMenuTrigger asChild>
361
+ <Button
362
+ variant='outline'
363
+ color='neutral'
364
+ size='small'
365
+ data-testid='api-inventory-actions'
366
+ >
367
+ Actions <ChevronDown />
368
+ </Button>
369
+ </DropdownMenuTrigger>
370
+ <DropdownMenuContent>
371
+ <DropdownMenuItem onSelect={handleMarkReviewed}>
372
+ <DropdownMenuItemText>Mark as reviewed</DropdownMenuItemText>
373
+ </DropdownMenuItem>
374
+ <DropdownMenuItem onSelect={handleAddToPolicy}>
375
+ <DropdownMenuItemText>Add to API policy</DropdownMenuItemText>
376
+ </DropdownMenuItem>
377
+ <DropdownMenuItem onSelect={handleViewRequests}>
378
+ <DropdownMenuItemText>Go to requests</DropdownMenuItemText>
379
+ </DropdownMenuItem>
380
+ <DropdownMenuSeparator />
381
+ <DropdownMenuItem variant='destructive' onSelect={handleHide}>
382
+ <DropdownMenuItemText>Hide endpoint</DropdownMenuItemText>
383
+ </DropdownMenuItem>
384
+ </DropdownMenuContent>
385
+ </DropdownMenu>
386
+ </HStack>
387
+
388
+ <div
389
+ className='grid grid-cols-2 gap-x-8 gap-y-6 px-24 pb-16'
390
+ data-testid='api-inventory-attributes'
391
+ >
392
+ <Attribute orientation='horizontal'>
393
+ <AttributeLabel>Risk score</AttributeLabel>
394
+ <AttributeValue>
395
+ <HStack gap={8} align='center'>
396
+ <Badge variant='dotted' type='secondary' color={risk.color}>
397
+ {risk.label}
398
+ </Badge>
399
+ <Text size='sm'>{endpoint.risk.toFixed(1)} of 10</Text>
400
+ </HStack>
401
+ </AttributeValue>
402
+ </Attribute>
403
+ <Attribute orientation='horizontal'>
404
+ <AttributeLabel>Requests, 24h</AttributeLabel>
405
+ <AttributeValue>
406
+ <FormatNumber value={endpoint.requests} unit='requests' />
407
+ </AttributeValue>
408
+ </Attribute>
409
+ <Attribute
410
+ orientation='horizontal'
411
+ isEmpty={endpoint.sensitive.length === 0}
412
+ >
413
+ <AttributeLabel>Sensitive data</AttributeLabel>
414
+ <AttributeValue>
415
+ <HStack gap={4} wrap='wrap'>
416
+ {endpoint.sensitive.map(item => (
417
+ <Badge key={item} type='secondary' color={SENSITIVE_COLOR[item]}>
418
+ {item}
419
+ </Badge>
420
+ ))}
421
+ </HStack>
422
+ </AttributeValue>
423
+ </Attribute>
424
+ <Attribute orientation='horizontal'>
425
+ <AttributeLabel>First seen</AttributeLabel>
426
+ <AttributeValue>
427
+ <FormatDateTime
428
+ value={endpoint.firstSeen}
429
+ format='datetime'
430
+ layout='inline'
431
+ />
432
+ </AttributeValue>
433
+ </Attribute>
434
+ <Attribute orientation='horizontal'>
435
+ <AttributeLabel>Authentication</AttributeLabel>
436
+ <AttributeValue>
437
+ {endpoint.auth === 'None' ? (
438
+ <Badge variant='dotted' type='secondary' color='red'>
439
+ Unauthenticated
440
+ </Badge>
441
+ ) : (
442
+ <Tag>{endpoint.auth}</Tag>
443
+ )}
444
+ </AttributeValue>
445
+ </Attribute>
446
+ <Attribute orientation='horizontal'>
447
+ <AttributeLabel>Last seen</AttributeLabel>
448
+ <AttributeValue>
449
+ <FormatDateTime
450
+ value={endpoint.lastSeen}
451
+ format='datetime'
452
+ layout='inline'
453
+ />
454
+ </AttributeValue>
455
+ </Attribute>
456
+ <Attribute orientation='horizontal'>
457
+ <AttributeLabel>Status codes</AttributeLabel>
458
+ <AttributeValue>
459
+ <HStack gap={4}>
460
+ {endpoint.responses.map(response => (
461
+ <ResponseCode key={response.code} code={response.code} />
462
+ ))}
463
+ </HStack>
464
+ </AttributeValue>
465
+ </Attribute>
466
+ <Attribute orientation='horizontal'>
467
+ <AttributeLabel>Application</AttributeLabel>
468
+ <AttributeValue>
469
+ <Tag>{endpoint.application}</Tag>
470
+ </AttributeValue>
471
+ </Attribute>
472
+ </div>
473
+
474
+ <Tabs value={tab} onChange={setTab} data-testid='api-inventory-tabs'>
475
+ <TabsList>
476
+ <TabsTrigger value='parameters'>
477
+ Parameters <NumericBadge>{endpoint.parameters.length}</NumericBadge>
478
+ </TabsTrigger>
479
+ <TabsTrigger value='responses'>
480
+ Responses <NumericBadge>{endpoint.responses.length}</NumericBadge>
481
+ </TabsTrigger>
482
+ </TabsList>
483
+ <TabsContent value='parameters'>
484
+ <div className='px-16 pt-8 pb-16'>
485
+ <Table
486
+ aria-label='Parameters'
487
+ data={endpoint.parameters}
488
+ columns={parameterColumns}
489
+ getRowId={getParameterId}
490
+ data-testid='api-inventory-parameters'
491
+ >
492
+ {endpoint.parameters.length === 0 && (
493
+ <EmptyState type='collection-empty'>
494
+ <EmptyStateMessage>
495
+ <EmptyStateTitle>No parameters</EmptyStateTitle>
496
+ <EmptyStateDescription>
497
+ Requests to this endpoint carry no query, body or header
498
+ parameters.
499
+ </EmptyStateDescription>
500
+ </EmptyStateMessage>
501
+ </EmptyState>
502
+ )}
503
+ </Table>
504
+ </div>
505
+ </TabsContent>
506
+ <TabsContent value='responses'>
507
+ <div className='px-16 pt-8 pb-16'>
508
+ <Table
509
+ aria-label='Responses'
510
+ data={endpoint.responses}
511
+ columns={responseColumns}
512
+ getRowId={getResponseId}
513
+ data-testid='api-inventory-responses'
514
+ />
515
+ </div>
516
+ </TabsContent>
517
+ </Tabs>
518
+ </ScrollAreaContent>
519
+ </ScrollAreaViewport>
520
+ <ScrollAreaScrollbar />
521
+ </ScrollArea>
522
+ ) : (
523
+ <div
524
+ className='flex h-full items-center justify-center'
525
+ data-testid='api-inventory-inspector-empty'
526
+ >
527
+ <Text size='sm' color='secondary'>
528
+ Select an endpoint to view details
529
+ </Text>
530
+ </div>
531
+ )}
532
+ </ResizablePanel>
533
+ </ResizablePanelGroup>
534
+ </div>
535
+ </PageContent>
536
+ </Page>
537
+ );
538
+ };
539
+ ```
540
+
541
+ Nothing selected yet: the inspector names the choice that fills it.
542
+
543
+ Nothing is selected yet: the tree is ready and the inspector names the choice that fills it,
544
+ with no action of its own.
545
+
546
+ ```tsx story=NothingSelected
547
+ import { useState } from 'react';
548
+ import { Badge } from '@wallarm-org/design-system/Badge';
549
+ import { Button } from '@wallarm-org/design-system/Button';
550
+ import { HttpMethod } from '@wallarm-org/design-system/HttpMethod';
551
+ import { Download, Globe } from '@wallarm-org/design-system/icons';
552
+ import { NumericBadge } from '@wallarm-org/design-system/NumericBadge';
553
+ import { Page, PageActions, PageContent, PageDescription, PageHeader, PageHeaderGroup, PageTitle, PageToolbar } from '@wallarm-org/design-system/Page';
554
+ import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from '@wallarm-org/design-system/Resizable';
555
+ import { ScrollArea, ScrollAreaContent, ScrollAreaScrollbar, ScrollAreaViewport } from '@wallarm-org/design-system/ScrollArea';
556
+ import { SearchInput } from '@wallarm-org/design-system/SearchInput';
557
+ import { SegmentedTabs, SegmentedTabsList, SegmentedTabsTrigger } from '@wallarm-org/design-system/SegmentedTabs';
558
+ import { Separator } from '@wallarm-org/design-system/Separator';
559
+ import { HStack } from '@wallarm-org/design-system/Stack';
560
+ import { Text } from '@wallarm-org/design-system/Text';
561
+ import { TreeView, TreeViewItem } from '@wallarm-org/design-system/TreeView';
562
+
563
+ export const NothingSelected = () => {
564
+ const [query, setQuery] = useState('');
565
+ const [status, setStatus] = useState('all');
566
+
567
+ const counts = {
568
+ all: ALL_ENDPOINTS.length,
569
+ sensitive: ALL_ENDPOINTS.filter(endpoint => endpoint.sensitive.length > 0).length,
570
+ new: ALL_ENDPOINTS.filter(endpoint => endpoint.isNew).length,
571
+ };
572
+
573
+ return (
574
+ <Page name='api-inventory' fullSize fixedHeight data-testid='api-inventory-page'>
575
+ <PageHeader>
576
+ <PageHeaderGroup className='flex-1'>
577
+ <PageTitle>API inventory</PageTitle>
578
+ <PageDescription>
579
+ Hosts and endpoints discovered from live traffic, with the parameters and sensitive data
580
+ each one carries.
581
+ </PageDescription>
582
+ </PageHeaderGroup>
583
+ <PageActions>
584
+ <Button variant='secondary' color='neutral' size='medium' onClick={onExport}>
585
+ <Download />
586
+ Export
587
+ </Button>
588
+ <Button size='medium' onClick={onUploadSpec} data-testid='api-inventory-upload'>
589
+ Upload specification
590
+ </Button>
591
+ </PageActions>
592
+ </PageHeader>
593
+
594
+ <PageToolbar>
595
+ <SearchInput
596
+ value={query}
597
+ onChange={setQuery}
598
+ placeholder='Search host or path'
599
+ className='w-[320px]'
600
+ data-testid='api-inventory-search'
601
+ />
602
+ <SegmentedTabs value={status} onChange={setStatus} data-testid='api-inventory-status'>
603
+ <SegmentedTabsList>
604
+ <SegmentedTabsTrigger value='all'>
605
+ All <NumericBadge>{counts.all}</NumericBadge>
606
+ </SegmentedTabsTrigger>
607
+ <SegmentedTabsTrigger value='sensitive'>
608
+ Sensitive data <NumericBadge>{counts.sensitive}</NumericBadge>
609
+ </SegmentedTabsTrigger>
610
+ <SegmentedTabsTrigger value='new'>
611
+ New <NumericBadge>{counts.new}</NumericBadge>
612
+ </SegmentedTabsTrigger>
613
+ </SegmentedTabsList>
614
+ </SegmentedTabs>
615
+ </PageToolbar>
616
+
617
+ <PageContent>
618
+ <div className='h-full overflow-hidden rounded-12 border border-border-primary'>
619
+ <ResizablePanelGroup data-testid='api-inventory-split'>
620
+ <ResizablePanel id='tree' defaultSize='32%' minSize='22%' maxSize='50%'>
621
+ <div className='flex h-full flex-col'>
622
+ <HStack align='center' className='h-40 shrink-0 px-12'>
623
+ <Text size='xs' weight='medium' color='secondary'>
624
+ {HOSTS.length} hosts · {ALL_ENDPOINTS.length} endpoints
625
+ </Text>
626
+ </HStack>
627
+ <Separator />
628
+ <ScrollArea className='min-h-0 flex-1'>
629
+ <ScrollAreaViewport>
630
+ <ScrollAreaContent className='min-w-0! py-4'>
631
+ <TreeView
632
+ selectable
633
+ aria-label='Hosts and endpoints'
634
+ data-testid='api-inventory-tree'
635
+ >
636
+ {HOSTS.map(host => (
637
+ <TreeViewItem key={host.id} defaultOpen>
638
+ <Globe />
639
+ {host.host}
640
+ <NumericBadge>{host.endpoints.length}</NumericBadge>
641
+ {host.endpoints.map(item => (
642
+ <TreeViewItem key={item.id} id={item.id}>
643
+ <span className='flex w-64 shrink-0'>
644
+ <HttpMethod method={item.method} size='small' />
645
+ </span>
646
+ {item.path}
647
+ <Badge
648
+ variant='dotted'
649
+ type='text-color'
650
+ size='small'
651
+ color={getRisk(item.risk).color}
652
+ >
653
+ {item.risk.toFixed(1)}
654
+ </Badge>
655
+ </TreeViewItem>
656
+ ))}
657
+ </TreeViewItem>
658
+ ))}
659
+ </TreeView>
660
+ </ScrollAreaContent>
661
+ </ScrollAreaViewport>
662
+ <ScrollAreaScrollbar />
663
+ </ScrollArea>
664
+ </div>
665
+ </ResizablePanel>
666
+
667
+ <ResizableHandle />
668
+
669
+ <ResizablePanel id='inspector' defaultSize='68%' minSize='40%'>
670
+ <div
671
+ className='flex h-full items-center justify-center'
672
+ data-testid='api-inventory-inspector-empty'
673
+ >
674
+ <Text size='sm' color='secondary'>
675
+ Select an endpoint to view details
676
+ </Text>
677
+ </div>
678
+ </ResizablePanel>
679
+ </ResizablePanelGroup>
680
+ </div>
681
+ </PageContent>
682
+ </Page>
683
+ );
684
+ };
685
+ ```
686
+
687
+ The inventory failed to load: the error and "Try again" take the tree's place.
688
+
689
+ The inventory failed to load: the header and toolbar stay, the tree panel shows the error in
690
+ place of the hosts with "Try again", and the inspector has nothing to show.
691
+
692
+ ```tsx story=LoadError
693
+ import { Button } from '@wallarm-org/design-system/Button';
694
+ import { EmptyState, EmptyStateActions, EmptyStateDescription, EmptyStateIllustration, EmptyStateMessage, EmptyStateTitle } from '@wallarm-org/design-system/EmptyState';
695
+ import { CloudOff, Download, RefreshCcw } from '@wallarm-org/design-system/icons';
696
+ import { Page, PageActions, PageContent, PageDescription, PageHeader, PageHeaderGroup, PageTitle, PageToolbar } from '@wallarm-org/design-system/Page';
697
+ import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from '@wallarm-org/design-system/Resizable';
698
+ import { SearchInput } from '@wallarm-org/design-system/SearchInput';
699
+ import { SegmentedTabs, SegmentedTabsList, SegmentedTabsTrigger } from '@wallarm-org/design-system/SegmentedTabs';
700
+ import { Text } from '@wallarm-org/design-system/Text';
701
+
702
+ export const LoadError = () => (
703
+ <Page name='api-inventory' fullSize fixedHeight data-testid='api-inventory-page'>
704
+ <PageHeader>
705
+ <PageHeaderGroup className='flex-1'>
706
+ <PageTitle>API inventory</PageTitle>
707
+ <PageDescription>
708
+ Hosts and endpoints discovered from live traffic, with the parameters and sensitive data
709
+ each one carries.
710
+ </PageDescription>
711
+ </PageHeaderGroup>
712
+ <PageActions>
713
+ <Button variant='secondary' color='neutral' size='medium' onClick={onExport}>
714
+ <Download />
715
+ Export
716
+ </Button>
717
+ <Button size='medium' onClick={onUploadSpec} data-testid='api-inventory-upload'>
718
+ Upload specification
719
+ </Button>
720
+ </PageActions>
721
+ </PageHeader>
722
+
723
+ <PageToolbar>
724
+ <SearchInput
725
+ placeholder='Search host or path'
726
+ className='w-[320px]'
727
+ data-testid='api-inventory-search'
728
+ />
729
+ <SegmentedTabs defaultValue='all' data-testid='api-inventory-status'>
730
+ <SegmentedTabsList>
731
+ <SegmentedTabsTrigger value='all'>All</SegmentedTabsTrigger>
732
+ <SegmentedTabsTrigger value='sensitive'>Sensitive data</SegmentedTabsTrigger>
733
+ <SegmentedTabsTrigger value='new'>New</SegmentedTabsTrigger>
734
+ </SegmentedTabsList>
735
+ </SegmentedTabs>
736
+ </PageToolbar>
737
+
738
+ <PageContent>
739
+ <div className='h-full overflow-hidden rounded-12 border border-border-primary'>
740
+ <ResizablePanelGroup data-testid='api-inventory-split'>
741
+ <ResizablePanel id='tree' defaultSize='32%' minSize='22%' maxSize='50%'>
742
+ <div className='flex justify-center py-48'>
743
+ <EmptyState data-testid='api-inventory-error'>
744
+ <EmptyStateIllustration>
745
+ <CloudOff />
746
+ </EmptyStateIllustration>
747
+ <EmptyStateMessage>
748
+ <EmptyStateTitle>Couldn't load endpoints</EmptyStateTitle>
749
+ <EmptyStateDescription>
750
+ The server didn't respond. Try again in a moment.
751
+ </EmptyStateDescription>
752
+ </EmptyStateMessage>
753
+ <EmptyStateActions>
754
+ <Button
755
+ size='medium'
756
+ variant='outline'
757
+ color='neutral'
758
+ onClick={onRetryInventory}
759
+ >
760
+ <RefreshCcw />
761
+ Try again
762
+ </Button>
763
+ </EmptyStateActions>
764
+ </EmptyState>
765
+ </div>
766
+ </ResizablePanel>
767
+
768
+ <ResizableHandle />
769
+
770
+ <ResizablePanel id='inspector' defaultSize='68%' minSize='40%'>
771
+ <div className='flex h-full items-center justify-center'>
772
+ <Text size='sm' color='secondary'>
773
+ Select an endpoint to view details
774
+ </Text>
775
+ </div>
776
+ </ResizablePanel>
777
+ </ResizablePanelGroup>
778
+ </div>
779
+ </PageContent>
780
+ </Page>
781
+ );
782
+ ```
783
+
784
+ First load: skeletons where the tree, attributes and parameters will be.
785
+
786
+ First load: the real header and toolbar stay, the tree and the inspector fill with skeletons,
787
+ and the parameters table shows placeholder rows. Never a `Loader` in place of the screen.
788
+
789
+ ```tsx story=Loading
790
+ import { Attribute } from '@wallarm-org/design-system/Attribute';
791
+ import { Button } from '@wallarm-org/design-system/Button';
792
+ import { Download } from '@wallarm-org/design-system/icons';
793
+ import { Page, PageActions, PageContent, PageDescription, PageHeader, PageHeaderGroup, PageTitle, PageToolbar } from '@wallarm-org/design-system/Page';
794
+ import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from '@wallarm-org/design-system/Resizable';
795
+ import { SearchInput } from '@wallarm-org/design-system/SearchInput';
796
+ import { SegmentedTabs, SegmentedTabsList, SegmentedTabsTrigger } from '@wallarm-org/design-system/SegmentedTabs';
797
+ import { Skeleton } from '@wallarm-org/design-system/Skeleton';
798
+ import { VStack } from '@wallarm-org/design-system/Stack';
799
+ import { type TableColumnDef, Table } from '@wallarm-org/design-system/Table';
800
+ import { Tabs, TabsContent, TabsList, TabsTrigger } from '@wallarm-org/design-system/Tabs';
801
+
802
+ export const Loading = () => {
803
+ const parameterColumns: TableColumnDef<Parameter>[] = [
804
+ { id: 'parameter', header: 'Parameter', size: 300 },
805
+ { accessorKey: 'type', header: 'Type', size: 120 },
806
+ { id: 'required', header: 'Presence', size: 120 },
807
+ { id: 'sensitive', header: 'Sensitive data', size: 160 },
808
+ ];
809
+
810
+ return (
811
+ <Page name='api-inventory' fullSize fixedHeight data-testid='api-inventory-page'>
812
+ <PageHeader>
813
+ <PageHeaderGroup className='flex-1'>
814
+ <PageTitle>API inventory</PageTitle>
815
+ <PageDescription>
816
+ Hosts and endpoints discovered from live traffic, with the parameters and sensitive data
817
+ each one carries.
818
+ </PageDescription>
819
+ </PageHeaderGroup>
820
+ <PageActions>
821
+ <Button variant='secondary' color='neutral' size='medium' onClick={onExport}>
822
+ <Download />
823
+ Export
824
+ </Button>
825
+ <Button size='medium' onClick={onUploadSpec} data-testid='api-inventory-upload'>
826
+ Upload specification
827
+ </Button>
828
+ </PageActions>
829
+ </PageHeader>
830
+
831
+ <PageToolbar>
832
+ <SearchInput
833
+ placeholder='Search host or path'
834
+ className='w-[320px]'
835
+ disabled
836
+ data-testid='api-inventory-search'
837
+ />
838
+ <SegmentedTabs defaultValue='all' data-testid='api-inventory-status'>
839
+ <SegmentedTabsList>
840
+ <SegmentedTabsTrigger value='all'>All</SegmentedTabsTrigger>
841
+ <SegmentedTabsTrigger value='sensitive'>Sensitive data</SegmentedTabsTrigger>
842
+ <SegmentedTabsTrigger value='new'>New</SegmentedTabsTrigger>
843
+ </SegmentedTabsList>
844
+ </SegmentedTabs>
845
+ </PageToolbar>
846
+
847
+ <PageContent>
848
+ <div className='h-full overflow-hidden rounded-12 border border-border-primary'>
849
+ <ResizablePanelGroup data-testid='api-inventory-split'>
850
+ <ResizablePanel id='tree' defaultSize='32%' minSize='22%' maxSize='50%'>
851
+ <VStack gap={12} className='px-12 py-12' data-testid='api-inventory-tree-loading'>
852
+ {SKELETON_ROWS.map(row => (
853
+ <Skeleton key={row} width='100%' height='16px' />
854
+ ))}
855
+ </VStack>
856
+ </ResizablePanel>
857
+
858
+ <ResizableHandle />
859
+
860
+ <ResizablePanel id='inspector' defaultSize='68%' minSize='40%'>
861
+ <VStack gap={16} className='px-24 pt-20 pb-16'>
862
+ <Skeleton width='320px' height='24px' />
863
+ <Skeleton width='160px' height='16px' />
864
+ </VStack>
865
+ <div className='grid grid-cols-2 gap-x-8 gap-y-6 px-24 pb-16'>
866
+ {SKELETON_ATTRIBUTES.map(item => (
867
+ <Attribute key={item} orientation='horizontal' loading />
868
+ ))}
869
+ </div>
870
+ <Tabs defaultValue='parameters' data-testid='api-inventory-tabs'>
871
+ <TabsList>
872
+ <TabsTrigger value='parameters'>Parameters</TabsTrigger>
873
+ <TabsTrigger value='responses'>Responses</TabsTrigger>
874
+ </TabsList>
875
+ <TabsContent value='parameters'>
876
+ <div className='px-16 pt-8 pb-16'>
877
+ <Table
878
+ aria-label='Parameters'
879
+ data={[]}
880
+ columns={parameterColumns}
881
+ getRowId={getParameterId}
882
+ isLoading
883
+ skeletonCount={6}
884
+ data-testid='api-inventory-parameters'
885
+ />
886
+ </div>
887
+ </TabsContent>
888
+ </Tabs>
889
+ </ResizablePanel>
890
+ </ResizablePanelGroup>
891
+ </div>
892
+ </PageContent>
893
+ </Page>
894
+ );
895
+ };
896
+ ```
897
+
898
+ ## Related
899
+
900
+ - [Resource list page](../patterns/resource-list-page.md)
901
+ - [Detail drawer](../patterns/detail-drawer.md)
902
+ - [Complex drawer](../patterns/complex-drawer.md)
903
+ - [Entity table](../patterns/entity-table.md)
904
+ - [Empty states](../patterns/empty-states.md)
905
+ - [Filtering](../patterns/filtering.md)