@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,282 +0,0 @@
|
|
|
1
|
-
import { ReactElement, ReactNode, useEffect, useRef } from 'react';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
atom,
|
|
5
|
-
createStore,
|
|
6
|
-
Provider,
|
|
7
|
-
useAtom,
|
|
8
|
-
useAtomValue,
|
|
9
|
-
useSetAtom,
|
|
10
|
-
useStore
|
|
11
|
-
} from 'jotai';
|
|
12
|
-
|
|
13
|
-
import {
|
|
14
|
-
ContactAccessRightResource,
|
|
15
|
-
ContactAccessRightStateResource,
|
|
16
|
-
ContactGroupResource,
|
|
17
|
-
ContactResource,
|
|
18
|
-
RoleResource
|
|
19
|
-
} from './AccessRights.resource';
|
|
20
|
-
import {
|
|
21
|
-
createInitialState,
|
|
22
|
-
sortOnAddedStateFirstAndContactName
|
|
23
|
-
} from './useAccessRightsForm.utils';
|
|
24
|
-
|
|
25
|
-
/** state */
|
|
26
|
-
|
|
27
|
-
type loadingState = 'idle' | 'loading';
|
|
28
|
-
|
|
29
|
-
const loadingStatusAtom = atom<loadingState>('idle');
|
|
30
|
-
|
|
31
|
-
type formOptions = {
|
|
32
|
-
contacts: Array<ContactResource | ContactGroupResource>;
|
|
33
|
-
roles: Array<RoleResource>;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const formOptionsAtom = atom<formOptions>({
|
|
37
|
-
contacts: [],
|
|
38
|
-
roles: []
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
const contactAccessRightsAtom = atom<Array<ContactAccessRightStateResource>>(
|
|
42
|
-
[]
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
type StateStats = {
|
|
46
|
-
added: number;
|
|
47
|
-
removed: number;
|
|
48
|
-
updated: number;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const contactAccessRightsStateAtom = atom<{
|
|
52
|
-
isDirty: boolean;
|
|
53
|
-
isLoading: boolean;
|
|
54
|
-
stats: StateStats;
|
|
55
|
-
}>((get) => ({
|
|
56
|
-
isDirty: get(contactAccessRightsAtom).some(
|
|
57
|
-
({ state }) => state !== 'unchanged'
|
|
58
|
-
),
|
|
59
|
-
isLoading: get(loadingStatusAtom) === 'loading',
|
|
60
|
-
stats: {
|
|
61
|
-
added: get(contactAccessRightsAtom).filter(({ state }) => state === 'added')
|
|
62
|
-
.length,
|
|
63
|
-
removed: get(contactAccessRightsAtom).filter(
|
|
64
|
-
({ state }) => state === 'removed'
|
|
65
|
-
).length,
|
|
66
|
-
updated: get(contactAccessRightsAtom).filter(
|
|
67
|
-
({ state }) => state === 'updated'
|
|
68
|
-
).length
|
|
69
|
-
}
|
|
70
|
-
}));
|
|
71
|
-
|
|
72
|
-
type callbacks = {
|
|
73
|
-
onSubmit?: (values: Array<ContactAccessRightStateResource>) => void;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
const callbacksAtom = atom<callbacks>({});
|
|
77
|
-
|
|
78
|
-
/** provider */
|
|
79
|
-
|
|
80
|
-
export type AccessRightsFormProviderProps = {
|
|
81
|
-
children: ReactNode;
|
|
82
|
-
initialValues?: Array<ContactAccessRightResource>;
|
|
83
|
-
loadingStatus?: loadingState;
|
|
84
|
-
onSubmit?: callbacks['onSubmit'];
|
|
85
|
-
options?: formOptions;
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
const AccessRightsFormProvider = ({
|
|
89
|
-
children,
|
|
90
|
-
initialValues,
|
|
91
|
-
options,
|
|
92
|
-
loadingStatus = 'idle',
|
|
93
|
-
onSubmit
|
|
94
|
-
}: AccessRightsFormProviderProps): ReactElement => {
|
|
95
|
-
const store = useRef(createStore()).current;
|
|
96
|
-
|
|
97
|
-
const setLoadingStatus = useSetAtom(loadingStatusAtom, { store });
|
|
98
|
-
const setFormOptions = useSetAtom(formOptionsAtom, { store });
|
|
99
|
-
const setContactAccessRights = useSetAtom(contactAccessRightsAtom, { store });
|
|
100
|
-
const setCallbacks = useSetAtom(callbacksAtom, { store });
|
|
101
|
-
|
|
102
|
-
useEffect(() => {
|
|
103
|
-
setLoadingStatus(loadingStatus);
|
|
104
|
-
}, [loadingStatus]);
|
|
105
|
-
|
|
106
|
-
useEffect(() => {
|
|
107
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
108
|
-
options && setFormOptions(options);
|
|
109
|
-
}, [options]);
|
|
110
|
-
|
|
111
|
-
useEffect(() => {
|
|
112
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
113
|
-
onSubmit && setCallbacks({ onSubmit });
|
|
114
|
-
}, [onSubmit]);
|
|
115
|
-
|
|
116
|
-
useEffect(() => {
|
|
117
|
-
setContactAccessRights(
|
|
118
|
-
initialValues ? createInitialState(initialValues) : []
|
|
119
|
-
);
|
|
120
|
-
}, [initialValues]);
|
|
121
|
-
|
|
122
|
-
return <Provider store={store}>{children}</Provider>;
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
/** hook */
|
|
126
|
-
|
|
127
|
-
type UseAccessRightsForm = {
|
|
128
|
-
addContactAccessRight: (
|
|
129
|
-
contactAccessRight: ContactAccessRightResource
|
|
130
|
-
) => void;
|
|
131
|
-
contactAccessRights: Array<ContactAccessRightStateResource>;
|
|
132
|
-
isDirty: boolean;
|
|
133
|
-
isLoading: boolean;
|
|
134
|
-
options: formOptions;
|
|
135
|
-
removeContactAccessRight: (
|
|
136
|
-
contactAccessRight: ContactAccessRightResource,
|
|
137
|
-
restore?: boolean
|
|
138
|
-
) => void;
|
|
139
|
-
stats: StateStats;
|
|
140
|
-
submit: () => void;
|
|
141
|
-
updateContactAccessRight: (
|
|
142
|
-
contactAccessRight: ContactAccessRightResource
|
|
143
|
-
) => void;
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
const useAccessRightsForm = (): UseAccessRightsForm => {
|
|
147
|
-
const store = useStore();
|
|
148
|
-
|
|
149
|
-
const [contactAccessRights, setContactAccessRights] = useAtom(
|
|
150
|
-
contactAccessRightsAtom,
|
|
151
|
-
{ store }
|
|
152
|
-
);
|
|
153
|
-
const { isLoading, isDirty, stats } = useAtomValue(
|
|
154
|
-
contactAccessRightsStateAtom,
|
|
155
|
-
{ store }
|
|
156
|
-
);
|
|
157
|
-
const options = useAtomValue(formOptionsAtom, { store });
|
|
158
|
-
const callbacks = useAtomValue(callbacksAtom, { store });
|
|
159
|
-
|
|
160
|
-
const addContactAccessRight = (
|
|
161
|
-
contactAccessRight: ContactAccessRightResource
|
|
162
|
-
): void =>
|
|
163
|
-
setContactAccessRights((prev) => {
|
|
164
|
-
const isContactAlreadyAdded = prev.some(
|
|
165
|
-
({ contactAccessRight: c }) =>
|
|
166
|
-
c.contact?.id === contactAccessRight.contact?.id
|
|
167
|
-
);
|
|
168
|
-
|
|
169
|
-
return isContactAlreadyAdded
|
|
170
|
-
? prev
|
|
171
|
-
: [
|
|
172
|
-
...prev,
|
|
173
|
-
{
|
|
174
|
-
contactAccessRight,
|
|
175
|
-
state: 'added',
|
|
176
|
-
stateHistory: []
|
|
177
|
-
} as ContactAccessRightStateResource
|
|
178
|
-
].sort(sortOnAddedStateFirstAndContactName);
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
const removeContactAccessRight = (
|
|
182
|
-
contactAccessRight: ContactAccessRightResource,
|
|
183
|
-
restore = false
|
|
184
|
-
): void =>
|
|
185
|
-
setContactAccessRights((prev) => {
|
|
186
|
-
const contactAccessRightIndex = prev.findIndex(
|
|
187
|
-
({ contactAccessRight: prevContactAccessRight }) =>
|
|
188
|
-
prevContactAccessRight.contact?.id === contactAccessRight.contact?.id
|
|
189
|
-
);
|
|
190
|
-
|
|
191
|
-
if (contactAccessRightIndex === -1) {
|
|
192
|
-
return prev;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
const { stateHistory } = prev[contactAccessRightIndex];
|
|
196
|
-
|
|
197
|
-
if (restore) {
|
|
198
|
-
return [
|
|
199
|
-
...prev.slice(0, contactAccessRightIndex),
|
|
200
|
-
{
|
|
201
|
-
...prev[contactAccessRightIndex],
|
|
202
|
-
state: stateHistory[stateHistory.length - 1],
|
|
203
|
-
stateHistory: [...stateHistory, prev[contactAccessRightIndex].state]
|
|
204
|
-
} as ContactAccessRightStateResource,
|
|
205
|
-
...prev.slice(contactAccessRightIndex + 1)
|
|
206
|
-
];
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
if (
|
|
210
|
-
prev[contactAccessRightIndex].state === 'added' ||
|
|
211
|
-
stateHistory[0] === 'added'
|
|
212
|
-
) {
|
|
213
|
-
return [
|
|
214
|
-
...prev.slice(0, contactAccessRightIndex),
|
|
215
|
-
...prev.slice(contactAccessRightIndex + 1)
|
|
216
|
-
];
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
return [
|
|
220
|
-
...prev.slice(0, contactAccessRightIndex),
|
|
221
|
-
{
|
|
222
|
-
...prev[contactAccessRightIndex],
|
|
223
|
-
state: 'removed',
|
|
224
|
-
stateHistory: [...stateHistory, prev[contactAccessRightIndex].state]
|
|
225
|
-
} as ContactAccessRightStateResource,
|
|
226
|
-
...prev.slice(contactAccessRightIndex + 1)
|
|
227
|
-
];
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
const updateContactAccessRight = (
|
|
231
|
-
contactAccessRight: ContactAccessRightResource
|
|
232
|
-
): void =>
|
|
233
|
-
setContactAccessRights((prev) => {
|
|
234
|
-
const contactAccessRightIndex = prev.findIndex(
|
|
235
|
-
({ contactAccessRight: prevContactAccessRight }) =>
|
|
236
|
-
prevContactAccessRight.contact?.id === contactAccessRight.contact?.id
|
|
237
|
-
);
|
|
238
|
-
|
|
239
|
-
if (contactAccessRightIndex === -1) {
|
|
240
|
-
return prev;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
const { stateHistory } = prev[contactAccessRightIndex];
|
|
244
|
-
|
|
245
|
-
const isAdded =
|
|
246
|
-
prev[contactAccessRightIndex].state === 'added' ||
|
|
247
|
-
stateHistory[0] === 'added';
|
|
248
|
-
const isUpdated =
|
|
249
|
-
prev[contactAccessRightIndex].state === 'updated' ||
|
|
250
|
-
stateHistory.findIndex((state) => state === 'updated') <
|
|
251
|
-
stateHistory.findIndex((state) => state === 'unchanged');
|
|
252
|
-
|
|
253
|
-
// eslint-disable-next-line no-nested-ternary
|
|
254
|
-
const state = isAdded ? 'added' : isUpdated ? 'unchanged' : 'updated';
|
|
255
|
-
|
|
256
|
-
return [
|
|
257
|
-
...prev.slice(0, contactAccessRightIndex),
|
|
258
|
-
{
|
|
259
|
-
contactAccessRight,
|
|
260
|
-
state,
|
|
261
|
-
stateHistory: [...stateHistory, prev[contactAccessRightIndex].state]
|
|
262
|
-
} as ContactAccessRightStateResource,
|
|
263
|
-
...prev.slice(contactAccessRightIndex + 1)
|
|
264
|
-
];
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
const submit = (): void => callbacks.onSubmit?.(contactAccessRights);
|
|
268
|
-
|
|
269
|
-
return {
|
|
270
|
-
addContactAccessRight,
|
|
271
|
-
contactAccessRights,
|
|
272
|
-
isDirty,
|
|
273
|
-
isLoading,
|
|
274
|
-
options,
|
|
275
|
-
removeContactAccessRight,
|
|
276
|
-
stats,
|
|
277
|
-
submit,
|
|
278
|
-
updateContactAccessRight
|
|
279
|
-
};
|
|
280
|
-
};
|
|
281
|
-
|
|
282
|
-
export { AccessRightsFormProvider, useAccessRightsForm };
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { ContactAccessRightStateResource } from './AccessRights.resource';
|
|
2
|
-
|
|
3
|
-
export const sortOnContactName = (
|
|
4
|
-
a: ContactAccessRightStateResource,
|
|
5
|
-
b: ContactAccessRightStateResource
|
|
6
|
-
): number =>
|
|
7
|
-
a.contactAccessRight.contact?.name.localeCompare(
|
|
8
|
-
b.contactAccessRight.contact?.name ?? ''
|
|
9
|
-
) || 0;
|
|
10
|
-
|
|
11
|
-
export const sortOnAddedStateFirstAndContactName = (
|
|
12
|
-
a: ContactAccessRightStateResource,
|
|
13
|
-
b: ContactAccessRightStateResource
|
|
14
|
-
): number => {
|
|
15
|
-
if (a.state === 'added' && b.state !== 'added') {
|
|
16
|
-
return -1;
|
|
17
|
-
}
|
|
18
|
-
if (a.state !== 'added' && b.state === 'added') {
|
|
19
|
-
return 1;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
a.contactAccessRight.contact?.name.localeCompare(
|
|
24
|
-
b.contactAccessRight.contact?.name ?? ''
|
|
25
|
-
) || 0
|
|
26
|
-
);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export const createInitialState = (
|
|
30
|
-
values
|
|
31
|
-
): Array<ContactAccessRightStateResource> =>
|
|
32
|
-
values
|
|
33
|
-
?.map(
|
|
34
|
-
(contactAccessRight) =>
|
|
35
|
-
({
|
|
36
|
-
contactAccessRight,
|
|
37
|
-
state: 'unchanged',
|
|
38
|
-
stateHistory: []
|
|
39
|
-
}) as ContactAccessRightStateResource
|
|
40
|
-
)
|
|
41
|
-
.sort(sortOnAddedStateFirstAndContactName);
|
|
@@ -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
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/src/components/Form/{AccessRightsV2 → AccessRights}/common/RoleSelectField.styles.tsx
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|