@centreon/ui 24.4.36 → 24.4.38
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.stories.tsx +1 -1
- package/src/Button/Icon/index.tsx +2 -2
- 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 +3 -3
- package/src/InputField/Select/index.tsx +1 -1
- package/src/InputField/Text/index.tsx +2 -2
- package/src/Listing/ActionBar/index.tsx +1 -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/Panel/index.tsx +1 -1
- 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/{AccessRightsV2 → AccessRights}/AccessRights.cypress.spec.tsx +23 -0
- package/src/components/Form/{AccessRightsV2 → AccessRights}/ShareInput/ContactSwitch.tsx +9 -1
- package/src/components/Form/{AccessRightsV2 → AccessRights}/ShareInput/ShareInput.styles.ts +8 -0
- package/src/components/Form/{AccessRightsV2 → AccessRights}/ShareInput/useShareInput.tsx +4 -0
- package/src/components/Form/{AccessRightsV2 → AccessRights}/models.ts +1 -0
- package/src/components/Form/{AccessRightsV2 → AccessRights}/storiesData.ts +1 -0
- package/src/components/Form/Dashboard/DashboardForm.tsx +12 -15
- package/src/components/Form/index.ts +2 -2
- 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/Form/AccessRights/AccessRights.resource.ts +0 -45
- package/src/components/Form/AccessRights/AccessRightsForm.stories.tsx +0 -59
- package/src/components/Form/AccessRights/AccessRightsForm.styles.ts +0 -21
- package/src/components/Form/AccessRights/AccessRightsForm.tsx +0 -67
- package/src/components/Form/AccessRights/AccessRightsFormActions.tsx +0 -80
- package/src/components/Form/AccessRights/Input/AddAction.tsx +0 -31
- package/src/components/Form/AccessRights/Input/ContactAccessRightInput.stories.tsx +0 -54
- package/src/components/Form/AccessRights/Input/ContactAccessRightInput.tsx +0 -72
- package/src/components/Form/AccessRights/Input/ContactAccessRightsInput.styles.ts +0 -22
- package/src/components/Form/AccessRights/Input/ContactInputField.tsx +0 -105
- package/src/components/Form/AccessRights/Input/RoleInputField.tsx +0 -29
- package/src/components/Form/AccessRights/List/ContactAccessRightsList.stories.tsx +0 -97
- package/src/components/Form/AccessRights/List/ContactAccessRightsList.styles.ts +0 -71
- package/src/components/Form/AccessRights/List/ContactAccessRightsList.tsx +0 -51
- package/src/components/Form/AccessRights/List/ContactAccessRightsListItem.stories.tsx +0 -116
- package/src/components/Form/AccessRights/List/ContactAccessRightsListItem.tsx +0 -118
- package/src/components/Form/AccessRights/List/ContactAccessRightsListItemSkeleton.tsx +0 -26
- package/src/components/Form/AccessRights/List/ContactAccessRightsListSkeleton.tsx +0 -28
- package/src/components/Form/AccessRights/Stats/AccessRightsStats.styles.ts +0 -18
- package/src/components/Form/AccessRights/Stats/AccessRightsStats.tsx +0 -41
- package/src/components/Form/AccessRights/__fixtures__/contactAccessRight.mock.ts +0 -54
- package/src/components/Form/AccessRights/common/GroupLabel.styles.ts +0 -18
- package/src/components/Form/AccessRights/common/GroupLabel.tsx +0 -15
- package/src/components/Form/AccessRights/common/Input.styles.ts +0 -48
- package/src/components/Form/AccessRights/common/RoleInputSelect.styles.ts +0 -11
- package/src/components/Form/AccessRights/common/RoleInputSelect.tsx +0 -57
- package/src/components/Form/AccessRights/index.ts +0 -3
- package/src/components/Form/AccessRights/useAccessRightsForm.test.tsx +0 -531
- package/src/components/Form/AccessRights/useAccessRightsForm.tsx +0 -282
- package/src/components/Form/AccessRights/useAccessRightsForm.utils.ts +0 -41
- 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
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/AccessRights.stories.tsx +0 -0
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/AccessRights.styles.ts +0 -0
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/AccessRights.tsx +0 -0
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/Actions/Actions.styles.ts +0 -0
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/Actions/Actions.tsx +0 -0
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/Actions/useActions.ts +0 -0
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/List/Item.tsx +0 -0
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/List/List.styles.tsx +0 -0
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/List/List.tsx +0 -0
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/List/ListItemSkeleton.tsx +0 -0
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/List/ListSkeleton.tsx +0 -0
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/List/RemoveAccessRight.tsx +0 -0
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/List/StateChip.tsx +0 -0
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/List/useItem.ts +0 -0
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/Provider.tsx +0 -0
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/ShareInput/ShareInput.tsx +0 -0
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/Stats/Stats.tsx +0 -0
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/atoms.ts +0 -0
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/common/RoleSelectField.styles.tsx +0 -0
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/common/RoleSelectField.tsx +0 -0
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/useAccessRightsInitValues.ts +0 -0
|
@@ -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,45 +0,0 @@
|
|
|
1
|
-
export type ContactAccessRightState =
|
|
2
|
-
| 'added'
|
|
3
|
-
| 'updated'
|
|
4
|
-
| 'removed'
|
|
5
|
-
| 'unchanged';
|
|
6
|
-
|
|
7
|
-
export type ContactAccessRightStateResource = {
|
|
8
|
-
contactAccessRight: ContactAccessRightResource;
|
|
9
|
-
state: ContactAccessRightState;
|
|
10
|
-
stateHistory: Array<ContactAccessRightState>;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export type ContactAccessRightResource = {
|
|
14
|
-
contact: ContactResource | ContactGroupResource | null;
|
|
15
|
-
role: RoleResource['role'];
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export type ContactResource = {
|
|
19
|
-
email?: string;
|
|
20
|
-
id?: number | string;
|
|
21
|
-
name: string;
|
|
22
|
-
type: 'contact';
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export const isContactResource = (
|
|
26
|
-
resource: ContactResource | ContactGroupResource | null
|
|
27
|
-
): resource is ContactResource => {
|
|
28
|
-
return resource?.type === 'contact';
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export type ContactGroupResource = {
|
|
32
|
-
id?: number | string;
|
|
33
|
-
name: string;
|
|
34
|
-
type: 'contact_group';
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export const isContactGroupResource = (
|
|
38
|
-
resource: ContactResource | ContactGroupResource | null
|
|
39
|
-
): resource is ContactResource => {
|
|
40
|
-
return resource?.type === 'contact_group';
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export type RoleResource = {
|
|
44
|
-
role: 'viewer' | 'editor' | string;
|
|
45
|
-
};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
|
|
3
|
-
import { AccessRightsForm } from './AccessRightsForm';
|
|
4
|
-
import { Default as DefaultContactAccessRightsListStory } from './List/ContactAccessRightsList.stories';
|
|
5
|
-
import { Default as DefaultContactAccessRightInputStory } from './Input/ContactAccessRightInput.stories';
|
|
6
|
-
import { ContactAccessRightsListProps } from './List/ContactAccessRightsList';
|
|
7
|
-
import { ContactAccessRightInputProps } from './Input/ContactAccessRightInput';
|
|
8
|
-
import {
|
|
9
|
-
contactAccessRightsMock,
|
|
10
|
-
contactsAndGroupsMock
|
|
11
|
-
} from './__fixtures__/contactAccessRight.mock';
|
|
12
|
-
|
|
13
|
-
const meta: Meta<typeof AccessRightsForm> = {
|
|
14
|
-
component: AccessRightsForm
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export default meta;
|
|
18
|
-
type Story = StoryObj<typeof AccessRightsForm>;
|
|
19
|
-
|
|
20
|
-
export const Default: Story = {
|
|
21
|
-
args: {
|
|
22
|
-
initialValues: contactAccessRightsMock(12),
|
|
23
|
-
labels: {
|
|
24
|
-
actions: {
|
|
25
|
-
cancel: 'Cancel',
|
|
26
|
-
copyLink: 'Copy link',
|
|
27
|
-
copyLinkMessages: {
|
|
28
|
-
error: 'Unable to copy link',
|
|
29
|
-
success: 'Link copied'
|
|
30
|
-
},
|
|
31
|
-
submit: 'Update'
|
|
32
|
-
},
|
|
33
|
-
input: {
|
|
34
|
-
...DefaultContactAccessRightInputStory.args?.labels
|
|
35
|
-
} as ContactAccessRightInputProps['labels'],
|
|
36
|
-
list: {
|
|
37
|
-
...DefaultContactAccessRightsListStory.args?.labels
|
|
38
|
-
} as ContactAccessRightsListProps['labels'],
|
|
39
|
-
stats: {
|
|
40
|
-
added: 'added',
|
|
41
|
-
removed: 'removed',
|
|
42
|
-
updated: 'updated'
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
options: {
|
|
46
|
-
contacts: contactsAndGroupsMock(25),
|
|
47
|
-
roles: [{ role: 'viewer' }, { role: 'editor' }]
|
|
48
|
-
},
|
|
49
|
-
resourceLink: 'https://app.centreon.com/resource/1'
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export const AsEmptyState: Story = {
|
|
54
|
-
args: {
|
|
55
|
-
labels: Default.args?.labels,
|
|
56
|
-
options: Default.args?.options,
|
|
57
|
-
resourceLink: Default.args?.resourceLink
|
|
58
|
-
}
|
|
59
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { makeStyles } from 'tss-react/mui';
|
|
2
|
-
|
|
3
|
-
const useStyles = makeStyles()((theme) => ({
|
|
4
|
-
accessRightsForm: {
|
|
5
|
-
display: 'flex',
|
|
6
|
-
flexDirection: 'column',
|
|
7
|
-
gap: theme.spacing(6),
|
|
8
|
-
|
|
9
|
-
maxWidth: '520px',
|
|
10
|
-
paddingTop: theme.spacing(3),
|
|
11
|
-
|
|
12
|
-
width: '100%'
|
|
13
|
-
},
|
|
14
|
-
accessRightsFormList: {
|
|
15
|
-
display: 'flex',
|
|
16
|
-
flexDirection: 'column',
|
|
17
|
-
gap: theme.spacing(1)
|
|
18
|
-
}
|
|
19
|
-
}));
|
|
20
|
-
|
|
21
|
-
export { useStyles };
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
|
|
3
|
-
import { useStyles } from './AccessRightsForm.styles';
|
|
4
|
-
import {
|
|
5
|
-
AccessRightsFormProvider,
|
|
6
|
-
AccessRightsFormProviderProps
|
|
7
|
-
} from './useAccessRightsForm';
|
|
8
|
-
import {
|
|
9
|
-
ContactAccessRightInput,
|
|
10
|
-
ContactAccessRightInputProps
|
|
11
|
-
} from './Input/ContactAccessRightInput';
|
|
12
|
-
import {
|
|
13
|
-
ContactAccessRightsList,
|
|
14
|
-
ContactAccessRightsListProps
|
|
15
|
-
} from './List/ContactAccessRightsList';
|
|
16
|
-
import {
|
|
17
|
-
AccessRightsFormActions,
|
|
18
|
-
AccessRightsFormActionsProps
|
|
19
|
-
} from './AccessRightsFormActions';
|
|
20
|
-
import {
|
|
21
|
-
AccessRightsStats,
|
|
22
|
-
AccessRightsStatsProps
|
|
23
|
-
} from './Stats/AccessRightsStats';
|
|
24
|
-
|
|
25
|
-
export type AccessRightsFormProps = {
|
|
26
|
-
labels: AccessRightsFormLabels;
|
|
27
|
-
onCancel?: AccessRightsFormActionsProps['onCancel'];
|
|
28
|
-
resourceLink: string;
|
|
29
|
-
} & Pick<
|
|
30
|
-
AccessRightsFormProviderProps,
|
|
31
|
-
'initialValues' | 'onSubmit' | 'options' | 'loadingStatus'
|
|
32
|
-
>;
|
|
33
|
-
|
|
34
|
-
export type AccessRightsFormLabels = {
|
|
35
|
-
actions: AccessRightsFormActionsProps['labels'];
|
|
36
|
-
input: ContactAccessRightInputProps['labels'];
|
|
37
|
-
list: ContactAccessRightsListProps['labels'];
|
|
38
|
-
stats: AccessRightsStatsProps['labels'];
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const AccessRightsForm = ({
|
|
42
|
-
labels,
|
|
43
|
-
onCancel,
|
|
44
|
-
resourceLink,
|
|
45
|
-
...providerProps
|
|
46
|
-
}: AccessRightsFormProps): ReactElement => {
|
|
47
|
-
const { classes } = useStyles();
|
|
48
|
-
|
|
49
|
-
return (
|
|
50
|
-
<AccessRightsFormProvider {...providerProps}>
|
|
51
|
-
<div className={classes.accessRightsForm}>
|
|
52
|
-
<ContactAccessRightInput labels={labels.input} />
|
|
53
|
-
<span className={classes.accessRightsFormList}>
|
|
54
|
-
<ContactAccessRightsList labels={labels.list} />
|
|
55
|
-
<AccessRightsStats labels={labels.stats} />
|
|
56
|
-
</span>
|
|
57
|
-
<AccessRightsFormActions
|
|
58
|
-
labels={labels.actions}
|
|
59
|
-
resourceLink={resourceLink}
|
|
60
|
-
onCancel={onCancel}
|
|
61
|
-
/>
|
|
62
|
-
</div>
|
|
63
|
-
</AccessRightsFormProvider>
|
|
64
|
-
);
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export { AccessRightsForm };
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
|
|
3
|
-
import { Link as LinkIcon } from '@mui/icons-material';
|
|
4
|
-
|
|
5
|
-
import { Button } from '../../Button';
|
|
6
|
-
import { useStyles } from '../Form.styles';
|
|
7
|
-
import { useCopyToClipboard } from '../../../utils';
|
|
8
|
-
|
|
9
|
-
import { useAccessRightsForm } from './useAccessRightsForm';
|
|
10
|
-
|
|
11
|
-
export type AccessRightsFormActionsProps = {
|
|
12
|
-
labels: AccessRightsFormActionsLabels;
|
|
13
|
-
onCancel?: () => void;
|
|
14
|
-
resourceLink: string;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
type AccessRightsFormActionsLabels = {
|
|
18
|
-
cancel: string;
|
|
19
|
-
copyLink: string;
|
|
20
|
-
copyLinkMessages: {
|
|
21
|
-
error: string;
|
|
22
|
-
success: string;
|
|
23
|
-
};
|
|
24
|
-
submit: string;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const AccessRightsFormActions = ({
|
|
28
|
-
labels,
|
|
29
|
-
onCancel,
|
|
30
|
-
resourceLink
|
|
31
|
-
}: AccessRightsFormActionsProps): ReactElement => {
|
|
32
|
-
const { classes } = useStyles();
|
|
33
|
-
const { isDirty, submit } = useAccessRightsForm();
|
|
34
|
-
const { copy } = useCopyToClipboard({
|
|
35
|
-
errorMessage: labels.copyLinkMessages.error,
|
|
36
|
-
successMessage: labels.copyLinkMessages.success
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<div className={classes.actions}>
|
|
41
|
-
<span>
|
|
42
|
-
<Button
|
|
43
|
-
aria-label={labels.copyLink}
|
|
44
|
-
data-testid="copy-link"
|
|
45
|
-
icon={<LinkIcon />}
|
|
46
|
-
iconVariant="start"
|
|
47
|
-
size="small"
|
|
48
|
-
variant="ghost"
|
|
49
|
-
onClick={() => copy(resourceLink)}
|
|
50
|
-
>
|
|
51
|
-
{labels.copyLink}
|
|
52
|
-
</Button>
|
|
53
|
-
</span>
|
|
54
|
-
<span>
|
|
55
|
-
<Button
|
|
56
|
-
aria-label={labels.cancel}
|
|
57
|
-
data-testid="cancel"
|
|
58
|
-
size="medium"
|
|
59
|
-
variant="secondary"
|
|
60
|
-
onClick={() => onCancel?.()}
|
|
61
|
-
>
|
|
62
|
-
{labels.cancel}
|
|
63
|
-
</Button>
|
|
64
|
-
<Button
|
|
65
|
-
aria-label={labels.submit}
|
|
66
|
-
data-testid="submit"
|
|
67
|
-
disabled={!isDirty}
|
|
68
|
-
size="medium"
|
|
69
|
-
type="submit"
|
|
70
|
-
variant="primary"
|
|
71
|
-
onClick={submit}
|
|
72
|
-
>
|
|
73
|
-
{labels.submit}
|
|
74
|
-
</Button>
|
|
75
|
-
</span>
|
|
76
|
-
</div>
|
|
77
|
-
);
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
export { AccessRightsFormActions };
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
|
|
3
|
-
import { useFormikContext } from 'formik';
|
|
4
|
-
|
|
5
|
-
import { Add as AddIcon } from '@mui/icons-material';
|
|
6
|
-
|
|
7
|
-
import { ContactAccessRightResource } from '../AccessRights.resource';
|
|
8
|
-
import { IconButton } from '../../../Button';
|
|
9
|
-
|
|
10
|
-
type AddActionProps = {
|
|
11
|
-
label?: string;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const AddAction = ({ label }: AddActionProps): ReactElement => {
|
|
15
|
-
const { dirty, isValid, submitForm } =
|
|
16
|
-
useFormikContext<Partial<ContactAccessRightResource>>();
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<IconButton
|
|
20
|
-
aria-label={label}
|
|
21
|
-
data-testid="add"
|
|
22
|
-
disabled={!dirty || !isValid}
|
|
23
|
-
icon={<AddIcon />}
|
|
24
|
-
size="medium"
|
|
25
|
-
variant="primary"
|
|
26
|
-
onClick={submitForm}
|
|
27
|
-
/>
|
|
28
|
-
);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export { AddAction };
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { ReactElement, ReactNode } from 'react';
|
|
2
|
-
|
|
3
|
-
import { Meta, StoryObj } from '@storybook/react';
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
AccessRightsFormProvider,
|
|
7
|
-
AccessRightsFormProviderProps
|
|
8
|
-
} from '../useAccessRightsForm';
|
|
9
|
-
import { contactsAndGroupsMock } from '../__fixtures__/contactAccessRight.mock';
|
|
10
|
-
|
|
11
|
-
import { ContactAccessRightInput } from './ContactAccessRightInput';
|
|
12
|
-
|
|
13
|
-
const meta: Meta<typeof ContactAccessRightInput> = {
|
|
14
|
-
component: ContactAccessRightInput,
|
|
15
|
-
title: 'components/Form/AccessRights/ContactAccessRightInput'
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export default meta;
|
|
19
|
-
type Story = StoryObj<typeof ContactAccessRightInput>;
|
|
20
|
-
|
|
21
|
-
const Wrapper = ({ children }: { children: ReactNode }): ReactElement => {
|
|
22
|
-
const options: AccessRightsFormProviderProps['options'] = {
|
|
23
|
-
contacts: contactsAndGroupsMock(25),
|
|
24
|
-
roles: [{ role: 'viewer' }, { role: 'editor' }]
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<AccessRightsFormProvider options={options}>
|
|
29
|
-
{children}
|
|
30
|
-
</AccessRightsFormProvider>
|
|
31
|
-
);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export const Default: Story = {
|
|
35
|
-
args: {
|
|
36
|
-
labels: {
|
|
37
|
-
actions: {
|
|
38
|
-
add: 'Add'
|
|
39
|
-
},
|
|
40
|
-
fields: {
|
|
41
|
-
contact: {
|
|
42
|
-
group: 'group',
|
|
43
|
-
noOptionsText: 'No contacts found',
|
|
44
|
-
placeholder: 'Add Contact...'
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
render: (args) => (
|
|
50
|
-
<Wrapper>
|
|
51
|
-
<ContactAccessRightInput labels={args.labels} />
|
|
52
|
-
</Wrapper>
|
|
53
|
-
)
|
|
54
|
-
};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
|
|
3
|
-
import { FormikProvider, useFormik } from 'formik';
|
|
4
|
-
import { mixed, object } from 'yup';
|
|
5
|
-
|
|
6
|
-
import { useAccessRightsForm } from '../useAccessRightsForm';
|
|
7
|
-
import { ContactAccessRightResource } from '../AccessRights.resource';
|
|
8
|
-
|
|
9
|
-
import { useStyles } from './ContactAccessRightsInput.styles';
|
|
10
|
-
import { ContactInputField, ContactInputFieldProps } from './ContactInputField';
|
|
11
|
-
import { AddAction } from './AddAction';
|
|
12
|
-
import { RoleInputField } from './RoleInputField';
|
|
13
|
-
|
|
14
|
-
export type ContactAccessRightInputProps = {
|
|
15
|
-
labels: ContactAccessRightInputLabels;
|
|
16
|
-
onAddContactAccessRight?: (value: ContactAccessRightResource) => void;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
type ContactAccessRightInputLabels = {
|
|
20
|
-
actions?: {
|
|
21
|
-
add: string;
|
|
22
|
-
};
|
|
23
|
-
fields: {
|
|
24
|
-
contact: ContactInputFieldProps['labels'];
|
|
25
|
-
role?: {
|
|
26
|
-
label: string;
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const ContactAccessRightInput = ({
|
|
32
|
-
labels,
|
|
33
|
-
onAddContactAccessRight
|
|
34
|
-
}: ContactAccessRightInputProps): ReactElement => {
|
|
35
|
-
const { classes } = useStyles();
|
|
36
|
-
const { addContactAccessRight, options } = useAccessRightsForm();
|
|
37
|
-
|
|
38
|
-
const formik = useFormik<ContactAccessRightResource>({
|
|
39
|
-
initialValues: { contact: null, role: 'viewer' },
|
|
40
|
-
onSubmit: (values, { resetForm }) => {
|
|
41
|
-
addContactAccessRight(values);
|
|
42
|
-
onAddContactAccessRight?.(values);
|
|
43
|
-
resetForm();
|
|
44
|
-
},
|
|
45
|
-
validationSchema: object({
|
|
46
|
-
contact: mixed()
|
|
47
|
-
.test(
|
|
48
|
-
'is-available-contact',
|
|
49
|
-
(d) => `${d.path} is not a contact available from the list`,
|
|
50
|
-
(value) => !!options.contacts?.find((c) => c.id === value?.id)
|
|
51
|
-
)
|
|
52
|
-
.required(),
|
|
53
|
-
role: mixed().oneOf(['viewer', 'editor']).required()
|
|
54
|
-
})
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
return (
|
|
58
|
-
<div className={classes.contactAccessRightsInput}>
|
|
59
|
-
<FormikProvider value={formik}>
|
|
60
|
-
<ContactInputField
|
|
61
|
-
id="contact"
|
|
62
|
-
labels={labels.fields.contact}
|
|
63
|
-
name="contact"
|
|
64
|
-
/>
|
|
65
|
-
<RoleInputField id="role" name="role" {...labels?.fields?.role} />
|
|
66
|
-
<AddAction />
|
|
67
|
-
</FormikProvider>
|
|
68
|
-
</div>
|
|
69
|
-
);
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export { ContactAccessRightInput };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { makeStyles } from 'tss-react/mui';
|
|
2
|
-
|
|
3
|
-
const useStyles = makeStyles()((theme) => ({
|
|
4
|
-
contactAccessRightsInput: {
|
|
5
|
-
alignItems: 'center',
|
|
6
|
-
display: 'flex',
|
|
7
|
-
flexGrow: 1,
|
|
8
|
-
gap: theme.spacing(2),
|
|
9
|
-
maxWidth: '520px',
|
|
10
|
-
|
|
11
|
-
width: '100%'
|
|
12
|
-
},
|
|
13
|
-
contactInput: {
|
|
14
|
-
'& .MuiOutlinedInput-root, & .MuiInputBase-input.MuiOutlinedInput-input': {
|
|
15
|
-
height: 'unset',
|
|
16
|
-
lineHeight: '1.5'
|
|
17
|
-
},
|
|
18
|
-
flexGrow: 1
|
|
19
|
-
}
|
|
20
|
-
}));
|
|
21
|
-
|
|
22
|
-
export { useStyles };
|