@centreon/ui 24.4.48 → 24.4.50
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 +36 -29
- package/public/mockServiceWorker.js +1 -1
- package/src/Button/Icon/index.tsx +1 -1
- package/src/Button/Save/StartIcon.tsx +3 -3
- package/src/Button/Save/index.tsx +9 -5
- package/src/Checkbox/Checkbox.tsx +2 -2
- package/src/Checkbox/CheckboxGroup/index.tsx +2 -2
- package/src/Dashboard/Item.tsx +1 -1
- package/src/Dashboard/Layout.tsx +2 -2
- package/src/Dialog/Confirm/index.tsx +10 -2
- package/src/Dialog/index.tsx +9 -2
- package/src/FallbackPage/FallbackPage.tsx +3 -3
- package/src/FileDropZone/index.tsx +3 -1
- package/src/Form/Form.cypress.spec.tsx +133 -0
- package/src/Form/Inputs/List/Content.tsx +62 -0
- package/src/Form/Inputs/List/List.styles.ts +29 -0
- package/src/Form/Inputs/List/List.tsx +58 -0
- package/src/Form/Inputs/List/useList.ts +81 -0
- package/src/Form/Inputs/index.tsx +3 -1
- package/src/Form/Inputs/models.ts +9 -1
- package/src/Graph/BarStack/BarStack.cypress.spec.tsx +154 -0
- package/src/Graph/BarStack/BarStack.stories.tsx +123 -0
- package/src/Graph/BarStack/BarStack.styles.ts +36 -0
- package/src/Graph/BarStack/BarStack.tsx +14 -0
- package/src/Graph/BarStack/ResponsiveBarStack.tsx +208 -0
- package/src/Graph/BarStack/index.ts +1 -0
- package/src/Graph/BarStack/models.ts +19 -0
- package/src/Graph/BarStack/useResponsiveBarStack.ts +139 -0
- package/src/Graph/Gauge/Gauge.cypress.spec.tsx +102 -0
- package/src/Graph/Gauge/Gauge.tsx +1 -1
- package/src/Graph/HeatMap/HeatMap.cypress.spec.tsx +145 -0
- package/src/Graph/HeatMap/HeatMap.stories.tsx +0 -25
- package/src/Graph/HeatMap/ResponsiveHeatMap.tsx +8 -2
- package/src/Graph/Legend/Legend.tsx +21 -0
- package/src/Graph/Legend/index.ts +1 -0
- package/src/Graph/Legend/models.ts +11 -0
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/Circle.tsx +2 -2
- package/src/Graph/LineChart/BasicComponents/Thresholds.tsx +2 -2
- package/src/Graph/LineChart/BasicComponents/useFilterLines.ts +1 -1
- package/src/Graph/LineChart/InteractiveComponents/AnchorPoint/GuidingLines.tsx +2 -2
- package/src/Graph/LineChart/InteractiveComponents/Annotations/EventAnnotations.tsx +1 -1
- package/src/Graph/LineChart/Legend/Legend.styles.ts +1 -1
- package/src/Graph/LineChart/Legend/LegendHeader.tsx +1 -1
- package/src/Graph/LineChart/Legend/useInteractiveValues.ts +2 -2
- package/src/Graph/LineChart/Legend/useLegend.ts +3 -3
- package/src/Graph/LineChart/helpers/doc.ts +16 -13
- package/src/Graph/LineChart/helpers/index.ts +1 -1
- package/src/Graph/LineChart/index.stories.tsx +4 -2
- package/src/Graph/LineChart/index.tsx +1 -1
- package/src/Graph/PieChart/PieChart.cypress.spec.tsx +169 -0
- package/src/Graph/PieChart/PieChart.stories.tsx +194 -0
- package/src/Graph/PieChart/PieChart.styles.ts +39 -0
- package/src/Graph/PieChart/PieChart.tsx +14 -0
- package/src/Graph/PieChart/ResponsivePie.tsx +251 -0
- package/src/Graph/PieChart/index.ts +1 -0
- package/src/Graph/PieChart/models.ts +19 -0
- package/src/Graph/PieChart/useResponsivePie.ts +86 -0
- package/src/Graph/SingleBar/SingleBar.cypress.spec.tsx +121 -0
- package/src/Graph/SingleBar/Thresholds.tsx +2 -2
- package/src/Graph/Text/Text.cypress.spec.tsx +101 -0
- package/src/Graph/Text/Text.stories.tsx +60 -4
- package/src/Graph/Text/Text.tsx +1 -1
- package/src/Graph/common/testUtils.ts +71 -0
- package/src/Graph/common/timeSeries/index.ts +22 -14
- package/src/Graph/common/utils.ts +19 -0
- package/src/Graph/index.ts +3 -0
- package/src/Graph/translatedLabels.ts +1 -0
- package/src/InputField/Select/Autocomplete/Connected/index.tsx +10 -7
- package/src/InputField/Select/Autocomplete/Draggable/SortableList.tsx +1 -1
- package/src/InputField/Select/Autocomplete/Draggable/SortableListContent.tsx +1 -1
- package/src/InputField/Select/Autocomplete/Draggable/index.tsx +1 -1
- package/src/InputField/Select/Autocomplete/index.tsx +128 -116
- package/src/InputField/Select/IconPopover/index.tsx +2 -2
- package/src/InputField/Select/index.tsx +1 -1
- package/src/InputField/Text/index.tsx +2 -2
- package/src/Listing/ActionBar/index.tsx +9 -8
- package/src/Listing/Cell/DataCell.styles.ts +3 -0
- package/src/Listing/Cell/DataCell.tsx +23 -5
- package/src/Listing/Header/ListingHeader.tsx +1 -1
- package/src/Listing/Listing.cypress.spec.tsx +80 -4
- package/src/Listing/Listing.styles.ts +4 -7
- package/src/Listing/index.stories.tsx +37 -3
- package/src/Listing/index.test.tsx +1 -1
- package/src/Listing/index.tsx +4 -3
- package/src/Listing/models.ts +1 -0
- package/src/Module/Module.cypress.spec.tsx +129 -0
- package/src/Module/index.tsx +2 -4
- package/src/RichTextEditor/RichTextEditor.tsx +12 -1
- package/src/SortableItems/index.tsx +2 -7
- package/src/ThemeProvider/index.tsx +24 -0
- package/src/TimePeriods/CustomTimePeriod/CompactCustomTimePeriod.styles.ts +6 -7
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/PickersStartEndDate.tsx +8 -3
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/models.ts +0 -2
- package/src/TimePeriods/DateTimePickerInput.tsx +56 -19
- package/src/TimePeriods/ResolutionTimePeriod.cypress.spec.tsx +12 -9
- package/src/TimePeriods/TimePeriods.cypress.spec.tsx +9 -33
- package/src/TimePeriods/helpers/index.ts +1 -1
- package/src/TimePeriods/index.stories.tsx +12 -4
- package/src/TimePeriods/index.tsx +2 -2
- package/src/api/QueryProvider.tsx +1 -1
- package/src/api/TestQueryProvider.tsx +1 -1
- package/src/api/useFetchQuery/index.ts +27 -23
- package/src/api/useMutationQuery/index.test.ts +4 -4
- package/src/api/useMutationQuery/index.ts +60 -25
- package/src/components/Button/Icon/IconButton.tsx +6 -2
- package/src/components/DataTable/DataListing.tsx +6 -0
- package/src/components/DataTable/DataTable.cypress.spec.tsx +193 -0
- package/src/components/DataTable/DataTable.stories.tsx +40 -0
- package/src/components/DataTable/DataTable.styles.ts +3 -0
- package/src/components/DataTable/DataTable.tsx +3 -3
- package/src/components/DataTable/Item/DataTableItem.styles.ts +7 -2
- package/src/components/DataTable/Item/DataTableItem.tsx +4 -4
- package/src/components/DataTable/index.ts +3 -1
- package/src/components/Form/AccessRights/ShareInput/ContactSwitch.tsx +3 -3
- package/src/components/Form/AccessRights/ShareInput/ShareInput.tsx +1 -0
- package/src/components/Form/Dashboard/DashboardForm.tsx +15 -12
- package/src/components/Layout/PageLayout/PageLayout.tsx +1 -1
- package/src/components/Layout/PageLayout/PageLayoutActions.tsx +1 -0
- package/src/components/Layout/PageLayout/PageLayoutBody.tsx +1 -0
- package/src/components/Layout/PageLayout/PageLayoutHeader.tsx +5 -1
- package/src/components/Layout/PageLayout/PageQuickAccess.tsx +76 -0
- package/src/components/Layout/PageLayout/index.ts +3 -1
- package/src/components/Layout/PageLayout.cypress.spec.tsx +66 -0
- package/src/components/Modal/Modal.styles.ts +8 -3
- package/src/components/Tooltip/ConfirmationTooltip/ConfirmationTooltip.stories.tsx +3 -3
- package/src/components/Tooltip/ConfirmationTooltip/ConfirmationTooltip.tsx +1 -1
- package/src/components/Tooltip/ConfirmationTooltip/models.ts +1 -1
- package/src/index.ts +2 -2
- package/src/queryParameters/url/index.ts +5 -1
- package/src/utils/index.ts +1 -1
- package/src/utils/useFullscreen/useFullscreenListener.ts +10 -7
- package/src/utils/{useLicenseExpirationWarning.cypress.spec.tsx → useLicenseExpirationWarning.test.tsx} +48 -37
- package/src/utils/useLicenseExpirationWarning.ts +18 -18
- package/src/utils/usePluralizedTranslation.ts +21 -0
- package/src/screens/dashboard/DashboardsDetail.stories.tsx +0 -108
- package/src/screens/dashboard/DashboardsOverview.stories.tsx +0 -281
- package/src/utils/useDateTimePickerAdapter.ts +0 -309
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@centreon/ui",
|
|
3
|
-
"version": "24.4.
|
|
3
|
+
"version": "24.4.50",
|
|
4
4
|
"description": "Centreon UI Components",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"eslint": "eslint ./src --ext .js,.jsx,.ts,.tsx --max-warnings 0",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"test:ci": "jest --silent --reporter=jest-junit",
|
|
13
13
|
"cypress:ui": "cypress open --component --browser=chrome",
|
|
14
14
|
"cypress:cli:updateSnapshot": "pnpm cypress:cli --env updateSnapshots=true",
|
|
15
|
+
"cypress:run:coverage": "cypress run --component --browser=chrome --env codeCoverageTasksRegistered=true",
|
|
15
16
|
"cypress:cli": "cypress run --component --browser=chrome",
|
|
16
17
|
"tokens:transform": "TS_NODE_PROJECT=tsconfig.node.json ts-node style-dictionary.transform.ts"
|
|
17
18
|
},
|
|
@@ -27,6 +28,7 @@
|
|
|
27
28
|
"author": {
|
|
28
29
|
"name": "centreon@centreon.com"
|
|
29
30
|
},
|
|
31
|
+
"baseCodeCoveragePercentage": 60,
|
|
30
32
|
"license": "GPL-2.0",
|
|
31
33
|
"bugs": {
|
|
32
34
|
"url": "https://github.com/centreon/centreon/issues"
|
|
@@ -46,11 +48,11 @@
|
|
|
46
48
|
"test/*"
|
|
47
49
|
],
|
|
48
50
|
"devDependencies": {
|
|
49
|
-
"@cypress/react": "^
|
|
50
|
-
"@cypress/webpack-dev-server": "^3.
|
|
51
|
+
"@cypress/react": "^8.0.0",
|
|
52
|
+
"@cypress/webpack-dev-server": "^3.7.3",
|
|
51
53
|
"@faker-js/faker": "^8.0.2",
|
|
52
|
-
"@mdx-js/react": "^
|
|
53
|
-
"@simonsmith/cypress-image-snapshot": "^
|
|
54
|
+
"@mdx-js/react": "^3.0.0",
|
|
55
|
+
"@simonsmith/cypress-image-snapshot": "^9.0.1",
|
|
54
56
|
"@storybook/addon-a11y": "^7.0.9",
|
|
55
57
|
"@storybook/addon-docs": "^7.0.9",
|
|
56
58
|
"@storybook/addon-essentials": "^7.0.9",
|
|
@@ -71,57 +73,62 @@
|
|
|
71
73
|
"@testing-library/jest-dom": "^5.16.5",
|
|
72
74
|
"@testing-library/react": "^13.4.0",
|
|
73
75
|
"@testing-library/react-hooks": "^8.0.1",
|
|
74
|
-
"@types/
|
|
75
|
-
"@types/
|
|
76
|
-
"@types/ramda": "^0.
|
|
77
|
-
"@types/react": "^18.
|
|
78
|
-
"@types/testing-library__jest-dom": "^
|
|
76
|
+
"@types/jest": "^29.5.11",
|
|
77
|
+
"@types/mocha": "^10.0.6",
|
|
78
|
+
"@types/ramda": "^0.29.9",
|
|
79
|
+
"@types/react": "^18.2.48",
|
|
80
|
+
"@types/testing-library__jest-dom": "^6.0.0",
|
|
79
81
|
"@vitejs/plugin-react": "^4.0.0",
|
|
80
82
|
"@vitejs/plugin-react-swc": "^3.3.0",
|
|
81
|
-
"axios-mock-adapter": "^1.
|
|
82
|
-
"cypress": "^
|
|
83
|
+
"axios-mock-adapter": "^1.22.0",
|
|
84
|
+
"cypress": "^13.6.2",
|
|
83
85
|
"identity-obj-proxy": "^3.0.0",
|
|
84
86
|
"jest-transform-stub": "^2.0.0",
|
|
85
87
|
"mochawesome": "^7.1.3",
|
|
88
|
+
"msw": "1.3.2",
|
|
89
|
+
"msw-storybook-addon": "^1.10.0",
|
|
86
90
|
"puppeteer": "^13.7.0",
|
|
87
91
|
"react": "^18.2.0",
|
|
88
92
|
"react-dom": "^18.2.0",
|
|
89
93
|
"react-test-renderer": "^18.2.0",
|
|
90
94
|
"remark-gfm": "^3.0.1",
|
|
91
|
-
"sass": "^1.62.1",
|
|
92
95
|
"speed-measure-vite-plugin": "^0.1.2",
|
|
93
|
-
"storybook": "^7.
|
|
96
|
+
"storybook": "^7.6.8",
|
|
94
97
|
"storybook-addon-mock": "^4.0.0",
|
|
95
|
-
"storybook-dark-mode": "^3.0.
|
|
98
|
+
"storybook-dark-mode": "^3.0.3",
|
|
96
99
|
"style-dictionary": "^3.8.0",
|
|
97
|
-
"ts-node": "^10.9.
|
|
100
|
+
"ts-node": "^10.9.2",
|
|
98
101
|
"use-resize-observer": "^9.1.0",
|
|
99
102
|
"vite": "^4.3.5",
|
|
103
|
+
"vite-plugin-istanbul": "^5.0.0",
|
|
100
104
|
"vite-plugin-svgr": "^3.2.0",
|
|
101
|
-
"vite-plugin-turbosnap": "^1.0.
|
|
105
|
+
"vite-plugin-turbosnap": "^1.0.3"
|
|
102
106
|
},
|
|
103
107
|
"dependencies": {
|
|
104
|
-
"@lexical/
|
|
105
|
-
"@lexical/
|
|
106
|
-
"@lexical/
|
|
107
|
-
"@lexical/
|
|
108
|
-
"@lexical/
|
|
109
|
-
"@lexical/
|
|
108
|
+
"@lexical/html": "^0.12.6",
|
|
109
|
+
"@lexical/link": "^0.12.6",
|
|
110
|
+
"@lexical/list": "^0.12.6",
|
|
111
|
+
"@lexical/react": "^0.12.6",
|
|
112
|
+
"@lexical/rich-text": "^0.12.6",
|
|
113
|
+
"@lexical/selection": "^0.12.6",
|
|
114
|
+
"@lexical/utils": "^0.12.6",
|
|
110
115
|
"@react-spring/web": "^9.7.3",
|
|
111
116
|
"@visx/curve": "^2.1.0",
|
|
112
117
|
"@visx/group": "^3.3.0",
|
|
118
|
+
"@visx/legend": "^3.5.0",
|
|
113
119
|
"@visx/pattern": "^3.0.0",
|
|
114
120
|
"@visx/scale": "^3.0.0",
|
|
115
121
|
"@visx/shape": "^2.12.2",
|
|
122
|
+
"@visx/text": "^3.3.0",
|
|
116
123
|
"@visx/threshold": "^2.12.2",
|
|
117
124
|
"@visx/visx": "2.16.0",
|
|
118
125
|
"anylogger": "^1.0.11",
|
|
119
|
-
"d3-array": "3.2.
|
|
126
|
+
"d3-array": "3.2.4",
|
|
120
127
|
"humanize-duration": "^3.27.3",
|
|
121
|
-
"lexical": "0.
|
|
122
|
-
"
|
|
123
|
-
"
|
|
124
|
-
"
|
|
128
|
+
"lexical": "^0.12.6",
|
|
129
|
+
"notistack": "^3.0.1",
|
|
130
|
+
"numeral": "^2.0.6",
|
|
131
|
+
"ramda": "0.29.1",
|
|
125
132
|
"react-grid-layout": "^1.3.4",
|
|
126
133
|
"react-html-parser": "^2.0.2",
|
|
127
134
|
"react-resizable": "^3.0.5",
|
|
@@ -137,7 +144,7 @@
|
|
|
137
144
|
"@mui/icons-material": "5.x",
|
|
138
145
|
"@mui/material": "5.x",
|
|
139
146
|
"@mui/styles": "5.x",
|
|
140
|
-
"@tanstack/react-query": "
|
|
147
|
+
"@tanstack/react-query": "5.x",
|
|
141
148
|
"axios": "0.x",
|
|
142
149
|
"dayjs": "1.x",
|
|
143
150
|
"formik": "2.x",
|
|
@@ -15,9 +15,9 @@ interface Props {
|
|
|
15
15
|
|
|
16
16
|
const StartIcon = ({ startIconConfig }: Props): JSX.Element | null =>
|
|
17
17
|
cond<Array<StartIconConfigProps>, JSX.Element | null>([
|
|
18
|
-
[pipe(propEq('hasLabel'
|
|
19
|
-
[propEq('succeeded'
|
|
20
|
-
[propEq('loading'
|
|
18
|
+
[pipe(propEq(true, 'hasLabel'), not), always(null)],
|
|
19
|
+
[propEq(true, 'succeeded'), always(<CheckIcon />)],
|
|
20
|
+
[propEq(true, 'loading'), always(<SaveIcon />)],
|
|
21
21
|
[T, always(<SaveIcon />)]
|
|
22
22
|
])(startIconConfig);
|
|
23
23
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { any, isEmpty, isNil, not, or, pipe } from 'ramda';
|
|
2
2
|
import { makeStyles } from 'tss-react/mui';
|
|
3
3
|
|
|
4
|
+
import { LoadingButton, LoadingButtonProps } from '@mui/lab';
|
|
4
5
|
import { Theme, Tooltip } from '@mui/material';
|
|
5
|
-
import { LoadingButton } from '@mui/lab';
|
|
6
6
|
|
|
7
7
|
import { getNormalizedId } from '../../utils';
|
|
8
8
|
|
|
9
|
-
import StartIcon from './StartIcon';
|
|
10
9
|
import Content from './Content';
|
|
10
|
+
import StartIcon from './StartIcon';
|
|
11
11
|
|
|
12
12
|
const useStyles = makeStyles()((theme: Theme) => ({
|
|
13
13
|
loadingButton: {
|
|
@@ -15,13 +15,14 @@ const useStyles = makeStyles()((theme: Theme) => ({
|
|
|
15
15
|
}
|
|
16
16
|
}));
|
|
17
17
|
|
|
18
|
-
interface Props
|
|
18
|
+
interface Props {
|
|
19
19
|
className?: string;
|
|
20
20
|
labelLoading?: string;
|
|
21
21
|
labelSave?: string;
|
|
22
22
|
labelSucceeded?: string;
|
|
23
23
|
loading?: boolean;
|
|
24
24
|
size?: 'small' | 'medium' | 'large';
|
|
25
|
+
startIcon?: boolean;
|
|
25
26
|
succeeded?: boolean;
|
|
26
27
|
tooltip?: string;
|
|
27
28
|
tooltipLabel?: string;
|
|
@@ -45,8 +46,9 @@ const SaveButton = ({
|
|
|
45
46
|
labelSave = '',
|
|
46
47
|
size = 'small',
|
|
47
48
|
className,
|
|
49
|
+
startIcon = true,
|
|
48
50
|
...rest
|
|
49
|
-
}: Props): JSX.Element => {
|
|
51
|
+
}: Props & LoadingButtonProps): JSX.Element => {
|
|
50
52
|
const { classes, cx } = useStyles();
|
|
51
53
|
const hasLabel = hasValue([labelLoading, labelSave, labelSucceeded]);
|
|
52
54
|
|
|
@@ -73,7 +75,9 @@ const SaveButton = ({
|
|
|
73
75
|
loading={loading}
|
|
74
76
|
loadingPosition={labelLoading ? 'start' : 'center'}
|
|
75
77
|
size={size}
|
|
76
|
-
startIcon={
|
|
78
|
+
startIcon={
|
|
79
|
+
startIcon && <StartIcon startIconConfig={startIconConfig} />
|
|
80
|
+
}
|
|
77
81
|
variant="contained"
|
|
78
82
|
{...rest}
|
|
79
83
|
>
|
|
@@ -2,7 +2,7 @@ import { makeStyles } from 'tss-react/mui';
|
|
|
2
2
|
import { T, always, cond, equals } from 'ramda';
|
|
3
3
|
|
|
4
4
|
import { SvgIconComponent } from '@mui/icons-material';
|
|
5
|
-
import Typography, {
|
|
5
|
+
import Typography, { TypographyProps } from '@mui/material/Typography';
|
|
6
6
|
import { FormControlLabel, Checkbox as MuiCheckbox, Box } from '@mui/material';
|
|
7
7
|
|
|
8
8
|
export type LabelPlacement = 'bottom' | 'top' | 'end' | 'start' | undefined;
|
|
@@ -56,7 +56,7 @@ interface Props {
|
|
|
56
56
|
disabled?: boolean;
|
|
57
57
|
label: string;
|
|
58
58
|
labelPlacement?: LabelPlacement;
|
|
59
|
-
labelProps?:
|
|
59
|
+
labelProps?: TypographyProps;
|
|
60
60
|
onChange?: (e) => void;
|
|
61
61
|
}
|
|
62
62
|
|
|
@@ -2,7 +2,7 @@ import { equals, includes } from 'ramda';
|
|
|
2
2
|
import { makeStyles } from 'tss-react/mui';
|
|
3
3
|
|
|
4
4
|
import FormGroup, { FormGroupProps } from '@mui/material/FormGroup';
|
|
5
|
-
import {
|
|
5
|
+
import { TypographyProps } from '@mui/material/Typography';
|
|
6
6
|
|
|
7
7
|
import Checkbox, { LabelPlacement } from '../Checkbox';
|
|
8
8
|
|
|
@@ -13,7 +13,7 @@ interface Props {
|
|
|
13
13
|
disabled?: boolean;
|
|
14
14
|
formGroupProps?: FormGroupProps;
|
|
15
15
|
labelPlacement?: LabelPlacement;
|
|
16
|
-
labelProps?:
|
|
16
|
+
labelProps?: TypographyProps;
|
|
17
17
|
onChange?: (e) => void;
|
|
18
18
|
options: Array<string>;
|
|
19
19
|
values: Array<string>;
|
package/src/Dashboard/Item.tsx
CHANGED
package/src/Dashboard/Layout.tsx
CHANGED
|
@@ -23,7 +23,7 @@ interface DashboardLayoutProps<T> {
|
|
|
23
23
|
layout: Array<T>;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
const
|
|
26
|
+
const DashboardLayout = <T extends Layout>({
|
|
27
27
|
children,
|
|
28
28
|
changeLayout,
|
|
29
29
|
displayGrid,
|
|
@@ -76,4 +76,4 @@ const Layout = <T extends Layout>({
|
|
|
76
76
|
});
|
|
77
77
|
};
|
|
78
78
|
|
|
79
|
-
export default
|
|
79
|
+
export default DashboardLayout;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DialogContentText, Typography } from '@mui/material';
|
|
1
|
+
import { ButtonProps, DialogContentText, Typography } from '@mui/material';
|
|
2
2
|
|
|
3
3
|
import Dialog, { Props as DialogProps } from '..';
|
|
4
4
|
|
|
@@ -6,15 +6,23 @@ type Props = DialogProps & {
|
|
|
6
6
|
children?: JSX.Element;
|
|
7
7
|
labelMessage?: string | null;
|
|
8
8
|
labelSecondMessage?: string | null;
|
|
9
|
+
restCancelButtonProps?: ButtonProps;
|
|
10
|
+
restConfirmButtonProps?: ButtonProps;
|
|
9
11
|
};
|
|
10
12
|
|
|
11
13
|
const Confirm = ({
|
|
12
14
|
labelMessage,
|
|
13
15
|
labelSecondMessage,
|
|
14
16
|
children,
|
|
17
|
+
restCancelButtonProps,
|
|
18
|
+
restConfirmButtonProps,
|
|
15
19
|
...rest
|
|
16
20
|
}: Props): JSX.Element => (
|
|
17
|
-
<Dialog
|
|
21
|
+
<Dialog
|
|
22
|
+
restCancelButtonProps={restCancelButtonProps}
|
|
23
|
+
restConfirmButtonProps={restConfirmButtonProps}
|
|
24
|
+
{...rest}
|
|
25
|
+
>
|
|
18
26
|
<DialogContentText>
|
|
19
27
|
{labelMessage && <Typography>{labelMessage}</Typography>}
|
|
20
28
|
{labelSecondMessage && <Typography>{labelSecondMessage}</Typography>}
|
package/src/Dialog/index.tsx
CHANGED
|
@@ -9,7 +9,8 @@ import {
|
|
|
9
9
|
DialogContent,
|
|
10
10
|
DialogActions,
|
|
11
11
|
DialogProps,
|
|
12
|
-
CircularProgress
|
|
12
|
+
CircularProgress,
|
|
13
|
+
ButtonProps
|
|
13
14
|
} from '@mui/material';
|
|
14
15
|
|
|
15
16
|
import { DataTestAttributes } from '../@types/data-attributes';
|
|
@@ -43,11 +44,13 @@ export type Props = {
|
|
|
43
44
|
dialogTitleClassName?: string;
|
|
44
45
|
labelCancel?: string | null;
|
|
45
46
|
labelConfirm?: string | null;
|
|
46
|
-
labelTitle?:
|
|
47
|
+
labelTitle?: ReactNode;
|
|
47
48
|
onCancel?: () => void;
|
|
48
49
|
onClose?: () => void;
|
|
49
50
|
onConfirm: (event, value?) => void;
|
|
50
51
|
open: boolean;
|
|
52
|
+
restCancelButtonProps?: ButtonProps;
|
|
53
|
+
restConfirmButtonProps?: ButtonProps;
|
|
51
54
|
submitting?: boolean;
|
|
52
55
|
} & DialogProps &
|
|
53
56
|
DataTestAttributes;
|
|
@@ -70,6 +73,8 @@ const Dialog = ({
|
|
|
70
73
|
dialogContentClassName,
|
|
71
74
|
dialogActionsClassName,
|
|
72
75
|
dialogConfirmButtonClassName,
|
|
76
|
+
restCancelButtonProps,
|
|
77
|
+
restConfirmButtonProps,
|
|
73
78
|
...rest
|
|
74
79
|
}: Props): JSX.Element => {
|
|
75
80
|
const { classes, cx } = useStyles({ contentWidth });
|
|
@@ -101,6 +106,7 @@ const Dialog = ({
|
|
|
101
106
|
data-testid="Cancel"
|
|
102
107
|
disabled={cancelDisabled}
|
|
103
108
|
onClick={onCancel}
|
|
109
|
+
{...restCancelButtonProps}
|
|
104
110
|
>
|
|
105
111
|
{labelCancel}
|
|
106
112
|
</Button>
|
|
@@ -113,6 +119,7 @@ const Dialog = ({
|
|
|
113
119
|
disabled={confirmDisabled}
|
|
114
120
|
endIcon={submitting && <CircularProgress size={15} />}
|
|
115
121
|
onClick={onConfirm}
|
|
122
|
+
{...restConfirmButtonProps}
|
|
116
123
|
>
|
|
117
124
|
{labelConfirm}
|
|
118
125
|
</Button>
|
|
@@ -17,7 +17,7 @@ const useStyles = makeStyles()((theme) => ({
|
|
|
17
17
|
logo: {
|
|
18
18
|
alignSelf: 'flex-end',
|
|
19
19
|
height: theme.spacing(11),
|
|
20
|
-
width: '
|
|
20
|
+
width: '239px'
|
|
21
21
|
},
|
|
22
22
|
message: {
|
|
23
23
|
color: theme.palette.text.primary
|
|
@@ -66,9 +66,9 @@ export const FallbackPage: FC<FallbackPageProps> = typedMemo(
|
|
|
66
66
|
|
|
67
67
|
return (
|
|
68
68
|
<div className={classes.notAuthorizedContainer}>
|
|
69
|
-
<
|
|
69
|
+
<div className={classes.logo}>
|
|
70
70
|
<CentreonLogo />
|
|
71
|
-
</
|
|
71
|
+
</div>
|
|
72
72
|
<section className={classes.messageBlock}>
|
|
73
73
|
<header>
|
|
74
74
|
<Typography color="primary" fontWeight="bold" variant="h3">
|
|
@@ -98,7 +98,9 @@ const getExtensions = cond([
|
|
|
98
98
|
[T, identity]
|
|
99
99
|
]) as (accept: string) => Array<string>;
|
|
100
100
|
|
|
101
|
-
export const transformFileListToArray = (
|
|
101
|
+
export const transformFileListToArray = (
|
|
102
|
+
files: FileList | null
|
|
103
|
+
): Array<File> =>
|
|
102
104
|
isNil(files)
|
|
103
105
|
? []
|
|
104
106
|
: (Array(files.length)
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { object } from 'yup';
|
|
2
|
+
import { faker } from '@faker-js/faker';
|
|
3
|
+
import { useFormikContext } from 'formik';
|
|
4
|
+
|
|
5
|
+
import { Typography } from '@mui/material';
|
|
6
|
+
|
|
7
|
+
import { Button } from '../components';
|
|
8
|
+
|
|
9
|
+
import { Form } from './Form';
|
|
10
|
+
import { InputType } from './Inputs/models';
|
|
11
|
+
|
|
12
|
+
faker.seed(42);
|
|
13
|
+
|
|
14
|
+
const AddItem = ({ addItem }: { addItem: (item) => void }): JSX.Element => {
|
|
15
|
+
const { values } = useFormikContext();
|
|
16
|
+
const add = (): void => {
|
|
17
|
+
addItem({
|
|
18
|
+
alias: faker.company.name(),
|
|
19
|
+
id: values.list.length,
|
|
20
|
+
name: faker.person.firstName()
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<Button variant="ghost" onClick={add}>
|
|
26
|
+
Add item
|
|
27
|
+
</Button>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const SortContent = ({
|
|
32
|
+
name,
|
|
33
|
+
alias
|
|
34
|
+
}: {
|
|
35
|
+
alias: string;
|
|
36
|
+
name: string;
|
|
37
|
+
}): JSX.Element => (
|
|
38
|
+
<Typography>
|
|
39
|
+
{name} ({alias})
|
|
40
|
+
</Typography>
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const initializeFormList = (): void => {
|
|
44
|
+
cy.mount({
|
|
45
|
+
Component: (
|
|
46
|
+
<Form
|
|
47
|
+
initialValues={{
|
|
48
|
+
list: []
|
|
49
|
+
}}
|
|
50
|
+
inputs={[
|
|
51
|
+
{
|
|
52
|
+
fieldName: 'list',
|
|
53
|
+
group: '',
|
|
54
|
+
label: '',
|
|
55
|
+
list: {
|
|
56
|
+
AddItem,
|
|
57
|
+
SortContent,
|
|
58
|
+
addItemLabel: 'Add an item to the list',
|
|
59
|
+
itemProps: ['id', 'name', 'alias'],
|
|
60
|
+
sortLabel: 'Sort items'
|
|
61
|
+
},
|
|
62
|
+
type: InputType.List
|
|
63
|
+
}
|
|
64
|
+
]}
|
|
65
|
+
submit={cy.stub()}
|
|
66
|
+
validationSchema={object()}
|
|
67
|
+
/>
|
|
68
|
+
)
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
describe('Form list', () => {
|
|
73
|
+
beforeEach(initializeFormList);
|
|
74
|
+
|
|
75
|
+
it('adds an element to the list', () => {
|
|
76
|
+
cy.contains('Add an item to the list').should('be.visible');
|
|
77
|
+
cy.contains('Sort items').should('be.visible');
|
|
78
|
+
|
|
79
|
+
cy.contains('Add item').click();
|
|
80
|
+
|
|
81
|
+
cy.findByLabelText('sort-0').should('be.visible');
|
|
82
|
+
cy.findByLabelText('delete-0').should('be.visible');
|
|
83
|
+
cy.contains('Christelle (Schinner - Wiegand)').should('be.visible');
|
|
84
|
+
|
|
85
|
+
cy.makeSnapshot();
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('sorts elements in the list', () => {
|
|
89
|
+
cy.contains('Add an item to the list').should('be.visible');
|
|
90
|
+
cy.contains('Sort items').should('be.visible');
|
|
91
|
+
|
|
92
|
+
cy.contains('Add item').click();
|
|
93
|
+
cy.contains('Add item').click();
|
|
94
|
+
|
|
95
|
+
cy.findByLabelText('sort-0').should('be.visible');
|
|
96
|
+
cy.findByLabelText('delete-0').should('be.visible');
|
|
97
|
+
cy.contains('Carley (Satterfield, Miller and Metz)').should('be.visible');
|
|
98
|
+
cy.findByLabelText('sort-1').should('be.visible');
|
|
99
|
+
cy.findByLabelText('delete-1').should('be.visible');
|
|
100
|
+
cy.contains('Anderson (Crist - Bradtke)').should('be.visible');
|
|
101
|
+
|
|
102
|
+
cy.moveSortableElementUsingAriaLabel({
|
|
103
|
+
ariaLabel: 'sort-0',
|
|
104
|
+
direction: 'down'
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
cy.contains('Carley (Satterfield, Miller and Metz)').should('be.visible');
|
|
108
|
+
cy.contains('Anderson (Crist - Bradtke)').should('be.visible');
|
|
109
|
+
|
|
110
|
+
cy.makeSnapshot();
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('removes an element from the list', () => {
|
|
114
|
+
cy.contains('Add an item to the list').should('be.visible');
|
|
115
|
+
cy.contains('Sort items').should('be.visible');
|
|
116
|
+
|
|
117
|
+
cy.contains('Add item').click();
|
|
118
|
+
cy.contains('Add item').click();
|
|
119
|
+
|
|
120
|
+
cy.findByLabelText('sort-0').should('be.visible');
|
|
121
|
+
cy.findByLabelText('delete-0').should('be.visible');
|
|
122
|
+
cy.contains('Lea (Streich - Hartmann)').should('be.visible');
|
|
123
|
+
cy.findByLabelText('sort-1').should('be.visible');
|
|
124
|
+
cy.findByLabelText('delete-1').should('be.visible');
|
|
125
|
+
cy.contains('Akeem (Quigley LLC)').should('be.visible');
|
|
126
|
+
|
|
127
|
+
cy.findByLabelText('delete-0').click();
|
|
128
|
+
|
|
129
|
+
cy.contains('Lea (Streich - Hartmann)').should('not.exist');
|
|
130
|
+
|
|
131
|
+
cy.makeSnapshot();
|
|
132
|
+
});
|
|
133
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import { DraggableSyntheticListeners } from '@dnd-kit/core';
|
|
4
|
+
|
|
5
|
+
import KrilinIndicatorIcon from '@mui/icons-material/DragIndicator';
|
|
6
|
+
import DeleteOutlineIcon from '@mui/icons-material/DeleteOutline';
|
|
7
|
+
|
|
8
|
+
import { IconButton } from '../../../components';
|
|
9
|
+
|
|
10
|
+
import { useListStyles } from './List.styles';
|
|
11
|
+
|
|
12
|
+
export interface ContentProps {
|
|
13
|
+
attributes;
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
deleteItem: (id: string) => () => void;
|
|
16
|
+
id: string;
|
|
17
|
+
isDragging: boolean;
|
|
18
|
+
isInDragOverlay?: boolean;
|
|
19
|
+
itemRef: React.RefObject<HTMLDivElement>;
|
|
20
|
+
listeners: DraggableSyntheticListeners;
|
|
21
|
+
name: string;
|
|
22
|
+
style;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const Content = ({
|
|
26
|
+
listeners,
|
|
27
|
+
itemRef,
|
|
28
|
+
attributes,
|
|
29
|
+
style,
|
|
30
|
+
isDragging,
|
|
31
|
+
id,
|
|
32
|
+
children,
|
|
33
|
+
deleteItem
|
|
34
|
+
}: ContentProps): JSX.Element => {
|
|
35
|
+
const { classes } = useListStyles();
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<div
|
|
39
|
+
className={classes.content}
|
|
40
|
+
ref={itemRef}
|
|
41
|
+
{...attributes}
|
|
42
|
+
style={style}
|
|
43
|
+
>
|
|
44
|
+
<IconButton
|
|
45
|
+
data-dragging={isDragging}
|
|
46
|
+
size="small"
|
|
47
|
+
{...listeners}
|
|
48
|
+
aria-label={`sort-${id}`}
|
|
49
|
+
icon={<KrilinIndicatorIcon fontSize="small" />}
|
|
50
|
+
/>
|
|
51
|
+
<div className={classes.innerContent}>{children}</div>
|
|
52
|
+
<IconButton
|
|
53
|
+
aria-label={`delete-${id}`}
|
|
54
|
+
icon={<DeleteOutlineIcon color="error" fontSize="small" />}
|
|
55
|
+
size="small"
|
|
56
|
+
onClick={deleteItem(id)}
|
|
57
|
+
/>
|
|
58
|
+
</div>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export default Content;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { makeStyles } from 'tss-react/mui';
|
|
2
|
+
|
|
3
|
+
export const useListStyles = makeStyles()((theme) => ({
|
|
4
|
+
content: {
|
|
5
|
+
'& [data-dragging="false"]': {
|
|
6
|
+
cursor: 'grab'
|
|
7
|
+
},
|
|
8
|
+
'& [data-dragging="true"]': {
|
|
9
|
+
cursor: 'grabbing'
|
|
10
|
+
},
|
|
11
|
+
alignItems: 'center',
|
|
12
|
+
borderBottom: `1px dashed ${theme.palette.action.disabledBackground}`,
|
|
13
|
+
display: 'flex',
|
|
14
|
+
flexDirection: 'row',
|
|
15
|
+
padding: theme.spacing(1, 0)
|
|
16
|
+
},
|
|
17
|
+
innerContent: {
|
|
18
|
+
flexGrow: 1
|
|
19
|
+
},
|
|
20
|
+
items: {
|
|
21
|
+
maxHeight: theme.spacing(16),
|
|
22
|
+
overflowY: 'auto'
|
|
23
|
+
},
|
|
24
|
+
list: {
|
|
25
|
+
display: 'flex',
|
|
26
|
+
flexDirection: 'column',
|
|
27
|
+
gap: theme.spacing(1)
|
|
28
|
+
}
|
|
29
|
+
}));
|