@centreon/ui 24.4.1-MON-21278-Delete-a-basic-token.11 → 24.4.1-MON-33898.15
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 +1 -1
- package/src/Button/Icon/index.stories.tsx +1 -1
- package/src/Button/Icon/index.tsx +1 -1
- package/src/Dialog/Confirm/index.tsx +2 -10
- package/src/Dialog/index.tsx +1 -8
- package/src/InputField/Select/IconPopover/index.tsx +1 -1
- package/src/Listing/ActionBar/index.tsx +1 -2
- package/src/Panel/index.tsx +1 -1
- package/src/TimePeriods/CustomTimePeriod/CompactCustomTimePeriod.styles.ts +7 -6
- package/src/TimePeriods/ResolutionTimePeriod.cypress.spec.tsx +9 -12
- 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/index.ts +2 -2
- 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/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
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@ import { makeStyles } from 'tss-react/mui';
|
|
|
4
4
|
import AccessibilityIcon from '@mui/icons-material/Accessibility';
|
|
5
5
|
import { Theme } from '@mui/material';
|
|
6
6
|
|
|
7
|
-
import IconButton from '.';
|
|
7
|
+
import { IconButton } from '.';
|
|
8
8
|
|
|
9
9
|
const useStyles = makeStyles()((theme: Theme) => ({
|
|
10
10
|
root: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DialogContentText, Typography } from '@mui/material';
|
|
2
2
|
|
|
3
3
|
import Dialog, { Props as DialogProps } from '..';
|
|
4
4
|
|
|
@@ -6,23 +6,15 @@ type Props = DialogProps & {
|
|
|
6
6
|
children?: JSX.Element;
|
|
7
7
|
labelMessage?: string | null;
|
|
8
8
|
labelSecondMessage?: string | null;
|
|
9
|
-
restCancelButtonProps?: ButtonProps;
|
|
10
|
-
restConfirmButtonProps?: ButtonProps;
|
|
11
9
|
};
|
|
12
10
|
|
|
13
11
|
const Confirm = ({
|
|
14
12
|
labelMessage,
|
|
15
13
|
labelSecondMessage,
|
|
16
14
|
children,
|
|
17
|
-
restCancelButtonProps,
|
|
18
|
-
restConfirmButtonProps,
|
|
19
15
|
...rest
|
|
20
16
|
}: Props): JSX.Element => (
|
|
21
|
-
<Dialog
|
|
22
|
-
restCancelButtonProps={restCancelButtonProps}
|
|
23
|
-
restConfirmButtonProps={restConfirmButtonProps}
|
|
24
|
-
{...rest}
|
|
25
|
-
>
|
|
17
|
+
<Dialog {...rest}>
|
|
26
18
|
<DialogContentText>
|
|
27
19
|
{labelMessage && <Typography>{labelMessage}</Typography>}
|
|
28
20
|
{labelSecondMessage && <Typography>{labelSecondMessage}</Typography>}
|
package/src/Dialog/index.tsx
CHANGED
|
@@ -9,8 +9,7 @@ import {
|
|
|
9
9
|
DialogContent,
|
|
10
10
|
DialogActions,
|
|
11
11
|
DialogProps,
|
|
12
|
-
CircularProgress
|
|
13
|
-
ButtonProps
|
|
12
|
+
CircularProgress
|
|
14
13
|
} from '@mui/material';
|
|
15
14
|
|
|
16
15
|
import { DataTestAttributes } from '../@types/data-attributes';
|
|
@@ -49,8 +48,6 @@ export type Props = {
|
|
|
49
48
|
onClose?: () => void;
|
|
50
49
|
onConfirm: (event, value?) => void;
|
|
51
50
|
open: boolean;
|
|
52
|
-
restCancelButtonProps?: ButtonProps;
|
|
53
|
-
restConfirmButtonProps?: ButtonProps;
|
|
54
51
|
submitting?: boolean;
|
|
55
52
|
} & DialogProps &
|
|
56
53
|
DataTestAttributes;
|
|
@@ -73,8 +70,6 @@ const Dialog = ({
|
|
|
73
70
|
dialogContentClassName,
|
|
74
71
|
dialogActionsClassName,
|
|
75
72
|
dialogConfirmButtonClassName,
|
|
76
|
-
restCancelButtonProps,
|
|
77
|
-
restConfirmButtonProps,
|
|
78
73
|
...rest
|
|
79
74
|
}: Props): JSX.Element => {
|
|
80
75
|
const { classes, cx } = useStyles({ contentWidth });
|
|
@@ -106,7 +101,6 @@ const Dialog = ({
|
|
|
106
101
|
data-testid="Cancel"
|
|
107
102
|
disabled={cancelDisabled}
|
|
108
103
|
onClick={onCancel}
|
|
109
|
-
{...restCancelButtonProps}
|
|
110
104
|
>
|
|
111
105
|
{labelCancel}
|
|
112
106
|
</Button>
|
|
@@ -119,7 +113,6 @@ const Dialog = ({
|
|
|
119
113
|
disabled={confirmDisabled}
|
|
120
114
|
endIcon={submitting && <CircularProgress size={15} />}
|
|
121
115
|
onClick={onConfirm}
|
|
122
|
-
{...restConfirmButtonProps}
|
|
123
116
|
>
|
|
124
117
|
{labelConfirm}
|
|
125
118
|
</Button>
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
} from '@mui/material';
|
|
16
16
|
import IconReset from '@mui/icons-material/RotateLeft';
|
|
17
17
|
|
|
18
|
-
import IconButton from '
|
|
18
|
+
import { IconButton } from '../../..';
|
|
19
19
|
import Option from '../Option';
|
|
20
20
|
import { SelectEntry } from '..';
|
|
21
21
|
|
|
@@ -9,10 +9,9 @@ import Divider from '@mui/material/Divider';
|
|
|
9
9
|
|
|
10
10
|
import { userAtom, ListingVariant } from '@centreon/ui-context';
|
|
11
11
|
|
|
12
|
-
import { ListingProps } from '../..';
|
|
12
|
+
import { ListingProps, IconButton } from '../..';
|
|
13
13
|
import { labelOf, labelRowsPerPage } from '../translatedLabels';
|
|
14
14
|
import { useMemoComponent } from '../../utils';
|
|
15
|
-
import IconButton from '../../Button/Icon/index';
|
|
16
15
|
|
|
17
16
|
import StyledPagination from './Pagination';
|
|
18
17
|
import PaginationActions from './PaginationActions';
|
package/src/Panel/index.tsx
CHANGED
|
@@ -9,7 +9,7 @@ import { makeStyles } from 'tss-react/mui';
|
|
|
9
9
|
import { Paper, Slide, Divider, AppBar, Tabs } from '@mui/material';
|
|
10
10
|
import IconClose from '@mui/icons-material/Clear';
|
|
11
11
|
|
|
12
|
-
import IconButton from '
|
|
12
|
+
import { IconButton } from '..';
|
|
13
13
|
|
|
14
14
|
import { minTabHeight } from './Tab';
|
|
15
15
|
|
|
@@ -12,21 +12,22 @@ const useStyles = makeStyles()((theme) => ({
|
|
|
12
12
|
},
|
|
13
13
|
containerDates: {
|
|
14
14
|
display: 'flex',
|
|
15
|
+
gap: theme.spacing(0.5),
|
|
15
16
|
[theme.breakpoints.down('sm')]: {
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
columnGap: theme.spacing(0.5),
|
|
18
|
+
flexDirection: 'column'
|
|
18
19
|
}
|
|
19
20
|
},
|
|
20
21
|
date: {
|
|
21
|
-
minWidth: theme.spacing(12),
|
|
22
|
+
minWidth: theme.spacing(12.5),
|
|
22
23
|
textAlign: 'start'
|
|
23
24
|
},
|
|
24
25
|
error: {
|
|
25
26
|
textAlign: 'center'
|
|
26
27
|
},
|
|
27
28
|
label: {
|
|
28
|
-
minWidth: theme.spacing(3
|
|
29
|
-
textAlign: '
|
|
29
|
+
minWidth: theme.spacing(3),
|
|
30
|
+
textAlign: 'start'
|
|
30
31
|
},
|
|
31
32
|
|
|
32
33
|
picker: {
|
|
@@ -38,7 +39,7 @@ const useStyles = makeStyles()((theme) => ({
|
|
|
38
39
|
},
|
|
39
40
|
timeContainer: {
|
|
40
41
|
alignItems: 'center',
|
|
41
|
-
columnGap: theme.spacing(
|
|
42
|
+
columnGap: theme.spacing(1),
|
|
42
43
|
display: 'flex',
|
|
43
44
|
flexDirection: 'row',
|
|
44
45
|
[theme.breakpoints.down('sm')]: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import dayjs from 'dayjs';
|
|
2
|
-
import 'dayjs/locale/
|
|
2
|
+
import 'dayjs/locale/fr';
|
|
3
3
|
import localizedFormatPlugin from 'dayjs/plugin/localizedFormat';
|
|
4
4
|
import timezonePlugin from 'dayjs/plugin/timezone';
|
|
5
5
|
import utcPlugin from 'dayjs/plugin/utc';
|
|
@@ -19,18 +19,18 @@ dayjs.extend(localizedFormatPlugin);
|
|
|
19
19
|
|
|
20
20
|
const data = [
|
|
21
21
|
{
|
|
22
|
-
locale: '
|
|
23
|
-
resolution: { height:
|
|
22
|
+
locale: 'fr_FR',
|
|
23
|
+
resolution: { height: 720, width: 500 },
|
|
24
24
|
timezone: 'Europe/Paris'
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
|
-
locale: '
|
|
28
|
-
resolution: { height:
|
|
27
|
+
locale: 'fr_FR',
|
|
28
|
+
resolution: { height: 720, width: 200 },
|
|
29
29
|
timezone: 'Europe/Paris'
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
|
-
locale: '
|
|
33
|
-
resolution: { height:
|
|
32
|
+
locale: 'fr_FR',
|
|
33
|
+
resolution: { height: 720, width: 1024 },
|
|
34
34
|
timezone: 'Europe/Paris'
|
|
35
35
|
}
|
|
36
36
|
];
|
|
@@ -45,7 +45,7 @@ data.forEach((item) =>
|
|
|
45
45
|
|
|
46
46
|
store.set(userAtom, {
|
|
47
47
|
...retrievedUser,
|
|
48
|
-
locale: '
|
|
48
|
+
locale: 'fr_FR',
|
|
49
49
|
timezone: 'Europe/Paris'
|
|
50
50
|
});
|
|
51
51
|
|
|
@@ -59,10 +59,7 @@ data.forEach((item) =>
|
|
|
59
59
|
});
|
|
60
60
|
|
|
61
61
|
it(`displays correctly the dates design when screen resolution is ${width}px`, () => {
|
|
62
|
-
cy.
|
|
63
|
-
resolution: { height, width },
|
|
64
|
-
title: `${width}px`
|
|
65
|
-
});
|
|
62
|
+
cy.makeSnapshot(`${width}px`);
|
|
66
63
|
});
|
|
67
64
|
})
|
|
68
65
|
);
|
|
@@ -347,4 +347,27 @@ describe('Access rights', () => {
|
|
|
347
347
|
|
|
348
348
|
cy.makeSnapshot();
|
|
349
349
|
});
|
|
350
|
+
|
|
351
|
+
it('resets the role to "viewer" when the "editor" role is selected and a contact with "viewer" right is selected', () => {
|
|
352
|
+
initialize({});
|
|
353
|
+
|
|
354
|
+
cy.findByLabelText(labels.add.autocompleteContact).click();
|
|
355
|
+
|
|
356
|
+
cy.waitForRequest('@getContacts');
|
|
357
|
+
|
|
358
|
+
cy.contains('Entity 10').click();
|
|
359
|
+
|
|
360
|
+
cy.findByTestId('add_role').parent().click();
|
|
361
|
+
cy.get('li[data-value="editor"]').click();
|
|
362
|
+
|
|
363
|
+
cy.findByLabelText(labels.add.autocompleteContact).click();
|
|
364
|
+
|
|
365
|
+
cy.waitForRequest('@getContacts');
|
|
366
|
+
|
|
367
|
+
cy.contains('Entity 11').click();
|
|
368
|
+
|
|
369
|
+
cy.findByTestId('add_role').should('have.value', 'viewer');
|
|
370
|
+
|
|
371
|
+
cy.makeSnapshot();
|
|
372
|
+
});
|
|
350
373
|
});
|
|
@@ -7,11 +7,14 @@ import { ContactType, Labels } from '../models';
|
|
|
7
7
|
import { contactTypeAtom } from '../atoms';
|
|
8
8
|
import { Subtitle } from '../../../..';
|
|
9
9
|
|
|
10
|
+
import { useContactSwitchStyles } from './ShareInput.styles';
|
|
11
|
+
|
|
10
12
|
interface Props {
|
|
11
13
|
labels: Labels['add'];
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
const ContactSwitch = ({ labels }: Props): JSX.Element => {
|
|
17
|
+
const { classes } = useContactSwitchStyles();
|
|
15
18
|
const { t } = useTranslation();
|
|
16
19
|
|
|
17
20
|
const setContactType = useSetAtom(contactTypeAtom);
|
|
@@ -23,7 +26,12 @@ const ContactSwitch = ({ labels }: Props): JSX.Element => {
|
|
|
23
26
|
return (
|
|
24
27
|
<>
|
|
25
28
|
<Subtitle>{t(labels.title)}</Subtitle>
|
|
26
|
-
<RadioGroup
|
|
29
|
+
<RadioGroup
|
|
30
|
+
row
|
|
31
|
+
className={classes.inputs}
|
|
32
|
+
defaultValue={ContactType.Contact}
|
|
33
|
+
onChange={change}
|
|
34
|
+
>
|
|
27
35
|
<FormControlLabel
|
|
28
36
|
control={<Radio />}
|
|
29
37
|
label={labels.contact}
|
|
@@ -7,3 +7,11 @@ export const useShareInputStyles = makeStyles()((theme) => ({
|
|
|
7
7
|
gridTemplateColumns: `1fr min-content min-content`
|
|
8
8
|
}
|
|
9
9
|
}));
|
|
10
|
+
|
|
11
|
+
export const useContactSwitchStyles = makeStyles()((theme) => ({
|
|
12
|
+
inputs: {
|
|
13
|
+
display: 'flex',
|
|
14
|
+
flexDirection: 'row',
|
|
15
|
+
gap: theme.spacing(2)
|
|
16
|
+
}
|
|
17
|
+
}));
|
|
@@ -40,6 +40,10 @@ const useShareInput = (endpoints: Endpoints): UseShareInputState => {
|
|
|
40
40
|
|
|
41
41
|
const selectContact = (_, entry): void => {
|
|
42
42
|
setSelectedContact(entry);
|
|
43
|
+
if (equals('editor', entry.most_permissive_role)) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
setSelectedRole('viewer');
|
|
43
47
|
};
|
|
44
48
|
|
|
45
49
|
const add = (): void => {
|
|
@@ -88,6 +88,7 @@ const buildEntities = (from, isGroup): Array<SelectEntry> => {
|
|
|
88
88
|
.map((_, index) => ({
|
|
89
89
|
email: isGroup ? undefined : faker.internet.email(),
|
|
90
90
|
id: 1000 + index,
|
|
91
|
+
most_permissive_role: index % 3 === 0 ? 'editor' : 'viewer',
|
|
91
92
|
name: `Entity ${isGroup ? 'Group' : ''} ${from + index}`
|
|
92
93
|
}));
|
|
93
94
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export * from './Form.models';
|
|
2
2
|
export * from './Dashboard';
|
|
3
|
-
export
|
|
4
|
-
export { default as AccessRightsV2 } from './
|
|
3
|
+
export { default as AccessRights } from './AccessRights/AccessRights';
|
|
4
|
+
export { default as AccessRightsV2 } from './AccessRights/AccessRights';
|
|
@@ -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 };
|