@centreon/ui 23.10.29 → 23.10.30-MON-19324-dashboard-section-navigation.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.
Files changed (86) hide show
  1. package/package.json +12 -2
  2. package/src/Dashboard/DashboardLayout.stories.tsx +3 -5
  3. package/src/Dashboard/Layout.tsx +4 -4
  4. package/src/Dashboard/utils.ts +28 -28
  5. package/src/ThemeProvider/index.tsx +6 -5
  6. package/src/ThemeProvider/palettes.ts +385 -208
  7. package/src/api/TestQueryProvider.tsx +2 -1
  8. package/src/api/useFetchQuery/index.ts +8 -7
  9. package/src/api/useMutationQuery/index.ts +11 -10
  10. package/src/base/tokens/README.md +3 -0
  11. package/src/base/tokens/source/$metadata.json +5 -0
  12. package/src/base/tokens/source/base.json +142 -0
  13. package/src/base/tokens/themes/base.tokens.d.ts +38 -0
  14. package/src/base/tokens/themes/base.tokens.json +695 -0
  15. package/src/base/tokens/themes/base.tokens.ts +38 -0
  16. package/src/base/tokens/themes/ui-dark.tokens.d.ts +38 -0
  17. package/src/base/tokens/themes/ui-dark.tokens.json +695 -0
  18. package/src/base/tokens/themes/ui-dark.tokens.ts +38 -0
  19. package/src/base/tokens/themes/ui-light.tokens.d.ts +38 -0
  20. package/src/base/tokens/themes/ui-light.tokens.json +695 -0
  21. package/src/base/tokens/themes/ui-light.tokens.ts +38 -0
  22. package/src/components/Button/Button.styles.ts +17 -3
  23. package/src/components/Button/Button.tsx +6 -3
  24. package/src/components/Button/Icon/IconButton.styles.ts +9 -2
  25. package/src/components/DataTable/DataTable.stories.tsx +9 -0
  26. package/src/components/DataTable/DataTable.styles.ts +5 -0
  27. package/src/components/DataTable/DataTable.tsx +8 -6
  28. package/src/components/DataTable/Item/DataTableItem.styles.ts +5 -2
  29. package/src/components/DataTable/Item/DataTableItem.tsx +36 -18
  30. package/src/components/Header/Header.styles.ts +0 -27
  31. package/src/components/Header/PageHeader/PageHeader.stories.tsx +88 -0
  32. package/src/components/Header/PageHeader/PageHeader.styles.ts +99 -0
  33. package/src/components/Header/PageHeader/PageHeader.tsx +15 -0
  34. package/src/components/Header/PageHeader/PageHeaderActions.tsx +17 -0
  35. package/src/components/Header/PageHeader/PageHeaderMain.tsx +15 -0
  36. package/src/components/Header/PageHeader/PageHeaderMenu.tsx +15 -0
  37. package/src/components/Header/PageHeader/PageHeaderTitle.tsx +44 -0
  38. package/src/components/Header/PageHeader/index.ts +12 -0
  39. package/src/components/Header/index.ts +1 -1
  40. package/src/components/Layout/AreaIndicator.styles.ts +33 -0
  41. package/src/components/Layout/AreaIndicator.tsx +35 -0
  42. package/src/components/Layout/PageLayout/PageLayout.stories.tsx +81 -0
  43. package/src/components/Layout/PageLayout/PageLayout.styles.ts +40 -0
  44. package/src/components/Layout/PageLayout/PageLayout.tsx +21 -0
  45. package/src/components/Layout/PageLayout/PageLayoutActions.tsx +15 -0
  46. package/src/components/Layout/PageLayout/PageLayoutBody.tsx +24 -0
  47. package/src/components/Layout/PageLayout/PageLayoutHeader.tsx +15 -0
  48. package/src/components/Layout/PageLayout/index.ts +10 -0
  49. package/src/components/Layout/index.ts +1 -0
  50. package/src/components/Menu/Button/MenuButton.stories.tsx +16 -0
  51. package/src/components/Menu/Button/MenuButton.styles.ts +27 -0
  52. package/src/components/Menu/Button/MenuButton.tsx +59 -0
  53. package/src/components/Menu/Button/index.ts +1 -0
  54. package/src/components/Menu/Menu.stories.tsx +71 -0
  55. package/src/components/Menu/Menu.styles.ts +70 -0
  56. package/src/components/Menu/Menu.tsx +25 -0
  57. package/src/components/Menu/MenuDivider.tsx +13 -0
  58. package/src/components/Menu/MenuItem.tsx +36 -0
  59. package/src/components/Menu/MenuItems.tsx +35 -0
  60. package/src/components/Menu/index.ts +12 -0
  61. package/src/components/Menu/useMenu.tsx +79 -0
  62. package/src/components/Modal/index.ts +2 -0
  63. package/src/components/Tooltip/TextOverflowTooltip/TextOverflowTooltip.stories.tsx +71 -0
  64. package/src/components/Tooltip/TextOverflowTooltip/TextOverflowTooltip.styles.ts +5 -0
  65. package/src/components/Tooltip/TextOverflowTooltip/TextOverflowTooltip.tsx +115 -0
  66. package/src/components/Tooltip/TextOverflowTooltip/index.tsx +1 -0
  67. package/src/components/Tooltip/Tooltip.stories.tsx +41 -0
  68. package/src/components/Tooltip/Tooltip.styles.ts +5 -0
  69. package/src/components/Tooltip/Tooltip.tsx +46 -0
  70. package/src/components/Tooltip/index.ts +1 -0
  71. package/src/components/index.ts +3 -0
  72. package/src/index.ts +0 -2
  73. package/src/screens/dashboard/DashboardsDetail.stories.tsx +108 -0
  74. package/src/screens/dashboard/DashboardsOverview.stories.tsx +110 -102
  75. package/src/utils/index.ts +1 -1
  76. package/src/utils/sanitizedHTML.ts +1 -1
  77. package/src/utils/useResizeObserver.ts +6 -0
  78. package/test/setupTests.js +3 -0
  79. package/src/components/Header/Header.stories.tsx +0 -27
  80. package/src/components/Header/Header.tsx +0 -23
  81. package/src/layout/TiledListingPage/TiledListingActions.tsx +0 -15
  82. package/src/layout/TiledListingPage/TiledListingContent.tsx +0 -21
  83. package/src/layout/TiledListingPage/TiledListingList.tsx +0 -11
  84. package/src/layout/TiledListingPage/TiledListingPage.styles.ts +0 -16
  85. package/src/layout/TiledListingPage/TiledListingPage.tsx +0 -15
  86. package/src/layout/TiledListingPage/index.ts +0 -4
@@ -11,16 +11,11 @@ import {
11
11
  DashboardForm,
12
12
  DashboardFormProps,
13
13
  DataTable,
14
- Header,
15
- Modal
14
+ Modal,
15
+ PageHeader,
16
+ PageLayout
16
17
  } from '../../components';
17
18
  import { Default as DashboardFormDefaultStory } from '../../components/Form/Dashboard/DashboardForm.stories';
18
- import {
19
- TiledListingActions,
20
- TiledListingContent,
21
- TiledListingList,
22
- TiledListingPage
23
- } from '../../layout/TiledListingPage';
24
19
 
25
20
  const meta: Meta = {
26
21
  args: {
@@ -64,7 +59,10 @@ const meta: Meta = {
64
59
  },
65
60
  title: 'Dashboards overview'
66
61
  },
67
- title: 'screens/Dashboards'
62
+ parameters: {
63
+ layout: 'fullscreen'
64
+ },
65
+ title: 'screens/Dashboards overview'
68
66
  };
69
67
 
70
68
  export default meta;
@@ -134,10 +132,16 @@ const DefaultView = (args): JSX.Element => {
134
132
  };
135
133
 
136
134
  return (
137
- <TiledListingPage>
138
- <Header title={title} />
139
- <TiledListingList>
140
- <TiledListingActions>
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>
141
145
  {dataDashboards.length !== 0 && (
142
146
  <Button
143
147
  aria-label="add"
@@ -150,101 +154,105 @@ const DefaultView = (args): JSX.Element => {
150
154
  {actions.create.label}
151
155
  </Button>
152
156
  )}
153
- </TiledListingActions>
154
- <TiledListingContent>
155
- <DataTable isEmpty={dataDashboards.length === 0}>
156
- {dataDashboards.length === 0 ? (
157
- <DataTable.EmptyState
158
- labels={list.emptyState.labels}
159
- onCreate={() =>
160
- setDialogState({ item: null, open: true, variant: 'create' })
161
- }
162
- />
163
- ) : (
164
- dataDashboards.map((dashboard) => (
165
- <DataTable.Item
166
- hasActions
167
- hasCardAction
168
- description={dashboard.description}
169
- key={dashboard.id}
170
- title={dashboard.name}
171
- onDelete={() =>
172
- setDeleteDialogState({ item: dashboard, open: true })
173
- }
174
- onEdit={() =>
175
- setDialogState({
176
- item: dashboard,
177
- open: true,
178
- variant: 'update'
179
- })
180
- }
181
- />
182
- ))
183
- )}
184
- </DataTable>
185
- </TiledListingContent>
186
- <Modal
187
- open={dialogState.open}
188
- onClose={() =>
189
- setDialogState({
190
- item: null,
191
- open: false,
192
- variant: dialogState.variant
193
- })
194
- }
195
- >
196
- <Modal.Header>
197
- {form.labels.title[dialogState.variant ?? 'create']}
198
- </Modal.Header>
199
- <Modal.Body>
200
- <DashboardForm
201
- labels={DashboardFormDefaultStory!.args!.labels!}
202
- resource={dialogState.item || undefined}
203
- variant={dialogState.variant}
204
- onCancel={() =>
157
+ </PageLayout.Actions>
158
+
159
+ <DataTable isEmpty={dataDashboards.length === 0}>
160
+ {dataDashboards.length === 0 ? (
161
+ <DataTable.EmptyState
162
+ labels={list.emptyState.labels}
163
+ onCreate={() =>
205
164
  setDialogState({
206
165
  item: null,
207
- open: false,
208
- variant: dialogState.variant
166
+ open: true,
167
+ variant: 'create'
209
168
  })
210
169
  }
211
- onSubmit={(values) =>
212
- dialogState.variant === 'create'
213
- ? createDashboard(values)
214
- : updateDashboard(values)
215
- }
216
170
  />
217
- </Modal.Body>
218
- </Modal>
219
- <Modal
220
- open={deleteDialogState.open}
221
- onClose={() =>
222
- setDeleteDialogState({
223
- ...deleteDialogState,
224
- open: false
225
- })
226
- }
227
- >
228
- <Modal.Header>{deleteConfirmation.labels.title}</Modal.Header>
229
- <Modal.Body>
230
- <p>
231
- {deleteConfirmation.labels.description(
232
- deleteDialogState.item?.name
233
- )}
234
- </p>
235
- </Modal.Body>
236
- <Modal.Actions
237
- isDanger
238
- labels={deleteConfirmation.labels.actions}
239
- onCancel={() => setDeleteDialogState({ item: null, open: false })}
240
- onConfirm={() => {
241
- deleteDashboard(deleteDialogState.item?.id);
242
- setDeleteDialogState({ item: null, open: false });
243
- }}
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
+ }
244
225
  />
245
- </Modal>
246
- </TiledListingList>
247
- </TiledListingPage>
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>
248
256
  );
249
257
  };
250
258
 
@@ -14,4 +14,4 @@ export * from './useMemoComponent';
14
14
  export * from './useThemeMode';
15
15
  export * from './useViewportIntersection';
16
16
  export * from './panelSize';
17
- export { default as sanitizedHTML } from './sanitizedHTML';
17
+ export * from './sanitizedHTML';
@@ -15,4 +15,4 @@ const sanitizedHTML = ({
15
15
  return ReactHtmlParser(sanitizedContent);
16
16
  };
17
17
 
18
- export default sanitizedHTML;
18
+ export { sanitizedHTML };
@@ -0,0 +1,6 @@
1
+ // https://github.com/ZeeCoder/use-resize-observer
2
+ import useResizeObserver from 'use-resize-observer';
3
+
4
+ export * from 'use-resize-observer';
5
+
6
+ export { useResizeObserver };
@@ -1,5 +1,8 @@
1
1
  /* eslint-disable no-underscore-dangle */
2
2
  /* eslint-disable no-undef */
3
+ // FIXME: testing library setup
4
+ // import '@testing-library/jest-dom';
5
+ // import '@testing-library/react';
3
6
  // import '@testing-library/jest-dom/extend-expect';
4
7
  import i18n from 'i18next';
5
8
  import { initReactI18next } from 'react-i18next';
@@ -1,27 +0,0 @@
1
- import { Meta, StoryObj } from '@storybook/react';
2
-
3
- import { Settings as SettingsIcon } from '@mui/icons-material';
4
-
5
- import { IconButton } from '../Button';
6
-
7
- import { Header } from './Header';
8
-
9
- const meta: Meta<typeof Header> = {
10
- component: Header
11
- };
12
-
13
- export default meta;
14
- type Story = StoryObj<typeof Header>;
15
-
16
- export const Default: Story = {
17
- args: {
18
- title: 'Header'
19
- }
20
- };
21
-
22
- export const WithNav: Story = {
23
- args: {
24
- nav: <IconButton icon={<SettingsIcon />} size="small" variant="ghost" />,
25
- title: 'Header with nav'
26
- }
27
- };
@@ -1,23 +0,0 @@
1
- import { ReactElement, ReactNode } from 'react';
2
-
3
- import { Typography as MuiTypography } from '@mui/material';
4
-
5
- import { useStyles } from './Header.styles';
6
-
7
- type HeaderProps = {
8
- nav?: ReactNode;
9
- title: string;
10
- };
11
-
12
- const Header = ({ title, nav }: HeaderProps): ReactElement => {
13
- const { classes } = useStyles();
14
-
15
- return (
16
- <header className={classes.header}>
17
- <MuiTypography variant="h1">{title}</MuiTypography>
18
- {nav && <nav>{nav}</nav>}
19
- </header>
20
- );
21
- };
22
-
23
- export { Header };
@@ -1,15 +0,0 @@
1
- import { ReactNode } from 'react';
2
-
3
- import { useTiledListingActionsStyles } from './TiledListingPage.styles';
4
-
5
- interface TiledListingActionsProps {
6
- children: Array<ReactNode> | ReactNode;
7
- }
8
-
9
- export const TiledListingActions = ({
10
- children
11
- }: TiledListingActionsProps): JSX.Element => {
12
- const { classes } = useTiledListingActionsStyles();
13
-
14
- return <div className={classes.actions}>{children}</div>;
15
- };
@@ -1,21 +0,0 @@
1
- import { ReactNode } from 'react';
2
-
3
- import Responsive from '../../Responsive';
4
-
5
- import { useTiledListingActionsStyles } from './TiledListingPage.styles';
6
-
7
- interface TiledListingContentProps {
8
- children: ReactNode;
9
- }
10
-
11
- export const TiledListingContent = ({
12
- children
13
- }: TiledListingContentProps): JSX.Element => {
14
- const { classes } = useTiledListingActionsStyles();
15
-
16
- return (
17
- <Responsive>
18
- <div className={classes.actions}>{children}</div>
19
- </Responsive>
20
- );
21
- };
@@ -1,11 +0,0 @@
1
- import { ReactNode } from 'react';
2
-
3
- interface TiledListingListProps {
4
- children: Array<ReactNode>;
5
- }
6
-
7
- export const TiledListingList = ({
8
- children
9
- }: TiledListingListProps): JSX.Element => {
10
- return <div>{children}</div>;
11
- };
@@ -1,16 +0,0 @@
1
- import { makeStyles } from 'tss-react/mui';
2
-
3
- export const useTiledListPageStyles = makeStyles()((theme) => ({
4
- listPage: {
5
- display: 'flex',
6
- flexDirection: 'column',
7
- height: '100%',
8
- padding: theme.spacing(1.5)
9
- }
10
- }));
11
-
12
- export const useTiledListingActionsStyles = makeStyles()((theme) => ({
13
- actions: {
14
- paddingBottom: theme.spacing(2.5)
15
- }
16
- }));
@@ -1,15 +0,0 @@
1
- import { ReactNode } from 'react';
2
-
3
- import { useTiledListPageStyles } from './TiledListingPage.styles';
4
-
5
- interface TiledListingPageProps {
6
- children: Array<ReactNode>;
7
- }
8
-
9
- export const TiledListingPage = ({
10
- children
11
- }: TiledListingPageProps): JSX.Element => {
12
- const { classes } = useTiledListPageStyles();
13
-
14
- return <div className={classes.listPage}>{children}</div>;
15
- };
@@ -1,4 +0,0 @@
1
- export * from './TiledListingPage';
2
- export * from './TiledListingActions';
3
- export * from './TiledListingList';
4
- export * from './TiledListingContent';