@centreon/ui 23.10.32 → 23.10.34-MON-19940-Add-testIds-cloud-notifications.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.
- package/package.json +12 -2
- package/src/Dashboard/DashboardLayout.stories.tsx +3 -5
- package/src/Dashboard/Layout.tsx +4 -4
- package/src/Dashboard/utils.ts +28 -28
- package/src/Dialog/index.tsx +20 -1
- package/src/ThemeProvider/index.tsx +6 -5
- package/src/ThemeProvider/palettes.ts +389 -215
- package/src/api/TestQueryProvider.tsx +2 -1
- package/src/api/useFetchQuery/index.ts +8 -7
- package/src/api/useMutationQuery/index.ts +11 -10
- package/src/base/tokens/README.md +3 -0
- package/src/base/tokens/source/$metadata.json +5 -0
- package/src/base/tokens/source/base.json +142 -0
- package/src/base/tokens/themes/base.tokens.d.ts +38 -0
- package/src/base/tokens/themes/base.tokens.json +695 -0
- package/src/base/tokens/themes/base.tokens.ts +38 -0
- package/src/base/tokens/themes/ui-dark.tokens.d.ts +38 -0
- package/src/base/tokens/themes/ui-dark.tokens.json +695 -0
- package/src/base/tokens/themes/ui-dark.tokens.ts +38 -0
- package/src/base/tokens/themes/ui-light.tokens.d.ts +38 -0
- package/src/base/tokens/themes/ui-light.tokens.json +695 -0
- package/src/base/tokens/themes/ui-light.tokens.ts +38 -0
- package/src/components/Button/Button.styles.ts +17 -3
- package/src/components/Button/Button.tsx +6 -3
- package/src/components/Button/Icon/IconButton.styles.ts +9 -2
- package/src/components/DataTable/DataTable.stories.tsx +9 -0
- package/src/components/DataTable/DataTable.styles.ts +5 -0
- package/src/components/DataTable/DataTable.tsx +8 -6
- package/src/components/DataTable/EmptyState/DataTableEmptyState.tsx +4 -1
- package/src/components/DataTable/Item/DataTableItem.styles.ts +5 -2
- package/src/components/DataTable/Item/DataTableItem.tsx +36 -18
- package/src/components/Header/Header.styles.ts +0 -27
- package/src/components/Header/PageHeader/PageHeader.stories.tsx +88 -0
- package/src/components/Header/PageHeader/PageHeader.styles.ts +99 -0
- package/src/components/Header/PageHeader/PageHeader.tsx +15 -0
- package/src/components/Header/PageHeader/PageHeaderActions.tsx +17 -0
- package/src/components/Header/PageHeader/PageHeaderMain.tsx +15 -0
- package/src/components/Header/PageHeader/PageHeaderMenu.tsx +15 -0
- package/src/components/Header/PageHeader/PageHeaderTitle.tsx +47 -0
- package/src/components/Header/PageHeader/index.ts +12 -0
- package/src/components/Header/index.ts +1 -1
- package/src/components/Layout/AreaIndicator.styles.ts +33 -0
- package/src/components/Layout/AreaIndicator.tsx +35 -0
- package/src/components/Layout/PageLayout/PageLayout.stories.tsx +81 -0
- package/src/components/Layout/PageLayout/PageLayout.styles.ts +40 -0
- package/src/components/Layout/PageLayout/PageLayout.tsx +21 -0
- package/src/components/Layout/PageLayout/PageLayoutActions.tsx +15 -0
- package/src/components/Layout/PageLayout/PageLayoutBody.tsx +24 -0
- package/src/components/Layout/PageLayout/PageLayoutHeader.tsx +15 -0
- package/src/components/Layout/PageLayout/index.ts +10 -0
- package/src/components/Layout/index.ts +1 -0
- package/src/components/Menu/Button/MenuButton.stories.tsx +16 -0
- package/src/components/Menu/Button/MenuButton.styles.ts +27 -0
- package/src/components/Menu/Button/MenuButton.tsx +62 -0
- package/src/components/Menu/Button/index.ts +1 -0
- package/src/components/Menu/Menu.stories.tsx +71 -0
- package/src/components/Menu/Menu.styles.ts +70 -0
- package/src/components/Menu/Menu.tsx +25 -0
- package/src/components/Menu/MenuDivider.tsx +13 -0
- package/src/components/Menu/MenuItem.tsx +36 -0
- package/src/components/Menu/MenuItems.tsx +35 -0
- package/src/components/Menu/index.ts +12 -0
- package/src/components/Menu/useMenu.tsx +79 -0
- package/src/components/Modal/index.ts +2 -0
- package/src/components/Tooltip/TextOverflowTooltip/TextOverflowTooltip.stories.tsx +70 -0
- package/src/components/Tooltip/TextOverflowTooltip/TextOverflowTooltip.styles.ts +5 -0
- package/src/components/Tooltip/TextOverflowTooltip/TextOverflowTooltip.tsx +115 -0
- package/src/components/Tooltip/TextOverflowTooltip/index.tsx +1 -0
- package/src/components/Tooltip/Tooltip.stories.tsx +41 -0
- package/src/components/Tooltip/Tooltip.styles.ts +5 -0
- package/src/components/Tooltip/Tooltip.tsx +46 -0
- package/src/components/Tooltip/index.ts +1 -0
- package/src/components/index.ts +3 -0
- package/src/index.ts +0 -2
- package/src/screens/dashboard/DashboardsDetail.stories.tsx +108 -0
- package/src/screens/dashboard/DashboardsOverview.stories.tsx +110 -102
- package/src/styles/tokens/themes/_ui-dark.tokens.json +695 -0
- package/src/styles/tokens/themes/_ui-light.tokens.json +695 -0
- package/src/utils/index.ts +1 -1
- package/src/utils/sanitizedHTML.ts +1 -1
- package/src/utils/useResizeObserver.ts +6 -0
- package/test/setupTests.js +1 -1
- package/src/components/Header/Header.stories.tsx +0 -27
- package/src/components/Header/Header.tsx +0 -23
- package/src/layout/TiledListingPage/TiledListingActions.tsx +0 -15
- package/src/layout/TiledListingPage/TiledListingContent.tsx +0 -21
- package/src/layout/TiledListingPage/TiledListingList.tsx +0 -11
- package/src/layout/TiledListingPage/TiledListingPage.styles.ts +0 -16
- package/src/layout/TiledListingPage/TiledListingPage.tsx +0 -15
- package/src/layout/TiledListingPage/index.ts +0 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@centreon/ui",
|
|
3
|
-
"version": "23.10.
|
|
3
|
+
"version": "23.10.34-MON-19940-Add-testIds-cloud-notifications.0",
|
|
4
4
|
"description": "Centreon UI Components",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"eslint": "eslint ./src --ext .js,.jsx,.ts,.tsx --max-warnings 0",
|
|
@@ -8,10 +8,12 @@
|
|
|
8
8
|
"storybook": "storybook dev -p 9001 -c .storybook",
|
|
9
9
|
"build:storybook": "storybook build -c .storybook -o .out",
|
|
10
10
|
"test": "jest",
|
|
11
|
+
"test:storybook:local": "test-storybook --url http://127.0.0.1:9001",
|
|
11
12
|
"test:ci": "jest --silent --reporter=jest-junit",
|
|
12
13
|
"cypress:ui": "cypress open --component --browser=chrome",
|
|
13
14
|
"cypress:cli:updateSnapshot": "pnpm cypress:cli --env updateSnapshots=true",
|
|
14
|
-
"cypress:cli": "cypress run --component --browser=chrome"
|
|
15
|
+
"cypress:cli": "cypress run --component --browser=chrome",
|
|
16
|
+
"tokens:transform": "TS_NODE_PROJECT=tsconfig.node.json ts-node style-dictionary.transform.ts"
|
|
15
17
|
},
|
|
16
18
|
"sideEffects": false,
|
|
17
19
|
"repository": {
|
|
@@ -54,18 +56,23 @@
|
|
|
54
56
|
"@storybook/addon-interactions": "^7.0.9",
|
|
55
57
|
"@storybook/addon-styling": "^1.0.6",
|
|
56
58
|
"@storybook/builder-vite": "^7.0.9",
|
|
59
|
+
"@storybook/jest": "^0.1.0",
|
|
57
60
|
"@storybook/manager-api": "^7.0.9",
|
|
58
61
|
"@storybook/mdx2-csf": "^1.0.0",
|
|
59
62
|
"@storybook/preview-api": "^7.0.9",
|
|
60
63
|
"@storybook/react": "^7.0.9",
|
|
61
64
|
"@storybook/react-vite": "^7.0.9",
|
|
65
|
+
"@storybook/test-runner": "^0.10.0",
|
|
66
|
+
"@storybook/testing-library": "^0.1.0",
|
|
62
67
|
"@storybook/theming": "^7.0.9",
|
|
63
68
|
"@testing-library/cypress": "^8.0.7",
|
|
69
|
+
"@testing-library/jest-dom": "^5.16.5",
|
|
64
70
|
"@testing-library/react": "^13.4.0",
|
|
65
71
|
"@testing-library/react-hooks": "^8.0.1",
|
|
66
72
|
"@types/jest": "^27.5.0",
|
|
67
73
|
"@types/ramda": "^0.28.12",
|
|
68
74
|
"@types/react": "^18.0.26",
|
|
75
|
+
"@types/testing-library__jest-dom": "^5.14.6",
|
|
69
76
|
"@vitejs/plugin-react": "^4.0.0",
|
|
70
77
|
"@vitejs/plugin-react-swc": "^3.3.0",
|
|
71
78
|
"axios-mock-adapter": "^1.21.4",
|
|
@@ -83,6 +90,9 @@
|
|
|
83
90
|
"storybook": "^7.0.9",
|
|
84
91
|
"storybook-addon-mock": "^4.0.0",
|
|
85
92
|
"storybook-dark-mode": "^3.0.0",
|
|
93
|
+
"style-dictionary": "^3.8.0",
|
|
94
|
+
"ts-node": "^10.9.1",
|
|
95
|
+
"use-resize-observer": "^9.1.0",
|
|
86
96
|
"vite": "^4.3.5",
|
|
87
97
|
"vite-plugin-svgr": "^3.2.0",
|
|
88
98
|
"vite-plugin-turbosnap": "^1.0.2"
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
|
|
3
1
|
import { ComponentMeta } from '@storybook/react';
|
|
4
2
|
import { Layout } from 'react-grid-layout';
|
|
5
3
|
|
|
@@ -62,18 +60,18 @@ const generateLayout = (maxElements: number): Array<CustomLayout> => {
|
|
|
62
60
|
};
|
|
63
61
|
|
|
64
62
|
interface DashboardTemplateProps {
|
|
65
|
-
header?:
|
|
63
|
+
header?: JSX.Element;
|
|
66
64
|
layout?: Array<CustomLayout>;
|
|
67
65
|
}
|
|
68
66
|
|
|
69
|
-
const Header = ():
|
|
67
|
+
const Header = (): JSX.Element => (
|
|
70
68
|
<Typography variant="body2">The title</Typography>
|
|
71
69
|
);
|
|
72
70
|
|
|
73
71
|
const DashboardTemplate = ({
|
|
74
72
|
header,
|
|
75
73
|
layout = dashboardLayout
|
|
76
|
-
}: DashboardTemplateProps):
|
|
74
|
+
}: DashboardTemplateProps): JSX.Element => (
|
|
77
75
|
<DashboardLayout.Layout<CustomLayout> layout={layout}>
|
|
78
76
|
{layout.map(({ i, content, shouldUseFluidTypography }) => (
|
|
79
77
|
<DashboardLayout.Item header={header} key={i}>
|
package/src/Dashboard/Layout.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
import { Responsive } from '@visx/visx';
|
|
4
4
|
import GridLayout, { Layout, WidthProvider } from 'react-grid-layout';
|
|
@@ -14,7 +14,7 @@ const ReactGridLayout = WidthProvider(GridLayout);
|
|
|
14
14
|
|
|
15
15
|
interface DashboardLayoutProps<T> {
|
|
16
16
|
changeLayout?: (newLayout: Array<Layout>) => void;
|
|
17
|
-
children: Array<
|
|
17
|
+
children: Array<JSX.Element>;
|
|
18
18
|
displayGrid?: boolean;
|
|
19
19
|
layout: Array<T>;
|
|
20
20
|
}
|
|
@@ -24,7 +24,7 @@ const Layout = <T extends Layout>({
|
|
|
24
24
|
changeLayout,
|
|
25
25
|
displayGrid,
|
|
26
26
|
layout
|
|
27
|
-
}: DashboardLayoutProps<T>):
|
|
27
|
+
}: DashboardLayoutProps<T>): JSX.Element => {
|
|
28
28
|
const { classes } = useDashboardLayoutStyles();
|
|
29
29
|
|
|
30
30
|
const [columns, setColumns] = useState(getColumnsFromScreenSize());
|
|
@@ -45,7 +45,7 @@ const Layout = <T extends Layout>({
|
|
|
45
45
|
Component: (
|
|
46
46
|
<ResponsiveHeight>
|
|
47
47
|
<Responsive.ParentSize>
|
|
48
|
-
{({ width, height }):
|
|
48
|
+
{({ width, height }): JSX.Element => (
|
|
49
49
|
<div className={classes.container}>
|
|
50
50
|
{displayGrid && (
|
|
51
51
|
<Grid columns={columns} height={height} width={width} />
|
package/src/Dashboard/utils.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { lt } from 'ramda';
|
|
2
|
-
import { Layout } from 'react-grid-layout';
|
|
3
|
-
|
|
4
|
-
export const maxColumns = 12;
|
|
5
|
-
const minColumns = 1;
|
|
6
|
-
const breakpoint = 768;
|
|
7
|
-
|
|
8
|
-
export const rowHeight = 64;
|
|
9
|
-
|
|
10
|
-
export const getIsSmallScreenSize = (): boolean =>
|
|
11
|
-
lt(window.innerWidth, breakpoint);
|
|
12
|
-
|
|
13
|
-
export const getColumnsFromScreenSize = (): number =>
|
|
14
|
-
getIsSmallScreenSize() ? minColumns : maxColumns;
|
|
15
|
-
|
|
16
|
-
export const getLayout = <T extends Layout>(layout: Array<T>): Array<T> => {
|
|
17
|
-
const isSmallScreenSize = getIsSmallScreenSize();
|
|
18
|
-
if (!isSmallScreenSize) {
|
|
19
|
-
return layout;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return layout
|
|
23
|
-
.sort((a, b) => a.x + a.y - (b.x + b.y))
|
|
24
|
-
.map((widget) => ({
|
|
25
|
-
...widget,
|
|
26
|
-
w: 1
|
|
27
|
-
}));
|
|
28
|
-
};
|
|
1
|
+
import { lt } from 'ramda';
|
|
2
|
+
import { Layout } from 'react-grid-layout';
|
|
3
|
+
|
|
4
|
+
export const maxColumns = 12;
|
|
5
|
+
const minColumns = 1;
|
|
6
|
+
const breakpoint = 768;
|
|
7
|
+
|
|
8
|
+
export const rowHeight = 64;
|
|
9
|
+
|
|
10
|
+
export const getIsSmallScreenSize = (): boolean =>
|
|
11
|
+
lt(window.innerWidth, breakpoint);
|
|
12
|
+
|
|
13
|
+
export const getColumnsFromScreenSize = (): number =>
|
|
14
|
+
getIsSmallScreenSize() ? minColumns : maxColumns;
|
|
15
|
+
|
|
16
|
+
export const getLayout = <T extends Layout>(layout: Array<T>): Array<T> => {
|
|
17
|
+
const isSmallScreenSize = getIsSmallScreenSize();
|
|
18
|
+
if (!isSmallScreenSize) {
|
|
19
|
+
return layout;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return layout
|
|
23
|
+
.sort((a, b) => a.x + a.y - (b.x + b.y))
|
|
24
|
+
.map((widget) => ({
|
|
25
|
+
...widget,
|
|
26
|
+
w: 1
|
|
27
|
+
}));
|
|
28
|
+
};
|
package/src/Dialog/index.tsx
CHANGED
|
@@ -28,12 +28,18 @@ const useStyles = makeStyles<StylesProps>()((theme, { contentWidth }) => ({
|
|
|
28
28
|
}
|
|
29
29
|
}));
|
|
30
30
|
|
|
31
|
+
interface DialogDataTestId {
|
|
32
|
+
dataTestIdCanceledButton?: string;
|
|
33
|
+
dataTestIdConfirmButton?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
31
36
|
export type Props = {
|
|
32
37
|
cancelDisabled?: boolean;
|
|
33
38
|
children?: ReactNode;
|
|
34
39
|
className?: string;
|
|
35
40
|
confirmDisabled?: boolean;
|
|
36
41
|
contentWidth?: number;
|
|
42
|
+
dataTestId?: DialogDataTestId;
|
|
37
43
|
dialogActionsClassName?: string;
|
|
38
44
|
dialogConfirmButtonClassName?: string;
|
|
39
45
|
dialogContentClassName?: string;
|
|
@@ -62,6 +68,7 @@ const Dialog = ({
|
|
|
62
68
|
confirmDisabled = false,
|
|
63
69
|
cancelDisabled = false,
|
|
64
70
|
submitting = false,
|
|
71
|
+
dataTestId,
|
|
65
72
|
dialogPaperClassName,
|
|
66
73
|
dialogTitleClassName,
|
|
67
74
|
dialogContentClassName,
|
|
@@ -71,6 +78,12 @@ const Dialog = ({
|
|
|
71
78
|
}: Props): JSX.Element => {
|
|
72
79
|
const { classes, cx } = useStyles({ contentWidth });
|
|
73
80
|
|
|
81
|
+
const dataTestIdConfirmButton =
|
|
82
|
+
dataTestId?.dataTestIdConfirmButton ?? labelConfirm;
|
|
83
|
+
|
|
84
|
+
const dataTestIdCanceledButton =
|
|
85
|
+
dataTestId?.dataTestIdCanceledButton ?? labelCancel;
|
|
86
|
+
|
|
74
87
|
return (
|
|
75
88
|
<MuiDialog
|
|
76
89
|
PaperProps={{
|
|
@@ -93,7 +106,12 @@ const Dialog = ({
|
|
|
93
106
|
)}
|
|
94
107
|
<DialogActions className={dialogActionsClassName}>
|
|
95
108
|
{onCancel && (
|
|
96
|
-
<Button
|
|
109
|
+
<Button
|
|
110
|
+
color="primary"
|
|
111
|
+
data-testid={dataTestIdCanceledButton}
|
|
112
|
+
disabled={cancelDisabled}
|
|
113
|
+
onClick={onCancel}
|
|
114
|
+
>
|
|
97
115
|
{labelCancel}
|
|
98
116
|
</Button>
|
|
99
117
|
)}
|
|
@@ -101,6 +119,7 @@ const Dialog = ({
|
|
|
101
119
|
aria-label={labelConfirm || ''}
|
|
102
120
|
className={dialogConfirmButtonClassName}
|
|
103
121
|
color="primary"
|
|
122
|
+
data-testid={dataTestIdConfirmButton}
|
|
104
123
|
disabled={confirmDisabled}
|
|
105
124
|
endIcon={submitting && <CircularProgress size={15} />}
|
|
106
125
|
onClick={onConfirm}
|
|
@@ -5,12 +5,12 @@ import { CSSInterpolation } from 'tss-react';
|
|
|
5
5
|
import { equals } from 'ramda';
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
|
-
|
|
9
|
-
Theme,
|
|
10
|
-
StyledEngineProvider,
|
|
8
|
+
ButtonProps,
|
|
11
9
|
createTheme,
|
|
12
10
|
InputBaseProps,
|
|
13
|
-
|
|
11
|
+
StyledEngineProvider,
|
|
12
|
+
Theme,
|
|
13
|
+
ThemeProvider as MuiThemeProvider
|
|
14
14
|
} from '@mui/material';
|
|
15
15
|
import CssBaseline from '@mui/material/CssBaseline';
|
|
16
16
|
import { autocompleteClasses } from '@mui/material/Autocomplete';
|
|
@@ -177,6 +177,7 @@ export const getTheme = (mode: ThemeMode): ThemeOptions => ({
|
|
|
177
177
|
padding: 0;
|
|
178
178
|
width: 100%;
|
|
179
179
|
height: 100%;
|
|
180
|
+
text-rendering: optimizeLegibility;
|
|
180
181
|
}
|
|
181
182
|
body {
|
|
182
183
|
background-color: ${theme.palette.background.paper};
|
|
@@ -205,7 +206,7 @@ export const getTheme = (mode: ThemeMode): ThemeOptions => ({
|
|
|
205
206
|
@font-face {
|
|
206
207
|
font-family: 'Roboto';
|
|
207
208
|
font-style: normal;
|
|
208
|
-
font-weight:
|
|
209
|
+
font-weight: 700;
|
|
209
210
|
src: local('Roboto'), local('Roboto-Bold'), url(${RobotoBoldWoff2}) format('woff2');
|
|
210
211
|
}
|
|
211
212
|
`
|