@centreon/ui 24.4.1-MON-34298-refato-metrics-selection.5 → 24.4.1-MON-21278-Delete-a-basic-token.24

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.
Files changed (79) hide show
  1. package/package.json +1 -1
  2. package/src/Button/Icon/index.stories.tsx +1 -1
  3. package/src/Button/Icon/index.tsx +1 -1
  4. package/src/Dialog/Confirm/index.tsx +10 -2
  5. package/src/Dialog/index.tsx +8 -1
  6. package/src/Graph/LineChart/Legend/index.tsx +8 -7
  7. package/src/Graph/LineChart/LineChart.tsx +1 -4
  8. package/src/Graph/LineChart/index.tsx +1 -4
  9. package/src/InputField/Select/IconPopover/index.tsx +1 -1
  10. package/src/Listing/ActionBar/index.tsx +1 -2
  11. package/src/Panel/index.tsx +1 -1
  12. package/src/api/useGraphQuery/index.ts +5 -26
  13. package/src/api/useGraphQuery/models.ts +0 -5
  14. package/src/components/CollapsibleItem/CollapsibleItem.stories.tsx +0 -26
  15. package/src/components/CollapsibleItem/CollapsibleItem.tsx +14 -43
  16. package/src/components/CollapsibleItem/useCollapsibleItemStyles.ts +1 -24
  17. package/src/components/Form/{AccessRightsV2 → AccessRights}/AccessRights.cypress.spec.tsx +23 -0
  18. package/src/components/Form/{AccessRightsV2 → AccessRights}/ShareInput/ContactSwitch.tsx +9 -1
  19. package/src/components/Form/{AccessRightsV2 → AccessRights}/ShareInput/ShareInput.styles.ts +8 -0
  20. package/src/components/Form/{AccessRightsV2 → AccessRights}/ShareInput/useShareInput.tsx +4 -0
  21. package/src/components/Form/{AccessRightsV2 → AccessRights}/models.ts +1 -0
  22. package/src/components/Form/{AccessRightsV2 → AccessRights}/storiesData.ts +1 -0
  23. package/src/components/Form/index.ts +2 -2
  24. package/src/components/ItemComposition/Item.tsx +1 -1
  25. package/src/components/ItemComposition/ItemComposition.styles.ts +1 -8
  26. package/src/components/ItemComposition/ItemComposition.tsx +16 -26
  27. package/src/components/CollapsibleItem/CollapsibleItem.cypress.spec.tsx +0 -76
  28. package/src/components/Form/AccessRights/AccessRights.resource.ts +0 -45
  29. package/src/components/Form/AccessRights/AccessRightsForm.stories.tsx +0 -59
  30. package/src/components/Form/AccessRights/AccessRightsForm.styles.ts +0 -21
  31. package/src/components/Form/AccessRights/AccessRightsForm.tsx +0 -67
  32. package/src/components/Form/AccessRights/AccessRightsFormActions.tsx +0 -80
  33. package/src/components/Form/AccessRights/Input/AddAction.tsx +0 -31
  34. package/src/components/Form/AccessRights/Input/ContactAccessRightInput.stories.tsx +0 -54
  35. package/src/components/Form/AccessRights/Input/ContactAccessRightInput.tsx +0 -72
  36. package/src/components/Form/AccessRights/Input/ContactAccessRightsInput.styles.ts +0 -22
  37. package/src/components/Form/AccessRights/Input/ContactInputField.tsx +0 -105
  38. package/src/components/Form/AccessRights/Input/RoleInputField.tsx +0 -29
  39. package/src/components/Form/AccessRights/List/ContactAccessRightsList.stories.tsx +0 -97
  40. package/src/components/Form/AccessRights/List/ContactAccessRightsList.styles.ts +0 -71
  41. package/src/components/Form/AccessRights/List/ContactAccessRightsList.tsx +0 -51
  42. package/src/components/Form/AccessRights/List/ContactAccessRightsListItem.stories.tsx +0 -116
  43. package/src/components/Form/AccessRights/List/ContactAccessRightsListItem.tsx +0 -118
  44. package/src/components/Form/AccessRights/List/ContactAccessRightsListItemSkeleton.tsx +0 -26
  45. package/src/components/Form/AccessRights/List/ContactAccessRightsListSkeleton.tsx +0 -28
  46. package/src/components/Form/AccessRights/Stats/AccessRightsStats.styles.ts +0 -18
  47. package/src/components/Form/AccessRights/Stats/AccessRightsStats.tsx +0 -41
  48. package/src/components/Form/AccessRights/__fixtures__/contactAccessRight.mock.ts +0 -54
  49. package/src/components/Form/AccessRights/common/GroupLabel.styles.ts +0 -18
  50. package/src/components/Form/AccessRights/common/GroupLabel.tsx +0 -15
  51. package/src/components/Form/AccessRights/common/Input.styles.ts +0 -48
  52. package/src/components/Form/AccessRights/common/RoleInputSelect.styles.ts +0 -11
  53. package/src/components/Form/AccessRights/common/RoleInputSelect.tsx +0 -57
  54. package/src/components/Form/AccessRights/index.ts +0 -3
  55. package/src/components/Form/AccessRights/useAccessRightsForm.test.tsx +0 -531
  56. package/src/components/Form/AccessRights/useAccessRightsForm.tsx +0 -282
  57. package/src/components/Form/AccessRights/useAccessRightsForm.utils.ts +0 -41
  58. package/src/components/ItemComposition/ItemComposition.cypress.spec.tsx +0 -116
  59. /package/src/components/Form/{AccessRightsV2 → AccessRights}/AccessRights.stories.tsx +0 -0
  60. /package/src/components/Form/{AccessRightsV2 → AccessRights}/AccessRights.styles.ts +0 -0
  61. /package/src/components/Form/{AccessRightsV2 → AccessRights}/AccessRights.tsx +0 -0
  62. /package/src/components/Form/{AccessRightsV2 → AccessRights}/Actions/Actions.styles.ts +0 -0
  63. /package/src/components/Form/{AccessRightsV2 → AccessRights}/Actions/Actions.tsx +0 -0
  64. /package/src/components/Form/{AccessRightsV2 → AccessRights}/Actions/useActions.ts +0 -0
  65. /package/src/components/Form/{AccessRightsV2 → AccessRights}/List/Item.tsx +0 -0
  66. /package/src/components/Form/{AccessRightsV2 → AccessRights}/List/List.styles.tsx +0 -0
  67. /package/src/components/Form/{AccessRightsV2 → AccessRights}/List/List.tsx +0 -0
  68. /package/src/components/Form/{AccessRightsV2 → AccessRights}/List/ListItemSkeleton.tsx +0 -0
  69. /package/src/components/Form/{AccessRightsV2 → AccessRights}/List/ListSkeleton.tsx +0 -0
  70. /package/src/components/Form/{AccessRightsV2 → AccessRights}/List/RemoveAccessRight.tsx +0 -0
  71. /package/src/components/Form/{AccessRightsV2 → AccessRights}/List/StateChip.tsx +0 -0
  72. /package/src/components/Form/{AccessRightsV2 → AccessRights}/List/useItem.ts +0 -0
  73. /package/src/components/Form/{AccessRightsV2 → AccessRights}/Provider.tsx +0 -0
  74. /package/src/components/Form/{AccessRightsV2 → AccessRights}/ShareInput/ShareInput.tsx +0 -0
  75. /package/src/components/Form/{AccessRightsV2 → AccessRights}/Stats/Stats.tsx +0 -0
  76. /package/src/components/Form/{AccessRightsV2 → AccessRights}/atoms.ts +0 -0
  77. /package/src/components/Form/{AccessRightsV2 → AccessRights}/common/RoleSelectField.styles.tsx +0 -0
  78. /package/src/components/Form/{AccessRightsV2 → AccessRights}/common/RoleSelectField.tsx +0 -0
  79. /package/src/components/Form/{AccessRightsV2 → AccessRights}/useAccessRightsInitValues.ts +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@centreon/ui",
3
- "version": "24.4.1-MON-34298-refato-metrics-selection.5",
3
+ "version": "24.4.1-MON-21278-Delete-a-basic-token.24",
4
4
  "description": "Centreon UI Components",
5
5
  "scripts": {
6
6
  "eslint": "eslint ./src --ext .js,.jsx,.ts,.tsx --max-warnings 0",
@@ -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: {
@@ -38,7 +38,7 @@ type Props = {
38
38
  | 'top-start';
39
39
  } & IconButtonProps;
40
40
 
41
- const IconButton = ({
41
+ export const IconButton = ({
42
42
  title = '',
43
43
  ariaLabel,
44
44
  className,
@@ -1,4 +1,4 @@
1
- import { DialogContentText, Typography } from '@mui/material';
1
+ import { ButtonProps, DialogContentText, Typography } from '@mui/material';
2
2
 
3
3
  import Dialog, { Props as DialogProps } from '..';
4
4
 
@@ -6,15 +6,23 @@ type Props = DialogProps & {
6
6
  children?: JSX.Element;
7
7
  labelMessage?: string | null;
8
8
  labelSecondMessage?: string | null;
9
+ restCancelButtonProps?: ButtonProps;
10
+ restConfirmButtonProps?: ButtonProps;
9
11
  };
10
12
 
11
13
  const Confirm = ({
12
14
  labelMessage,
13
15
  labelSecondMessage,
14
16
  children,
17
+ restCancelButtonProps,
18
+ restConfirmButtonProps,
15
19
  ...rest
16
20
  }: Props): JSX.Element => (
17
- <Dialog {...rest}>
21
+ <Dialog
22
+ restCancelButtonProps={restCancelButtonProps}
23
+ restConfirmButtonProps={restConfirmButtonProps}
24
+ {...rest}
25
+ >
18
26
  <DialogContentText>
19
27
  {labelMessage && <Typography>{labelMessage}</Typography>}
20
28
  {labelSecondMessage && <Typography>{labelSecondMessage}</Typography>}
@@ -9,7 +9,8 @@ import {
9
9
  DialogContent,
10
10
  DialogActions,
11
11
  DialogProps,
12
- CircularProgress
12
+ CircularProgress,
13
+ ButtonProps
13
14
  } from '@mui/material';
14
15
 
15
16
  import { DataTestAttributes } from '../@types/data-attributes';
@@ -48,6 +49,8 @@ export type Props = {
48
49
  onClose?: () => void;
49
50
  onConfirm: (event, value?) => void;
50
51
  open: boolean;
52
+ restCancelButtonProps?: ButtonProps;
53
+ restConfirmButtonProps?: ButtonProps;
51
54
  submitting?: boolean;
52
55
  } & DialogProps &
53
56
  DataTestAttributes;
@@ -70,6 +73,8 @@ const Dialog = ({
70
73
  dialogContentClassName,
71
74
  dialogActionsClassName,
72
75
  dialogConfirmButtonClassName,
76
+ restCancelButtonProps,
77
+ restConfirmButtonProps,
73
78
  ...rest
74
79
  }: Props): JSX.Element => {
75
80
  const { classes, cx } = useStyles({ contentWidth });
@@ -101,6 +106,7 @@ const Dialog = ({
101
106
  data-testid="Cancel"
102
107
  disabled={cancelDisabled}
103
108
  onClick={onCancel}
109
+ {...restCancelButtonProps}
104
110
  >
105
111
  {labelCancel}
106
112
  </Button>
@@ -113,6 +119,7 @@ const Dialog = ({
113
119
  disabled={confirmDisabled}
114
120
  endIcon={submitting && <CircularProgress size={15} />}
115
121
  onClick={onConfirm}
122
+ {...restConfirmButtonProps}
116
123
  >
117
124
  {labelConfirm}
118
125
  </Button>
@@ -7,6 +7,7 @@ import { Box, alpha, useTheme } from '@mui/material';
7
7
 
8
8
  import { useMemoComponent } from '@centreon/ui';
9
9
 
10
+ import { maxLinesDisplayedLegend } from '../common';
10
11
  import { formatMetricValue } from '../../common/timeSeries';
11
12
  import { Line, TimeValue } from '../../common/timeSeries/models';
12
13
  import { labelAvg, labelMax, labelMin } from '../translatedLabels';
@@ -23,7 +24,7 @@ import LegendContent from './LegendContent';
23
24
  interface Props {
24
25
  base: number;
25
26
  displayAnchor?: boolean;
26
- limitLegend?: false | number;
27
+ limitLegendRows?: boolean;
27
28
  lines: Array<Line>;
28
29
  renderExtraComponent?: ReactNode;
29
30
  setLinesGraph: Dispatch<SetStateAction<Array<Line> | null>>;
@@ -38,14 +39,14 @@ const MainLegend = ({
38
39
  timeSeries,
39
40
  base,
40
41
  toggable = true,
41
- limitLegend = false,
42
+ limitLegendRows = true,
42
43
  renderExtraComponent,
43
44
  displayAnchor = true,
44
45
  setLinesGraph,
45
46
  xScale,
46
47
  shouldDisplayLegendInCompactMode
47
48
  }: Props): JSX.Element => {
48
- const { classes, cx } = useStyles({ limitLegendRows: Boolean(limitLegend) });
49
+ const { classes, cx } = useStyles({ limitLegendRows });
49
50
  const theme = useTheme();
50
51
 
51
52
  const { selectMetricLine, clearHighlight, highlightLine, toggleMetricLine } =
@@ -60,8 +61,8 @@ const MainLegend = ({
60
61
 
61
62
  const sortedData = sortBy(prop('metric_id'), lines);
62
63
 
63
- const displayedLines = limitLegend
64
- ? slice(0, limitLegend, sortedData)
64
+ const displayedLines = limitLegendRows
65
+ ? slice(0, maxLinesDisplayedLegend, sortedData)
65
66
  : sortedData;
66
67
 
67
68
  const getMetricValue = ({ value, unit }: GetMetricValueProps): string =>
@@ -173,7 +174,7 @@ const MainLegend = ({
173
174
  const Legend = (props: Props): JSX.Element => {
174
175
  const {
175
176
  toggable,
176
- limitLegend,
177
+ limitLegendRows,
177
178
  timeSeries,
178
179
  lines,
179
180
  base,
@@ -190,7 +191,7 @@ const Legend = (props: Props): JSX.Element => {
190
191
  lines,
191
192
  base,
192
193
  toggable,
193
- limitLegend,
194
+ limitLegendRows,
194
195
  displayAnchor,
195
196
  shouldDisplayLegendInCompactMode
196
197
  ]
@@ -43,7 +43,6 @@ interface Props extends LineChartProps {
43
43
  graphInterval: GraphInterval;
44
44
  graphRef: MutableRefObject<HTMLDivElement | null>;
45
45
  legend?: LegendModel;
46
- limitLegend?: false | number;
47
46
  marginBottom: number;
48
47
  shapeLines?: GlobalAreaLines;
49
48
  thresholdUnit?: string;
@@ -74,8 +73,7 @@ const LineChart = ({
74
73
  curve,
75
74
  marginBottom,
76
75
  thresholds,
77
- thresholdUnit,
78
- limitLegend
76
+ thresholdUnit
79
77
  }: Props): JSX.Element => {
80
78
  const { classes } = useStyles();
81
79
 
@@ -303,7 +301,6 @@ const LineChart = ({
303
301
  <Legend
304
302
  base={baseAxis}
305
303
  displayAnchor={displayAnchor?.displayGuidingLines ?? true}
306
- limitLegend={limitLegend}
307
304
  lines={newLines}
308
305
  renderExtraComponent={legend?.renderExtraComponent}
309
306
  setLinesGraph={setLinesGraph}
@@ -28,7 +28,6 @@ interface Props extends Partial<LineChartProps> {
28
28
  data?: LineChartData;
29
29
  end: string;
30
30
  legend: LegendModel;
31
- limitLegend?: false | number;
32
31
  loading: boolean;
33
32
  marginBottom?: number;
34
33
  shapeLines?: GlobalAreaLines;
@@ -56,8 +55,7 @@ const WrapperLineChart = ({
56
55
  curve = Curve.curveLinear,
57
56
  marginBottom = 0,
58
57
  thresholds,
59
- thresholdUnit,
60
- limitLegend
58
+ thresholdUnit
61
59
  }: Props): JSX.Element | null => {
62
60
  const { adjustedData } = useLineChartData({ data, end, start });
63
61
  const lineChartRef = useRef<HTMLDivElement | null>(null);
@@ -97,7 +95,6 @@ const WrapperLineChart = ({
97
95
  header={header}
98
96
  height={height || responsiveHeight}
99
97
  legend={legend}
100
- limitLegend={limitLegend}
101
98
  loading={loading}
102
99
  marginBottom={marginBottom}
103
100
  shapeLines={shapeLines}
@@ -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 '../../../Button/Icon';
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';
@@ -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 '../Button/Icon';
12
+ import { IconButton } from '..';
13
13
 
14
14
  import { minTabHeight } from './Tab';
15
15
 
@@ -1,20 +1,11 @@
1
1
  import { useRef } from 'react';
2
2
 
3
- import {
4
- equals,
5
- flatten,
6
- has,
7
- includes,
8
- isEmpty,
9
- not,
10
- pipe,
11
- pluck
12
- } from 'ramda';
3
+ import { equals, has, isEmpty, pluck } from 'ramda';
13
4
  import dayjs from 'dayjs';
14
5
 
15
6
  import { LineChartData, buildListingEndpoint, useFetchQuery } from '../..';
16
7
 
17
- import { Metric, Resource, WidgetResourceType } from './models';
8
+ import { Resource, WidgetResourceType } from './models';
18
9
 
19
10
  interface CustomTimePeriod {
20
11
  end: string;
@@ -23,9 +14,7 @@ interface CustomTimePeriod {
23
14
 
24
15
  interface UseMetricsQueryProps {
25
16
  baseEndpoint: string;
26
- bypassMetricsExclusion?: boolean;
27
- includeAllResources?: boolean;
28
- metrics: Array<Metric>;
17
+ metrics: Array<string>;
29
18
  refreshCount?: number;
30
19
  refreshInterval?: number | false;
31
20
  resources?: Array<Resource>;
@@ -82,7 +71,6 @@ const areResourcesFullfilled = (value: Array<Resource>): boolean =>
82
71
  );
83
72
 
84
73
  const useGraphQuery = ({
85
- bypassMetricsExclusion,
86
74
  metrics,
87
75
  resources = [],
88
76
  baseEndpoint,
@@ -105,7 +93,7 @@ const useGraphQuery = ({
105
93
 
106
94
  const definedMetrics = metrics.filter((metric) => metric);
107
95
  const formattedDefinedMetrics = definedMetrics.map((metric) =>
108
- encodeURIComponent(metric.name)
96
+ encodeURIComponent(metric)
109
97
  );
110
98
 
111
99
  const {
@@ -157,16 +145,7 @@ const useGraphQuery = ({
157
145
  base: data.current.base,
158
146
  title: ''
159
147
  },
160
- metrics: bypassMetricsExclusion
161
- ? data.current.metrics
162
- : data.current.metrics.filter(({ metric_id }) => {
163
- return pipe(
164
- pluck('excludedMetrics'),
165
- flatten,
166
- includes(metric_id),
167
- not
168
- )(metrics);
169
- }),
148
+ metrics: data.current.metrics,
170
149
  times: data.current.times
171
150
  }
172
151
  : undefined;
@@ -13,8 +13,3 @@ export enum WidgetResourceType {
13
13
  serviceCategory = 'service-category',
14
14
  serviceGroup = 'service-group'
15
15
  }
16
-
17
- export interface Metric {
18
- excludedMetrics: Array<number>;
19
- name: string;
20
- }
@@ -1,7 +1,5 @@
1
1
  import { Meta, StoryObj } from '@storybook/react';
2
2
 
3
- import { Checkbox, Typography } from '@mui/material';
4
-
5
3
  import { CollapsibleItem } from './CollapsibleItem';
6
4
 
7
5
  const meta: Meta<typeof CollapsibleItem> = {
@@ -25,27 +23,3 @@ export const ExpandedByDefault: Story = {
25
23
  title: 'Title'
26
24
  }
27
25
  };
28
-
29
- export const customizedTitle: Story = {
30
- args: {
31
- children: 'Label',
32
- defaultExpanded: false,
33
- title: <Typography>Title</Typography>
34
- }
35
- };
36
-
37
- export const customizedTitleAndCompact: Story = {
38
- args: {
39
- children: 'Label',
40
- compact: true,
41
- defaultExpanded: false,
42
- title: (
43
- <div
44
- style={{ alignItems: 'center', display: 'flex', flexDirection: 'row' }}
45
- >
46
- <Checkbox size="small" />
47
- <Typography>Title compact</Typography>
48
- </div>
49
- )
50
- }
51
- };
@@ -1,7 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
2
 
3
- import { equals, type } from 'ramda';
4
-
5
3
  import {
6
4
  AccordionDetails,
7
5
  AccordionSummary,
@@ -12,63 +10,36 @@ import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
12
10
 
13
11
  import { useCollapsibleItemStyles } from './useCollapsibleItemStyles';
14
12
 
15
- export interface Props {
13
+ interface Props {
16
14
  children: ReactNode;
17
- compact?: boolean;
18
- dataTestId?: string;
19
15
  defaultExpanded?: boolean;
20
- title: string | JSX.Element;
16
+ title: string;
21
17
  }
22
18
 
23
19
  export const CollapsibleItem = ({
24
20
  title,
25
21
  children,
26
- defaultExpanded,
27
- compact = false,
28
- dataTestId = ''
22
+ defaultExpanded
29
23
  }: Props): JSX.Element => {
30
- const { classes, cx } = useCollapsibleItemStyles();
31
-
32
- const isStringTitle = equals(type(title), 'String');
24
+ const { classes } = useCollapsibleItemStyles();
33
25
 
34
26
  return (
35
27
  <Accordion
36
28
  disableGutters
37
29
  className={classes.accordion}
38
- data-compact={compact}
39
- data-testid={`${dataTestId}-accordion`}
40
30
  defaultExpanded={defaultExpanded}
41
31
  >
42
- <div className={classes.summaryContainer}>
43
- <div className={classes.customTitle}>{!isStringTitle && title}</div>
44
- <AccordionSummary
45
- classes={{
46
- content: cx(
47
- compact
48
- ? classes.accordionSummaryCompactContent
49
- : classes.accordionSummary
50
- ),
51
- root: cx(
52
- compact
53
- ? classes.accordionSummaryCompactRoot
54
- : classes.accordionSummaryRoot
55
- )
56
- }}
57
- data-testid={`${dataTestId}-summary`}
58
- expandIcon={<ExpandMoreIcon color="primary" />}
59
- >
60
- {isStringTitle && (
61
- <Typography color="primary" variant="h6">
62
- {title}
63
- </Typography>
64
- )}
65
- </AccordionSummary>
66
- </div>
67
- <AccordionDetails
68
- className={cx(
69
- compact ? classes.accordionDetailsCompact : classes.accordionDetails
70
- )}
32
+ <AccordionSummary
33
+ classes={{
34
+ content: classes.accordionSummary
35
+ }}
36
+ expandIcon={<ExpandMoreIcon color="primary" />}
71
37
  >
38
+ <Typography color="primary" variant="h6">
39
+ {title}
40
+ </Typography>
41
+ </AccordionSummary>
42
+ <AccordionDetails className={classes.accordionDetails}>
72
43
  {children}
73
44
  </AccordionDetails>
74
45
  </Accordion>
@@ -4,35 +4,12 @@ export const useCollapsibleItemStyles = makeStyles()((theme) => ({
4
4
  accordion: {
5
5
  backgroundColor: 'transparent',
6
6
  border: 'none',
7
- borderBottom: `1px solid ${theme.palette.divider}`,
8
- width: '100%'
7
+ borderBottom: `1px solid ${theme.palette.divider}`
9
8
  },
10
9
  accordionDetails: {
11
10
  padding: theme.spacing(0, 2, 2)
12
11
  },
13
- accordionDetailsCompact: {
14
- padding: theme.spacing(0)
15
- },
16
12
  accordionSummary: {
17
13
  margin: theme.spacing(1.5, 0)
18
- },
19
- accordionSummaryCompactContent: {
20
- margin: theme.spacing(0, 0, 0.5)
21
- },
22
- accordionSummaryCompactRoot: {
23
- minHeight: theme.spacing(1),
24
- width: '100%'
25
- },
26
- accordionSummaryRoot: {
27
- width: '100%'
28
- },
29
- customTitle: {
30
- whiteSpace: 'nowrap'
31
- },
32
- summaryContainer: {
33
- alignItems: 'center',
34
- display: 'flex',
35
- flexDirection: 'row',
36
- width: '100%'
37
14
  }
38
15
  }));
@@ -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 row defaultValue={ContactType.Contact} onChange={change}>
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 => {
@@ -2,6 +2,7 @@ export interface AccessRightInitialValues {
2
2
  email?: string;
3
3
  id: number | string;
4
4
  isContactGroup: boolean;
5
+ most_permissive_role?: 'editor' | 'viewer';
5
6
  name: string;
6
7
  role: string;
7
8
  }
@@ -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 * from './AccessRights';
4
- export { default as AccessRightsV2 } from './AccessRightsV2/AccessRights';
3
+ export { default as AccessRights } from './AccessRights/AccessRights';
4
+ export { default as AccessRightsV2 } from './AccessRights/AccessRights';
@@ -7,7 +7,7 @@ import { IconButton } from '..';
7
7
  import { useItemStyles } from './ItemComposition.styles';
8
8
 
9
9
  type Props = {
10
- children: ReactElement | Array<ReactElement>;
10
+ children: Array<ReactElement>;
11
11
  className?: string;
12
12
  deleteButtonHidden?: boolean;
13
13
  labelDelete: string;
@@ -1,13 +1,6 @@
1
1
  import { makeStyles } from 'tss-react/mui';
2
2
 
3
3
  export const useItemCompositionStyles = makeStyles()((theme) => ({
4
- buttonAndSecondaryLabel: {
5
- alignItems: 'center',
6
- display: 'flex',
7
- flexDirection: 'row',
8
- justifyContent: 'space-between',
9
- width: '100%'
10
- },
11
4
  itemCompositionContainer: {
12
5
  alignItems: 'flex-start',
13
6
  display: 'flex',
@@ -31,6 +24,6 @@ export const useItemStyles = makeStyles()((theme) => ({
31
24
  width: '100%'
32
25
  },
33
26
  visibilityHiden: {
34
- display: 'none'
27
+ visibility: 'hidden'
35
28
  }
36
29
  }));