@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.
- package/package.json +19 -14
- 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/index.tsx +1 -1
- 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/CheckboxGroup.tsx +1 -4
- 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/LineChart/BasicComponents/Lines/Threshold/Circle.tsx +2 -2
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/index.tsx +5 -4
- 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/Annotation/index.tsx +2 -3
- package/src/Graph/LineChart/InteractiveComponents/Annotations/EventAnnotations.tsx +1 -1
- package/src/Graph/LineChart/Legend/index.tsx +7 -8
- package/src/Graph/LineChart/Legend/useLegend.ts +3 -3
- package/src/Graph/LineChart/LineChart.tsx +4 -1
- 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 +4 -1
- package/src/Graph/SingleBar/Thresholds.tsx +2 -2
- package/src/Graph/Text/Text.stories.tsx +60 -4
- package/src/Graph/common/timeSeries/index.ts +3 -3
- 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 +121 -115
- 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/Cell/DataCell.tsx +15 -1
- package/src/Listing/Header/ListingHeader.tsx +1 -1
- package/src/Listing/Listing.styles.ts +2 -3
- package/src/Listing/index.stories.tsx +12 -1
- package/src/Listing/index.tsx +1 -2
- 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/useGraphQuery/index.ts +26 -5
- package/src/api/useGraphQuery/models.ts +5 -0
- package/src/api/useMutationQuery/index.ts +45 -21
- package/src/components/Button/Icon/IconButton.tsx +6 -2
- package/src/components/CollapsibleItem/CollapsibleItem.cypress.spec.tsx +76 -0
- package/src/components/CollapsibleItem/CollapsibleItem.stories.tsx +26 -0
- package/src/components/CollapsibleItem/CollapsibleItem.tsx +43 -14
- package/src/components/CollapsibleItem/useCollapsibleItemStyles.ts +24 -1
- 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/Dashboard/DashboardForm.tsx +15 -12
- package/src/components/ItemComposition/Item.tsx +1 -1
- package/src/components/ItemComposition/ItemComposition.cypress.spec.tsx +116 -0
- package/src/components/ItemComposition/ItemComposition.styles.ts +8 -1
- package/src/components/ItemComposition/ItemComposition.tsx +26 -16
- 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 +1 -1
- 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 +2 -1
- 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
|
@@ -22,7 +22,7 @@ export interface DataTableItemProps {
|
|
|
22
22
|
description?: string;
|
|
23
23
|
hasActions?: boolean;
|
|
24
24
|
hasCardAction?: boolean;
|
|
25
|
-
labelsDelete
|
|
25
|
+
labelsDelete?: {
|
|
26
26
|
cancel: string;
|
|
27
27
|
confirm: {
|
|
28
28
|
label: string;
|
|
@@ -76,20 +76,20 @@ const DataTableItem = forwardRef(
|
|
|
76
76
|
{hasActions && (
|
|
77
77
|
<MuiCardActions>
|
|
78
78
|
<span>
|
|
79
|
-
{onDelete && (
|
|
79
|
+
{onDelete && labelsDelete && (
|
|
80
80
|
<ConfirmationTooltip
|
|
81
81
|
confirmVariant="error"
|
|
82
82
|
labels={labelsDelete}
|
|
83
83
|
onConfirm={onDelete}
|
|
84
84
|
>
|
|
85
|
-
{(
|
|
85
|
+
{({ toggleTooltip }) => (
|
|
86
86
|
<IconButton
|
|
87
87
|
aria-label="delete"
|
|
88
88
|
data-testid="delete"
|
|
89
89
|
icon={<DeleteIcon />}
|
|
90
90
|
size="small"
|
|
91
91
|
variant="ghost"
|
|
92
|
-
onClick={
|
|
92
|
+
onClick={toggleTooltip}
|
|
93
93
|
/>
|
|
94
94
|
)}
|
|
95
95
|
</ConfirmationTooltip>
|
|
@@ -2,9 +2,11 @@ import { DataTable as DataTableRoot } from './DataTable';
|
|
|
2
2
|
import { DataTableItem } from './Item/DataTableItem';
|
|
3
3
|
import { DataTableItemSkeleton } from './Item/DataTableItemSkeleton';
|
|
4
4
|
import { DataTableEmptyState } from './EmptyState/DataTableEmptyState';
|
|
5
|
+
import { DataListing } from './DataListing';
|
|
5
6
|
|
|
6
7
|
export const DataTable = Object.assign(DataTableRoot, {
|
|
7
8
|
EmptyState: DataTableEmptyState,
|
|
8
9
|
Item: DataTableItem,
|
|
9
|
-
ItemSkeleton: DataTableItemSkeleton
|
|
10
|
+
ItemSkeleton: DataTableItemSkeleton,
|
|
11
|
+
Listing: DataListing
|
|
10
12
|
});
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ReactElement, useCallback, useMemo } from 'react';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { string, number, object } from 'yup';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { equals } from 'ramda';
|
|
5
6
|
|
|
6
7
|
import { InputType } from '../../../Form/Inputs/models';
|
|
7
8
|
import { Form, FormProps } from '../../../Form';
|
|
@@ -84,8 +85,8 @@ const DashboardForm = ({
|
|
|
84
85
|
}
|
|
85
86
|
],
|
|
86
87
|
submit: (values, bag) => onSubmit?.(values, bag),
|
|
87
|
-
validationSchema:
|
|
88
|
-
description:
|
|
88
|
+
validationSchema: object({
|
|
89
|
+
description: string()
|
|
89
90
|
.label(labels?.entity?.description || '')
|
|
90
91
|
.max(
|
|
91
92
|
180,
|
|
@@ -93,17 +94,19 @@ const DashboardForm = ({
|
|
|
93
94
|
`${p.label} ${t(labelMustBeMost)} ${p.max} ${t(labelCharacters)}`
|
|
94
95
|
)
|
|
95
96
|
.nullable(),
|
|
96
|
-
globalRefreshInterval:
|
|
97
|
-
interval:
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
97
|
+
globalRefreshInterval: object({
|
|
98
|
+
interval: number().when('type', ([type], schema) => {
|
|
99
|
+
if (equals(type, 'manual')) {
|
|
100
|
+
schema
|
|
101
|
+
.min(1, ({ min }) => t(labelMustBeAtLeast, { min }))
|
|
102
|
+
.required(t(labelRequired) as string);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return schema.nullable();
|
|
103
106
|
}),
|
|
104
|
-
type:
|
|
107
|
+
type: string()
|
|
105
108
|
}),
|
|
106
|
-
name:
|
|
109
|
+
name: string()
|
|
107
110
|
.label(labels?.entity?.name)
|
|
108
111
|
.min(3, ({ min, label }) => t(labelMustBeAtLeast, { label, min }))
|
|
109
112
|
.max(50, ({ max, label }) => t(labelMustBeMost, { label, max }))
|
|
@@ -7,7 +7,7 @@ import { IconButton } from '..';
|
|
|
7
7
|
import { useItemStyles } from './ItemComposition.styles';
|
|
8
8
|
|
|
9
9
|
type Props = {
|
|
10
|
-
children: Array<ReactElement>;
|
|
10
|
+
children: ReactElement | Array<ReactElement>;
|
|
11
11
|
className?: string;
|
|
12
12
|
deleteButtonHidden?: boolean;
|
|
13
13
|
labelDelete: string;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { ItemComposition } from '.';
|
|
2
|
+
|
|
3
|
+
interface Props {
|
|
4
|
+
addButtonHidden?: boolean;
|
|
5
|
+
addbuttonDisabled?: boolean;
|
|
6
|
+
deleteButtonHidden?: boolean;
|
|
7
|
+
secondaryLabel?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const initialize = ({
|
|
11
|
+
addButtonHidden,
|
|
12
|
+
addbuttonDisabled,
|
|
13
|
+
secondaryLabel,
|
|
14
|
+
deleteButtonHidden
|
|
15
|
+
}: Props): unknown => {
|
|
16
|
+
const addItem = cy.stub();
|
|
17
|
+
const deleteItem = cy.stub();
|
|
18
|
+
|
|
19
|
+
cy.mount({
|
|
20
|
+
Component: (
|
|
21
|
+
<ItemComposition
|
|
22
|
+
addButtonHidden={addButtonHidden}
|
|
23
|
+
addbuttonDisabled={addbuttonDisabled}
|
|
24
|
+
labelAdd="Add"
|
|
25
|
+
secondaryLabel={secondaryLabel}
|
|
26
|
+
onAddItem={addItem}
|
|
27
|
+
>
|
|
28
|
+
<ItemComposition.Item
|
|
29
|
+
deleteButtonHidden={deleteButtonHidden}
|
|
30
|
+
labelDelete="Delete"
|
|
31
|
+
onDeleteItem={deleteItem}
|
|
32
|
+
>
|
|
33
|
+
<div>Item 1</div>
|
|
34
|
+
</ItemComposition.Item>
|
|
35
|
+
<ItemComposition.Item
|
|
36
|
+
deleteButtonHidden={deleteButtonHidden}
|
|
37
|
+
labelDelete="Delete"
|
|
38
|
+
onDeleteItem={deleteItem}
|
|
39
|
+
>
|
|
40
|
+
<div>Item 2</div>
|
|
41
|
+
</ItemComposition.Item>
|
|
42
|
+
</ItemComposition>
|
|
43
|
+
)
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
addItem,
|
|
48
|
+
deleteItem
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
describe('ItemComposition', () => {
|
|
53
|
+
it('displays the component', () => {
|
|
54
|
+
initialize({});
|
|
55
|
+
|
|
56
|
+
cy.contains('Item 1').should('be.visible');
|
|
57
|
+
cy.contains('Item 2').should('be.visible');
|
|
58
|
+
cy.findAllByTestId('Delete').should('have.length', 2);
|
|
59
|
+
cy.findByTestId('Add').should('be.enabled');
|
|
60
|
+
|
|
61
|
+
cy.makeSnapshot();
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('displays the component with a secondary label', () => {
|
|
65
|
+
initialize({ secondaryLabel: 'Secondary label' });
|
|
66
|
+
|
|
67
|
+
cy.contains('Secondary label').should('be.visible');
|
|
68
|
+
|
|
69
|
+
cy.makeSnapshot();
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('displays add button as hidden when the prop is set to true', () => {
|
|
73
|
+
initialize({ addbuttonDisabled: true });
|
|
74
|
+
|
|
75
|
+
cy.findByTestId('Add').should('be.disabled');
|
|
76
|
+
|
|
77
|
+
cy.makeSnapshot();
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('does not display the add button when the prop is set to true', () => {
|
|
81
|
+
initialize({ addButtonHidden: true });
|
|
82
|
+
|
|
83
|
+
cy.findByTestId('Add').should('not.exist');
|
|
84
|
+
|
|
85
|
+
cy.makeSnapshot();
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('does not display the delete button when the prop is set to true', () => {
|
|
89
|
+
initialize({ deleteButtonHidden: true });
|
|
90
|
+
|
|
91
|
+
cy.findByTestId('Delete').should('not.exist');
|
|
92
|
+
|
|
93
|
+
cy.makeSnapshot();
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('calls the add function when the button is clicked', () => {
|
|
97
|
+
const { addItem } = initialize({});
|
|
98
|
+
|
|
99
|
+
cy.findByTestId('Add')
|
|
100
|
+
.click()
|
|
101
|
+
.then(() => {
|
|
102
|
+
expect(addItem).to.have.been.calledWith();
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('calls the delete function when the button is clicked', () => {
|
|
107
|
+
const { deleteItem } = initialize({});
|
|
108
|
+
|
|
109
|
+
cy.findAllByTestId('Delete')
|
|
110
|
+
.eq(1)
|
|
111
|
+
.click()
|
|
112
|
+
.then(() => {
|
|
113
|
+
expect(deleteItem).to.have.been.calledWith();
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
});
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { makeStyles } from 'tss-react/mui';
|
|
2
2
|
|
|
3
3
|
export const useItemCompositionStyles = makeStyles()((theme) => ({
|
|
4
|
+
buttonAndSecondaryLabel: {
|
|
5
|
+
alignItems: 'center',
|
|
6
|
+
display: 'flex',
|
|
7
|
+
flexDirection: 'row',
|
|
8
|
+
justifyContent: 'space-between',
|
|
9
|
+
width: '100%'
|
|
10
|
+
},
|
|
4
11
|
itemCompositionContainer: {
|
|
5
12
|
alignItems: 'flex-start',
|
|
6
13
|
display: 'flex',
|
|
@@ -24,6 +31,6 @@ export const useItemStyles = makeStyles()((theme) => ({
|
|
|
24
31
|
width: '100%'
|
|
25
32
|
},
|
|
26
33
|
visibilityHiden: {
|
|
27
|
-
|
|
34
|
+
display: 'none'
|
|
28
35
|
}
|
|
29
36
|
}));
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
2
|
|
|
3
3
|
import AddIcon from '@mui/icons-material/Add';
|
|
4
|
+
import { Typography } from '@mui/material';
|
|
4
5
|
|
|
5
6
|
import { Button } from '..';
|
|
6
7
|
|
|
7
8
|
import { useItemCompositionStyles } from './ItemComposition.styles';
|
|
8
9
|
|
|
9
|
-
type Props = {
|
|
10
|
+
export type Props = {
|
|
10
11
|
IconAdd?;
|
|
11
12
|
addButtonHidden?: boolean;
|
|
12
13
|
addbuttonDisabled?: boolean;
|
|
13
14
|
children: Array<ReactElement>;
|
|
14
15
|
labelAdd: string;
|
|
15
16
|
onAddItem: () => void;
|
|
17
|
+
secondaryLabel?: string;
|
|
16
18
|
};
|
|
17
19
|
|
|
18
20
|
export const ItemComposition = ({
|
|
@@ -21,27 +23,35 @@ export const ItemComposition = ({
|
|
|
21
23
|
labelAdd,
|
|
22
24
|
addbuttonDisabled,
|
|
23
25
|
addButtonHidden,
|
|
24
|
-
IconAdd
|
|
26
|
+
IconAdd,
|
|
27
|
+
secondaryLabel
|
|
25
28
|
}: Props): JSX.Element => {
|
|
26
29
|
const { classes } = useItemCompositionStyles();
|
|
27
30
|
|
|
28
31
|
return (
|
|
29
32
|
<div className={classes.itemCompositionContainer}>
|
|
30
33
|
{children}
|
|
31
|
-
{
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
34
|
+
<div className={classes.buttonAndSecondaryLabel}>
|
|
35
|
+
{!addButtonHidden && (
|
|
36
|
+
<Button
|
|
37
|
+
aria-label={labelAdd}
|
|
38
|
+
data-testid={labelAdd}
|
|
39
|
+
disabled={addbuttonDisabled}
|
|
40
|
+
icon={IconAdd || <AddIcon />}
|
|
41
|
+
iconVariant="start"
|
|
42
|
+
size="small"
|
|
43
|
+
variant="ghost"
|
|
44
|
+
onClick={onAddItem}
|
|
45
|
+
>
|
|
46
|
+
{labelAdd}
|
|
47
|
+
</Button>
|
|
48
|
+
)}
|
|
49
|
+
{secondaryLabel && (
|
|
50
|
+
<Typography sx={{ color: 'text.secondary' }}>
|
|
51
|
+
{secondaryLabel}
|
|
52
|
+
</Typography>
|
|
53
|
+
)}
|
|
54
|
+
</div>
|
|
45
55
|
</div>
|
|
46
56
|
);
|
|
47
57
|
};
|
|
@@ -11,5 +11,9 @@ export const PageLayoutHeader = ({
|
|
|
11
11
|
}: PageLayoutHeaderProps): JSX.Element => {
|
|
12
12
|
const { classes } = useStyles();
|
|
13
13
|
|
|
14
|
-
return
|
|
14
|
+
return (
|
|
15
|
+
<header className={classes.pageLayoutHeader} id="header">
|
|
16
|
+
{children}
|
|
17
|
+
</header>
|
|
18
|
+
);
|
|
15
19
|
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { useTranslation } from 'react-i18next';
|
|
2
|
+
|
|
3
|
+
import AddIcon from '@mui/icons-material/Add';
|
|
4
|
+
import ArrowBackIcon from '@mui/icons-material/ArrowBack';
|
|
5
|
+
|
|
6
|
+
import { Button, Menu } from '../..';
|
|
7
|
+
|
|
8
|
+
interface NamedEntity {
|
|
9
|
+
id: number | string;
|
|
10
|
+
name: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type Props = {
|
|
14
|
+
create: () => void;
|
|
15
|
+
elements: Array<NamedEntity>;
|
|
16
|
+
goBack: () => void;
|
|
17
|
+
isActive: (id: number | string) => boolean;
|
|
18
|
+
labels: {
|
|
19
|
+
create: string;
|
|
20
|
+
goBack: string;
|
|
21
|
+
};
|
|
22
|
+
navigateToElement: (id: number | string) => () => void;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const PageQuickAccess = ({
|
|
26
|
+
elements,
|
|
27
|
+
isActive,
|
|
28
|
+
navigateToElement,
|
|
29
|
+
goBack,
|
|
30
|
+
create,
|
|
31
|
+
labels
|
|
32
|
+
}: Props): JSX.Element => {
|
|
33
|
+
const { t } = useTranslation();
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<Menu>
|
|
37
|
+
<Menu.Button data-testid="quickaccess" />
|
|
38
|
+
<Menu.Items>
|
|
39
|
+
{elements &&
|
|
40
|
+
elements.map((element) => (
|
|
41
|
+
<Menu.Item
|
|
42
|
+
key={`${element.id}`}
|
|
43
|
+
onClick={navigateToElement(element.id)}
|
|
44
|
+
{...(isActive(element.id) && {
|
|
45
|
+
isActive: true,
|
|
46
|
+
isDisabled: true
|
|
47
|
+
})}
|
|
48
|
+
>
|
|
49
|
+
{element.name}
|
|
50
|
+
</Menu.Item>
|
|
51
|
+
))}
|
|
52
|
+
<Menu.Divider key="divider" />
|
|
53
|
+
<Menu.Item key="create">
|
|
54
|
+
<>
|
|
55
|
+
<Button
|
|
56
|
+
icon={<ArrowBackIcon />}
|
|
57
|
+
iconVariant="start"
|
|
58
|
+
variant="ghost"
|
|
59
|
+
onClick={goBack}
|
|
60
|
+
>
|
|
61
|
+
{t(labels.goBack)}
|
|
62
|
+
</Button>
|
|
63
|
+
<Button
|
|
64
|
+
icon={<AddIcon />}
|
|
65
|
+
iconVariant="start"
|
|
66
|
+
variant="secondary"
|
|
67
|
+
onClick={create}
|
|
68
|
+
>
|
|
69
|
+
{t(labels.create)}
|
|
70
|
+
</Button>
|
|
71
|
+
</>
|
|
72
|
+
</Menu.Item>
|
|
73
|
+
</Menu.Items>
|
|
74
|
+
</Menu>
|
|
75
|
+
);
|
|
76
|
+
};
|
|
@@ -2,9 +2,11 @@ import { PageLayout as PageLayoutRoot } from './PageLayout';
|
|
|
2
2
|
import { PageLayoutHeader } from './PageLayoutHeader';
|
|
3
3
|
import { PageLayoutBody } from './PageLayoutBody';
|
|
4
4
|
import { PageLayoutActions } from './PageLayoutActions';
|
|
5
|
+
import { PageQuickAccess } from './PageQuickAccess';
|
|
5
6
|
|
|
6
7
|
export const PageLayout = Object.assign(PageLayoutRoot, {
|
|
7
8
|
Actions: PageLayoutActions,
|
|
8
9
|
Body: PageLayoutBody,
|
|
9
|
-
Header: PageLayoutHeader
|
|
10
|
+
Header: PageLayoutHeader,
|
|
11
|
+
QuickAccess: PageQuickAccess
|
|
10
12
|
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { T } from 'ramda';
|
|
2
|
+
|
|
3
|
+
import { PageHeader } from '..';
|
|
4
|
+
|
|
5
|
+
import { AreaIndicator } from './AreaIndicator';
|
|
6
|
+
|
|
7
|
+
import { PageLayout } from '.';
|
|
8
|
+
|
|
9
|
+
const initialize = (): void => {
|
|
10
|
+
cy.mount({
|
|
11
|
+
Component: (
|
|
12
|
+
<PageLayout>
|
|
13
|
+
<PageLayout.Header>
|
|
14
|
+
<PageHeader>
|
|
15
|
+
<PageHeader.Menu>
|
|
16
|
+
<PageLayout.QuickAccess
|
|
17
|
+
create={cy.stub()}
|
|
18
|
+
elements={[
|
|
19
|
+
{
|
|
20
|
+
id: 1,
|
|
21
|
+
name: 'Entity'
|
|
22
|
+
}
|
|
23
|
+
]}
|
|
24
|
+
goBack={cy.stub()}
|
|
25
|
+
isActive={T}
|
|
26
|
+
labels={{
|
|
27
|
+
create: 'Create',
|
|
28
|
+
goBack: 'Go back'
|
|
29
|
+
}}
|
|
30
|
+
navigateToElement={cy.stub()}
|
|
31
|
+
/>
|
|
32
|
+
</PageHeader.Menu>
|
|
33
|
+
<PageHeader.Main>
|
|
34
|
+
<PageHeader.Title description="Description" title="Title" />
|
|
35
|
+
</PageHeader.Main>
|
|
36
|
+
<PageHeader.Actions>Actions</PageHeader.Actions>
|
|
37
|
+
</PageHeader>
|
|
38
|
+
</PageLayout.Header>
|
|
39
|
+
<PageLayout.Body>
|
|
40
|
+
<PageLayout.Actions>
|
|
41
|
+
<AreaIndicator name="Body actions" />
|
|
42
|
+
</PageLayout.Actions>
|
|
43
|
+
<h1>Content</h1>
|
|
44
|
+
</PageLayout.Body>
|
|
45
|
+
</PageLayout>
|
|
46
|
+
)
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
describe('Page layout', () => {
|
|
51
|
+
beforeEach(initialize);
|
|
52
|
+
|
|
53
|
+
it('displays the page layout', () => {
|
|
54
|
+
cy.makeSnapshot();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('opens the quick access poppin when the corresponding logo is displayed', () => {
|
|
58
|
+
cy.findByTestId('quickaccess').click();
|
|
59
|
+
|
|
60
|
+
cy.contains('Entity').should('be.visible');
|
|
61
|
+
cy.contains('Create').should('be.visible');
|
|
62
|
+
cy.contains('Go back').should('be.visible');
|
|
63
|
+
|
|
64
|
+
cy.makeSnapshot();
|
|
65
|
+
});
|
|
66
|
+
});
|
|
@@ -15,7 +15,7 @@ type Story = StoryObj<typeof ConfirmationTooltip>;
|
|
|
15
15
|
|
|
16
16
|
export const Default: Story = {
|
|
17
17
|
args: {
|
|
18
|
-
children: (toggleTooltip) => (
|
|
18
|
+
children: ({ toggleTooltip }) => (
|
|
19
19
|
<IconButton icon={<SaveIcon />} onClick={toggleTooltip} />
|
|
20
20
|
),
|
|
21
21
|
labels: {
|
|
@@ -30,7 +30,7 @@ export const Default: Story = {
|
|
|
30
30
|
|
|
31
31
|
export const WithConfirmVariant: Story = {
|
|
32
32
|
args: {
|
|
33
|
-
children: (toggleTooltip) => (
|
|
33
|
+
children: ({ toggleTooltip }) => (
|
|
34
34
|
<IconButton icon={<DeleteIcon color="error" />} onClick={toggleTooltip} />
|
|
35
35
|
),
|
|
36
36
|
confirmVariant: 'error',
|
|
@@ -46,7 +46,7 @@ export const WithConfirmVariant: Story = {
|
|
|
46
46
|
|
|
47
47
|
export const WithSecondaryLabel: Story = {
|
|
48
48
|
args: {
|
|
49
|
-
children: (toggleTooltip) => (
|
|
49
|
+
children: ({ toggleTooltip }) => (
|
|
50
50
|
<IconButton icon={<DeleteIcon color="error" />} onClick={toggleTooltip} />
|
|
51
51
|
),
|
|
52
52
|
confirmVariant: 'error',
|
|
@@ -49,7 +49,7 @@ export const ConfirmationTooltip = ({
|
|
|
49
49
|
return (
|
|
50
50
|
<ClickAwayListener onClickAway={close}>
|
|
51
51
|
<div>
|
|
52
|
-
{children(isOpen ? close : open)}
|
|
52
|
+
{children({ isOpen, toggleTooltip: isOpen ? close : open })}
|
|
53
53
|
<Popper
|
|
54
54
|
anchorEl={anchorElement}
|
|
55
55
|
className={classes.popper}
|
package/src/index.ts
CHANGED
|
@@ -163,8 +163,8 @@ export * from './Graph/common/timeSeries';
|
|
|
163
163
|
|
|
164
164
|
export { default as TimePeriods } from './TimePeriods';
|
|
165
165
|
export { default as SimpleCustomTimePeriod } from './TimePeriods/CustomTimePeriod/SimpleCustomTimePeriod';
|
|
166
|
+
export { default as DateTimePickerInput } from './TimePeriods/DateTimePickerInput';
|
|
166
167
|
export * from './ParentSize';
|
|
167
|
-
|
|
168
|
+
export { default as Subtitle } from './Typography/Subtitle';
|
|
168
169
|
export { default as TablePagination } from './Listing/ActionBar/Pagination';
|
|
169
170
|
export { default as PaginationActions } from './Listing/ActionBar/PaginationActions';
|
|
170
|
-
export { default as Subtitle } from './Typography/Subtitle';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { fromPairs } from 'ramda';
|
|
1
|
+
import { fromPairs, startsWith } from 'ramda';
|
|
2
2
|
|
|
3
3
|
import { QueryParameter } from '../models';
|
|
4
4
|
|
|
@@ -25,6 +25,10 @@ const getUrlQueryParameters = <
|
|
|
25
25
|
|
|
26
26
|
const entries = [...urlParams.entries()].map<[string, string]>(
|
|
27
27
|
([key, value]) => {
|
|
28
|
+
if (startsWith('/', value)) {
|
|
29
|
+
return [key, value];
|
|
30
|
+
}
|
|
31
|
+
|
|
28
32
|
return [key, JSON.parse(value)];
|
|
29
33
|
}
|
|
30
34
|
);
|
package/src/utils/index.ts
CHANGED
|
@@ -3,7 +3,6 @@ export * from './getNormalizedId';
|
|
|
3
3
|
export * from './statuses';
|
|
4
4
|
export * from './typedMemo';
|
|
5
5
|
export * from './useCopyToClipboard';
|
|
6
|
-
export * from './useDateTimePickerAdapter';
|
|
7
6
|
export * from './useDebounce';
|
|
8
7
|
export * from './useDeepCallback';
|
|
9
8
|
export * from './useDeepMemo';
|
|
@@ -20,3 +19,5 @@ export * from './useInfiniteScrollListing';
|
|
|
20
19
|
export * from './useLicenseExpirationWarning';
|
|
21
20
|
export * from './useRefreshInterval';
|
|
22
21
|
export * from './centreonBaseURL';
|
|
22
|
+
export * from './usePluralizedTranslation';
|
|
23
|
+
export * from './useResizeObserver';
|