@centreon/ui 24.4.1-MON-33898.13 → 24.4.1-MON-21278-Delete-a-basic-token.9
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 +10 -2
- package/src/Dialog/index.tsx +8 -1
- package/src/InputField/Select/IconPopover/index.tsx +1 -1
- package/src/Listing/ActionBar/index.tsx +2 -1
- package/src/Panel/index.tsx +1 -1
- package/src/components/Form/AccessRights/AccessRights.resource.ts +45 -0
- package/src/components/Form/AccessRights/AccessRightsForm.stories.tsx +59 -0
- package/src/components/Form/AccessRights/AccessRightsForm.styles.ts +21 -0
- package/src/components/Form/AccessRights/AccessRightsForm.tsx +67 -0
- package/src/components/Form/AccessRights/AccessRightsFormActions.tsx +80 -0
- package/src/components/Form/AccessRights/Input/AddAction.tsx +31 -0
- package/src/components/Form/AccessRights/Input/ContactAccessRightInput.stories.tsx +54 -0
- package/src/components/Form/AccessRights/Input/ContactAccessRightInput.tsx +72 -0
- package/src/components/Form/AccessRights/Input/ContactAccessRightsInput.styles.ts +22 -0
- package/src/components/Form/AccessRights/Input/ContactInputField.tsx +105 -0
- package/src/components/Form/AccessRights/Input/RoleInputField.tsx +29 -0
- package/src/components/Form/AccessRights/List/ContactAccessRightsList.stories.tsx +97 -0
- package/src/components/Form/AccessRights/List/ContactAccessRightsList.styles.ts +71 -0
- package/src/components/Form/AccessRights/List/ContactAccessRightsList.tsx +51 -0
- package/src/components/Form/AccessRights/List/ContactAccessRightsListItem.stories.tsx +116 -0
- package/src/components/Form/AccessRights/List/ContactAccessRightsListItem.tsx +118 -0
- package/src/components/Form/AccessRights/List/ContactAccessRightsListItemSkeleton.tsx +26 -0
- package/src/components/Form/AccessRights/List/ContactAccessRightsListSkeleton.tsx +28 -0
- package/src/components/Form/AccessRights/Stats/AccessRightsStats.styles.ts +18 -0
- package/src/components/Form/AccessRights/Stats/AccessRightsStats.tsx +41 -0
- package/src/components/Form/AccessRights/__fixtures__/contactAccessRight.mock.ts +54 -0
- package/src/components/Form/AccessRights/common/GroupLabel.styles.ts +18 -0
- package/src/components/Form/AccessRights/common/GroupLabel.tsx +15 -0
- package/src/components/Form/AccessRights/common/Input.styles.ts +48 -0
- package/src/components/Form/AccessRights/common/RoleInputSelect.styles.ts +11 -0
- package/src/components/Form/AccessRights/common/RoleInputSelect.tsx +57 -0
- package/src/components/Form/AccessRights/index.ts +3 -0
- package/src/components/Form/AccessRights/useAccessRightsForm.test.tsx +531 -0
- package/src/components/Form/AccessRights/useAccessRightsForm.tsx +282 -0
- package/src/components/Form/AccessRights/useAccessRightsForm.utils.ts +41 -0
- package/src/components/Form/{AccessRights → AccessRightsV2}/AccessRights.cypress.spec.tsx +0 -23
- package/src/components/Form/{AccessRights → AccessRightsV2}/ShareInput/ContactSwitch.tsx +1 -9
- package/src/components/Form/{AccessRights → AccessRightsV2}/ShareInput/ShareInput.styles.ts +0 -8
- package/src/components/Form/{AccessRights → AccessRightsV2}/ShareInput/useShareInput.tsx +0 -4
- package/src/components/Form/{AccessRights → AccessRightsV2}/models.ts +0 -1
- package/src/components/Form/{AccessRights → AccessRightsV2}/storiesData.ts +0 -1
- package/src/components/Form/index.ts +2 -2
- /package/src/components/Form/{AccessRights → AccessRightsV2}/AccessRights.stories.tsx +0 -0
- /package/src/components/Form/{AccessRights → AccessRightsV2}/AccessRights.styles.ts +0 -0
- /package/src/components/Form/{AccessRights → AccessRightsV2}/AccessRights.tsx +0 -0
- /package/src/components/Form/{AccessRights → AccessRightsV2}/Actions/Actions.styles.ts +0 -0
- /package/src/components/Form/{AccessRights → AccessRightsV2}/Actions/Actions.tsx +0 -0
- /package/src/components/Form/{AccessRights → AccessRightsV2}/Actions/useActions.ts +0 -0
- /package/src/components/Form/{AccessRights → AccessRightsV2}/List/Item.tsx +0 -0
- /package/src/components/Form/{AccessRights → AccessRightsV2}/List/List.styles.tsx +0 -0
- /package/src/components/Form/{AccessRights → AccessRightsV2}/List/List.tsx +0 -0
- /package/src/components/Form/{AccessRights → AccessRightsV2}/List/ListItemSkeleton.tsx +0 -0
- /package/src/components/Form/{AccessRights → AccessRightsV2}/List/ListSkeleton.tsx +0 -0
- /package/src/components/Form/{AccessRights → AccessRightsV2}/List/RemoveAccessRight.tsx +0 -0
- /package/src/components/Form/{AccessRights → AccessRightsV2}/List/StateChip.tsx +0 -0
- /package/src/components/Form/{AccessRights → AccessRightsV2}/List/useItem.ts +0 -0
- /package/src/components/Form/{AccessRights → AccessRightsV2}/Provider.tsx +0 -0
- /package/src/components/Form/{AccessRights → AccessRightsV2}/ShareInput/ShareInput.tsx +0 -0
- /package/src/components/Form/{AccessRights → AccessRightsV2}/Stats/Stats.tsx +0 -0
- /package/src/components/Form/{AccessRights → AccessRightsV2}/atoms.ts +0 -0
- /package/src/components/Form/{AccessRights → AccessRightsV2}/common/RoleSelectField.styles.tsx +0 -0
- /package/src/components/Form/{AccessRights → AccessRightsV2}/common/RoleSelectField.tsx +0 -0
- /package/src/components/Form/{AccessRights → AccessRightsV2}/useAccessRightsInitValues.ts +0 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { faker } from '@faker-js/faker';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
ContactAccessRightResource,
|
|
5
|
+
ContactGroupResource,
|
|
6
|
+
ContactResource,
|
|
7
|
+
RoleResource
|
|
8
|
+
} from '../AccessRights.resource';
|
|
9
|
+
|
|
10
|
+
faker.seed(42);
|
|
11
|
+
|
|
12
|
+
export const rolesMock = (): Array<RoleResource> => [
|
|
13
|
+
{ role: 'viewer' },
|
|
14
|
+
{ role: 'editor' }
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
export const contactMock = (): ContactResource => ({
|
|
18
|
+
email: faker.internet.email(),
|
|
19
|
+
id: faker.string.uuid(),
|
|
20
|
+
name: faker.person.fullName(),
|
|
21
|
+
type: 'contact'
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export const contactsMock = (length: number): Array<ContactResource> =>
|
|
25
|
+
[...Array(length).keys()].map(contactMock);
|
|
26
|
+
|
|
27
|
+
export const contactGroupMock = (): ContactGroupResource => ({
|
|
28
|
+
id: faker.string.uuid(),
|
|
29
|
+
name: faker.company.name(),
|
|
30
|
+
type: 'contact_group'
|
|
31
|
+
});
|
|
32
|
+
export const contactGroupsMock = (
|
|
33
|
+
length: number
|
|
34
|
+
): Array<ContactGroupResource> =>
|
|
35
|
+
[...Array(length).keys()].map(contactGroupMock);
|
|
36
|
+
|
|
37
|
+
export const contactsAndGroupsMock = (
|
|
38
|
+
length: number
|
|
39
|
+
): Array<ContactResource | ContactGroupResource> =>
|
|
40
|
+
[...Array(length).keys()].map(
|
|
41
|
+
() =>
|
|
42
|
+
faker.helpers.maybe(contactGroupMock, { probability: 0.2 }) ??
|
|
43
|
+
contactMock()
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
export const contactAccessRightsMock = (
|
|
47
|
+
length: number
|
|
48
|
+
): Array<ContactAccessRightResource> =>
|
|
49
|
+
[...Array(length).keys()].map(() => ({
|
|
50
|
+
contact:
|
|
51
|
+
faker.helpers.maybe(contactGroupMock, { probability: 0.2 }) ??
|
|
52
|
+
contactMock(),
|
|
53
|
+
role: faker.helpers.arrayElement(rolesMock().map(({ role }) => role))
|
|
54
|
+
}));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { makeStyles } from 'tss-react/mui';
|
|
2
|
+
|
|
3
|
+
const useStyles = makeStyles()((theme) => ({
|
|
4
|
+
groupLabel: {
|
|
5
|
+
backgroundColor: theme.palette.chip.color.neutral,
|
|
6
|
+
borderRadius: '0.1875rem',
|
|
7
|
+
color: theme.palette.primary.contrastText,
|
|
8
|
+
fontSize: '0.5625rem',
|
|
9
|
+
fontWeight: 500,
|
|
10
|
+
letterSpacing: '0.05rem',
|
|
11
|
+
marginLeft: theme.spacing(1),
|
|
12
|
+
padding: theme.spacing(0.125, 0.5),
|
|
13
|
+
textTransform: 'uppercase',
|
|
14
|
+
verticalAlign: 'middle'
|
|
15
|
+
}
|
|
16
|
+
}));
|
|
17
|
+
|
|
18
|
+
export { useStyles };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
|
|
3
|
+
import { useStyles } from './GroupLabel.styles';
|
|
4
|
+
|
|
5
|
+
export type GroupLabelProps = {
|
|
6
|
+
label: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const GroupLabel = ({ label }: GroupLabelProps): ReactElement => {
|
|
10
|
+
const { classes } = useStyles();
|
|
11
|
+
|
|
12
|
+
return <span className={classes.groupLabel}>{label}</span>;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { GroupLabel };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { makeStyles } from 'tss-react/mui';
|
|
2
|
+
|
|
3
|
+
const useInputStyles = makeStyles()((theme) => ({
|
|
4
|
+
inputDropdown: {
|
|
5
|
+
'& .MuiMenuItem-root': {
|
|
6
|
+
'& > .MuiTouchRipple-root': {
|
|
7
|
+
display: 'none'
|
|
8
|
+
},
|
|
9
|
+
|
|
10
|
+
'&.Mui-disabled': {
|
|
11
|
+
opacity: 0.5
|
|
12
|
+
},
|
|
13
|
+
'&.Mui-selected, &.Mui-selected:hover, &.MuiAutocomplete-option[aria-selected="true"], &.MuiAutocomplete-option[aria-selected="true"].Mui-focused':
|
|
14
|
+
{
|
|
15
|
+
'&.Mui-disabled': {
|
|
16
|
+
opacity: 1
|
|
17
|
+
},
|
|
18
|
+
backgroundColor: theme.palette.menu.item.background.active,
|
|
19
|
+
color: theme.palette.menu.item.color.active,
|
|
20
|
+
opacity: 1
|
|
21
|
+
},
|
|
22
|
+
'&:hover, &.MuiAutocomplete-option.Mui-focused:not(&[aria-selected="true"])':
|
|
23
|
+
{
|
|
24
|
+
backgroundColor: theme.palette.menu.item.background.hover,
|
|
25
|
+
color: theme.palette.menu.item.color.hover
|
|
26
|
+
},
|
|
27
|
+
backgroundColor: theme.palette.menu.item.background.default,
|
|
28
|
+
color: theme.palette.menu.item.color.default,
|
|
29
|
+
fontSize: '0.875rem',
|
|
30
|
+
|
|
31
|
+
minHeight: 'unset',
|
|
32
|
+
|
|
33
|
+
padding: theme.spacing(0.75, 2)
|
|
34
|
+
},
|
|
35
|
+
'&.MuiAutocomplete-popper > .MuiPaper-root, &.MuiPopover-root > .MuiPaper-root':
|
|
36
|
+
{
|
|
37
|
+
'& > ul.MuiAutocomplete-listbox, & > ul.MuiList-root': {
|
|
38
|
+
padding: theme.spacing(1, 0)
|
|
39
|
+
},
|
|
40
|
+
backgroundColor: theme.palette.menu.background,
|
|
41
|
+
borderRadius: '4px',
|
|
42
|
+
|
|
43
|
+
boxShadow: theme.shadows[8]
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}));
|
|
47
|
+
|
|
48
|
+
export { useInputStyles };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ReactElement, useCallback } from 'react';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
MenuItem as MuiMenuItem,
|
|
5
|
+
Select as MuiSelect,
|
|
6
|
+
SelectProps as MuiSelectProps
|
|
7
|
+
} from '@mui/material';
|
|
8
|
+
|
|
9
|
+
import { useAccessRightsForm } from '../useAccessRightsForm';
|
|
10
|
+
import { RoleResource } from '../AccessRights.resource';
|
|
11
|
+
|
|
12
|
+
import { useStyles } from './RoleInputSelect.styles';
|
|
13
|
+
import { useInputStyles } from './Input.styles';
|
|
14
|
+
|
|
15
|
+
type RoleInputSelectProps = {
|
|
16
|
+
id: string;
|
|
17
|
+
label?: string;
|
|
18
|
+
name: string;
|
|
19
|
+
onChange?: (value: RoleResource['role']) => void;
|
|
20
|
+
} & Pick<MuiSelectProps, 'value' | 'defaultValue' | 'disabled'>;
|
|
21
|
+
|
|
22
|
+
const RoleInputSelect = ({
|
|
23
|
+
label,
|
|
24
|
+
onChange,
|
|
25
|
+
...props
|
|
26
|
+
}: RoleInputSelectProps): ReactElement => {
|
|
27
|
+
const { classes } = useStyles();
|
|
28
|
+
const { classes: inputClasses } = useInputStyles();
|
|
29
|
+
|
|
30
|
+
const {
|
|
31
|
+
options: { roles }
|
|
32
|
+
} = useAccessRightsForm();
|
|
33
|
+
|
|
34
|
+
const onInputChange = useCallback((e) => onChange?.(e), [onChange]);
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<MuiSelect
|
|
38
|
+
size="small"
|
|
39
|
+
{...props}
|
|
40
|
+
{...(label && { label })}
|
|
41
|
+
MenuProps={{
|
|
42
|
+
className: inputClasses.inputDropdown
|
|
43
|
+
}}
|
|
44
|
+
className={classes.roleInputSelect}
|
|
45
|
+
data-testid="role-input"
|
|
46
|
+
onChange={onInputChange}
|
|
47
|
+
>
|
|
48
|
+
{roles.map(({ role }) => (
|
|
49
|
+
<MuiMenuItem key={role} value={role}>
|
|
50
|
+
{role}
|
|
51
|
+
</MuiMenuItem>
|
|
52
|
+
))}
|
|
53
|
+
</MuiSelect>
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export { RoleInputSelect };
|