@centreon/ui 24.4.39 → 24.4.40
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 +14 -19
- 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 +5 -9
- 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 +1 -3
- package/src/Form/Inputs/CheckboxGroup.tsx +4 -1
- package/src/Form/Inputs/index.tsx +1 -3
- package/src/Form/Inputs/models.ts +1 -9
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/Circle.tsx +2 -2
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/index.tsx +4 -5
- 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 +3 -2
- package/src/Graph/LineChart/InteractiveComponents/Annotations/EventAnnotations.tsx +1 -1
- package/src/Graph/LineChart/Legend/useLegend.ts +3 -3
- package/src/Graph/LineChart/helpers/doc.ts +13 -16
- package/src/Graph/LineChart/helpers/index.ts +1 -1
- package/src/Graph/LineChart/index.stories.tsx +2 -4
- package/src/Graph/SingleBar/Thresholds.tsx +2 -2
- package/src/Graph/Text/Text.stories.tsx +4 -60
- package/src/Graph/common/timeSeries/index.ts +3 -3
- package/src/InputField/Select/Autocomplete/Connected/index.tsx +7 -10
- 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 +115 -121
- 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 +1 -15
- package/src/Listing/Header/ListingHeader.tsx +1 -1
- package/src/Listing/Listing.styles.ts +3 -2
- package/src/Listing/index.stories.tsx +1 -12
- package/src/Listing/index.tsx +2 -1
- package/src/Module/index.tsx +4 -2
- package/src/RichTextEditor/RichTextEditor.tsx +1 -12
- package/src/SortableItems/index.tsx +7 -2
- package/src/ThemeProvider/index.tsx +0 -24
- package/src/TimePeriods/CustomTimePeriod/CompactCustomTimePeriod.styles.ts +7 -6
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/PickersStartEndDate.tsx +3 -8
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/models.ts +2 -0
- package/src/TimePeriods/DateTimePickerInput.tsx +19 -56
- package/src/TimePeriods/ResolutionTimePeriod.cypress.spec.tsx +9 -12
- package/src/TimePeriods/TimePeriods.cypress.spec.tsx +33 -9
- package/src/TimePeriods/helpers/index.ts +1 -1
- package/src/TimePeriods/index.stories.tsx +4 -12
- 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 +23 -27
- package/src/api/useMutationQuery/index.ts +21 -45
- package/src/components/Button/Icon/IconButton.tsx +2 -6
- package/src/components/DataTable/DataTable.stories.tsx +0 -40
- package/src/components/DataTable/DataTable.styles.ts +0 -3
- package/src/components/DataTable/DataTable.tsx +3 -3
- package/src/components/DataTable/Item/DataTableItem.styles.ts +2 -7
- package/src/components/DataTable/Item/DataTableItem.tsx +4 -4
- package/src/components/DataTable/index.ts +1 -3
- package/src/components/Form/Dashboard/DashboardForm.tsx +12 -15
- package/src/components/Layout/PageLayout/PageLayout.tsx +1 -1
- package/src/components/Layout/PageLayout/PageLayoutActions.tsx +0 -1
- package/src/components/Layout/PageLayout/PageLayoutBody.tsx +0 -1
- package/src/components/Layout/PageLayout/PageLayoutHeader.tsx +1 -5
- package/src/components/Layout/PageLayout/index.ts +1 -3
- 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 +1 -5
- package/src/screens/dashboard/DashboardsDetail.stories.tsx +108 -0
- package/src/screens/dashboard/DashboardsOverview.stories.tsx +281 -0
- package/src/utils/index.ts +1 -2
- package/src/utils/useDateTimePickerAdapter.ts +309 -0
- package/src/utils/{useLicenseExpirationWarning.test.tsx → useLicenseExpirationWarning.cypress.spec.tsx} +37 -48
- package/src/utils/useLicenseExpirationWarning.ts +18 -18
- package/src/Form/Form.cypress.spec.tsx +0 -133
- package/src/Form/Inputs/List/Content.tsx +0 -62
- package/src/Form/Inputs/List/List.styles.ts +0 -29
- package/src/Form/Inputs/List/List.tsx +0 -58
- package/src/Form/Inputs/List/useList.ts +0 -81
- package/src/Module/Module.cypress.spec.tsx +0 -129
- package/src/components/DataTable/DataListing.tsx +0 -6
- package/src/components/DataTable/DataTable.cypress.spec.tsx +0 -193
- package/src/components/Layout/PageLayout/PageQuickAccess.tsx +0 -76
- package/src/components/Layout/PageLayout.cypress.spec.tsx +0 -66
- package/src/utils/usePluralizedTranslation.ts +0 -21
|
@@ -1,29 +0,0 @@
|
|
|
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
|
-
}));
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { ComponentType } from 'react';
|
|
2
|
-
|
|
3
|
-
import { closestCenter } from '@dnd-kit/core';
|
|
4
|
-
import { verticalListSortingStrategy } from '@dnd-kit/sortable';
|
|
5
|
-
import { useTranslation } from 'react-i18next';
|
|
6
|
-
|
|
7
|
-
import { InputPropsWithoutGroup } from '../models';
|
|
8
|
-
import { SortableItems, Subtitle } from '../../..';
|
|
9
|
-
|
|
10
|
-
import { useList } from './useList';
|
|
11
|
-
import { useListStyles } from './List.styles';
|
|
12
|
-
import Content, { ContentProps } from './Content';
|
|
13
|
-
|
|
14
|
-
const List = ({
|
|
15
|
-
list,
|
|
16
|
-
fieldName
|
|
17
|
-
}: InputPropsWithoutGroup): JSX.Element | null => {
|
|
18
|
-
const { t } = useTranslation();
|
|
19
|
-
const { classes } = useListStyles();
|
|
20
|
-
|
|
21
|
-
const { addItem, sortList, sortedList, deleteItem } = useList({ fieldName });
|
|
22
|
-
|
|
23
|
-
const { AddItem, addItemLabel, sortLabel, SortContent, itemProps } = list as {
|
|
24
|
-
AddItem: ComponentType<{ addItem }>;
|
|
25
|
-
SortContent: ComponentType;
|
|
26
|
-
addItemLabel?: string;
|
|
27
|
-
itemProps: Array<string>;
|
|
28
|
-
sortLabel?: string;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<div className={classes.list}>
|
|
33
|
-
{addItemLabel && <Subtitle>{t(addItemLabel)}</Subtitle>}
|
|
34
|
-
<AddItem addItem={addItem} />
|
|
35
|
-
{sortLabel && <Subtitle>{t(sortLabel)}</Subtitle>}
|
|
36
|
-
<div className={classes.items}>
|
|
37
|
-
<SortableItems
|
|
38
|
-
updateSortableItemsOnItemsChange
|
|
39
|
-
// eslint-disable-next-line react/no-unstable-nested-components
|
|
40
|
-
Content={(props: Omit<ContentProps, 'children' | 'deleteItem'>) => (
|
|
41
|
-
<Content {...props} deleteItem={deleteItem}>
|
|
42
|
-
<SortContent {...props} />
|
|
43
|
-
</Content>
|
|
44
|
-
)}
|
|
45
|
-
collisionDetection={closestCenter}
|
|
46
|
-
itemProps={itemProps}
|
|
47
|
-
items={sortedList}
|
|
48
|
-
sortingStrategy={verticalListSortingStrategy}
|
|
49
|
-
onDragEnd={({ items }): void => {
|
|
50
|
-
sortList(items);
|
|
51
|
-
}}
|
|
52
|
-
/>
|
|
53
|
-
</div>
|
|
54
|
-
</div>
|
|
55
|
-
);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export default List;
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { useMemo, useRef } from 'react';
|
|
2
|
-
|
|
3
|
-
import { FormikValues, useFormikContext } from 'formik';
|
|
4
|
-
import {
|
|
5
|
-
append,
|
|
6
|
-
equals,
|
|
7
|
-
inc,
|
|
8
|
-
isEmpty,
|
|
9
|
-
pluck,
|
|
10
|
-
prop,
|
|
11
|
-
reject,
|
|
12
|
-
sortBy
|
|
13
|
-
} from 'ramda';
|
|
14
|
-
|
|
15
|
-
import { SelectEntry } from '../../..';
|
|
16
|
-
|
|
17
|
-
interface UseListState {
|
|
18
|
-
addItem: (newItem: SelectEntry) => void;
|
|
19
|
-
deleteItem: (id: string) => () => void;
|
|
20
|
-
sortList: (items: Array<string>) => void;
|
|
21
|
-
sortedList: Array<unknown>;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const useList = ({ fieldName }): UseListState => {
|
|
25
|
-
const { values, setFieldValue } = useFormikContext<FormikValues>();
|
|
26
|
-
const maxOrder = useRef(0);
|
|
27
|
-
|
|
28
|
-
const list = values[fieldName];
|
|
29
|
-
|
|
30
|
-
const sortedList = useMemo(
|
|
31
|
-
() =>
|
|
32
|
-
sortBy(prop('order'), list).map(({ id, ...props }) => ({
|
|
33
|
-
id: `${id}`,
|
|
34
|
-
...props
|
|
35
|
-
})),
|
|
36
|
-
[list]
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
const addItem = (newItem: SelectEntry): void => {
|
|
40
|
-
setFieldValue(
|
|
41
|
-
fieldName,
|
|
42
|
-
append(
|
|
43
|
-
{
|
|
44
|
-
...newItem,
|
|
45
|
-
id: (newItem as SelectEntry).id as number,
|
|
46
|
-
order: inc(maxOrder.current)
|
|
47
|
-
},
|
|
48
|
-
list
|
|
49
|
-
)
|
|
50
|
-
);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const deleteItem = (id: string) => (): void => {
|
|
54
|
-
const newItems = reject((item) => equals(Number(id), item.id))(list);
|
|
55
|
-
|
|
56
|
-
setFieldValue(fieldName, newItems);
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const sortList = (items: Array<string>): void => {
|
|
60
|
-
const newOrderedList = items.map((itemId, idx) => {
|
|
61
|
-
const item = sortedList.find(({ id }) => equals(id, itemId));
|
|
62
|
-
|
|
63
|
-
return {
|
|
64
|
-
...item,
|
|
65
|
-
id: Number(item?.id),
|
|
66
|
-
order: inc(idx)
|
|
67
|
-
};
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
setFieldValue(fieldName, newOrderedList);
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
maxOrder.current = isEmpty(list) ? 0 : Math.max(...pluck('order', list));
|
|
74
|
-
|
|
75
|
-
return {
|
|
76
|
-
addItem,
|
|
77
|
-
deleteItem,
|
|
78
|
-
sortList,
|
|
79
|
-
sortedList
|
|
80
|
-
};
|
|
81
|
-
};
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { createStore } from 'jotai';
|
|
2
|
-
|
|
3
|
-
import { Method } from '..';
|
|
4
|
-
|
|
5
|
-
import LicensedModule from './LicensedModule';
|
|
6
|
-
|
|
7
|
-
import Module from '.';
|
|
8
|
-
|
|
9
|
-
const initializeModule = (): void => {
|
|
10
|
-
cy.mount({
|
|
11
|
-
Component: (
|
|
12
|
-
<Module seedName="seed" store={createStore()}>
|
|
13
|
-
<p>Module</p>
|
|
14
|
-
</Module>
|
|
15
|
-
)
|
|
16
|
-
});
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const initializeModuleWithValidLicense = (
|
|
20
|
-
isFederatedComponent = false
|
|
21
|
-
): void => {
|
|
22
|
-
cy.interceptAPIRequest({
|
|
23
|
-
alias: 'getValidLicense',
|
|
24
|
-
method: Method.GET,
|
|
25
|
-
path: './api/internal.php?object=centreon_license_manager&action=licenseValid&productName=valid',
|
|
26
|
-
response: {
|
|
27
|
-
success: true
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
cy.mount({
|
|
32
|
-
Component: (
|
|
33
|
-
<div style={{ height: '100vh' }}>
|
|
34
|
-
<LicensedModule
|
|
35
|
-
isFederatedComponent={isFederatedComponent}
|
|
36
|
-
moduleName="valid"
|
|
37
|
-
seedName="seed"
|
|
38
|
-
store={createStore()}
|
|
39
|
-
>
|
|
40
|
-
<p>Module</p>
|
|
41
|
-
</LicensedModule>
|
|
42
|
-
</div>
|
|
43
|
-
)
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const initializeModuleWithInvalidLicense = (
|
|
48
|
-
isFederatedComponent = false
|
|
49
|
-
): void => {
|
|
50
|
-
cy.interceptAPIRequest({
|
|
51
|
-
alias: 'getInvalidLicense',
|
|
52
|
-
method: Method.GET,
|
|
53
|
-
path: './api/internal.php?object=centreon_license_manager&action=licenseValid&productName=invalid',
|
|
54
|
-
response: {
|
|
55
|
-
success: false
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
cy.mount({
|
|
60
|
-
Component: (
|
|
61
|
-
<div style={{ height: '100vh' }}>
|
|
62
|
-
<LicensedModule
|
|
63
|
-
isFederatedComponent={isFederatedComponent}
|
|
64
|
-
moduleName="invalid"
|
|
65
|
-
seedName="seed"
|
|
66
|
-
store={createStore()}
|
|
67
|
-
>
|
|
68
|
-
<p>Module</p>
|
|
69
|
-
</LicensedModule>
|
|
70
|
-
</div>
|
|
71
|
-
)
|
|
72
|
-
});
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
describe('Module', () => {
|
|
76
|
-
beforeEach(() => {
|
|
77
|
-
initializeModule();
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it('displays the content of the module', () => {
|
|
81
|
-
cy.contains('Module').should('be.visible');
|
|
82
|
-
|
|
83
|
-
cy.makeSnapshot();
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
describe('Valid license module', () => {
|
|
88
|
-
it('displays the content of the page when the license is valid license', () => {
|
|
89
|
-
initializeModuleWithValidLicense();
|
|
90
|
-
cy.waitForRequest('@getValidLicense');
|
|
91
|
-
|
|
92
|
-
cy.contains('Module').should('be.visible');
|
|
93
|
-
|
|
94
|
-
cy.makeSnapshot();
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it('displays the content of the component when the license is valid license', () => {
|
|
98
|
-
initializeModuleWithValidLicense(true);
|
|
99
|
-
|
|
100
|
-
cy.contains('Module').should('be.visible');
|
|
101
|
-
|
|
102
|
-
cy.makeSnapshot();
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
describe('Invalid license module', () => {
|
|
107
|
-
it('displays the content of the page when the license is invalid license', () => {
|
|
108
|
-
initializeModuleWithInvalidLicense();
|
|
109
|
-
cy.waitForRequest('@getInvalidLicense');
|
|
110
|
-
|
|
111
|
-
cy.contains('Module').should('not.exist');
|
|
112
|
-
|
|
113
|
-
cy.contains('Oops').should('be.visible');
|
|
114
|
-
cy.contains('License invalid or expired').should('be.visible');
|
|
115
|
-
cy.contains('Please contact your administrator.').should('be.visible');
|
|
116
|
-
cy.get('img[alt="License invalid or expired !"]').should('be.visible');
|
|
117
|
-
cy.get('img[alt="Centreon Logo"]').should('be.visible');
|
|
118
|
-
|
|
119
|
-
cy.makeSnapshot();
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
it('displays the content of the module when the license is invalid license', () => {
|
|
123
|
-
initializeModuleWithInvalidLicense(true);
|
|
124
|
-
|
|
125
|
-
cy.contains('Module').should('not.exist');
|
|
126
|
-
|
|
127
|
-
cy.makeSnapshot();
|
|
128
|
-
});
|
|
129
|
-
});
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import { Box } from '@mui/material';
|
|
2
|
-
|
|
3
|
-
import { ColumnType } from '../../Listing/models';
|
|
4
|
-
|
|
5
|
-
import { DataTable } from '.';
|
|
6
|
-
|
|
7
|
-
const data = Array(5)
|
|
8
|
-
.fill(0)
|
|
9
|
-
.map((_, idx) => ({
|
|
10
|
-
description: `Description ${idx}`,
|
|
11
|
-
id: idx,
|
|
12
|
-
title: `Entity ${idx}`
|
|
13
|
-
}));
|
|
14
|
-
|
|
15
|
-
const initializeDataTableGrid = ({
|
|
16
|
-
hasActions,
|
|
17
|
-
hasCardAction,
|
|
18
|
-
canDelete
|
|
19
|
-
}): void => {
|
|
20
|
-
cy.viewport(1200, 590);
|
|
21
|
-
cy.mount({
|
|
22
|
-
Component: (
|
|
23
|
-
<DataTable variant="grid">
|
|
24
|
-
{data.map(({ title, description }) => (
|
|
25
|
-
<DataTable.Item
|
|
26
|
-
description={description}
|
|
27
|
-
hasActions={hasActions}
|
|
28
|
-
hasCardAction={hasCardAction}
|
|
29
|
-
key={title}
|
|
30
|
-
labelsDelete={{
|
|
31
|
-
cancel: 'Cancel',
|
|
32
|
-
confirm: {
|
|
33
|
-
label: 'Delete'
|
|
34
|
-
}
|
|
35
|
-
}}
|
|
36
|
-
title={title}
|
|
37
|
-
onDelete={canDelete ? cy.stub() : undefined}
|
|
38
|
-
/>
|
|
39
|
-
))}
|
|
40
|
-
</DataTable>
|
|
41
|
-
)
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const initializeDataTableEmpty = (canCreate = false): void => {
|
|
46
|
-
cy.viewport(1200, 590);
|
|
47
|
-
cy.mount({
|
|
48
|
-
Component: (
|
|
49
|
-
<DataTable isEmpty variant="grid">
|
|
50
|
-
<DataTable.EmptyState
|
|
51
|
-
canCreate={canCreate}
|
|
52
|
-
labels={{
|
|
53
|
-
actions: {
|
|
54
|
-
create: 'Create'
|
|
55
|
-
},
|
|
56
|
-
title: 'Welcome'
|
|
57
|
-
}}
|
|
58
|
-
onCreate={cy.stub()}
|
|
59
|
-
/>
|
|
60
|
-
</DataTable>
|
|
61
|
-
)
|
|
62
|
-
});
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const initializeDataTableListing = (): void => {
|
|
66
|
-
cy.viewport(1200, 590);
|
|
67
|
-
cy.mount({
|
|
68
|
-
Component: (
|
|
69
|
-
<Box sx={{ height: '100vh' }}>
|
|
70
|
-
<DataTable variant="listing">
|
|
71
|
-
<DataTable.Listing
|
|
72
|
-
columns={[
|
|
73
|
-
{
|
|
74
|
-
getFormattedString: (row) => row.title,
|
|
75
|
-
id: 'title',
|
|
76
|
-
label: 'Title',
|
|
77
|
-
type: ColumnType.string
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
getFormattedString: (row) => row.description,
|
|
81
|
-
id: 'description',
|
|
82
|
-
label: 'Description',
|
|
83
|
-
type: ColumnType.string
|
|
84
|
-
}
|
|
85
|
-
]}
|
|
86
|
-
rows={data}
|
|
87
|
-
/>
|
|
88
|
-
</DataTable>
|
|
89
|
-
</Box>
|
|
90
|
-
)
|
|
91
|
-
});
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
describe('DataTable: Grid', () => {
|
|
95
|
-
it('displays items with title and description only', () => {
|
|
96
|
-
initializeDataTableGrid({
|
|
97
|
-
canDelete: false,
|
|
98
|
-
hasActions: false,
|
|
99
|
-
hasCardAction: false
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
data.forEach(({ title, description }) => {
|
|
103
|
-
cy.contains(title).should('be.visible');
|
|
104
|
-
cy.contains(description).should('be.visible');
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
cy.makeSnapshot();
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it('displays items with actions', () => {
|
|
111
|
-
initializeDataTableGrid({
|
|
112
|
-
canDelete: false,
|
|
113
|
-
hasActions: true,
|
|
114
|
-
hasCardAction: false
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
cy.findAllByLabelText('edit access rights').should('have.length', 5);
|
|
118
|
-
cy.findAllByLabelText('edit').should('have.length', 5);
|
|
119
|
-
|
|
120
|
-
cy.makeSnapshot();
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it('displays items with delete action', () => {
|
|
124
|
-
initializeDataTableGrid({
|
|
125
|
-
canDelete: true,
|
|
126
|
-
hasActions: true,
|
|
127
|
-
hasCardAction: false
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
cy.findAllByLabelText('delete').should('have.length', 5);
|
|
131
|
-
|
|
132
|
-
cy.makeSnapshot();
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
it('displays items with card action only', () => {
|
|
136
|
-
initializeDataTableGrid({
|
|
137
|
-
canDelete: false,
|
|
138
|
-
hasActions: false,
|
|
139
|
-
hasCardAction: true
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
cy.findAllByLabelText('view').should('have.length', 5);
|
|
143
|
-
|
|
144
|
-
cy.makeSnapshot();
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it('displays items with card action and bottom actions', () => {
|
|
148
|
-
initializeDataTableGrid({
|
|
149
|
-
canDelete: true,
|
|
150
|
-
hasActions: true,
|
|
151
|
-
hasCardAction: true
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
cy.findAllByLabelText('view').should('have.length', 5);
|
|
155
|
-
cy.findAllByLabelText('delete').should('have.length', 5);
|
|
156
|
-
cy.findAllByLabelText('edit access rights').should('have.length', 5);
|
|
157
|
-
cy.findAllByLabelText('edit').should('have.length', 5);
|
|
158
|
-
|
|
159
|
-
cy.makeSnapshot();
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
describe('DataTable: Empty', () => {
|
|
164
|
-
it('displays the title', () => {
|
|
165
|
-
initializeDataTableEmpty();
|
|
166
|
-
|
|
167
|
-
cy.contains('Welcome').should('be.visible');
|
|
168
|
-
|
|
169
|
-
cy.makeSnapshot();
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
it('displays the title and the action button', () => {
|
|
173
|
-
initializeDataTableEmpty(true);
|
|
174
|
-
|
|
175
|
-
cy.contains('Welcome').should('be.visible');
|
|
176
|
-
cy.contains('Create').should('be.visible');
|
|
177
|
-
|
|
178
|
-
cy.makeSnapshot();
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
describe('DataTable: Listing', () => {
|
|
183
|
-
it('displays the listing', () => {
|
|
184
|
-
initializeDataTableListing();
|
|
185
|
-
|
|
186
|
-
data.forEach(({ title, description }) => {
|
|
187
|
-
cy.contains(title).should('be.visible');
|
|
188
|
-
cy.contains(description).should('be.visible');
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
cy.makeSnapshot();
|
|
192
|
-
});
|
|
193
|
-
});
|
|
@@ -1,76 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,66 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,21 +0,0 @@
|
|
|
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
|
-
};
|