@centreon/ui 23.10.25 → 23.10.26-MON-19396-update-dashboard-rights.0

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 (43) hide show
  1. package/package.json +1 -1
  2. package/src/Button/Save/index.stories.tsx +5 -10
  3. package/src/Form/CollapsibleGroup.tsx +5 -11
  4. package/src/Form/Form.stories.tsx +1 -1
  5. package/src/Form/Form.tsx +9 -24
  6. package/src/Form/Inputs/Grid.tsx +2 -4
  7. package/src/Form/Inputs/index.tsx +7 -29
  8. package/src/Form/Inputs/models.ts +1 -13
  9. package/src/Form/storiesData.tsx +0 -45
  10. package/src/Panel/index.tsx +4 -6
  11. package/src/RichTextEditor/ContentEditable.tsx +7 -27
  12. package/src/RichTextEditor/RichTextEditor.tsx +45 -86
  13. package/src/ThemeProvider/index.tsx +1 -4
  14. package/src/ThemeProvider/palettes.ts +0 -7
  15. package/src/api/useMutationQuery/index.ts +10 -2
  16. package/src/components/Button/Button.tsx +1 -1
  17. package/src/components/DataTable/EmptyState/DataTableEmptyState.tsx +13 -9
  18. package/src/components/DataTable/Item/DataTableItem.tsx +1 -0
  19. package/src/components/Form/Dashboard/Dashboard.resource.ts +1 -1
  20. package/src/components/Form/Dashboard/DashboardForm.tsx +6 -10
  21. package/src/components/Form/Dashboard/translatedLabels.ts +0 -1
  22. package/src/components/List/Item/Avatar.tsx +14 -0
  23. package/src/components/List/Item/Item.tsx +18 -0
  24. package/src/components/List/Item/Text.tsx +13 -0
  25. package/src/components/List/Item/index.ts +8 -0
  26. package/src/components/List/List.stories.tsx +70 -0
  27. package/src/components/List/List.styles.ts +20 -0
  28. package/src/components/List/List.tsx +19 -0
  29. package/src/components/List/index.ts +6 -0
  30. package/src/components/Modal/Modal.styles.ts +3 -1
  31. package/src/components/Modal/ModalActions.tsx +4 -1
  32. package/src/components/index.ts +1 -0
  33. package/src/index.ts +0 -2
  34. package/src/utils/index.ts +1 -1
  35. package/src/utils/useInfiniteScrollListing.ts +106 -0
  36. package/src/Checkbox/Checkbox.tsx +0 -107
  37. package/src/Checkbox/CheckboxGroup/index.stories.tsx +0 -41
  38. package/src/Checkbox/CheckboxGroup/index.tsx +0 -66
  39. package/src/Checkbox/index.stories.tsx +0 -39
  40. package/src/Checkbox/index.tsx +0 -2
  41. package/src/Form/Inputs/Checkbox.tsx +0 -57
  42. package/src/Form/Inputs/CheckboxGroup.tsx +0 -76
  43. package/src/utils/panelSize.ts +0 -15
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@centreon/ui",
3
- "version": "23.10.25",
3
+ "version": "23.10.26-MON-19396-update-dashboard-rights.0",
4
4
  "description": "Centreon UI Components",
5
5
  "scripts": {
6
6
  "eslint": "eslint ./src --ext .js,.jsx,.ts,.tsx --max-warnings 0",
@@ -1,4 +1,4 @@
1
- import { ComponentStory } from '@storybook/react';
1
+ import { ComponentMeta, ComponentStory } from '@storybook/react';
2
2
  import { makeStyles } from 'tss-react/mui';
3
3
 
4
4
  import { Theme } from '@mui/material';
@@ -13,7 +13,7 @@ const useStyles = makeStyles()((theme: Theme) => ({
13
13
  }
14
14
  }));
15
15
 
16
- const meta = {
16
+ export default {
17
17
  argTypes: {
18
18
  labelLoading: { control: 'text' },
19
19
  labelSave: { control: 'text' },
@@ -26,13 +26,8 @@ const meta = {
26
26
 
27
27
  component: ButtonSave,
28
28
 
29
- parameters: {
30
- chromatic: { delay: 300 }
31
- },
32
29
  title: 'Button/Save'
33
- };
34
-
35
- export default meta;
30
+ } as ComponentMeta<typeof ButtonSave>;
36
31
 
37
32
  const TemplateButtonSave: ComponentStory<typeof ButtonSave> = (args) => (
38
33
  <ButtonSave {...args} />
@@ -47,7 +42,7 @@ export const loading = (): JSX.Element => <ButtonSave loading />;
47
42
  export const succeeded = (): JSX.Element => <ButtonSave succeeded />;
48
43
 
49
44
  export const normalWithText = (): JSX.Element => (
50
- <ButtonSave labelSave="Save" size="medium" />
45
+ <ButtonSave labelSave="Save" />
51
46
  );
52
47
 
53
48
  export const largeWithText = (): JSX.Element => (
@@ -55,7 +50,7 @@ export const largeWithText = (): JSX.Element => (
55
50
  );
56
51
 
57
52
  export const loadingWithTextAndMediumSize = (): JSX.Element => (
58
- <ButtonSave loading labelLoading="Loading" size="medium" />
53
+ <ButtonSave loading labelLoading="Loading" />
59
54
  );
60
55
 
61
56
  export const succeededWithText = (): JSX.Element => (
@@ -18,7 +18,6 @@ import { Group } from './Inputs/models';
18
18
 
19
19
  interface Props {
20
20
  children: React.ReactNode;
21
- className?: string;
22
21
  defaultIsOpen?: boolean;
23
22
  group?: Group;
24
23
  hasGroupTitle: boolean;
@@ -51,10 +50,9 @@ const CollapsibleGroup = ({
51
50
  isCollapsible,
52
51
  group,
53
52
  hasGroupTitle,
54
- defaultIsOpen = false,
55
- className
53
+ defaultIsOpen = false
56
54
  }: Props): JSX.Element => {
57
- const { classes, cx } = useStyles();
55
+ const { classes } = useStyles();
58
56
  const { t } = useTranslation();
59
57
 
60
58
  const [isOpen, setIsOpen] = useState(isCollapsible && defaultIsOpen);
@@ -63,8 +61,6 @@ const CollapsibleGroup = ({
63
61
  setIsOpen((currentIsOpen) => !currentIsOpen);
64
62
  };
65
63
 
66
- const containerClassName = className || '';
67
-
68
64
  const CollapseIcon = isOpen ? ExpandMore : ChevronRightIcon;
69
65
  const ContainerComponent = useCallback(
70
66
  ({
@@ -76,13 +72,13 @@ const CollapsibleGroup = ({
76
72
  disableGutters
77
73
  disableRipple
78
74
  aria-label={group?.name}
79
- className={cx(classes.groupTitleContainer, containerClassName)}
75
+ className={classes.groupTitleContainer}
80
76
  onClick={toggle}
81
77
  >
82
78
  {containerComponentChildren}
83
79
  </ListItemButton>
84
80
  ) : (
85
- <Box className={cx(classes.groupTitleContainer, containerClassName)}>
81
+ <Box className={classes.groupTitleContainer}>
86
82
  {containerComponentChildren}
87
83
  </Box>
88
84
  ),
@@ -95,9 +91,7 @@ const CollapsibleGroup = ({
95
91
  <ContainerComponent>
96
92
  {isCollapsible && <CollapseIcon />}
97
93
  <div className={classes.groupTitleIcon}>
98
- <Typography className="groupText" variant="h5">
99
- {t(group?.name as string)}
100
- </Typography>
94
+ <Typography variant="h5">{t(group?.name as string)}</Typography>
101
95
  {group?.EndIcon && (
102
96
  <Tooltip
103
97
  classes={{
@@ -71,7 +71,7 @@ export const basicFormWithHorizontalGroups = (): JSX.Element => (
71
71
  <Form<BasicForm>
72
72
  {...mandatoryProps}
73
73
  groupDirection={GroupDirection.Horizontal}
74
- groups={basicFormGroups.filter((group) => group.order !== 3)}
74
+ groups={basicFormGroups}
75
75
  />
76
76
  </Paper>
77
77
  );
package/src/Form/Form.tsx CHANGED
@@ -18,12 +18,8 @@ export enum GroupDirection {
18
18
 
19
19
  export type FormProps<T> = {
20
20
  Buttons?: React.ComponentType;
21
- areGroupsOpen?: boolean;
22
- children?: JSX.Element;
23
- className?: string;
24
21
  groupDirection?: GroupDirection;
25
22
  groups?: Array<Group>;
26
- groupsClassName?: string;
27
23
  initialValues: T;
28
24
  inputs: Array<InputProps>;
29
25
  isCollapsible?: boolean;
@@ -34,10 +30,6 @@ export type FormProps<T> = {
34
30
  } & Omit<FormikSharedConfig<T>, 'isInitialValid'>;
35
31
 
36
32
  const Form = <T extends object>({
37
- children,
38
- className,
39
- groupsClassName,
40
- areGroupsOpen,
41
33
  initialValues,
42
34
  validate,
43
35
  validationSchema,
@@ -50,15 +42,13 @@ const Form = <T extends object>({
50
42
  groupDirection = GroupDirection.Vertical,
51
43
  ...formikSharedConfig
52
44
  }: FormProps<T>): JSX.Element => {
53
- const { cx, classes } = useStyles();
45
+ const { classes } = useStyles();
54
46
 
55
47
  if (isLoading) {
56
48
  return (
57
49
  <Inputs
58
50
  isLoading
59
- areGroupsOpen={areGroupsOpen}
60
51
  groups={groups}
61
- groupsClassName={groupsClassName}
62
52
  inputs={inputs}
63
53
  isCollapsible={isCollapsible}
64
54
  />
@@ -73,19 +63,14 @@ const Form = <T extends object>({
73
63
  onSubmit={submit}
74
64
  {...formikSharedConfig}
75
65
  >
76
- <div>
77
- {children}
78
- <div className={cx(className, classes.form)}>
79
- <Inputs
80
- areGroupsOpen={areGroupsOpen}
81
- groupDirection={groupDirection}
82
- groups={groups}
83
- groupsClassName={groupsClassName}
84
- inputs={inputs}
85
- isCollapsible={isCollapsible}
86
- />
87
- <Buttons />
88
- </div>
66
+ <div className={classes.form}>
67
+ <Inputs
68
+ groupDirection={groupDirection}
69
+ groups={groups}
70
+ inputs={inputs}
71
+ isCollapsible={isCollapsible}
72
+ />
73
+ <Buttons />
89
74
  </div>
90
75
  </Formik>
91
76
  );
@@ -23,16 +23,14 @@ const useStyles = makeStyles<StylesProps>()(
23
23
  );
24
24
 
25
25
  const Grid = ({ grid }: InputPropsWithoutGroup): JSX.Element => {
26
- const { classes, cx } = useStyles({
26
+ const { classes } = useStyles({
27
27
  alignItems: grid?.alignItems,
28
28
  columns: grid?.columns.length,
29
29
  gridTemplateColumns: grid?.gridTemplateColumns
30
30
  });
31
31
 
32
- const className = grid?.className || '';
33
-
34
32
  return (
35
- <div className={cx(classes.gridFields, className)}>
33
+ <div className={classes.gridFields}>
36
34
  {grid?.columns.map((field) => {
37
35
  const Input = getInput(field.type);
38
36
 
@@ -18,8 +18,6 @@ import TextInput from './Text';
18
18
  import ConnectedAutocomplete from './ConnectedAutocomplete';
19
19
  import FieldsTable from './FieldsTable/FieldsTable';
20
20
  import Grid from './Grid';
21
- import CheckboxGroup from './CheckboxGroup';
22
- import Checkbox from './Checkbox';
23
21
  import Custom from './Custom';
24
22
  import LoadingSkeleton from './LoadingSkeleton';
25
23
 
@@ -63,15 +61,7 @@ export const getInput = R.cond<
63
61
  R.always(FieldsTable)
64
62
  ],
65
63
  [R.equals(InputType.Grid) as (b: InputType) => boolean, R.always(Grid)],
66
- [R.equals(InputType.Custom) as (b: InputType) => boolean, R.always(Custom)],
67
- [
68
- R.equals(InputType.Checkbox) as (b: InputType) => boolean,
69
- R.always(Checkbox)
70
- ],
71
- [
72
- R.equals(InputType.CheckboxGroup) as (b: InputType) => boolean,
73
- R.always(CheckboxGroup)
74
- ]
64
+ [R.equals(InputType.Custom) as (b: InputType) => boolean, R.always(Custom)]
75
65
  ]);
76
66
 
77
67
  interface StylesProps {
@@ -99,9 +89,7 @@ const useStyles = makeStyles<StylesProps>()((theme, { groupDirection }) => ({
99
89
  ? 'row'
100
90
  : 'column'
101
91
  },
102
- inputWrapper: {
103
- width: '100%'
104
- },
92
+ inputWrapper: { width: '100%' },
105
93
  inputs: {
106
94
  display: 'flex',
107
95
  flexDirection: 'column',
@@ -111,10 +99,8 @@ const useStyles = makeStyles<StylesProps>()((theme, { groupDirection }) => ({
111
99
  }));
112
100
 
113
101
  interface Props {
114
- areGroupsOpen?: boolean;
115
102
  groupDirection?: GroupDirection;
116
103
  groups?: Array<Group>;
117
- groupsClassName?: string;
118
104
  inputs: Array<InputProps>;
119
105
  isCollapsible: boolean;
120
106
  isLoading?: boolean;
@@ -125,11 +111,9 @@ const Inputs = ({
125
111
  groups = [],
126
112
  isLoading = false,
127
113
  isCollapsible,
128
- groupDirection,
129
- groupsClassName,
130
- areGroupsOpen
114
+ groupDirection
131
115
  }: Props): JSX.Element => {
132
- const { classes, cx } = useStyles({ groupDirection });
116
+ const { classes } = useStyles({ groupDirection });
133
117
  const { t } = useTranslation();
134
118
  const formikContext = useFormikContext<FormikValues>();
135
119
 
@@ -194,13 +178,12 @@ const Inputs = ({
194
178
  ? R.find(R.propEq('name', groupName), groups)
195
179
  : ({} as Group);
196
180
 
197
- const isFirstElement = areGroupsOpen || R.equals(index, 0);
181
+ const isFirstElement = R.equals(index, 0);
198
182
 
199
183
  return (
200
184
  <Fragment key={groupName}>
201
185
  <div>
202
186
  <CollapsibleGroup
203
- className={groupsClassName}
204
187
  defaultIsOpen={isFirstElement}
205
188
  group={groupProps}
206
189
  hasGroupTitle={hasGroupTitle}
@@ -226,18 +209,13 @@ const Inputs = ({
226
209
  >
227
210
  {inputProps.additionalLabel && (
228
211
  <Typography
229
- className={cx(
230
- classes.additionalLabel,
231
- inputProps?.additionalLabelClassName
232
- )}
212
+ className={classes.additionalLabel}
233
213
  variant="body1"
234
214
  >
235
215
  {t(inputProps.additionalLabel)}
236
216
  </Typography>
237
217
  )}
238
- <div className={inputProps?.inputClassName || ''}>
239
- <Input {...inputProps} />
240
- </div>
218
+ <Input {...inputProps} />
241
219
  </div>
242
220
  );
243
221
  })}
@@ -16,9 +16,7 @@ export enum InputType {
16
16
  MultiConnectedAutocomplete,
17
17
  FieldsTable,
18
18
  Grid,
19
- Custom,
20
- Checkbox,
21
- CheckboxGroup
19
+ Custom
22
20
  }
23
21
 
24
22
  interface FieldsTableGetRequiredProps {
@@ -26,22 +24,14 @@ interface FieldsTableGetRequiredProps {
26
24
  values: FormikValues;
27
25
  }
28
26
 
29
- export type LabelPlacement = 'bottom' | 'top' | 'end' | 'start' | undefined;
30
-
31
27
  export interface InputProps {
32
28
  additionalLabel?: string;
33
- additionalLabelClassName?: string;
34
29
  additionalMemoProps?: Array<unknown>;
35
30
  autocomplete?: {
36
31
  creatable?: boolean;
37
32
  options: Array<SelectEntry>;
38
33
  };
39
34
  change?: ({ setFieldValue, value }) => void;
40
- checkbox?: {
41
- direction?: 'horizontal' | 'vertical';
42
- labelPlacement?: LabelPlacement;
43
- options?: Array<string>;
44
- };
45
35
  connectedAutocomplete?: {
46
36
  additionalConditionParameters: Array<ConditionsSearchParameter>;
47
37
  endpoint?: string;
@@ -67,13 +57,11 @@ export interface InputProps {
67
57
  getRequired?: (values: FormikValues) => boolean;
68
58
  grid?: {
69
59
  alignItems?: string;
70
- className?: string;
71
60
  columns: Array<Omit<InputProps, 'group'>>;
72
61
  gridTemplateColumns?: string;
73
62
  };
74
63
  group: string;
75
64
  hideInput?: (values: FormikValues) => boolean;
76
- inputClassName?: string;
77
65
  label: string;
78
66
  radio?: {
79
67
  options?: Array<{
@@ -4,7 +4,6 @@ import { equals, prop } from 'ramda';
4
4
 
5
5
  import { Typography } from '@mui/material';
6
6
  import HelpOutlineIcon from '@mui/icons-material/HelpOutline';
7
- import MailIcon from '@mui/icons-material/MailOutline';
8
7
 
9
8
  import { SelectEntry } from '../InputField/Select';
10
9
  import { Listing } from '../api/models';
@@ -114,11 +113,6 @@ export const basicFormInitialValues = {
114
113
  isForced: false,
115
114
  language: 'French',
116
115
  name: '',
117
- notifications: {
118
- channels: { Icon: MailIcon, checked: true, label: 'mail' },
119
- hostevents: ['ok', 'warning'],
120
- includeServices: { checked: true, label: 'Include services for this host' }
121
- },
122
116
  password: '',
123
117
  roleMapping: [
124
118
  {
@@ -161,10 +155,6 @@ export const basicFormGroups: Array<Group> = [
161
155
  TooltipContent: (): JSX.Element => <Typography>Tooltip content</Typography>,
162
156
  name: 'Second group',
163
157
  order: 2
164
- },
165
- {
166
- name: 'Third group',
167
- order: 3
168
158
  }
169
159
  ];
170
160
 
@@ -213,41 +203,6 @@ export const basicFormInputs: Array<InputProps> = [
213
203
  },
214
204
  type: InputType.Radio
215
205
  },
216
- {
217
- additionalLabel: 'Notifications',
218
- fieldName: '',
219
- grid: {
220
- alignItems: 'center',
221
- columns: [
222
- {
223
- checkbox: {
224
- direction: 'horizontal'
225
- },
226
- fieldName: 'notifications.channels',
227
- label: 'channels',
228
- type: InputType.Checkbox
229
- },
230
- {
231
- fieldName: 'notifications.includeServices',
232
- label: 'Iclude services',
233
- type: InputType.Checkbox
234
- },
235
- {
236
- checkbox: {
237
- direction: 'horizontal',
238
- labelPlacement: 'top',
239
- options: ['ok', 'warning', 'critical', 'unknown']
240
- },
241
- fieldName: 'notifications.hostevents',
242
- label: 'host events',
243
- type: InputType.CheckboxGroup
244
- }
245
- ]
246
- },
247
- group: 'Third group',
248
- label: 'Notifications',
249
- type: InputType.Grid
250
- },
251
206
  {
252
207
  fieldName: 'anotherText',
253
208
  group: 'First group',
@@ -33,7 +33,7 @@ const useStyles = makeStyles<StylesProps>()(
33
33
  height: '100%'
34
34
  },
35
35
  container: {
36
- backgroundColor: theme.palette.background.panel,
36
+ backgroundColor: theme.palette.background.default,
37
37
  borderTopRightRadius: 0,
38
38
  display: 'grid',
39
39
  gridTemplate: 'auto auto 1fr / 1fr',
@@ -85,7 +85,6 @@ export interface Tab {
85
85
  }
86
86
 
87
87
  export interface Props {
88
- className?: string;
89
88
  header: React.ReactElement;
90
89
  headerBackgroundColor?: string;
91
90
  labelClose?: string;
@@ -112,12 +111,11 @@ const Panel = React.forwardRef(
112
111
  width = 550,
113
112
  minWidth = 550,
114
113
  headerBackgroundColor,
115
- onResize,
116
- className
114
+ onResize
117
115
  }: Props,
118
116
  ref
119
117
  ): JSX.Element => {
120
- const { classes, cx } = useStyles({
118
+ const { classes } = useStyles({
121
119
  hasTabs: !isEmpty(tabs),
122
120
  headerBackgroundColor,
123
121
  width
@@ -181,7 +179,7 @@ const Panel = React.forwardRef(
181
179
  exit: 50
182
180
  }}
183
181
  >
184
- <Paper className={cx(classes.container, className)} elevation={2}>
182
+ <Paper className={classes.container} elevation={2}>
185
183
  {!isNil(onResize) && (
186
184
  <div className={classes.dragger} role="none" onMouseDown={resize} />
187
185
  )}
@@ -9,20 +9,17 @@ import { Typography } from '@mui/material';
9
9
 
10
10
  interface StyleProps {
11
11
  editable: boolean;
12
- error?: string;
13
12
  minInputHeight: number;
14
13
  }
15
14
 
16
15
  const useStyles = makeStyles<StyleProps>()(
17
- (theme, { minInputHeight, editable, error }) => ({
16
+ (theme, { minInputHeight, editable }) => ({
18
17
  container: {
19
18
  '& p': {
20
19
  margin: 0
21
20
  },
22
21
  backgroundColor: theme.palette.background.paper,
23
- border: error
24
- ? `1px solid ${theme.palette.error.main}`
25
- : '1px solid transparent',
22
+ border: '1px solid transparent',
26
23
  borderRadius: theme.shape.borderRadius,
27
24
  padding: theme.spacing(0.5, 1)
28
25
  },
@@ -34,9 +31,7 @@ const useStyles = makeStyles<StyleProps>()(
34
31
  outline: '0px solid transparent'
35
32
  },
36
33
  inputFocused: {
37
- border: error
38
- ? `1px solid ${theme.palette.error.main}`
39
- : `1px solid ${theme.palette.primary.main}`
34
+ border: `1px solid ${theme.palette.primary.main}`
40
35
  },
41
36
  placeholder: {
42
37
  color: theme.palette.grey[500],
@@ -46,16 +41,13 @@ const useStyles = makeStyles<StyleProps>()(
46
41
  );
47
42
 
48
43
  interface Props {
49
- className?: string;
50
44
  editable: boolean;
51
45
  editorState?: string;
52
- error?: string;
53
46
  hasInitialTextContent?: boolean;
54
47
  initialEditorState?: string;
55
48
  inputClassname?: string;
56
49
  minInputHeight: number;
57
50
  namespace: string;
58
- onBlur?: (e: string) => void;
59
51
  placeholder: string;
60
52
  resetEditorToInitialStateCondition?: () => boolean;
61
53
  }
@@ -69,12 +61,9 @@ const ContentEditable = ({
69
61
  editorState,
70
62
  namespace,
71
63
  resetEditorToInitialStateCondition,
72
- initialEditorState,
73
- error,
74
- onBlur,
75
- className
64
+ initialEditorState
76
65
  }: Props): JSX.Element => {
77
- const { classes, cx } = useStyles({ editable, error, minInputHeight });
66
+ const { classes, cx } = useStyles({ editable, minInputHeight });
78
67
  const { t } = useTranslation();
79
68
 
80
69
  const [editor] = useLexicalComposerContext();
@@ -130,18 +119,9 @@ const ContentEditable = ({
130
119
 
131
120
  const isTextEmpty = isEmpty(root);
132
121
 
133
- const handleBlur = (event: React.FocusEvent<HTMLInputElement>): void => {
134
- setFocused(false);
135
- onBlur?.(event);
136
- };
137
-
138
122
  return (
139
123
  <div
140
- className={cx(
141
- classes.container,
142
- className,
143
- isFocused && classes.inputFocused
144
- )}
124
+ className={cx(classes.container, isFocused && classes.inputFocused)}
145
125
  id={namespace}
146
126
  >
147
127
  {editable && isTextEmpty && (
@@ -159,7 +139,7 @@ const ContentEditable = ({
159
139
  contentEditable={isEditable}
160
140
  data-testid={namespace}
161
141
  ref={ref}
162
- onBlur={handleBlur}
142
+ onBlur={(): void => setFocused(false)}
163
143
  onFocus={(): void => setFocused(true)}
164
144
  />
165
145
  </div>