@centreon/ui 24.4.38 → 24.4.39

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 (108) hide show
  1. package/package.json +19 -14
  2. package/public/mockServiceWorker.js +1 -1
  3. package/src/Button/Icon/index.tsx +1 -1
  4. package/src/Button/Save/StartIcon.tsx +3 -3
  5. package/src/Button/Save/index.tsx +9 -5
  6. package/src/Checkbox/Checkbox.tsx +2 -2
  7. package/src/Checkbox/CheckboxGroup/index.tsx +2 -2
  8. package/src/Dashboard/Item.tsx +1 -1
  9. package/src/Dashboard/Layout.tsx +2 -2
  10. package/src/Dialog/index.tsx +1 -1
  11. package/src/FallbackPage/FallbackPage.tsx +3 -3
  12. package/src/FileDropZone/index.tsx +3 -1
  13. package/src/Form/Form.cypress.spec.tsx +133 -0
  14. package/src/Form/Inputs/CheckboxGroup.tsx +1 -4
  15. package/src/Form/Inputs/List/Content.tsx +62 -0
  16. package/src/Form/Inputs/List/List.styles.ts +29 -0
  17. package/src/Form/Inputs/List/List.tsx +58 -0
  18. package/src/Form/Inputs/List/useList.ts +81 -0
  19. package/src/Form/Inputs/index.tsx +3 -1
  20. package/src/Form/Inputs/models.ts +9 -1
  21. package/src/Graph/LineChart/BasicComponents/Lines/Threshold/Circle.tsx +2 -2
  22. package/src/Graph/LineChart/BasicComponents/Lines/Threshold/index.tsx +5 -4
  23. package/src/Graph/LineChart/BasicComponents/Thresholds.tsx +2 -2
  24. package/src/Graph/LineChart/BasicComponents/useFilterLines.ts +1 -1
  25. package/src/Graph/LineChart/InteractiveComponents/AnchorPoint/GuidingLines.tsx +2 -2
  26. package/src/Graph/LineChart/InteractiveComponents/Annotations/Annotation/index.tsx +2 -3
  27. package/src/Graph/LineChart/InteractiveComponents/Annotations/EventAnnotations.tsx +1 -1
  28. package/src/Graph/LineChart/Legend/index.tsx +7 -8
  29. package/src/Graph/LineChart/Legend/useLegend.ts +3 -3
  30. package/src/Graph/LineChart/LineChart.tsx +4 -1
  31. package/src/Graph/LineChart/helpers/doc.ts +16 -13
  32. package/src/Graph/LineChart/helpers/index.ts +1 -1
  33. package/src/Graph/LineChart/index.stories.tsx +4 -2
  34. package/src/Graph/LineChart/index.tsx +4 -1
  35. package/src/Graph/SingleBar/Thresholds.tsx +2 -2
  36. package/src/Graph/Text/Text.stories.tsx +60 -4
  37. package/src/Graph/common/timeSeries/index.ts +3 -3
  38. package/src/InputField/Select/Autocomplete/Connected/index.tsx +10 -7
  39. package/src/InputField/Select/Autocomplete/Draggable/SortableList.tsx +1 -1
  40. package/src/InputField/Select/Autocomplete/Draggable/SortableListContent.tsx +1 -1
  41. package/src/InputField/Select/Autocomplete/Draggable/index.tsx +1 -1
  42. package/src/InputField/Select/Autocomplete/index.tsx +121 -115
  43. package/src/InputField/Select/IconPopover/index.tsx +2 -2
  44. package/src/InputField/Select/index.tsx +1 -1
  45. package/src/InputField/Text/index.tsx +2 -2
  46. package/src/Listing/Cell/DataCell.tsx +15 -1
  47. package/src/Listing/Header/ListingHeader.tsx +1 -1
  48. package/src/Listing/Listing.styles.ts +2 -3
  49. package/src/Listing/index.stories.tsx +12 -1
  50. package/src/Listing/index.tsx +1 -2
  51. package/src/Module/Module.cypress.spec.tsx +129 -0
  52. package/src/Module/index.tsx +2 -4
  53. package/src/RichTextEditor/RichTextEditor.tsx +12 -1
  54. package/src/SortableItems/index.tsx +2 -7
  55. package/src/ThemeProvider/index.tsx +24 -0
  56. package/src/TimePeriods/CustomTimePeriod/CompactCustomTimePeriod.styles.ts +6 -7
  57. package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/PickersStartEndDate.tsx +8 -3
  58. package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/models.ts +0 -2
  59. package/src/TimePeriods/DateTimePickerInput.tsx +56 -19
  60. package/src/TimePeriods/ResolutionTimePeriod.cypress.spec.tsx +12 -9
  61. package/src/TimePeriods/TimePeriods.cypress.spec.tsx +9 -33
  62. package/src/TimePeriods/helpers/index.ts +1 -1
  63. package/src/TimePeriods/index.stories.tsx +12 -4
  64. package/src/TimePeriods/index.tsx +2 -2
  65. package/src/api/QueryProvider.tsx +1 -1
  66. package/src/api/TestQueryProvider.tsx +1 -1
  67. package/src/api/useFetchQuery/index.ts +27 -23
  68. package/src/api/useGraphQuery/index.ts +26 -5
  69. package/src/api/useGraphQuery/models.ts +5 -0
  70. package/src/api/useMutationQuery/index.ts +45 -21
  71. package/src/components/Button/Icon/IconButton.tsx +6 -2
  72. package/src/components/CollapsibleItem/CollapsibleItem.cypress.spec.tsx +76 -0
  73. package/src/components/CollapsibleItem/CollapsibleItem.stories.tsx +26 -0
  74. package/src/components/CollapsibleItem/CollapsibleItem.tsx +43 -14
  75. package/src/components/CollapsibleItem/useCollapsibleItemStyles.ts +24 -1
  76. package/src/components/DataTable/DataListing.tsx +6 -0
  77. package/src/components/DataTable/DataTable.cypress.spec.tsx +193 -0
  78. package/src/components/DataTable/DataTable.stories.tsx +40 -0
  79. package/src/components/DataTable/DataTable.styles.ts +3 -0
  80. package/src/components/DataTable/DataTable.tsx +3 -3
  81. package/src/components/DataTable/Item/DataTableItem.styles.ts +7 -2
  82. package/src/components/DataTable/Item/DataTableItem.tsx +4 -4
  83. package/src/components/DataTable/index.ts +3 -1
  84. package/src/components/Form/Dashboard/DashboardForm.tsx +15 -12
  85. package/src/components/ItemComposition/Item.tsx +1 -1
  86. package/src/components/ItemComposition/ItemComposition.cypress.spec.tsx +116 -0
  87. package/src/components/ItemComposition/ItemComposition.styles.ts +8 -1
  88. package/src/components/ItemComposition/ItemComposition.tsx +26 -16
  89. package/src/components/Layout/PageLayout/PageLayout.tsx +1 -1
  90. package/src/components/Layout/PageLayout/PageLayoutActions.tsx +1 -0
  91. package/src/components/Layout/PageLayout/PageLayoutBody.tsx +1 -0
  92. package/src/components/Layout/PageLayout/PageLayoutHeader.tsx +5 -1
  93. package/src/components/Layout/PageLayout/PageQuickAccess.tsx +76 -0
  94. package/src/components/Layout/PageLayout/index.ts +3 -1
  95. package/src/components/Layout/PageLayout.cypress.spec.tsx +66 -0
  96. package/src/components/Modal/Modal.styles.ts +1 -1
  97. package/src/components/Tooltip/ConfirmationTooltip/ConfirmationTooltip.stories.tsx +3 -3
  98. package/src/components/Tooltip/ConfirmationTooltip/ConfirmationTooltip.tsx +1 -1
  99. package/src/components/Tooltip/ConfirmationTooltip/models.ts +1 -1
  100. package/src/index.ts +2 -2
  101. package/src/queryParameters/url/index.ts +5 -1
  102. package/src/utils/index.ts +2 -1
  103. package/src/utils/{useLicenseExpirationWarning.cypress.spec.tsx → useLicenseExpirationWarning.test.tsx} +48 -37
  104. package/src/utils/useLicenseExpirationWarning.ts +18 -18
  105. package/src/utils/usePluralizedTranslation.ts +21 -0
  106. package/src/screens/dashboard/DashboardsDetail.stories.tsx +0 -108
  107. package/src/screens/dashboard/DashboardsOverview.stories.tsx +0 -281
  108. package/src/utils/useDateTimePickerAdapter.ts +0 -309
@@ -1,6 +1,13 @@
1
1
  import dayjs from 'dayjs';
2
+ import { renderHook } from '@testing-library/react';
2
3
 
3
- import { TestQueryProvider, Method, SnackbarProvider } from '@centreon/ui';
4
+ import {
5
+ getFetchCall,
6
+ mockResponse,
7
+ resetMocks,
8
+ waitFor
9
+ } from '../../test/testRenderer';
10
+ import TestQueryProvider from '../api/TestQueryProvider';
4
11
 
5
12
  import { labelLicenseWarning } from './translatedLabel';
6
13
 
@@ -79,59 +86,63 @@ const getMockedResponse = (expirationDate): object => ({
79
86
  });
80
87
 
81
88
  const mockRequest = ({ expirationDate }: { expirationDate }): void => {
82
- cy.interceptAPIRequest({
83
- alias: 'getLicenseInformations',
84
- method: Method.GET,
85
- path: '**internal.php?object=centreon_module&action=list',
86
- response: getMockedResponse(expirationDate)
89
+ resetMocks();
90
+ mockResponse({
91
+ data: getMockedResponse(expirationDate)
87
92
  });
88
93
  };
89
94
 
90
- const TestComponent = (): JSX.Element => {
91
- useLicenseExpirationWarning({
92
- module: 'centreon-autodiscovery-server'
93
- });
95
+ const showMessage = jest.fn();
94
96
 
95
- return <div />;
96
- };
97
-
98
- const TestWithQueryProvider = (): JSX.Element => {
99
- return (
100
- <TestQueryProvider>
101
- <SnackbarProvider>
102
- <TestComponent />
103
- </SnackbarProvider>
104
- </TestQueryProvider>
105
- );
106
- };
97
+ jest.mock('../Snackbar/useSnackbar', () => ({
98
+ __esModule: true,
99
+ default: jest
100
+ .fn()
101
+ .mockImplementation(() => ({ showWarningMessage: showMessage }))
102
+ }));
107
103
 
108
104
  const initialize = (): void => {
109
- cy.viewport('macbook-13');
110
-
111
- cy.mount({
112
- Component: <TestWithQueryProvider />
113
- });
105
+ renderHook(
106
+ () =>
107
+ useLicenseExpirationWarning({
108
+ module: 'centreon-autodiscovery-server'
109
+ }),
110
+ {
111
+ wrapper: TestQueryProvider
112
+ }
113
+ );
114
114
  };
115
115
 
116
116
  const currentDate = dayjs();
117
117
 
118
118
  describe('License', () => {
119
- beforeEach(initialize);
120
-
121
119
  it('does not display any warning message when the license expires in more than 15 days from the current date', () => {
122
120
  mockRequest({ expirationDate: currentDate.add(20, 'day') });
121
+ initialize();
123
122
 
124
- cy.waitForRequest('@getLicenseInformations');
123
+ waitFor(() => {
124
+ expect(getFetchCall(0)).toEqual(
125
+ 'internal.php?object=centreon_module&action=list'
126
+ );
127
+ });
125
128
 
126
- cy.findByText(
127
- labelLicenseWarning('centreon-autodiscovery-server', 20)
128
- ).should('not.exist');
129
+ expect(showMessage).not.toHaveBeenCalled();
129
130
  });
131
+
130
132
  it('displays a warning message when the license expires within 15 days', () => {
131
133
  mockRequest({ expirationDate: currentDate.add(10.5, 'day') });
132
-
133
- cy.findByText(labelLicenseWarning('centreon-autodiscovery-server', 10));
134
-
135
- cy.makeSnapshot();
134
+ initialize();
135
+
136
+ waitFor(() => {
137
+ expect(getFetchCall(0)).toEqual(
138
+ 'internal.php?object=centreon_module&action=list'
139
+ );
140
+ });
141
+
142
+ waitFor(() => {
143
+ expect(showMessage).toHaveBeenCalledWith(
144
+ labelLicenseWarning('centreon-autodiscovery-server', 10)
145
+ );
146
+ });
136
147
  });
137
148
  });
@@ -19,7 +19,7 @@ export const useLicenseExpirationWarning = ({ module }: Props): void => {
19
19
  const { t } = useTranslation();
20
20
  const { showWarningMessage } = useSnackbar();
21
21
 
22
- const { fetchQuery } = useFetchQuery({
22
+ const { data } = useFetchQuery({
23
23
  getEndpoint: () => extensionsEndpoint,
24
24
  getQueryKey: () => [module]
25
25
  });
@@ -28,25 +28,25 @@ export const useLicenseExpirationWarning = ({ module }: Props): void => {
28
28
 
29
29
  const getExpirationDate = pipe(
30
30
  path(['result', 'module', 'entities']),
31
- find(propEq('id', module)),
31
+ find(propEq(module, 'id')),
32
32
  path(['license', 'expiration_date'])
33
33
  ) as (data) => string;
34
34
 
35
35
  useEffect(() => {
36
- fetchQuery().then((response) => {
37
- const expirationDate = getExpirationDate(response);
38
- if (isNil(expirationDate)) {
39
- return;
40
- }
41
-
42
- const daysUntilExpiration = dayjs(expirationDate).diff(
43
- currentDate,
44
- 'day'
45
- );
46
-
47
- if (lt(daysUntilExpiration, 15)) {
48
- showWarningMessage(t(labelLicenseWarning(module, daysUntilExpiration)));
49
- }
50
- });
51
- }, []);
36
+ if (isNil(data)) {
37
+ return;
38
+ }
39
+
40
+ const expirationDate = getExpirationDate(data);
41
+
42
+ if (isNil(expirationDate)) {
43
+ return;
44
+ }
45
+
46
+ const daysUntilExpiration = dayjs(expirationDate).diff(currentDate, 'day');
47
+
48
+ if (lt(daysUntilExpiration, 15)) {
49
+ showWarningMessage(t(labelLicenseWarning(module, daysUntilExpiration)));
50
+ }
51
+ }, [data]);
52
52
  };
@@ -0,0 +1,21 @@
1
+ import { useTranslation } from 'react-i18next';
2
+ import pluralize from 'pluralize';
3
+
4
+ interface TProps {
5
+ count: number;
6
+ label: string;
7
+ }
8
+
9
+ export const usePluralizedTranslation = (): {
10
+ pluralizedT: (props: TProps) => string;
11
+ } => {
12
+ const translation = useTranslation();
13
+
14
+ const pluralizedT = ({ label, count }: TProps): string => {
15
+ return pluralize(translation.t(label), count);
16
+ };
17
+
18
+ return {
19
+ pluralizedT
20
+ };
21
+ };
@@ -1,108 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-non-null-assertion */
2
- import React, { ReactElement } from 'react';
3
-
4
- import { Meta } from '@storybook/react';
5
-
6
- import {
7
- Add as AddIcon,
8
- Settings as SettingsIcon,
9
- Share as ShareIcon
10
- } from '@mui/icons-material';
11
-
12
- import {
13
- Button,
14
- IconButton,
15
- Menu,
16
- PageHeader,
17
- PageLayout
18
- } from '../../components';
19
-
20
- const meta: Meta = {
21
- args: {
22
- actions: {}
23
- },
24
- parameters: {
25
- layout: 'fullscreen'
26
- },
27
- title: 'screens/Dashboards detail'
28
- };
29
-
30
- export default meta;
31
-
32
- const DefaultView = (args): ReactElement => {
33
- const { data } = args;
34
-
35
- return (
36
- <PageLayout>
37
- <PageLayout.Header>
38
- <PageHeader>
39
- <PageHeader.Main>
40
- <PageHeader.Menu>
41
- <Menu>
42
- <Menu.Button />
43
- <Menu.Items>
44
- <Menu.Item>Menu Item</Menu.Item>
45
- <Menu.Item>Menu Item</Menu.Item>
46
- <Menu.Item>Menu Item</Menu.Item>
47
- <Menu.Divider />
48
- <Menu.Item>
49
- <Button
50
- icon={<AddIcon />}
51
- iconVariant="start"
52
- variant="ghost"
53
- >
54
- Add item
55
- </Button>
56
- </Menu.Item>
57
- </Menu.Items>
58
- </Menu>
59
- </PageHeader.Menu>
60
- <PageHeader.Title
61
- description={data.dashboard.description}
62
- title={data.dashboard.name}
63
- />
64
- </PageHeader.Main>
65
- </PageHeader>
66
- </PageLayout.Header>
67
- <PageLayout.Body>
68
- <PageLayout.Actions>
69
- <IconButton
70
- aria-label="edit"
71
- data-testid="edit"
72
- icon={<SettingsIcon />}
73
- size="small"
74
- variant="ghost"
75
- />
76
- <IconButton
77
- aria-label="share"
78
- data-testid="share"
79
- icon={<ShareIcon />}
80
- size="small"
81
- variant="ghost"
82
- />
83
- </PageLayout.Actions>
84
- </PageLayout.Body>
85
- </PageLayout>
86
- );
87
- };
88
-
89
- export const Default = {
90
- args: {
91
- data: {
92
- dashboard: {
93
- description:
94
- 'Description et culpa sit commodo ea enim excepteur elit. Velit irure velit tempor culpa commodo eu adipisicing eu proident ullamco.',
95
- id: 1,
96
- name: 'Dashboard 1'
97
- }
98
- }
99
- },
100
- render: DefaultView
101
- };
102
-
103
- export const AsEditLayoutState = {
104
- args: {
105
- ...Default.args
106
- },
107
- render: DefaultView
108
- };
@@ -1,281 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-non-null-assertion */
2
- import { useEffect } from 'react';
3
-
4
- import { Meta } from '@storybook/react';
5
- import { atom, useAtom } from 'jotai';
6
-
7
- import { Add as AddIcon } from '@mui/icons-material';
8
-
9
- import {
10
- Button,
11
- DashboardForm,
12
- DashboardFormProps,
13
- DataTable,
14
- Modal,
15
- PageHeader,
16
- PageLayout
17
- } from '../../components';
18
- import { Default as DashboardFormDefaultStory } from '../../components/Form/Dashboard/DashboardForm.stories';
19
-
20
- const meta: Meta = {
21
- args: {
22
- actions: {
23
- create: {
24
- label: 'Create a dashboard'
25
- }
26
- },
27
- deleteConfirmation: {
28
- labels: {
29
- actions: {
30
- cancel: 'Cancel',
31
- confirm: 'Delete'
32
- },
33
- description: (name) => (
34
- <>
35
- Are you sure you want to delete <strong>{name}</strong> ?
36
- </>
37
- ),
38
- title: 'Delete dashboard'
39
- }
40
- },
41
- form: {
42
- labels: {
43
- ...DashboardFormDefaultStory.args!.labels,
44
- title: {
45
- create: 'Create dashboard',
46
- update: 'Update dashboard'
47
- }
48
- }
49
- },
50
- list: {
51
- emptyState: {
52
- labels: {
53
- actions: {
54
- create: 'Create dashboard'
55
- },
56
- title: 'No dashboards found'
57
- }
58
- }
59
- },
60
- title: 'Dashboards overview'
61
- },
62
- parameters: {
63
- layout: 'fullscreen'
64
- },
65
- title: 'screens/Dashboards overview'
66
- };
67
-
68
- export default meta;
69
-
70
- interface dashboardItem {
71
- description: string;
72
- id: number;
73
- name: string;
74
- }
75
-
76
- const dialogStateAtom = atom<{
77
- item: dashboardItem | null;
78
- open: boolean;
79
- variant: DashboardFormProps['variant'];
80
- }>({
81
- item: null,
82
- open: false,
83
- variant: 'create'
84
- });
85
-
86
- const deleteDialogStateAtom = atom<{
87
- item: dashboardItem | null;
88
- open: boolean;
89
- }>({
90
- item: null,
91
- open: false
92
- });
93
-
94
- const dataDashboardsAtom = atom<Array<dashboardItem>>([]);
95
-
96
- const DefaultView = (args): JSX.Element => {
97
- const { data, title, actions, list, form, deleteConfirmation } = args;
98
- const [dialogState, setDialogState] = useAtom(dialogStateAtom);
99
- const [deleteDialogState, setDeleteDialogState] = useAtom(
100
- deleteDialogStateAtom
101
- );
102
- const [dataDashboards, setDataDashboards] = useAtom(dataDashboardsAtom);
103
-
104
- useEffect(() => {
105
- setDataDashboards(data.dashboards);
106
- }, [data.dashboards]);
107
-
108
- const createDashboard = (d): void => {
109
- const dashboard = { ...d };
110
- dashboard.id = dataDashboards.length
111
- ? Math.max(...dataDashboards.map((db) => db.id)) + 1
112
- : 0;
113
- setDataDashboards((prev) =>
114
- [...prev, dashboard].sort((a, b) => a.name.localeCompare(b.name))
115
- );
116
- setDialogState({ item: null, open: false, variant: 'create' });
117
- };
118
-
119
- const updateDashboard = (d): void => {
120
- setDataDashboards((prev) =>
121
- prev
122
- .map((dashboard) => (dashboard.id === d.id ? d : dashboard))
123
- .sort((a, b) => a.name.localeCompare(b.name))
124
- );
125
- setDialogState({ item: null, open: false, variant: 'update' });
126
- };
127
-
128
- const deleteDashboard = (id): void => {
129
- setDataDashboards((prev) =>
130
- prev.filter((dashboard) => dashboard.id !== id)
131
- );
132
- };
133
-
134
- return (
135
- <PageLayout>
136
- <PageLayout.Header>
137
- <PageHeader>
138
- <PageHeader.Main>
139
- <PageHeader.Title title={title} />
140
- </PageHeader.Main>
141
- </PageHeader>
142
- </PageLayout.Header>
143
- <PageLayout.Body>
144
- <PageLayout.Actions>
145
- {dataDashboards.length !== 0 && (
146
- <Button
147
- aria-label="add"
148
- icon={<AddIcon />}
149
- iconVariant="start"
150
- onClick={() =>
151
- setDialogState({ item: null, open: true, variant: 'create' })
152
- }
153
- >
154
- {actions.create.label}
155
- </Button>
156
- )}
157
- </PageLayout.Actions>
158
-
159
- <DataTable isEmpty={dataDashboards.length === 0}>
160
- {dataDashboards.length === 0 ? (
161
- <DataTable.EmptyState
162
- labels={list.emptyState.labels}
163
- onCreate={() =>
164
- setDialogState({
165
- item: null,
166
- open: true,
167
- variant: 'create'
168
- })
169
- }
170
- />
171
- ) : (
172
- dataDashboards.map((dashboard) => (
173
- <DataTable.Item
174
- hasActions
175
- hasCardAction
176
- description={dashboard.description}
177
- key={dashboard.id}
178
- title={dashboard.name}
179
- onDelete={() =>
180
- setDeleteDialogState({ item: dashboard, open: true })
181
- }
182
- onEdit={() =>
183
- setDialogState({
184
- item: dashboard,
185
- open: true,
186
- variant: 'update'
187
- })
188
- }
189
- />
190
- ))
191
- )}
192
- </DataTable>
193
- </PageLayout.Body>
194
-
195
- <Modal
196
- open={dialogState.open}
197
- onClose={() =>
198
- setDialogState({
199
- item: null,
200
- open: false,
201
- variant: dialogState.variant
202
- })
203
- }
204
- >
205
- <Modal.Header>
206
- {form.labels.title[dialogState.variant ?? 'create']}
207
- </Modal.Header>
208
- <Modal.Body>
209
- <DashboardForm
210
- labels={DashboardFormDefaultStory!.args!.labels!}
211
- resource={dialogState.item || undefined}
212
- variant={dialogState.variant}
213
- onCancel={() =>
214
- setDialogState({
215
- item: null,
216
- open: false,
217
- variant: dialogState.variant
218
- })
219
- }
220
- onSubmit={(values) =>
221
- dialogState.variant === 'create'
222
- ? createDashboard(values)
223
- : updateDashboard(values)
224
- }
225
- />
226
- </Modal.Body>
227
- </Modal>
228
- <Modal
229
- open={deleteDialogState.open}
230
- onClose={() =>
231
- setDeleteDialogState({
232
- ...deleteDialogState,
233
- open: false
234
- })
235
- }
236
- >
237
- <Modal.Header>{deleteConfirmation.labels.title}</Modal.Header>
238
- <Modal.Body>
239
- <p>
240
- {deleteConfirmation.labels.description(
241
- deleteDialogState.item?.name
242
- )}
243
- </p>
244
- </Modal.Body>
245
- <Modal.Actions
246
- isDanger
247
- labels={deleteConfirmation.labels.actions}
248
- onCancel={() => setDeleteDialogState({ item: null, open: false })}
249
- onConfirm={() => {
250
- deleteDashboard(deleteDialogState.item?.id);
251
- setDeleteDialogState({ item: null, open: false });
252
- }}
253
- />
254
- </Modal>
255
- </PageLayout>
256
- );
257
- };
258
-
259
- export const Default = {
260
- args: {
261
- data: {
262
- dashboards: [
263
- { description: 'Dashboard 1 description', id: 1, name: 'Dashboard 1' },
264
- { description: 'Dashboard 2 description', id: 2, name: 'Dashboard 2' },
265
- { description: 'Dashboard 3 description', id: 3, name: 'Dashboard 3' },
266
- { description: 'Dashboard 4 description', id: 4, name: 'Dashboard 4' },
267
- { description: 'Dashboard 5 description', id: 5, name: 'Dashboard 5' }
268
- ]
269
- }
270
- },
271
- render: DefaultView
272
- };
273
-
274
- export const AsInitialState = {
275
- args: {
276
- data: {
277
- dashboards: []
278
- }
279
- },
280
- render: DefaultView
281
- };