@centreon/ui 23.10.1-MON-20802-fe-implement-new-visualization.4 → 23.10.1-MON-20803-RS-add-basic-filter.1

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 (45) hide show
  1. package/package.json +1 -1
  2. package/src/Dashboard/Dashboard.styles.ts +1 -6
  3. package/src/Dashboard/Item.tsx +1 -4
  4. package/src/Dashboard/Layout.tsx +1 -1
  5. package/src/Graph/Gauge/Gauge.stories.tsx +0 -10
  6. package/src/Graph/Gauge/Gauge.tsx +1 -10
  7. package/src/Graph/Gauge/PieData.tsx +8 -8
  8. package/src/Graph/Gauge/ResponsiveGauge.tsx +23 -32
  9. package/src/Graph/Gauge/Thresholds.tsx +25 -2
  10. package/src/Graph/Gauge/models.ts +0 -1
  11. package/src/Graph/SingleBar/ResponsiveSingleBar.tsx +23 -41
  12. package/src/Graph/SingleBar/SingleBar.stories.tsx +0 -46
  13. package/src/Graph/SingleBar/ThresholdLine.tsx +12 -41
  14. package/src/Graph/SingleBar/Thresholds.tsx +1 -5
  15. package/src/Graph/SingleBar/models.ts +0 -4
  16. package/src/Graph/Text/Text.stories.tsx +0 -13
  17. package/src/Graph/Text/Text.tsx +12 -19
  18. package/src/Graph/common/timeSeries/index.test.ts +3 -106
  19. package/src/Graph/common/timeSeries/index.ts +4 -67
  20. package/src/Graph/common/timeSeries/models.ts +3 -6
  21. package/src/Graph/common/utils.ts +2 -4
  22. package/src/InputField/Select/Autocomplete/Multi/index.tsx +2 -4
  23. package/src/InputField/Select/Autocomplete/index.tsx +1 -4
  24. package/src/InputField/Text/index.tsx +7 -10
  25. package/src/Listing/Cell/index.tsx +2 -2
  26. package/src/RichTextEditor/ContentEditable.tsx +1 -0
  27. package/src/RichTextEditor/RichTextEditor.cypress.spec.tsx +13 -5
  28. package/src/RichTextEditor/RichTextEditor.tsx +2 -5
  29. package/src/RichTextEditor/plugins/AutoLinkPlugin/index.tsx +1 -40
  30. package/src/RichTextEditor/plugins/FloatingLinkEditorPlugin.tsx +8 -33
  31. package/src/RichTextEditor/plugins/ToolbarPlugin/index.tsx +4 -10
  32. package/src/ThemeProvider/index.tsx +4 -6
  33. package/src/api/buildListingEndpoint/getSearchQueryParameterValue.ts +2 -4
  34. package/src/api/buildListingEndpoint/index.ts +1 -1
  35. package/src/api/useFetchQuery/index.ts +8 -10
  36. package/src/components/Modal/Modal.styles.ts +1 -3
  37. package/src/components/index.ts +0 -1
  38. package/src/index.ts +4 -1
  39. package/src/utils/index.ts +0 -1
  40. package/src/utils/useDebounce.ts +7 -2
  41. package/src/components/Inputs/Switch/Switch.stories.tsx +0 -22
  42. package/src/components/Inputs/Switch/Switch.styles.ts +0 -13
  43. package/src/components/Inputs/Switch/Switch.tsx +0 -18
  44. package/src/components/Inputs/index.ts +0 -1
  45. package/src/utils/centreonBaseURL.ts +0 -4
@@ -11,7 +11,7 @@ import { mergeRegister } from '@lexical/utils';
11
11
  import { useAtom, useAtomValue, useSetAtom } from 'jotai';
12
12
  import { $isLinkNode, TOGGLE_LINK_COMMAND } from '@lexical/link';
13
13
  import { useTranslation } from 'react-i18next';
14
- import { dec, equals, gt, isNil, replace } from 'ramda';
14
+ import { equals, isNil } from 'ramda';
15
15
 
16
16
  import { Popper, IconButton, Paper, Link, Box } from '@mui/material';
17
17
  import EditIcon from '@mui/icons-material/Edit';
@@ -56,7 +56,6 @@ const FloatingLinkEditor = ({
56
56
  x: 0,
57
57
  y: 0
58
58
  });
59
- const [editedUrl, setEditedUrl] = useState('');
60
59
 
61
60
  const [editMode, setEditMode] = useAtom(editLinkModeAtom);
62
61
  const [linkUrl, setLinkUrl] = useAtom(linkValueAtom);
@@ -66,10 +65,9 @@ const FloatingLinkEditor = ({
66
65
  const acceptOrCancelNewLinkValue = useCallback(
67
66
  (event): void => {
68
67
  const { value } = event.target;
69
-
70
- event.preventDefault();
71
-
72
68
  if (event.key === 'Enter') {
69
+ event.preventDefault();
70
+
73
71
  if (value !== '') {
74
72
  editor.dispatchCommand(TOGGLE_LINK_COMMAND, {
75
73
  target: openLinkInNewTab ? '_blank' : undefined,
@@ -77,36 +75,14 @@ const FloatingLinkEditor = ({
77
75
  });
78
76
  }
79
77
  setEditMode(false);
80
- }
81
-
82
- if (event.key === 'Escape') {
78
+ } else if (event.key === 'Escape') {
79
+ event.preventDefault();
83
80
  setEditMode(false);
84
81
  }
85
82
  },
86
83
  [setEditMode, setLinkUrl]
87
84
  );
88
85
 
89
- const enterInEditMode = useCallback(() => {
90
- setEditedUrl(linkUrl);
91
- setEditMode(true);
92
- }, [linkUrl]);
93
-
94
- const changeValue = useCallback((event): void => {
95
- const { value } = event.target;
96
-
97
- const matched = value.match(/https?:\/\//g);
98
-
99
- if (gt(matched.length, 1)) {
100
- setEditedUrl(
101
- replace(matched.join(''), matched[dec(matched.length)], value)
102
- );
103
-
104
- return;
105
- }
106
-
107
- setEditedUrl(value);
108
- }, []);
109
-
110
86
  useEffect(() => {
111
87
  const isPositioned =
112
88
  rangeRect && (!equals(rangeRect.x, 0) || !equals(rangeRect.y, 0));
@@ -150,9 +126,9 @@ const FloatingLinkEditor = ({
150
126
  <InputField
151
127
  autoFocus
152
128
  dataTestId="InputLinkField"
129
+ defaultValue={linkUrl}
153
130
  label={t(labelInputLink)}
154
131
  size="small"
155
- value={editedUrl}
156
132
  onBlur={(event): void => {
157
133
  const { value } = event.target;
158
134
 
@@ -163,8 +139,7 @@ const FloatingLinkEditor = ({
163
139
  }
164
140
  setEditMode(false);
165
141
  }}
166
- onChange={changeValue}
167
- onKeyUp={acceptOrCancelNewLinkValue}
142
+ onKeyDown={acceptOrCancelNewLinkValue}
168
143
  />
169
144
  ) : (
170
145
  <Box component="span" sx={{ margin: '10px' }}>
@@ -181,7 +156,7 @@ const FloatingLinkEditor = ({
181
156
  aria-label={labelEditLink}
182
157
  size="small"
183
158
  sx={{ marginLeft: '5px' }}
184
- onClick={enterInEditMode}
159
+ onClick={(): void => setEditMode(true)}
185
160
  >
186
161
  <EditIcon fontSize="small" />
187
162
  </IconButton>
@@ -8,8 +8,7 @@ import MacrosButton from './MacrosButton';
8
8
  import BlockButtons from './BlockButtons';
9
9
 
10
10
  interface Props {
11
- disabled: boolean;
12
- displayBlockButtons: boolean;
11
+ disabled?: boolean;
13
12
  displayMacrosButton?: boolean;
14
13
  editable: boolean;
15
14
  }
@@ -34,20 +33,15 @@ export const useStyles = makeStyles()((theme) => ({
34
33
  const ToolbarPlugin = ({
35
34
  editable,
36
35
  displayMacrosButton,
37
- disabled,
38
- displayBlockButtons
36
+ disabled
39
37
  }: Props): JSX.Element | null => {
40
38
  const { classes } = useStyles();
41
39
 
42
40
  return editable ? (
43
41
  <div className={classes.container}>
44
42
  <UndoRedoButtons disabled={disabled} />
45
- {displayBlockButtons && (
46
- <>
47
- <Divider flexItem orientation="vertical" />
48
- <BlockButtons disabled={disabled} />
49
- </>
50
- )}
43
+ <Divider flexItem orientation="vertical" />
44
+ <BlockButtons disabled={disabled} />
51
45
  <Divider flexItem orientation="vertical" />
52
46
  <FormatButtons disabled={disabled} />
53
47
  {displayMacrosButton && (
@@ -48,7 +48,8 @@ const getInputBaseRootStyle = ({
48
48
 
49
49
  if (equals(size, 'compact')) {
50
50
  return {
51
- padding: '0px 0px 0px 8px'
51
+ padding: '8px 8px',
52
+ paddingRight: '0px'
52
53
  };
53
54
  }
54
55
  if (equals(size, 'small')) {
@@ -74,6 +75,7 @@ const getInputBaseRootStyle = ({
74
75
  const getInputBaseInputStyle = ({ size }: InputBaseProps): CSSInterpolation => {
75
76
  if (equals(size, 'compact')) {
76
77
  return {
78
+ fontSize: 'x-small',
77
79
  minHeight: '32px'
78
80
  };
79
81
  }
@@ -121,7 +123,6 @@ export const getTheme = (mode: ThemeMode): ThemeOptions => ({
121
123
  MuiChip: {
122
124
  styleOverrides: {
123
125
  root: ({ ownerState, theme }) => ({
124
- backgroundColor: !ownerState.color && theme.palette.divider,
125
126
  ...(equals(ownerState.size, 'medium') && {
126
127
  borderRadius: theme.spacing(1.25),
127
128
  fontSize: theme.typography.body2.fontSize,
@@ -188,10 +189,7 @@ export const getTheme = (mode: ThemeMode): ThemeOptions => ({
188
189
  },
189
190
  MuiInputBase: {
190
191
  styleOverrides: {
191
- root: ({ ownerState, theme }) => ({
192
- ...getInputBaseInputStyle(ownerState),
193
- backgroundColor: theme.palette.background.paper
194
- })
192
+ root: ({ ownerState }) => getInputBaseInputStyle(ownerState)
195
193
  }
196
194
  },
197
195
  MuiList: {
@@ -21,7 +21,7 @@ import {
21
21
  GetConditionsSearchQueryParameterValueState
22
22
  } from './models';
23
23
 
24
- const getFoundFields = ({
24
+ export const getFoundFields = ({
25
25
  value,
26
26
  fields
27
27
  }: RegexSearchParameter): Array<SearchMatch> => {
@@ -108,7 +108,7 @@ const getConditionsSearchQueryParameterValue = (
108
108
  };
109
109
  };
110
110
 
111
- const getSearchQueryParameterValue = (
111
+ export const getSearchQueryParameterValue = (
112
112
  search: SearchParameter | undefined
113
113
  ): SearchQueryParameterValue => {
114
114
  if (search === undefined) {
@@ -134,5 +134,3 @@ const getSearchQueryParameterValue = (
134
134
 
135
135
  return { $and: result };
136
136
  };
137
-
138
- export default getSearchQueryParameterValue;
@@ -1,7 +1,7 @@
1
1
  import toRawQueryParameters from '../../queryParameters';
2
2
  import { QueryParameter } from '../../queryParameters/models';
3
3
 
4
- import getSearchQueryParameterValue from './getSearchQueryParameterValue';
4
+ import { getSearchQueryParameterValue } from './getSearchQueryParameterValue';
5
5
  import { Parameters, BuildListingEndpointParameters } from './models';
6
6
 
7
7
  const getQueryParameters = ({
@@ -90,6 +90,14 @@ const useFetchQuery = <T extends object>({
90
90
  }
91
91
  };
92
92
 
93
+ useEffect(() => {
94
+ return (): void => {
95
+ queryClient.cancelQueries(getQueryKey());
96
+ };
97
+ }, []);
98
+
99
+ manageError();
100
+
93
101
  const prefetchQuery = ({ endpointParams, queryKey }): void => {
94
102
  queryClient.prefetchQuery(
95
103
  queryKey,
@@ -154,16 +162,6 @@ const useFetchQuery = <T extends object>({
154
162
 
155
163
  const errorData = queryData.data as ResponseError | undefined;
156
164
 
157
- useEffect(() => {
158
- return (): void => {
159
- queryClient.cancelQueries(getQueryKey());
160
- };
161
- }, []);
162
-
163
- useEffect(() => {
164
- manageError();
165
- }, [queryData.data]);
166
-
167
165
  return {
168
166
  ...omit(['data'], queryData),
169
167
  data,
@@ -48,12 +48,10 @@ const useStyles = makeStyles<{
48
48
  }
49
49
  },
50
50
  modalActions: {
51
- bottom: 0,
52
51
  display: 'flex',
53
52
  flexDirection: 'row',
54
53
  gap: theme.spacing(2),
55
- justifyContent: 'flex-end',
56
- position: 'sticky'
54
+ justifyContent: 'flex-end'
57
55
  },
58
56
  modalBody: {
59
57
  '& > p': {
@@ -10,4 +10,3 @@ export * from './List';
10
10
  export * from './ItemComposition';
11
11
  export * from './Avatar';
12
12
  export * from './CollapsibleItem';
13
- export * from './Inputs';
package/src/index.ts CHANGED
@@ -75,7 +75,10 @@ export { default as useCancelTokenSource } from './api/useCancelTokenSource';
75
75
  export { getData, patchData, postData, putData, deleteData } from './api';
76
76
  export { default as useRequest } from './api/useRequest';
77
77
  export { default as buildListingEndpoint } from './api/buildListingEndpoint';
78
- export { default as getSearchQueryParameterValue } from './api/buildListingEndpoint/getSearchQueryParameterValue';
78
+ export {
79
+ getSearchQueryParameterValue,
80
+ getFoundFields
81
+ } from './api/buildListingEndpoint/getSearchQueryParameterValue';
79
82
  export type {
80
83
  Parameters as ListingParameters,
81
84
  BuildListingEndpointParameters,
@@ -19,4 +19,3 @@ export * from './docsURL';
19
19
  export * from './useInfiniteScrollListing';
20
20
  export * from './useLicenseExpirationWarning';
21
21
  export * from './useRefreshInterval';
22
- export * from './centreonBaseURL';
@@ -1,4 +1,4 @@
1
- import { useRef, useCallback } from 'react';
1
+ import { useRef, useCallback, useEffect } from 'react';
2
2
 
3
3
  interface Props {
4
4
  functionToDebounce: (...args) => void;
@@ -12,6 +12,11 @@ export const useDebounce = ({
12
12
  memoProps = []
13
13
  }: Props): ((...args) => void) => {
14
14
  const timeoutRef = useRef<number | null>(null);
15
+ const ref = useRef();
16
+
17
+ useEffect(() => {
18
+ ref.current = functionToDebounce;
19
+ }, [functionToDebounce]);
15
20
 
16
21
  return useCallback((...args): void => {
17
22
  if (timeoutRef.current) {
@@ -19,7 +24,7 @@ export const useDebounce = ({
19
24
  }
20
25
 
21
26
  timeoutRef.current = setTimeout(() => {
22
- functionToDebounce(...args);
27
+ ref.current?.(...args);
23
28
  }, wait);
24
29
  }, memoProps);
25
30
  };
@@ -1,22 +0,0 @@
1
- import { Meta, StoryObj } from '@storybook/react';
2
-
3
- import Switch from './Switch';
4
-
5
- const meta: Meta<typeof Switch> = {
6
- component: Switch
7
- };
8
-
9
- export default meta;
10
- type Story = StoryObj<typeof Switch>;
11
-
12
- export const notChecked: Story = {
13
- args: {
14
- checked: false
15
- }
16
- };
17
-
18
- export const checked: Story = {
19
- args: {
20
- checked: true
21
- }
22
- };
@@ -1,13 +0,0 @@
1
- import { makeStyles } from 'tss-react/mui';
2
-
3
- export const useSwitchStyles = makeStyles()((theme) => ({
4
- switch: {
5
- '& .MuiSwitch-thumb': {
6
- backgroundColor: theme.palette.common.white
7
- },
8
- '& span[data-checked="true"] + .MuiSwitch-track': {
9
- backgroundColor: theme.palette.success.main,
10
- opacity: 1
11
- }
12
- }
13
- }));
@@ -1,18 +0,0 @@
1
- import { SwitchProps, Switch as MuiSwitch } from '@mui/material';
2
-
3
- import { useSwitchStyles } from './Switch.styles';
4
-
5
- const Switch = ({ checked, ...props }: SwitchProps): JSX.Element => {
6
- const { classes } = useSwitchStyles();
7
-
8
- return (
9
- <MuiSwitch
10
- checked={checked}
11
- className={classes.switch}
12
- data-checked={checked}
13
- {...props}
14
- />
15
- );
16
- };
17
-
18
- export default Switch;
@@ -1 +0,0 @@
1
- export { default as Switch } from './Switch/Switch';
@@ -1,4 +0,0 @@
1
- export const centreonBaseURL =
2
- (
3
- document.getElementsByTagName('base')[0]?.getAttribute('href') as string
4
- )?.slice(0, -1) || '';