@centreon/ui 23.10.117 → 23.10.119

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 (63) hide show
  1. package/package.json +12 -14
  2. package/src/Button/Save/StartIcon.tsx +3 -3
  3. package/src/Dashboard/Item.tsx +1 -1
  4. package/src/FileDropZone/index.tsx +1 -3
  5. package/src/Form/Inputs/CheckboxGroup.tsx +4 -1
  6. package/src/Form/Inputs/index.tsx +1 -1
  7. package/src/Graph/LineChart/BasicComponents/Lines/Threshold/index.tsx +4 -5
  8. package/src/Graph/LineChart/BasicComponents/useFilterLines.ts +1 -1
  9. package/src/Graph/LineChart/InteractiveComponents/Annotations/Annotation/index.tsx +3 -2
  10. package/src/Graph/LineChart/InteractiveComponents/Annotations/EventAnnotations.tsx +1 -1
  11. package/src/Graph/LineChart/Legend/useLegend.ts +5 -5
  12. package/src/Graph/LineChart/helpers/doc.ts +13 -16
  13. package/src/Graph/LineChart/helpers/index.ts +1 -1
  14. package/src/Graph/LineChart/index.stories.tsx +2 -1
  15. package/src/Graph/Text/Text.stories.tsx +4 -60
  16. package/src/Graph/common/timeSeries/index.ts +3 -3
  17. package/src/InputField/Select/Autocomplete/Connected/index.tsx +7 -10
  18. package/src/InputField/Select/Autocomplete/Draggable/SortableList.tsx +1 -1
  19. package/src/InputField/Select/Autocomplete/Draggable/SortableListContent.tsx +1 -1
  20. package/src/InputField/Select/Autocomplete/Draggable/index.tsx +1 -1
  21. package/src/InputField/Select/IconPopover/index.tsx +2 -2
  22. package/src/InputField/Select/index.tsx +1 -1
  23. package/src/Listing/Header/ListingHeader.tsx +1 -1
  24. package/src/Listing/index.stories.tsx +1 -12
  25. package/src/Listing/index.tsx +1 -1
  26. package/src/RichTextEditor/RichTextEditor.cypress.spec.tsx +52 -100
  27. package/src/RichTextEditor/RichTextEditor.tsx +4 -20
  28. package/src/RichTextEditor/plugins/ToolbarPlugin/AlignPicker.tsx +20 -21
  29. package/src/RichTextEditor/plugins/ToolbarPlugin/BlockButtons.tsx +77 -35
  30. package/src/RichTextEditor/plugins/ToolbarPlugin/FormatButtons.tsx +83 -29
  31. package/src/RichTextEditor/plugins/ToolbarPlugin/MacrosButton.tsx +39 -23
  32. package/src/RichTextEditor/plugins/ToolbarPlugin/ToolbarPlugin.styles.ts +14 -24
  33. package/src/RichTextEditor/plugins/ToolbarPlugin/UndoRedoButtons.tsx +0 -6
  34. package/src/RichTextEditor/plugins/ToolbarPlugin/index.tsx +10 -5
  35. package/src/RichTextEditor/translatedLabels.ts +0 -3
  36. package/src/SortableItems/index.tsx +7 -2
  37. package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/PickersStartEndDate.tsx +3 -8
  38. package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/models.ts +2 -0
  39. package/src/TimePeriods/DateTimePickerInput.tsx +17 -45
  40. package/src/TimePeriods/TimePeriods.cypress.spec.tsx +33 -9
  41. package/src/TimePeriods/helpers/index.ts +1 -1
  42. package/src/api/QueryProvider.tsx +1 -1
  43. package/src/api/TestQueryProvider.tsx +1 -1
  44. package/src/api/useFetchQuery/index.ts +24 -28
  45. package/src/api/useMutationQuery/index.ts +17 -39
  46. package/src/components/DataTable/Item/DataTableItem.tsx +2 -2
  47. package/src/components/Form/AccessRights/__fixtures__/contactAccessRight.mock.ts +0 -2
  48. package/src/components/Form/AccessRights/useAccessRightsForm.utils.ts +1 -1
  49. package/src/components/Form/Dashboard/DashboardForm.tsx +12 -15
  50. package/src/components/ItemComposition/ItemComposition.tsx +2 -4
  51. package/src/components/Menu/Button/MenuButton.tsx +2 -4
  52. package/src/components/Menu/MenuItem.tsx +3 -5
  53. package/src/components/Menu/MenuItems.tsx +3 -4
  54. package/src/index.ts +0 -1
  55. package/src/queryParameters/url/index.ts +1 -5
  56. package/src/screens/dashboard/DashboardsDetail.stories.tsx +108 -0
  57. package/src/screens/dashboard/DashboardsOverview.stories.tsx +281 -0
  58. package/src/utils/index.ts +1 -0
  59. package/src/utils/useDateTimePickerAdapter.ts +309 -0
  60. package/src/utils/{useLicenseExpirationWarning.test.tsx → useLicenseExpirationWarning.cypress.spec.tsx} +37 -48
  61. package/src/utils/useLicenseExpirationWarning.ts +18 -18
  62. package/src/RichTextEditor/plugins/ToolbarPlugin/LinkButton.tsx +0 -106
  63. package/src/RichTextEditor/plugins/ToolbarPlugin/ListButton.tsx +0 -155
@@ -19,7 +19,7 @@ export const useLicenseExpirationWarning = ({ module }: Props): void => {
19
19
  const { t } = useTranslation();
20
20
  const { showWarningMessage } = useSnackbar();
21
21
 
22
- const { data } = useFetchQuery({
22
+ const { fetchQuery } = useFetchQuery({
23
23
  getEndpoint: () => extensionsEndpoint,
24
24
  getQueryKey: () => [module]
25
25
  });
@@ -28,25 +28,25 @@ export const useLicenseExpirationWarning = ({ module }: Props): void => {
28
28
 
29
29
  const getExpirationDate = pipe(
30
30
  path(['result', 'module', 'entities']),
31
- find(propEq(module, 'id')),
31
+ find(propEq('id', module)),
32
32
  path(['license', 'expiration_date'])
33
33
  ) as (data) => string;
34
34
 
35
35
  useEffect(() => {
36
- if (isNil(data)) {
37
- return;
38
- }
39
-
40
- const expirationDate = getExpirationDate(data);
41
-
42
- if (isNil(expirationDate)) {
43
- return;
44
- }
45
-
46
- const daysUntilExpiration = dayjs(expirationDate).diff(currentDate, 'day');
47
-
48
- if (lt(daysUntilExpiration, 15)) {
49
- showWarningMessage(t(labelLicenseWarning(module, daysUntilExpiration)));
50
- }
51
- }, [data]);
36
+ fetchQuery().then((response) => {
37
+ const expirationDate = getExpirationDate(response);
38
+ if (isNil(expirationDate)) {
39
+ return;
40
+ }
41
+
42
+ const daysUntilExpiration = dayjs(expirationDate).diff(
43
+ currentDate,
44
+ 'day'
45
+ );
46
+
47
+ if (lt(daysUntilExpiration, 15)) {
48
+ showWarningMessage(t(labelLicenseWarning(module, daysUntilExpiration)));
49
+ }
50
+ });
51
+ }, []);
52
52
  };
@@ -1,106 +0,0 @@
1
- import { useCallback, useEffect } from 'react';
2
-
3
- import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
4
- import {
5
- $getSelection,
6
- $isRangeSelection,
7
- RangeSelection,
8
- SELECTION_CHANGE_COMMAND,
9
- ElementNode,
10
- TextNode
11
- } from 'lexical';
12
- import { $isLinkNode, TOGGLE_LINK_COMMAND } from '@lexical/link';
13
- import { $isAtNodeEnd } from '@lexical/selection';
14
- import { mergeRegister } from '@lexical/utils';
15
- import { useAtom } from 'jotai';
16
-
17
- import LinkIcon from '@mui/icons-material/Link';
18
-
19
- import { IconButton } from '../../..';
20
- import { isInsertingLinkAtom } from '../../atoms';
21
-
22
- import { useStyles } from './ToolbarPlugin.styles';
23
-
24
- const LowPriority = 1;
25
-
26
- const getSelectedNode = (selection: RangeSelection): ElementNode | TextNode => {
27
- const { anchor } = selection;
28
- const { focus } = selection;
29
- const anchorNode = selection.anchor.getNode();
30
- const focusNode = selection.focus.getNode();
31
- if (anchorNode === focusNode) {
32
- return anchorNode;
33
- }
34
- const isBackward = selection.isBackward();
35
- if (isBackward) {
36
- return $isAtNodeEnd(focus) ? anchorNode : focusNode;
37
- }
38
-
39
- return $isAtNodeEnd(anchor) ? focusNode : anchorNode;
40
- };
41
-
42
- interface Props {
43
- disabled: boolean;
44
- }
45
-
46
- const LinkButton = ({ disabled }: Props): JSX.Element => {
47
- const { classes, cx } = useStyles();
48
-
49
- const [isLink, setIsLink] = useAtom(isInsertingLinkAtom);
50
-
51
- const [editor] = useLexicalComposerContext();
52
-
53
- const updateToolbar = useCallback((): void => {
54
- const selection = $getSelection();
55
- if (!$isRangeSelection(selection)) {
56
- return;
57
- }
58
-
59
- const node = getSelectedNode(selection);
60
- const parent = node.getParent();
61
- if ($isLinkNode(parent) || $isLinkNode(node)) {
62
- setIsLink(true);
63
- } else {
64
- setIsLink(false);
65
- }
66
- }, [editor]);
67
-
68
- const insertLink = useCallback(() => {
69
- if (!isLink) {
70
- editor.dispatchCommand(TOGGLE_LINK_COMMAND, 'https://');
71
- } else {
72
- editor.dispatchCommand(TOGGLE_LINK_COMMAND, null);
73
- }
74
- }, [editor, isLink]);
75
-
76
- useEffect(() => {
77
- return mergeRegister(
78
- editor.registerCommand(
79
- SELECTION_CHANGE_COMMAND,
80
- () => {
81
- updateToolbar();
82
-
83
- return false;
84
- },
85
- LowPriority
86
- )
87
- );
88
- }, [editor, updateToolbar]);
89
-
90
- return (
91
- <IconButton
92
- ariaLabel="link"
93
- className={cx(classes.button, { [classes.buttonSelected]: isLink })}
94
- disabled={disabled}
95
- key="link"
96
- size="medium"
97
- title="link"
98
- tooltipPlacement="top"
99
- onClick={insertLink}
100
- >
101
- <LinkIcon />
102
- </IconButton>
103
- );
104
- };
105
-
106
- export default LinkButton;
@@ -1,155 +0,0 @@
1
- import { useCallback, useEffect, useState } from 'react';
2
-
3
- import {
4
- $isListNode,
5
- INSERT_ORDERED_LIST_COMMAND,
6
- INSERT_UNORDERED_LIST_COMMAND,
7
- ListNode,
8
- REMOVE_LIST_COMMAND
9
- } from '@lexical/list';
10
- import { $getSelection, $isRootOrShadowRoot } from 'lexical';
11
- import {
12
- $findMatchingParent,
13
- $getNearestNodeOfType,
14
- mergeRegister
15
- } from '@lexical/utils';
16
- import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
17
- import { equals, isNil } from 'ramda';
18
- import { useTranslation } from 'react-i18next';
19
-
20
- import UnorderedListIcon from '@mui/icons-material/FormatListBulleted';
21
- import OrderedListIcon from '@mui/icons-material/FormatListNumbered';
22
-
23
- import { Menu } from '../../../components';
24
- import { labelOrderedList, labelUnorderedList } from '../../translatedLabels';
25
-
26
- import { useStyles } from './ToolbarPlugin.styles';
27
-
28
- const options = [
29
- {
30
- Icon: UnorderedListIcon,
31
- label: labelUnorderedList,
32
- value: 'bullet'
33
- },
34
- {
35
- Icon: OrderedListIcon,
36
- label: labelOrderedList,
37
- value: 'number'
38
- }
39
- ];
40
-
41
- interface Props {
42
- disabled?: boolean;
43
- }
44
-
45
- const ListButton = ({ disabled }: Props): JSX.Element => {
46
- const { classes } = useStyles();
47
- const { t } = useTranslation();
48
-
49
- const [editor] = useLexicalComposerContext();
50
-
51
- const [elementList, setElementList] = useState(null);
52
-
53
- const formatBulletList = (): void => {
54
- if (elementList !== 'bullet') {
55
- editor.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, undefined);
56
- } else {
57
- editor.dispatchCommand(REMOVE_LIST_COMMAND, undefined);
58
- }
59
- };
60
-
61
- const formatNumberedList = (): void => {
62
- if (elementList !== 'number') {
63
- editor.dispatchCommand(INSERT_ORDERED_LIST_COMMAND, undefined);
64
- } else {
65
- editor.dispatchCommand(REMOVE_LIST_COMMAND, undefined);
66
- }
67
- };
68
-
69
- const formatList = (type): void => {
70
- if (equals(type, elementList)) {
71
- setElementList(null);
72
- }
73
-
74
- if (equals(type, 'bullet')) {
75
- formatBulletList();
76
-
77
- return;
78
- }
79
- formatNumberedList();
80
- };
81
-
82
- const updateToolbar = useCallback(() => {
83
- const selection = $getSelection();
84
- const anchorNode = selection?.anchor.getNode();
85
- const element = equals(anchorNode?.getKey(), 'root')
86
- ? anchorNode
87
- : $findMatchingParent(anchorNode, (e) => {
88
- const parent = e.getParent();
89
-
90
- return parent !== null && $isRootOrShadowRoot(parent);
91
- }) || anchorNode?.getTopLevelElementOrThrow();
92
-
93
- const elementKey = element?.getKey();
94
- const elementDOM = editor.getElementByKey(elementKey);
95
-
96
- if (isNil(elementDOM)) {
97
- return;
98
- }
99
-
100
- if ($isListNode(element)) {
101
- const parentList = $getNearestNodeOfType(anchorNode, ListNode);
102
- const type = parentList
103
- ? parentList.getListType()
104
- : element.getListType();
105
- setElementList(type);
106
- }
107
- }, [editor]);
108
-
109
- const selectedList = options.find(({ value }) => equals(value, elementList));
110
-
111
- useEffect(() => {
112
- return editor.registerUpdateListener(({ editorState }) => {
113
- editorState.read(() => {
114
- updateToolbar();
115
- });
116
- });
117
- }, [editor, updateToolbar]);
118
-
119
- useEffect(() => {
120
- return mergeRegister(
121
- editor.registerUpdateListener(({ editorState }) => {
122
- editorState.read(() => {
123
- updateToolbar();
124
- });
125
- })
126
- );
127
- }, [editor, updateToolbar]);
128
-
129
- return (
130
- <Menu>
131
- <Menu.Button
132
- ariaLabel="list"
133
- className={classes.button}
134
- disabled={disabled}
135
- >
136
- {selectedList ? <selectedList.Icon /> : <UnorderedListIcon />}
137
- </Menu.Button>
138
- <Menu.Items className={classes.menuItems}>
139
- <div className={classes.menu}>
140
- {options.map(({ Icon, value, label }) => (
141
- <Menu.Item
142
- isActive={equals(value, elementList)}
143
- key={value}
144
- onClick={() => formatList(value)}
145
- >
146
- <Icon aria-label={t(label)} />
147
- </Menu.Item>
148
- ))}
149
- </div>
150
- </Menu.Items>
151
- </Menu>
152
- );
153
- };
154
-
155
- export default ListButton;