@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.
- 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/Graph/LineChart/Legend/index.tsx +8 -7
- package/src/Graph/LineChart/LineChart.tsx +1 -4
- package/src/Graph/LineChart/index.tsx +1 -4
- 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/api/useGraphQuery/index.ts +5 -26
- package/src/api/useGraphQuery/models.ts +0 -5
- package/src/components/CollapsibleItem/CollapsibleItem.stories.tsx +0 -26
- package/src/components/CollapsibleItem/CollapsibleItem.tsx +14 -43
- package/src/components/CollapsibleItem/useCollapsibleItemStyles.ts +1 -24
- 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/ItemComposition/Item.tsx +1 -1
- package/src/components/ItemComposition/ItemComposition.styles.ts +1 -8
- package/src/components/ItemComposition/ItemComposition.tsx +16 -26
- package/src/components/CollapsibleItem/CollapsibleItem.cypress.spec.tsx +0 -76
- 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/ItemComposition/ItemComposition.cypress.spec.tsx +0 -116
- /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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@centreon/ui",
|
|
3
|
-
"version": "24.4.1-MON-
|
|
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: {
|
|
@@ -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
|
|
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>}
|
package/src/Dialog/index.tsx
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
|
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 =
|
|
64
|
-
? slice(0,
|
|
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
|
-
|
|
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
|
-
|
|
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 '
|
|
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
|
|
|
@@ -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 {
|
|
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
|
-
|
|
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
|
|
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:
|
|
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;
|
|
@@ -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
|
-
|
|
13
|
+
interface Props {
|
|
16
14
|
children: ReactNode;
|
|
17
|
-
compact?: boolean;
|
|
18
|
-
dataTestId?: string;
|
|
19
15
|
defaultExpanded?: boolean;
|
|
20
|
-
title: string
|
|
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
|
|
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
|
-
<
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
|
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';
|
|
@@ -7,7 +7,7 @@ import { IconButton } from '..';
|
|
|
7
7
|
import { useItemStyles } from './ItemComposition.styles';
|
|
8
8
|
|
|
9
9
|
type Props = {
|
|
10
|
-
children:
|
|
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
|
-
|
|
27
|
+
visibility: 'hidden'
|
|
35
28
|
}
|
|
36
29
|
}));
|