@wallarm-org/design-system 4.8.0-rc-fix-claude-code.1 → 4.8.0-rc-feat-parser.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 +2 -4
- package/dist/components/BulkBar/index.d.ts +0 -5
- package/dist/components/Drawer/classes.js +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.d.ts +2 -0
- package/dist/components/DropdownMenu/DropdownMenu.js +84 -71
- package/dist/components/DropdownMenu/DropdownMenuItemDescription.js +1 -1
- package/dist/components/FilterInput/hooks/useFilterInputAutocomplete/useFilterInputAutocomplete.js +1 -1
- package/dist/components/Overlay/Overlay.js +1 -1
- package/dist/components/Rules/PointSelector/KeyboardShortcutsDialog.d.ts +14 -0
- package/dist/components/Rules/PointSelector/KeyboardShortcutsDialog.js +209 -0
- package/dist/components/Rules/PointSelector/MatchStep.d.ts +15 -0
- package/dist/components/Rules/PointSelector/MatchStep.js +186 -0
- package/dist/components/Rules/PointSelector/MenuFooterHints.d.ts +16 -0
- package/dist/components/Rules/PointSelector/MenuFooterHints.js +177 -0
- package/dist/components/Rules/PointSelector/PointPreview.d.ts +10 -0
- package/dist/components/Rules/PointSelector/PointPreview.js +88 -0
- package/dist/components/Rules/PointSelector/PointSelector.d.ts +17 -0
- package/dist/components/Rules/PointSelector/PointSelector.js +937 -0
- package/dist/components/Rules/PointSelector/PointSelectorEmptyState.d.ts +12 -0
- package/dist/components/Rules/PointSelector/PointSelectorEmptyState.js +173 -0
- package/dist/components/Rules/PointSelector/PointSelectorError.d.ts +31 -0
- package/dist/components/Rules/PointSelector/PointSelectorError.js +275 -0
- package/dist/components/Rules/PointSelector/PointSelectorInput.d.ts +20 -0
- package/dist/components/Rules/PointSelector/PointSelectorInput.js +130 -0
- package/dist/components/Rules/PointSelector/PointSelectorMenu.d.ts +31 -0
- package/dist/components/Rules/PointSelector/PointSelectorMenu.js +317 -0
- package/dist/components/Rules/PointSelector/PointSelectorSkeleton.d.ts +8 -0
- package/dist/components/Rules/PointSelector/PointSelectorSkeleton.js +73 -0
- package/dist/components/Rules/PointSelector/SampleRequest.d.ts +14 -0
- package/dist/components/Rules/PointSelector/SampleRequest.js +116 -0
- package/dist/components/Rules/PointSelector/StepMenu.d.ts +40 -0
- package/dist/components/Rules/PointSelector/StepMenu.js +210 -0
- package/dist/components/Rules/PointSelector/VersionWarning.d.ts +26 -0
- package/dist/components/Rules/PointSelector/VersionWarning.js +231 -0
- package/dist/components/Rules/PointSelector/WhereBar.d.ts +48 -0
- package/dist/components/Rules/PointSelector/WhereBar.js +263 -0
- package/dist/components/Rules/PointSelector/classes.d.ts +28 -0
- package/dist/components/Rules/PointSelector/classes.js +22 -0
- package/dist/components/Rules/PointSelector/index.d.ts +20 -0
- package/dist/components/Rules/PointSelector/index.js +18 -0
- package/dist/components/Rules/PointSelector/liftLayer.d.ts +8 -0
- package/dist/components/Rules/PointSelector/liftLayer.js +4 -0
- package/dist/components/Rules/PointSelector/sampleValue.d.ts +6 -0
- package/dist/components/Rules/PointSelector/sampleValue.js +51 -0
- package/dist/components/Rules/PointSelector/sdkBridge.d.ts +508 -0
- package/dist/components/Rules/PointSelector/sdkBridge.js +339 -0
- package/dist/components/Rules/PointSelector/types.d.ts +304 -0
- package/dist/components/Rules/PointSelector/types.js +0 -0
- package/dist/components/Rules/PointSelector/usePointSelector.d.ts +161 -0
- package/dist/components/Rules/PointSelector/usePointSelector.js +1088 -0
- package/dist/components/Rules/RuleBuilder/ActionEditor/ActionEditor.d.ts +28 -0
- package/dist/components/Rules/RuleBuilder/ActionEditor/ActionEditor.js +208 -0
- package/dist/components/Rules/RuleBuilder/ActionEditor/ActionFields.d.ts +23 -0
- package/dist/components/Rules/RuleBuilder/ActionEditor/ActionFields.js +950 -0
- package/dist/components/Rules/RuleBuilder/ActionEditor/ActionTargetPicker.d.ts +21 -0
- package/dist/components/Rules/RuleBuilder/ActionEditor/ActionTargetPicker.js +110 -0
- package/dist/components/Rules/RuleBuilder/ActionEditor/ActionTypeSelect.d.ts +20 -0
- package/dist/components/Rules/RuleBuilder/ActionEditor/ActionTypeSelect.js +31 -0
- package/dist/components/Rules/RuleBuilder/ActionEditor/AttackTypeField.d.ts +23 -0
- package/dist/components/Rules/RuleBuilder/ActionEditor/AttackTypeField.js +131 -0
- package/dist/components/Rules/RuleBuilder/ActionEditor/classes.d.ts +17 -0
- package/dist/components/Rules/RuleBuilder/ActionEditor/classes.js +14 -0
- package/dist/components/Rules/RuleBuilder/ActionEditor/index.d.ts +6 -0
- package/dist/components/Rules/RuleBuilder/ActionEditor/index.js +6 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/AddConditionMenu.d.ts +24 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/AddConditionMenu.js +245 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/AttackCondition.d.ts +15 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/AttackCondition.js +691 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/ConditionCard.d.ts +19 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/ConditionCard.js +72 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/ConditionTree.d.ts +27 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/ConditionTree.js +407 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/FieldCondition.d.ts +14 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/FieldCondition.js +269 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/GroupCondition.d.ts +25 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/GroupCondition.js +99 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/SampleCondition.d.ts +14 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/SampleCondition.js +118 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/SignalCondition.d.ts +14 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/SignalCondition.js +446 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/TagCondition.d.ts +14 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/TagCondition.js +266 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/classes.d.ts +35 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/classes.js +57 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/index.d.ts +15 -0
- package/dist/components/Rules/RuleBuilder/ConditionTree/index.js +10 -0
- package/dist/components/Rules/RuleBuilder/RuleBuilder.d.ts +67 -0
- package/dist/components/Rules/RuleBuilder/RuleBuilder.js +366 -0
- package/dist/components/Rules/RuleBuilder/Summary/ActionSummary.d.ts +32 -0
- package/dist/components/Rules/RuleBuilder/Summary/ActionSummary.js +420 -0
- package/dist/components/Rules/RuleBuilder/Summary/ConditionSummary.d.ts +27 -0
- package/dist/components/Rules/RuleBuilder/Summary/ConditionSummary.js +446 -0
- package/dist/components/Rules/RuleBuilder/Summary/index.d.ts +7 -0
- package/dist/components/Rules/RuleBuilder/Summary/index.js +2 -0
- package/dist/components/Rules/RuleBuilder/classes.d.ts +19 -0
- package/dist/components/Rules/RuleBuilder/classes.js +18 -0
- package/dist/components/Rules/RuleBuilder/index.d.ts +55 -0
- package/dist/components/Rules/RuleBuilder/index.js +11 -0
- package/dist/components/Rules/RuleBuilder/models/actionModel.d.ts +31 -0
- package/dist/components/Rules/RuleBuilder/models/actionModel.js +276 -0
- package/dist/components/Rules/RuleBuilder/models/conditionModel.d.ts +95 -0
- package/dist/components/Rules/RuleBuilder/models/conditionModel.js +418 -0
- package/dist/components/Rules/RuleBuilder/models/index.d.ts +3 -0
- package/dist/components/Rules/RuleBuilder/models/index.js +3 -0
- package/dist/components/Rules/RuleBuilder/models/validation.d.ts +176 -0
- package/dist/components/Rules/RuleBuilder/models/validation.js +242 -0
- package/dist/components/Rules/RuleBuilder/shared/ChoiceSelect.d.ts +27 -0
- package/dist/components/Rules/RuleBuilder/shared/ChoiceSelect.js +92 -0
- package/dist/components/Rules/RuleBuilder/shared/index.d.ts +1 -0
- package/dist/components/Rules/RuleBuilder/shared/index.js +1 -0
- package/dist/components/Rules/RuleBuilder/types.d.ts +384 -0
- package/dist/components/Rules/RuleBuilder/types.js +0 -0
- package/dist/components/Rules/RuleBuilder/utils/constants.d.ts +65 -0
- package/dist/components/Rules/RuleBuilder/utils/constants.js +356 -0
- package/dist/components/Rules/RuleBuilder/utils/extractBindings.d.ts +48 -0
- package/dist/components/Rules/RuleBuilder/utils/extractBindings.js +42 -0
- package/dist/components/Rules/RuleBuilder/utils/helpers.d.ts +92 -0
- package/dist/components/Rules/RuleBuilder/utils/helpers.js +54 -0
- package/dist/components/Rules/RuleBuilder/utils/index.d.ts +2 -0
- package/dist/components/Rules/RuleBuilder/utils/index.js +2 -0
- package/dist/components/SearchInput/SearchInput.d.ts +5 -7
- package/dist/components/SearchInput/SearchInput.js +101 -119
- package/dist/components/Select/SelectSearchInput.d.ts +1 -1
- package/dist/components/Table/types.d.ts +1 -1
- package/dist/components/Tabs/Tabs.d.ts +0 -1
- package/dist/components/Tabs/Tabs.js +28 -30
- package/dist/components/Tabs/TabsList/index.d.ts +1 -1
- package/dist/components/Tabs/index.d.ts +2 -2
- package/dist/components/Tour/TourPositioner.d.ts +0 -3
- package/dist/components/Tour/TourPositioner.js +4 -4
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/metadata/components.json +9077 -12300
- package/dist/theme/typography.css +0 -5
- package/dist/utils/formatDateTime.d.ts +0 -6
- package/dist/utils/formatDateTime.js +1 -13
- package/package.json +4 -6
- package/dist/components/NotificationCenter/NotificationCenter.d.ts +0 -20
- package/dist/components/NotificationCenter/NotificationCenter.js +0 -65
- package/dist/components/NotificationCenter/NotificationCenterBody.d.ts +0 -18
- package/dist/components/NotificationCenter/NotificationCenterBody.js +0 -202
- package/dist/components/NotificationCenter/NotificationCenterContent.d.ts +0 -5
- package/dist/components/NotificationCenter/NotificationCenterContent.js +0 -42
- package/dist/components/NotificationCenter/NotificationCenterHeader.d.ts +0 -20
- package/dist/components/NotificationCenter/NotificationCenterHeader.js +0 -202
- package/dist/components/NotificationCenter/NotificationCenterItem.d.ts +0 -26
- package/dist/components/NotificationCenter/NotificationCenterItem.js +0 -211
- package/dist/components/NotificationCenter/NotificationCenterItemTime.d.ts +0 -9
- package/dist/components/NotificationCenter/NotificationCenterItemTime.js +0 -148
- package/dist/components/NotificationCenter/NotificationCenterItemTitle.d.ts +0 -14
- package/dist/components/NotificationCenter/NotificationCenterItemTitle.js +0 -115
- package/dist/components/NotificationCenter/NotificationCenterTabs.d.ts +0 -10
- package/dist/components/NotificationCenter/NotificationCenterTabs.js +0 -77
- package/dist/components/NotificationCenter/NotificationCenterTrigger.d.ts +0 -13
- package/dist/components/NotificationCenter/NotificationCenterTrigger.js +0 -138
- package/dist/components/NotificationCenter/index.d.ts +0 -9
- package/dist/components/NotificationCenter/index.js +0 -9
- package/dist/guidelines/foundations/color.md +0 -157
- package/dist/guidelines/foundations/focus.md +0 -122
- package/dist/guidelines/foundations/layering.md +0 -131
- package/dist/guidelines/foundations/radius-elevation.md +0 -111
- package/dist/guidelines/foundations/spacing.md +0 -117
- package/dist/guidelines/foundations/typography.md +0 -114
- package/dist/guidelines/patterns/app-layout.md +0 -1567
- package/dist/guidelines/patterns/auth-page.md +0 -668
- package/dist/guidelines/patterns/confirmation-dialogs.md +0 -605
- package/dist/guidelines/patterns/create-edit-forms.md +0 -768
- package/dist/guidelines/patterns/detail-drawer.md +0 -868
- package/dist/guidelines/patterns/empty-states.md +0 -461
- package/dist/guidelines/patterns/entity-table.md +0 -533
- package/dist/guidelines/patterns/feedback-toasts.md +0 -493
- package/dist/guidelines/patterns/filtering.md +0 -630
- package/dist/guidelines/patterns/resource-list-page.md +0 -558
- package/dist/guidelines/patterns/settings-page.md +0 -752
- package/dist/guidelines/rules.md +0 -25
- package/dist/metadata/guidelines.json +0 -1705
|
@@ -1,493 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Feedback toasts
|
|
3
|
-
description: Use when a mutation finishes (row menu, bulk bar, dialog confirm, autosave, test run) and the app must report the result with a transient toast.
|
|
4
|
-
components: [Toaster, ToastActions, Button, Alert, Banner, Dialog, FieldError]
|
|
5
|
-
keywords: [toast, toaster, useToast, notification, snackbar, feedback, success message, error message, loading toast, action result, confirmation message, flash message, saved, deleted]
|
|
6
|
-
order: 40
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
# Feedback toasts
|
|
10
|
-
|
|
11
|
-
A toast reports the result of the user's last action, then leaves on its own.
|
|
12
|
-
|
|
13
|
-
## When to use
|
|
14
|
-
|
|
15
|
-
| Need | Use | Not |
|
|
16
|
-
| --- | --- | --- |
|
|
17
|
-
| Confirm a finished mutation ("User deleted") | Toast, `type: 'default'` | `Alert` in the page |
|
|
18
|
-
| Show progress of a request that takes seconds | Toast, `type: 'loading'`, then `update` | A spinner in a blocking `Dialog` |
|
|
19
|
-
| Report an async result (test sent, sync done) | Toast, `type: 'success'` or `'error'` | `type: 'default'` |
|
|
20
|
-
| Offer one next step after create | Toast with `actions` | A second dialog |
|
|
21
|
-
| Ask the user to decide | `Dialog` | Toast with two action buttons |
|
|
22
|
-
| Show a result inside a form (connection test) | `Alert` in the form | Toast |
|
|
23
|
-
| Show standing account or system state | `Banner` | Toast with a long `duration` |
|
|
24
|
-
| Show a field validation error | `FieldError` under the field | Toast |
|
|
25
|
-
|
|
26
|
-
If the message is the only place the user learns something important, do not use a toast. It disappears.
|
|
27
|
-
|
|
28
|
-
## Rules
|
|
29
|
-
|
|
30
|
-
### Type and layout
|
|
31
|
-
|
|
32
|
-
- If the user's own mutation finished, use `type: 'default'` (no icon). A delete confirmed in a `Dialog` is a finished mutation.
|
|
33
|
-
- Otherwise use `'success'`, `'error'`, `'warning'` (finished with a caveat) or `'info'` (neutral notice).
|
|
34
|
-
- Exception: save toasts on a settings page use `type: 'success'`. See [Settings page](./settings-page.md).
|
|
35
|
-
- **Always** set `type`. Without it the toast renders as `'info'` with a blue icon.
|
|
36
|
-
- A `description` always switches to the `extended` layout (title over description, 10000 ms), even with `variant: 'simple'`. Without it the toast is one 48px row, 5000 ms.
|
|
37
|
-
- `icon` replaces the type icon and takes the type color unless it sets its own `text-*` class.
|
|
38
|
-
|
|
39
|
-
### Placement and spacing
|
|
40
|
-
|
|
41
|
-
- `Toaster` owns position (bottom center), 24px padding, 12px gaps and layering above every drawer and dialog. **Never** wrap it in a positioned element.
|
|
42
|
-
- `Toast` owns its padding and width (256–560px). **Never** add spacing or width to toast content.
|
|
43
|
-
- Three toasts show at once; hover expands the stack and pauses every timer.
|
|
44
|
-
- Mount one `Toaster` at the app root. **Never** mount a second.
|
|
45
|
-
|
|
46
|
-
### Loading and updates
|
|
47
|
-
|
|
48
|
-
- If you create a `loading` toast, **always** resolve it with `update` or `dismiss`. It has no timer and never leaves on its own.
|
|
49
|
-
- If an `update` adds a `description`, also pass `duration: 10000`. The timer is fixed at `create`.
|
|
50
|
-
- Pass `closable: false` only to a `loading` toast the user must not lose.
|
|
51
|
-
- If the user can repeat an action (copy, save), pass a stable `id` so the toast updates instead of stacking.
|
|
52
|
-
|
|
53
|
-
### Copy
|
|
54
|
-
|
|
55
|
-
| Case | Pattern | Example |
|
|
56
|
-
| --- | --- | --- |
|
|
57
|
-
| Mutation done | `<Object> <past-tense verb>` | "User deleted", "Changes saved" |
|
|
58
|
-
| Toggle | `<Object> enabled` / `disabled` | "Policy enabled" |
|
|
59
|
-
| In flight | `<Verb>ing <object>…` | "Testing channel…" |
|
|
60
|
-
| Async success | `<Result> via <provider>` | "Test delivered via Slack" |
|
|
61
|
-
| Failure | `<Action> failed — <cause>` | "Test failed — Slack rejected the request: missing API key" |
|
|
62
|
-
| Create with next step | Title, one-sentence description, one action | "Channel created" + "Go to destination" |
|
|
63
|
-
|
|
64
|
-
- Use sentence case and name the object, not "Success" or "Done". **Never** end a title with a period or "!".
|
|
65
|
-
- If the error text is long, put the action in `title` and the cause in `description`.
|
|
66
|
-
- **Never** pre-truncate copy; it clamps with a tooltip.
|
|
67
|
-
|
|
68
|
-
### Behavior
|
|
69
|
-
|
|
70
|
-
- Fire one toast per user action. A bulk action fires one toast for the batch ("3 users deleted").
|
|
71
|
-
- If a `Dialog` confirmed the action, close the dialog first, then fire the toast.
|
|
72
|
-
- Use `actions` only for a next step after create, one action (two max), each a `<Button variant='secondary' size='small' color='neutral-alt'>` inside `ToastActions`.
|
|
73
|
-
- **Never** make Undo, Confirm or Retry available only in a toast.
|
|
74
|
-
|
|
75
|
-
### Imports
|
|
76
|
-
|
|
77
|
-
- Import `useToast` from `@wallarm-org/design-system/Toast`. It is not exported from the package root.
|
|
78
|
-
- Outside React, use `toaster.create(options)` and `toaster.update(id, options)`.
|
|
79
|
-
|
|
80
|
-
## Examples
|
|
81
|
-
|
|
82
|
-
Confirm a finished mutation with a plain toast. A delete confirmed in a dialog closes the dialog first.
|
|
83
|
-
|
|
84
|
-
The whole page, with every toast from the one app-root `Toaster`: create, then send test, copy
|
|
85
|
-
link and delete from each row's menu. The parts below show each toast on its own.
|
|
86
|
-
|
|
87
|
-
```tsx story=Default
|
|
88
|
-
import { useState } from 'react';
|
|
89
|
-
import { Button } from '@wallarm-org/design-system/Button';
|
|
90
|
-
import { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@wallarm-org/design-system/Dialog';
|
|
91
|
-
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuItemText, DropdownMenuSeparator, DropdownMenuTrigger } from '@wallarm-org/design-system/DropdownMenu';
|
|
92
|
-
import { Ellipsis } from '@wallarm-org/design-system/icons';
|
|
93
|
-
import { Page, PageActions, PageContent, PageDescription, PageHeader, PageHeaderGroup, PageTitle } from '@wallarm-org/design-system/Page';
|
|
94
|
-
import { type TableCellContext, type TableColumnDef, Table } from '@wallarm-org/design-system/Table';
|
|
95
|
-
import { ToastActions, useToast } from '@wallarm-org/design-system/Toast';
|
|
96
|
-
|
|
97
|
-
export const Default = () => {
|
|
98
|
-
const toast = useToast();
|
|
99
|
-
const [channels, setChannels] = useState(CHANNELS);
|
|
100
|
-
const [deleteTarget, setDeleteTarget] = useState<Channel | null>(null);
|
|
101
|
-
const [deleteOpen, setDeleteOpen] = useState(false);
|
|
102
|
-
|
|
103
|
-
const handleCreate = () => {
|
|
104
|
-
toast.create({
|
|
105
|
-
id: 'channel-created',
|
|
106
|
-
title: 'Channel created',
|
|
107
|
-
description: 'Route notifications through this channel in a destination.',
|
|
108
|
-
type: 'default',
|
|
109
|
-
actions: (
|
|
110
|
-
<ToastActions>
|
|
111
|
-
<Button variant='secondary' size='small' color='neutral-alt' onClick={onOpenDestination}>
|
|
112
|
-
Go to destination
|
|
113
|
-
</Button>
|
|
114
|
-
</ToastActions>
|
|
115
|
-
),
|
|
116
|
-
});
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
const handleConfirmDelete = () => {
|
|
120
|
-
if (!deleteTarget) return;
|
|
121
|
-
onDeleteChannel(deleteTarget);
|
|
122
|
-
setChannels(channels.filter(channel => channel.id !== deleteTarget.id));
|
|
123
|
-
setDeleteOpen(false);
|
|
124
|
-
toast.create({ id: `delete-${deleteTarget.id}`, title: 'Channel deleted', type: 'default' });
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
const renderActions = ({ row }: TableCellContext<Channel, unknown>) => {
|
|
128
|
-
const channel = row.original;
|
|
129
|
-
|
|
130
|
-
const handleTest = async () => {
|
|
131
|
-
const id = toast.create({
|
|
132
|
-
id: `test-${channel.id}`,
|
|
133
|
-
title: 'Testing channel…',
|
|
134
|
-
type: 'loading',
|
|
135
|
-
});
|
|
136
|
-
try {
|
|
137
|
-
await sendTestNotification();
|
|
138
|
-
toast.update({ id, title: `Test delivered via ${channel.provider}`, type: 'success' });
|
|
139
|
-
} catch (error) {
|
|
140
|
-
toast.update({
|
|
141
|
-
id,
|
|
142
|
-
title: 'Test failed',
|
|
143
|
-
description: error instanceof Error ? error.message : undefined,
|
|
144
|
-
type: 'error',
|
|
145
|
-
duration: 10000,
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
const handleCopyLink = async () => {
|
|
151
|
-
try {
|
|
152
|
-
await navigator.clipboard.writeText(channel.link);
|
|
153
|
-
toast.create({ id: 'copy-link', title: 'Link copied', type: 'default' });
|
|
154
|
-
} catch {
|
|
155
|
-
toast.create({ id: 'copy-link', title: 'Copy failed', type: 'error' });
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
const handleDelete = () => {
|
|
160
|
-
setDeleteTarget(channel);
|
|
161
|
-
setDeleteOpen(true);
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
return (
|
|
165
|
-
<DropdownMenu data-testid='channel-actions'>
|
|
166
|
-
<DropdownMenuTrigger asChild>
|
|
167
|
-
<Button
|
|
168
|
-
variant='ghost'
|
|
169
|
-
color='neutral'
|
|
170
|
-
size='small'
|
|
171
|
-
aria-label={`Actions for ${channel.name}`}
|
|
172
|
-
>
|
|
173
|
-
<Ellipsis />
|
|
174
|
-
</Button>
|
|
175
|
-
</DropdownMenuTrigger>
|
|
176
|
-
<DropdownMenuContent>
|
|
177
|
-
<DropdownMenuItem onSelect={handleTest}>
|
|
178
|
-
<DropdownMenuItemText>Send test</DropdownMenuItemText>
|
|
179
|
-
</DropdownMenuItem>
|
|
180
|
-
<DropdownMenuItem onSelect={handleCopyLink}>
|
|
181
|
-
<DropdownMenuItemText>Copy link</DropdownMenuItemText>
|
|
182
|
-
</DropdownMenuItem>
|
|
183
|
-
<DropdownMenuSeparator />
|
|
184
|
-
<DropdownMenuItem variant='destructive' onSelect={handleDelete}>
|
|
185
|
-
<DropdownMenuItemText>Delete channel</DropdownMenuItemText>
|
|
186
|
-
</DropdownMenuItem>
|
|
187
|
-
</DropdownMenuContent>
|
|
188
|
-
</DropdownMenu>
|
|
189
|
-
);
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
const columns: TableColumnDef<Channel>[] = [
|
|
193
|
-
{ accessorKey: 'name', header: 'Name', size: 240 },
|
|
194
|
-
{ accessorKey: 'provider', header: 'Provider', size: 160 },
|
|
195
|
-
{ accessorKey: 'events', header: 'Events', size: 320 },
|
|
196
|
-
{
|
|
197
|
-
id: 'actions',
|
|
198
|
-
header: '',
|
|
199
|
-
size: 60,
|
|
200
|
-
minSize: 60,
|
|
201
|
-
enableHiding: false,
|
|
202
|
-
cell: renderActions,
|
|
203
|
-
},
|
|
204
|
-
];
|
|
205
|
-
|
|
206
|
-
return (
|
|
207
|
-
<Page name='integrations-channels' fullSize fixedHeight data-testid='channels-page'>
|
|
208
|
-
<PageHeader>
|
|
209
|
-
<PageHeaderGroup className='flex-1'>
|
|
210
|
-
<PageTitle>Notification channels</PageTitle>
|
|
211
|
-
<PageDescription>
|
|
212
|
-
Where Wallarm sends attack, incident and system notifications.
|
|
213
|
-
</PageDescription>
|
|
214
|
-
</PageHeaderGroup>
|
|
215
|
-
<PageActions>
|
|
216
|
-
<Button size='medium' onClick={handleCreate} data-testid='channels-create'>
|
|
217
|
-
Create channel
|
|
218
|
-
</Button>
|
|
219
|
-
</PageActions>
|
|
220
|
-
</PageHeader>
|
|
221
|
-
|
|
222
|
-
<PageContent>
|
|
223
|
-
<Table
|
|
224
|
-
aria-label='Notification channels'
|
|
225
|
-
data={channels}
|
|
226
|
-
columns={columns}
|
|
227
|
-
getRowId={getChannelId}
|
|
228
|
-
data-testid='channels-table'
|
|
229
|
-
/>
|
|
230
|
-
</PageContent>
|
|
231
|
-
|
|
232
|
-
<Dialog
|
|
233
|
-
width={400}
|
|
234
|
-
open={deleteOpen}
|
|
235
|
-
onOpenChange={setDeleteOpen}
|
|
236
|
-
data-testid='channels-delete-dialog'
|
|
237
|
-
>
|
|
238
|
-
<DialogContent>
|
|
239
|
-
<DialogHeader>
|
|
240
|
-
<DialogTitle>Delete channel?</DialogTitle>
|
|
241
|
-
<DialogDescription>
|
|
242
|
-
Wallarm stops sending notifications to {deleteTarget?.name}. You can't undo this.
|
|
243
|
-
</DialogDescription>
|
|
244
|
-
</DialogHeader>
|
|
245
|
-
<DialogFooter>
|
|
246
|
-
<DialogClose asChild>
|
|
247
|
-
<Button variant='ghost' color='neutral'>
|
|
248
|
-
Cancel
|
|
249
|
-
</Button>
|
|
250
|
-
</DialogClose>
|
|
251
|
-
<Button color='destructive' onClick={handleConfirmDelete}>
|
|
252
|
-
Delete channel
|
|
253
|
-
</Button>
|
|
254
|
-
</DialogFooter>
|
|
255
|
-
</DialogContent>
|
|
256
|
-
</Dialog>
|
|
257
|
-
</Page>
|
|
258
|
-
);
|
|
259
|
-
};
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
Offer one next step after create.
|
|
263
|
-
|
|
264
|
-
The description switches the toast to the extended layout, so it stays 10000 ms.
|
|
265
|
-
|
|
266
|
-
```tsx story=NextStep
|
|
267
|
-
import { Button } from '@wallarm-org/design-system/Button';
|
|
268
|
-
import { Page, PageActions, PageDescription, PageHeader, PageHeaderGroup, PageTitle } from '@wallarm-org/design-system/Page';
|
|
269
|
-
import { ToastActions, useToast } from '@wallarm-org/design-system/Toast';
|
|
270
|
-
|
|
271
|
-
export const NextStep = () => {
|
|
272
|
-
const toast = useToast();
|
|
273
|
-
|
|
274
|
-
const handleCreate = () => {
|
|
275
|
-
toast.create({
|
|
276
|
-
id: 'channel-created',
|
|
277
|
-
title: 'Channel created',
|
|
278
|
-
description: 'Route notifications through this channel in a destination.',
|
|
279
|
-
type: 'default',
|
|
280
|
-
actions: (
|
|
281
|
-
<ToastActions>
|
|
282
|
-
<Button variant='secondary' size='small' color='neutral-alt' onClick={onOpenDestination}>
|
|
283
|
-
Go to destination
|
|
284
|
-
</Button>
|
|
285
|
-
</ToastActions>
|
|
286
|
-
),
|
|
287
|
-
});
|
|
288
|
-
};
|
|
289
|
-
|
|
290
|
-
return (
|
|
291
|
-
<Page name='integrations-channels' data-testid='channels-page'>
|
|
292
|
-
<PageHeader>
|
|
293
|
-
<PageHeaderGroup className='flex-1'>
|
|
294
|
-
<PageTitle>Notification channels</PageTitle>
|
|
295
|
-
<PageDescription>
|
|
296
|
-
Where Wallarm sends attack, incident and system notifications.
|
|
297
|
-
</PageDescription>
|
|
298
|
-
</PageHeaderGroup>
|
|
299
|
-
<PageActions>
|
|
300
|
-
<Button size='medium' onClick={handleCreate} data-testid='channels-create'>
|
|
301
|
-
Create channel
|
|
302
|
-
</Button>
|
|
303
|
-
</PageActions>
|
|
304
|
-
</PageHeader>
|
|
305
|
-
</Page>
|
|
306
|
-
);
|
|
307
|
-
};
|
|
308
|
-
```
|
|
309
|
-
|
|
310
|
-
Turn a loading toast into the result in place.
|
|
311
|
-
|
|
312
|
-
The loading toast has no timer; the 5000 ms timer starts when `update` resolves it.
|
|
313
|
-
|
|
314
|
-
```tsx story=TestDelivered
|
|
315
|
-
import { Button } from '@wallarm-org/design-system/Button';
|
|
316
|
-
import { Page, PageActions, PageDescription, PageHeader, PageHeaderGroup, PageTitle } from '@wallarm-org/design-system/Page';
|
|
317
|
-
import { useToast } from '@wallarm-org/design-system/Toast';
|
|
318
|
-
|
|
319
|
-
export const TestDelivered = () => {
|
|
320
|
-
const toast = useToast();
|
|
321
|
-
|
|
322
|
-
const handleTest = async () => {
|
|
323
|
-
const id = toast.create({
|
|
324
|
-
id: 'test-ch-soc-alerts',
|
|
325
|
-
title: 'Testing channel…',
|
|
326
|
-
type: 'loading',
|
|
327
|
-
});
|
|
328
|
-
try {
|
|
329
|
-
await sendTestNotification();
|
|
330
|
-
toast.update({ id, title: 'Test delivered via Slack', type: 'success' });
|
|
331
|
-
} catch (error) {
|
|
332
|
-
toast.update({
|
|
333
|
-
id,
|
|
334
|
-
title: 'Test failed',
|
|
335
|
-
description: error instanceof Error ? error.message : undefined,
|
|
336
|
-
type: 'error',
|
|
337
|
-
duration: 10000,
|
|
338
|
-
});
|
|
339
|
-
}
|
|
340
|
-
};
|
|
341
|
-
|
|
342
|
-
return (
|
|
343
|
-
<Page name='integrations-channel' data-testid='channel-page'>
|
|
344
|
-
<PageHeader>
|
|
345
|
-
<PageHeaderGroup className='flex-1'>
|
|
346
|
-
<PageTitle>#soc-alerts</PageTitle>
|
|
347
|
-
<PageDescription>Slack channel. Receives attacks and vulnerabilities.</PageDescription>
|
|
348
|
-
</PageHeaderGroup>
|
|
349
|
-
<PageActions>
|
|
350
|
-
<Button
|
|
351
|
-
size='medium'
|
|
352
|
-
variant='outline'
|
|
353
|
-
color='neutral'
|
|
354
|
-
onClick={handleTest}
|
|
355
|
-
data-testid='channel-send-test'
|
|
356
|
-
>
|
|
357
|
-
Send test
|
|
358
|
-
</Button>
|
|
359
|
-
</PageActions>
|
|
360
|
-
</PageHeader>
|
|
361
|
-
</Page>
|
|
362
|
-
);
|
|
363
|
-
};
|
|
364
|
-
```
|
|
365
|
-
|
|
366
|
-
If the failure adds a description, extend the timer in the same update.
|
|
367
|
-
|
|
368
|
-
The action goes in `title` and the provider's cause in `description`.
|
|
369
|
-
|
|
370
|
-
```tsx story=TestFailed
|
|
371
|
-
import { Button } from '@wallarm-org/design-system/Button';
|
|
372
|
-
import { Page, PageActions, PageDescription, PageHeader, PageHeaderGroup, PageTitle } from '@wallarm-org/design-system/Page';
|
|
373
|
-
import { useToast } from '@wallarm-org/design-system/Toast';
|
|
374
|
-
|
|
375
|
-
export const TestFailed = () => {
|
|
376
|
-
const toast = useToast();
|
|
377
|
-
|
|
378
|
-
const handleTest = async () => {
|
|
379
|
-
const id = toast.create({ id: 'test-ch-siem', title: 'Testing channel…', type: 'loading' });
|
|
380
|
-
try {
|
|
381
|
-
await sendRejectedTestNotification();
|
|
382
|
-
toast.update({ id, title: 'Test delivered via Splunk', type: 'success' });
|
|
383
|
-
} catch (error) {
|
|
384
|
-
toast.update({
|
|
385
|
-
id,
|
|
386
|
-
title: 'Test failed',
|
|
387
|
-
description: error instanceof Error ? error.message : undefined,
|
|
388
|
-
type: 'error',
|
|
389
|
-
duration: 10000,
|
|
390
|
-
});
|
|
391
|
-
}
|
|
392
|
-
};
|
|
393
|
-
|
|
394
|
-
return (
|
|
395
|
-
<Page name='integrations-channel' data-testid='channel-page'>
|
|
396
|
-
<PageHeader>
|
|
397
|
-
<PageHeaderGroup className='flex-1'>
|
|
398
|
-
<PageTitle>SIEM ingest</PageTitle>
|
|
399
|
-
<PageDescription>
|
|
400
|
-
Splunk HTTP Event Collector. Receives attacks, incidents and system events.
|
|
401
|
-
</PageDescription>
|
|
402
|
-
</PageHeaderGroup>
|
|
403
|
-
<PageActions>
|
|
404
|
-
<Button
|
|
405
|
-
size='medium'
|
|
406
|
-
variant='outline'
|
|
407
|
-
color='neutral'
|
|
408
|
-
onClick={handleTest}
|
|
409
|
-
data-testid='channel-send-test'
|
|
410
|
-
>
|
|
411
|
-
Send test
|
|
412
|
-
</Button>
|
|
413
|
-
</PageActions>
|
|
414
|
-
</PageHeader>
|
|
415
|
-
</Page>
|
|
416
|
-
);
|
|
417
|
-
};
|
|
418
|
-
```
|
|
419
|
-
|
|
420
|
-
Reuse an `id` so repeated clicks update one toast instead of stacking.
|
|
421
|
-
|
|
422
|
-
If the clipboard is blocked, the same id turns the toast into an error.
|
|
423
|
-
|
|
424
|
-
```tsx story=CopyLink
|
|
425
|
-
import { Button } from '@wallarm-org/design-system/Button';
|
|
426
|
-
import { Page, PageActions, PageDescription, PageHeader, PageHeaderGroup, PageTitle } from '@wallarm-org/design-system/Page';
|
|
427
|
-
import { useToast } from '@wallarm-org/design-system/Toast';
|
|
428
|
-
|
|
429
|
-
export const CopyLink = () => {
|
|
430
|
-
const toast = useToast();
|
|
431
|
-
|
|
432
|
-
const handleCopyLink = async () => {
|
|
433
|
-
try {
|
|
434
|
-
await navigator.clipboard.writeText(ONCALL_LINK);
|
|
435
|
-
toast.create({ id: 'copy-link', title: 'Link copied', type: 'default' });
|
|
436
|
-
} catch {
|
|
437
|
-
toast.create({ id: 'copy-link', title: 'Copy failed', type: 'error' });
|
|
438
|
-
}
|
|
439
|
-
};
|
|
440
|
-
|
|
441
|
-
return (
|
|
442
|
-
<Page name='integrations-channel' data-testid='channel-page'>
|
|
443
|
-
<PageHeader>
|
|
444
|
-
<PageHeaderGroup className='flex-1'>
|
|
445
|
-
<PageTitle>Security on-call</PageTitle>
|
|
446
|
-
<PageDescription>PagerDuty service. Receives incidents.</PageDescription>
|
|
447
|
-
</PageHeaderGroup>
|
|
448
|
-
<PageActions>
|
|
449
|
-
<Button
|
|
450
|
-
size='medium'
|
|
451
|
-
variant='outline'
|
|
452
|
-
color='neutral'
|
|
453
|
-
onClick={handleCopyLink}
|
|
454
|
-
data-testid='channel-copy-link'
|
|
455
|
-
>
|
|
456
|
-
Copy link
|
|
457
|
-
</Button>
|
|
458
|
-
</PageActions>
|
|
459
|
-
</PageHeader>
|
|
460
|
-
</Page>
|
|
461
|
-
);
|
|
462
|
-
};
|
|
463
|
-
```
|
|
464
|
-
|
|
465
|
-
## States
|
|
466
|
-
|
|
467
|
-
| State | Show | Example component |
|
|
468
|
-
| --- | --- | --- |
|
|
469
|
-
| Done | Plain toast, leaves after 5000 ms | `toast.create({ title, type: 'default' })` |
|
|
470
|
-
| In flight | Spinner, no timer, no progress bar | `toast.create({ title, type: 'loading' })` |
|
|
471
|
-
| Resolved | Same toast changes in place, timer starts | `toast.update({ id, title, type: 'success' })` |
|
|
472
|
-
| Failed | Same toast turns into an error | `toast.update({ id, title, type: 'error' })` |
|
|
473
|
-
| Repeated action | Visible toast updates, no copy | `toast.create({ id: 'copy-link', … })` |
|
|
474
|
-
| Dismissed by code | One toast removed, or all | `toast.dismiss({ id })`, `toast.dismiss()` |
|
|
475
|
-
|
|
476
|
-
## What your app owns
|
|
477
|
-
|
|
478
|
-
- Toast copy, firing after the request resolves, resolving every `loading` toast, and stable ids.
|
|
479
|
-
|
|
480
|
-
These do not exist:
|
|
481
|
-
|
|
482
|
-
- Placement or visible-count props. `Toaster` takes no props.
|
|
483
|
-
- An Undo helper or a promise helper on `useToast`.
|
|
484
|
-
- Rich text. `title` and `description` are strings.
|
|
485
|
-
- `className` or `testId` options. The toast root gets `data-testid` equal to its `id`, so pass `id` to locate it in tests.
|
|
486
|
-
- An exported duration constant. Use the literals 5000 and 10000.
|
|
487
|
-
|
|
488
|
-
## Related
|
|
489
|
-
|
|
490
|
-
- [Confirmation dialogs](./confirmation-dialogs.md): the dialog before most toasts.
|
|
491
|
-
- [Settings page](./settings-page.md): autosave fires a "<Field> updated" toast.
|
|
492
|
-
- [Create and edit forms](./create-edit-forms.md): the create toast with a next-step action.
|
|
493
|
-
- [Layering](../foundations/layering.md): why toasts paint above drawers and dialogs.
|