@centreon/ui 26.5.14 → 26.5.15

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 (170) hide show
  1. package/package.json +6 -1
  2. package/src/ActionsList/ActionsList.styles.ts +2 -1
  3. package/src/ActionsList/index.tsx +1 -1
  4. package/src/Button/Icon/index.tsx +1 -1
  5. package/src/Button/Save/useSave.tsx +2 -1
  6. package/src/Checkbox/Checkbox.tsx +14 -9
  7. package/src/Checkbox/CheckboxGroup/index.tsx +1 -1
  8. package/src/Colors/index.tsx +12 -2
  9. package/src/Dashboard/Item.tsx +1 -1
  10. package/src/Dialog/Duplicate/index.tsx +5 -3
  11. package/src/Dialog/index.tsx +4 -1
  12. package/src/Form/Inputs/Autocomplete.tsx +30 -19
  13. package/src/Form/Inputs/ConnectedAutocomplete.tsx +27 -9
  14. package/src/Form/Inputs/FieldsTable/FieldsTable.tsx +24 -13
  15. package/src/Form/Inputs/FieldsTable/Row.tsx +7 -1
  16. package/src/Form/Inputs/List/Content.tsx +2 -2
  17. package/src/Form/Inputs/List/List.tsx +2 -1
  18. package/src/Form/Inputs/List/useList.ts +1 -1
  19. package/src/Form/Inputs/Radio.tsx +4 -1
  20. package/src/Form/Inputs/models.ts +42 -8
  21. package/src/Form/Section/PanelTabs.tsx +1 -1
  22. package/src/Form/storiesData.tsx +2 -2
  23. package/src/Graph/BarChart/Bar.tsx +39 -5
  24. package/src/Graph/BarChart/BarGroup.tsx +9 -5
  25. package/src/Graph/BarChart/BarStack.tsx +17 -4
  26. package/src/Graph/BarChart/useBarStack.ts +16 -8
  27. package/src/Graph/BarStack/Graph.tsx +21 -5
  28. package/src/Graph/BarStack/GraphAndLegend.tsx +2 -1
  29. package/src/Graph/BarStack/models.ts +23 -3
  30. package/src/Graph/BarStack/useGraphAndLegend.ts +10 -6
  31. package/src/Graph/BarStack/useResponsiveBarStack.ts +2 -1
  32. package/src/Graph/Chart/BasicComponents/Lines/Point.tsx +2 -1
  33. package/src/Graph/Chart/BasicComponents/Lines/RegularLines/index.tsx +4 -3
  34. package/src/Graph/Chart/BasicComponents/Lines/RegularLines/useRegularLines.ts +1 -1
  35. package/src/Graph/Chart/BasicComponents/Lines/StackedLines/index.tsx +4 -5
  36. package/src/Graph/Chart/BasicComponents/Lines/StackedLines/useStackedLines.ts +10 -1
  37. package/src/Graph/Chart/BasicComponents/Lines/Threshold/index.tsx +13 -4
  38. package/src/Graph/Chart/BasicComponents/Lines/Threshold/models.ts +2 -2
  39. package/src/Graph/Chart/BasicComponents/Lines/index.tsx +2 -10
  40. package/src/Graph/Chart/InteractiveComponents/AnchorPoint/StackedAnchorPoint.tsx +7 -3
  41. package/src/Graph/Chart/InteractiveComponents/AnchorPoint/models.ts +2 -2
  42. package/src/Graph/Chart/InteractiveComponents/AnchorPoint/useTickGraph.ts +4 -4
  43. package/src/Graph/Chart/InteractiveComponents/Annotations/Annotation/Area.tsx +9 -1
  44. package/src/Graph/Chart/InteractiveComponents/Annotations/Annotation/Line.tsx +9 -1
  45. package/src/Graph/Chart/InteractiveComponents/Annotations/EventAnnotations.tsx +9 -1
  46. package/src/Graph/Chart/InteractiveComponents/Annotations/useAnnotation.ts +1 -5
  47. package/src/Graph/Chart/InteractiveComponents/Tooltip/useGraphTooltip.ts +2 -2
  48. package/src/Graph/Chart/InteractiveComponents/index.tsx +8 -8
  49. package/src/Graph/Chart/Legend/LegendHeader.tsx +6 -1
  50. package/src/Graph/Chart/Legend/index.tsx +4 -1
  51. package/src/Graph/Chart/Legend/useLegend.ts +2 -2
  52. package/src/Graph/Chart/helpers/doc.ts +11 -1
  53. package/src/Graph/Chart/models.ts +2 -2
  54. package/src/Graph/Chart/useChartData.ts +4 -3
  55. package/src/Graph/Chart/useChartIntersection.ts +5 -1
  56. package/src/Graph/Gauge/AnimatedPie.tsx +7 -2
  57. package/src/Graph/Gauge/models.ts +7 -1
  58. package/src/Graph/PieChart/ResponsivePie.tsx +7 -1
  59. package/src/Graph/PieChart/models.ts +22 -3
  60. package/src/Graph/PieChart/useResponsivePie.ts +3 -2
  61. package/src/Graph/SingleBar/ThresholdLine.tsx +5 -1
  62. package/src/Graph/SingleBar/Thresholds.tsx +5 -1
  63. package/src/Graph/Timeline/ResponsiveTimeline.tsx +2 -2
  64. package/src/Graph/Timeline/useTimeline.ts +2 -1
  65. package/src/Graph/Tree/DescendantNodes.tsx +4 -3
  66. package/src/Graph/Tree/Tree.tsx +7 -1
  67. package/src/Graph/Tree/models.ts +2 -2
  68. package/src/Graph/common/Axes/UnitLabel.tsx +1 -1
  69. package/src/Graph/common/Axes/index.tsx +15 -6
  70. package/src/Graph/common/Axes/useAxisY.ts +3 -3
  71. package/src/Graph/common/BaseChart/AdditionalLine.tsx +2 -1
  72. package/src/Graph/common/BaseChart/ChartSvgWrapper.tsx +7 -3
  73. package/src/Graph/common/Grids/index.tsx +9 -3
  74. package/src/Graph/common/Thresholds/ThresholdLine.tsx +7 -1
  75. package/src/Graph/common/Thresholds/Thresholds.tsx +7 -1
  76. package/src/Graph/common/models.ts +9 -1
  77. package/src/Graph/common/timeSeries/index.test.ts +1 -1
  78. package/src/Graph/common/timeSeries/index.ts +72 -26
  79. package/src/Graph/common/timeSeries/models.ts +1 -1
  80. package/src/Graph/common/utils.ts +3 -1
  81. package/src/Image/useLoadImage.ts +6 -1
  82. package/src/InputField/Search/RegexpHelpTooltip.tsx +3 -1
  83. package/src/InputField/Select/Autocomplete/Connected/Multi/utils/index.ts +4 -1
  84. package/src/InputField/Select/Autocomplete/Connected/index.test.tsx +7 -2
  85. package/src/InputField/Select/Autocomplete/Connected/index.tsx +70 -26
  86. package/src/InputField/Select/Autocomplete/Draggable/SortableList.tsx +2 -2
  87. package/src/InputField/Select/Autocomplete/Draggable/SortableListContent.tsx +6 -4
  88. package/src/InputField/Select/Autocomplete/Draggable/index.tsx +35 -10
  89. package/src/InputField/Select/Autocomplete/Multi/Listbox.tsx +12 -2
  90. package/src/InputField/Select/Autocomplete/Multi/Multi.tsx +15 -8
  91. package/src/InputField/Select/Autocomplete/Popover/index.tsx +5 -2
  92. package/src/InputField/Select/Autocomplete/index.tsx +23 -10
  93. package/src/InputField/Select/IconPopover/index.tsx +8 -5
  94. package/src/InputField/Select/index.tsx +4 -3
  95. package/src/InputField/Text/index.tsx +1 -1
  96. package/src/InputField/Text/useAutoSize.ts +0 -2
  97. package/src/Listing/ActionBar/ColumnMultiSelect.tsx +2 -2
  98. package/src/Listing/ActionBar/Pagination.tsx +4 -2
  99. package/src/Listing/ActionBar/PaginationActions.tsx +12 -4
  100. package/src/Listing/ActionBar/index.tsx +19 -7
  101. package/src/Listing/Cell/DataCell.tsx +3 -3
  102. package/src/Listing/Cell/index.tsx +26 -13
  103. package/src/Listing/Header/Cell/ListingHeaderCell.tsx +2 -2
  104. package/src/Listing/Header/Cell/SelectActionListingHeaderCell.tsx +6 -4
  105. package/src/Listing/Header/ListingHeader.tsx +2 -2
  106. package/src/Listing/Header/_internals/PredefinedSelectionList.tsx +3 -1
  107. package/src/Listing/Row/Row.tsx +3 -3
  108. package/src/Listing/index.tsx +48 -28
  109. package/src/Listing/models.ts +11 -9
  110. package/src/MultiSelectEntries/index.tsx +3 -3
  111. package/src/Pagination/Pagination.tsx +3 -1
  112. package/src/Panel/index.tsx +2 -2
  113. package/src/PopoverMenu/index.tsx +3 -3
  114. package/src/RichTextEditor/ContentEditable.tsx +2 -1
  115. package/src/RichTextEditor/RichTextEditor.tsx +1 -1
  116. package/src/RichTextEditor/plugins/FloatingLinkEditorPlugin.tsx +16 -14
  117. package/src/RichTextEditor/plugins/ToolbarPlugin/BlockButtons.tsx +3 -3
  118. package/src/RichTextEditor/plugins/ToolbarPlugin/ListButton.tsx +1 -1
  119. package/src/RichTextEditor/plugins/ToolbarPlugin/MacrosButton.tsx +1 -1
  120. package/src/Snackbar/SnackbarProvider.tsx +1 -1
  121. package/src/Snackbar/index.tsx +4 -2
  122. package/src/Snackbar/useSnackbar.tsx +14 -4
  123. package/src/SortableItems/index.tsx +4 -4
  124. package/src/TimePeriods/CustomTimePeriod/CompactCustomTimePeriod.tsx +1 -1
  125. package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/models.ts +1 -1
  126. package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/usePickersStartEndDate.ts +9 -3
  127. package/src/TimePeriods/CustomTimePeriod/index.tsx +7 -2
  128. package/src/TimePeriods/helpers/index.ts +7 -2
  129. package/src/TimePeriods/models.ts +4 -1
  130. package/src/TimePeriods/useTimePeriod.ts +0 -2
  131. package/src/Wizard/ActionsBar.tsx +1 -1
  132. package/src/Wizard/index.test.tsx +0 -66
  133. package/src/Wizard/index.tsx +10 -5
  134. package/src/Wizard/models.ts +1 -1
  135. package/src/api/buildListingEndpoint/getSearchQueryParameterValue.ts +2 -1
  136. package/src/api/buildListingEndpoint/index.ts +7 -1
  137. package/src/api/customFetch.ts +3 -3
  138. package/src/api/useBulkResponse.ts +31 -9
  139. package/src/api/useFetchQuery/index.ts +28 -6
  140. package/src/api/useGraphQuery/index.ts +1 -1
  141. package/src/api/useRequest/index.ts +7 -7
  142. package/src/components/Button/Button.tsx +1 -1
  143. package/src/components/Button/Icon/IconButton.tsx +1 -1
  144. package/src/components/CrudPage/Listing.tsx +3 -3
  145. package/src/components/CrudPage/utils.ts +1 -1
  146. package/src/components/Form/AccessRights/AccessRights.tsx +4 -1
  147. package/src/components/Form/AccessRights/Actions/Actions.tsx +4 -1
  148. package/src/components/Form/AccessRights/ShareInput/ShareInput.tsx +1 -1
  149. package/src/components/Form/AccessRights/ShareInput/useShareInput.tsx +35 -13
  150. package/src/components/Form/AccessRights/common/RoleSelectField.tsx +1 -1
  151. package/src/components/Form/AccessRights/storiesData.ts +2 -2
  152. package/src/components/ItemComposition/ItemComposition.tsx +1 -1
  153. package/src/components/Menu/Button/MenuButton.tsx +1 -1
  154. package/src/components/Menu/useMenu.tsx +3 -1
  155. package/src/components/Tabs/Tabs.tsx +1 -1
  156. package/src/components/Tooltip/ConfirmationTooltip/models.ts +5 -1
  157. package/src/components/Zoom/useMinimap.ts +16 -10
  158. package/src/components/Zoom/useZoom.ts +12 -6
  159. package/src/components/Zoom/utils.ts +3 -1
  160. package/src/queryParameters/index.ts +8 -2
  161. package/src/utils/resourcesStatusURL.ts +20 -3
  162. package/src/utils/translatedLabel.ts +4 -2
  163. package/src/utils/useDebounce.ts +10 -9
  164. package/src/utils/useInfiniteScrollListing.ts +2 -2
  165. package/src/utils/useIntersectionObserver.ts +2 -2
  166. package/src/utils/useLicenseExpirationWarning.test.tsx +4 -2
  167. package/src/utils/useLoadImage.tsx +7 -2
  168. package/src/utils/useLocaleDateTimeFormat/index.test.tsx +2 -3
  169. package/src/utils/useLocaleDateTimeFormat/localeFallback.test.tsx +2 -3
  170. package/test/testRenderer.tsx +9 -5
@@ -29,7 +29,7 @@ const RoleSelectField = ({
29
29
  fullWidth
30
30
  label={label}
31
31
  onChange={(event) => {
32
- onChange(event.target.value);
32
+ onChange(event.target.value as string);
33
33
  }}
34
34
  options={roles}
35
35
  selectedOptionId={value}
@@ -81,7 +81,7 @@ export const accessRightsWithStates = [
81
81
 
82
82
  export const emptyAccessRights = [];
83
83
 
84
- const buildEntities = (from, isGroup): Array<SelectEntry> => {
84
+ const buildEntities = (from: number, isGroup: boolean): Array<SelectEntry> => {
85
85
  return Array(10)
86
86
  .fill(0)
87
87
  .map((_, index) => ({
@@ -92,7 +92,7 @@ const buildEntities = (from, isGroup): Array<SelectEntry> => {
92
92
  }));
93
93
  };
94
94
 
95
- export const buildResult = (isGroup): Listing<SelectEntry> => ({
95
+ export const buildResult = (isGroup: boolean): Listing<SelectEntry> => ({
96
96
  meta: {
97
97
  limit: 10,
98
98
  page: 1,
@@ -9,7 +9,7 @@ import { Button } from '..';
9
9
  import { useItemCompositionStyles } from './ItemComposition.styles';
10
10
 
11
11
  export type Props = {
12
- IconAdd?;
12
+ IconAdd?: ReactElement;
13
13
  addButtonHidden?: boolean;
14
14
  addbuttonDisabled?: boolean;
15
15
  children: Array<ReactElement>;
@@ -34,7 +34,7 @@ const MenuButton = ({
34
34
  const { isMenuOpen, setIsMenuOpen, setAnchorEl, onOpen } = useMenu();
35
35
 
36
36
  const onToggle = useCallback(
37
- (e): void => {
37
+ (e: React.MouseEvent<HTMLButtonElement>): void => {
38
38
  setAnchorEl(e.currentTarget);
39
39
 
40
40
  setIsMenuOpen(!isMenuOpen);
@@ -54,7 +54,9 @@ type UseMenu = {
54
54
  onClose: (() => void) | null;
55
55
  onOpen: (() => void) | null;
56
56
  setAnchorEl: (event: null | HTMLElement) => void;
57
- setIsMenuOpen: (isOpen: boolean | ((currentIsMenuOpen) => boolean)) => void;
57
+ setIsMenuOpen: (
58
+ isOpen: boolean | ((currentIsMenuOpen: boolean) => boolean)
59
+ ) => void;
58
60
  };
59
61
 
60
62
  const useMenu = (): UseMenu => {
@@ -36,7 +36,7 @@ export const Tabs = ({
36
36
  const [selectedTab, setSelectedTab] = useState(defaultTab);
37
37
 
38
38
  const changeTab = useCallback(
39
- (_, newValue: string): void => {
39
+ (_: React.SyntheticEvent, newValue: string): void => {
40
40
  if (onChange) onChange(newValue);
41
41
 
42
42
  setSelectedTab(newValue);
@@ -1,3 +1,4 @@
1
+ import type React from 'react';
1
2
  import type { ReactElement } from 'react';
2
3
 
3
4
  import type { ActionVariants } from '../../../ActionsList/models';
@@ -11,7 +12,10 @@ interface Labels {
11
12
  }
12
13
 
13
14
  export interface Props {
14
- children: ({ toggleTooltip, isOpen }) => ReactElement;
15
+ children: (params: {
16
+ isOpen: boolean;
17
+ toggleTooltip: (event: React.MouseEvent<HTMLButtonElement>) => void;
18
+ }) => ReactElement;
15
19
  confirmVariant?: ActionVariants;
16
20
  labels: Labels;
17
21
  onConfirm: () => void;
@@ -1,6 +1,7 @@
1
1
  import type { Point } from '@visx/point';
2
2
  import type { ProvidedZoom, Translate } from '@visx/zoom/lib/types';
3
3
  import { equals, gt, pick } from 'ramda';
4
+ import type React from 'react';
4
5
  import { useCallback, useState } from 'react';
5
6
 
6
7
  import type { ZoomState } from './models';
@@ -15,11 +16,11 @@ export interface UseMinimapProps {
15
16
  }
16
17
 
17
18
  interface UseMinimapState {
18
- dragEnd: (e) => void;
19
- dragStart: (e) => void;
20
- move: (e) => void;
21
- transformTo: (e) => void;
22
- zoomInOut: (e) => void;
19
+ dragEnd: () => void;
20
+ dragStart: (e: React.MouseEvent<SVGRectElement>) => void;
21
+ move: (e: React.MouseEvent<SVGRectElement>) => void;
22
+ transformTo: (e: React.MouseEvent<SVGRectElement>) => void;
23
+ zoomInOut: (e: React.WheelEvent<SVGRectElement>) => void;
23
24
  }
24
25
 
25
26
  export const useMinimap = ({
@@ -36,7 +37,12 @@ export const useMinimap = ({
36
37
  const [startTranslate, setStartTranslate] = useState<Translate | null>(null);
37
38
 
38
39
  const getMatrixPoint = useCallback(
39
- (event, newScale?: number): { x: number; y: number } => {
40
+ (
41
+ event:
42
+ | React.MouseEvent<SVGRectElement>
43
+ | React.WheelEvent<SVGRectElement>,
44
+ newScale?: number
45
+ ): { x: number; y: number } => {
40
46
  const hasScale = scale > 1;
41
47
  const point = {
42
48
  x: event.nativeEvent.offsetX * (1 / minimapScale),
@@ -61,7 +67,7 @@ export const useMinimap = ({
61
67
  );
62
68
 
63
69
  const transformTo = useCallback(
64
- (e: MouseEvent): void => {
70
+ (e: React.MouseEvent<SVGRectElement>): void => {
65
71
  if (!equals(e.buttons, 1)) {
66
72
  return;
67
73
  }
@@ -75,7 +81,7 @@ export const useMinimap = ({
75
81
  [zoom.transformMatrix, getMatrixPoint, zoom.setTransformMatrix]
76
82
  );
77
83
 
78
- const dragStart = (e: MouseEvent): void => {
84
+ const dragStart = (e: React.MouseEvent<SVGRectElement>): void => {
79
85
  if (!equals(e.buttons, 1) || isDraggingFromContainer) {
80
86
  return;
81
87
  }
@@ -89,7 +95,7 @@ export const useMinimap = ({
89
95
  };
90
96
 
91
97
  const move = useCallback(
92
- (e): void => {
98
+ (e: React.MouseEvent<SVGRectElement>): void => {
93
99
  if (!startPoint || !startTranslate) {
94
100
  return;
95
101
  }
@@ -115,7 +121,7 @@ export const useMinimap = ({
115
121
  );
116
122
 
117
123
  const zoomInOut = useCallback(
118
- (e): void => {
124
+ (e: React.WheelEvent<SVGRectElement>): void => {
119
125
  const isZoomIn = gt(0, e.deltaY);
120
126
 
121
127
  const newScaleX = isZoomIn
@@ -1,18 +1,24 @@
1
1
  import type { Point, ProvidedZoom, Translate } from '@visx/zoom/lib/types';
2
2
  import { equals } from 'ramda';
3
+ import type React from 'react';
3
4
  import { useCallback, useState } from 'react';
4
5
 
5
6
  import { localPoint } from './localPoint';
6
7
  import type { ZoomState } from './models';
7
8
 
8
- const isLeftMouseButtonClicked = (e: MouseEvent): boolean =>
9
- equals(e.buttons, 1);
9
+ const isLeftMouseButtonClicked = (
10
+ e: React.MouseEvent<SVGSVGElement>
11
+ ): boolean => equals(e.buttons, 1);
10
12
 
11
13
  interface UseZoomState {
12
14
  dragEnd: () => void;
13
- dragStart: (zoom: ProvidedZoom<SVGSVGElement> & ZoomState) => (e) => void;
15
+ dragStart: (
16
+ zoom: ProvidedZoom<SVGSVGElement> & ZoomState
17
+ ) => (e: React.MouseEvent<SVGSVGElement>) => void;
14
18
  isDragging: boolean;
15
- move: (zoom: ProvidedZoom<SVGSVGElement> & ZoomState) => (e) => void;
19
+ move: (
20
+ zoom: ProvidedZoom<SVGSVGElement> & ZoomState
21
+ ) => (e: React.MouseEvent<SVGSVGElement>) => void;
16
22
  }
17
23
 
18
24
  export const useZoom = (): UseZoomState => {
@@ -21,7 +27,7 @@ export const useZoom = (): UseZoomState => {
21
27
 
22
28
  const dragStart = useCallback(
23
29
  (zoom: ProvidedZoom<SVGSVGElement> & ZoomState) =>
24
- (e): void => {
30
+ (e: React.MouseEvent<SVGSVGElement>): void => {
25
31
  if (!isLeftMouseButtonClicked(e)) {
26
32
  return;
27
33
  }
@@ -34,7 +40,7 @@ export const useZoom = (): UseZoomState => {
34
40
 
35
41
  const move = useCallback(
36
42
  (zoom: ProvidedZoom<SVGSVGElement> & ZoomState) =>
37
- (e): void => {
43
+ (e: React.MouseEvent<SVGSVGElement>): void => {
38
44
  if (!startPoint || !startTranslate) {
39
45
  return;
40
46
  }
@@ -15,7 +15,9 @@ export const applyTranformStylesForZoom = ({
15
15
  width: contentClientRect?.width || 1
16
16
  };
17
17
  const isPortrait = contentRect.height > contentRect.width;
18
- const sizes = isPortrait ? ['width', 'height'] : ['height', 'width'];
18
+ const sizes: Array<'width' | 'height'> = isPortrait
19
+ ? ['width', 'height']
20
+ : ['height', 'width'];
19
21
  const sizeScale = contentRect[sizes[0]] / contentRect[sizes[1]];
20
22
 
21
23
  const lengthToUse = isPortrait
@@ -7,8 +7,14 @@ interface ToRawQueryParametersProps {
7
7
  apiFormat: 'Standard' | 'JSON-LD';
8
8
  }
9
9
 
10
- const toRawQueryParameter = ({ name, value }): string => {
11
- return `${name}=${encodeURIComponent(value)}`;
10
+ const toRawQueryParameter = ({
11
+ name,
12
+ value
13
+ }: {
14
+ name: string;
15
+ value: unknown;
16
+ }): string => {
17
+ return `${name}=${encodeURIComponent(value as string)}`;
12
18
  };
13
19
 
14
20
  const toRawQueryParameters = ({
@@ -19,16 +19,30 @@ export interface Resource {
19
19
  resources: Array<SelectEntry>;
20
20
  }
21
21
 
22
+ interface ResourceDetails {
23
+ id: number | string;
24
+ parentId?: number | string;
25
+ uuid?: string;
26
+ }
27
+
22
28
  interface GetResourcesUrlProps {
23
29
  allResources: Array<Resource>;
24
30
  isForOneResource: boolean;
25
- resource?;
31
+ resource?: ResourceDetails;
26
32
  states: Array<string>;
27
33
  statuses: Array<string>;
28
34
  type: string;
29
35
  }
30
36
 
31
- export const getDetailsPanelQueriers = ({ resource, type }): object => {
37
+ interface GetDetailsPanelQueriersProps {
38
+ resource: ResourceDetails;
39
+ type: string;
40
+ }
41
+
42
+ export const getDetailsPanelQueriers = ({
43
+ resource,
44
+ type
45
+ }: GetDetailsPanelQueriersProps): object => {
32
46
  const { id, parentId, uuid } = resource;
33
47
 
34
48
  const resourcesDetailsEndpoint = cond([
@@ -158,7 +172,10 @@ export const getResourcesUrl = ({
158
172
  return `/monitoring/resources?filter=${encodedFilterParams}&fromTopCounter=true`;
159
173
  }
160
174
 
161
- const detailsPanelQueriers = getDetailsPanelQueriers({ resource, type });
175
+ const detailsPanelQueriers = getDetailsPanelQueriers({
176
+ resource: resource as ResourceDetails,
177
+ type
178
+ });
162
179
 
163
180
  const encodedDetailsParams = encodeURIComponent(
164
181
  JSON.stringify(detailsPanelQueriers)
@@ -1,2 +1,4 @@
1
- export const labelLicenseWarning = (module, daysUntilExpiration): string =>
2
- `The ${module} license will expire in ${daysUntilExpiration} days`;
1
+ export const labelLicenseWarning = (
2
+ module: string,
3
+ daysUntilExpiration: number
4
+ ): string => `The ${module} license will expire in ${daysUntilExpiration} days`;
@@ -1,27 +1,28 @@
1
1
  import { useCallback, useEffect, useRef } from 'react';
2
2
 
3
- interface Props {
4
- functionToDebounce: (...args) => void;
3
+ // biome-ignore lint/suspicious/noExplicitAny: needed for variadic generic
4
+ type AnyFunction = (...args: Array<any>) => void;
5
+
6
+ interface Props<T extends AnyFunction> {
7
+ functionToDebounce: T;
5
8
  memoProps?: Array<unknown>;
6
9
  wait: number;
7
10
  }
8
11
 
9
- export const useDebounce = ({
12
+ export const useDebounce = <T extends AnyFunction>({
10
13
  functionToDebounce,
11
14
  wait,
12
15
  memoProps = []
13
- }: Props): ((...args) => void) => {
14
- const timeoutRef = useRef<number | null>(null);
15
- const ref = useRef<((...args: Array<unknown>) => void) | undefined>(
16
- undefined
17
- );
16
+ }: Props<T>): ((...args: Parameters<T>) => void) => {
17
+ const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
18
+ const ref = useRef<T | undefined>(undefined);
18
19
 
19
20
  useEffect(() => {
20
21
  ref.current = functionToDebounce;
21
22
  }, [functionToDebounce]);
22
23
 
23
24
  return useCallback(
24
- (...args): void => {
25
+ (...args: Parameters<T>): void => {
25
26
  if (timeoutRef.current) {
26
27
  clearTimeout(timeoutRef.current);
27
28
  }
@@ -14,7 +14,7 @@ import type { Parameters } from '../api/buildListingEndpoint/models';
14
14
  import type { Listing } from '../api/models';
15
15
 
16
16
  interface UseInfiniteScrollListing<T> {
17
- elementRef: (node) => void;
17
+ elementRef: (node: Element | null) => void;
18
18
  elements: Array<T>;
19
19
  isLoading: boolean;
20
20
  total?: number;
@@ -110,7 +110,7 @@ export const useInfiniteScrollListing = <T>({
110
110
  }
111
111
 
112
112
  prefetchNextPage({
113
- getPrefetchQueryKey: (newPage) => ['dashboards', newPage],
113
+ getPrefetchQueryKey: (newPage: number) => ['dashboards', newPage],
114
114
  page
115
115
  });
116
116
  }, [data, limit, page, prefetchNextPage]);
@@ -14,10 +14,10 @@ export const useIntersectionObserver = ({
14
14
  loading,
15
15
  action,
16
16
  intersectionObserverOptions
17
- }: HookParam): ((node) => void) => {
17
+ }: HookParam): ((node: Element | null) => void) => {
18
18
  const observer = useRef<IntersectionObserver | null>(null);
19
19
  const lastElementRef = useCallback(
20
- (node) => {
20
+ (node: Element | null) => {
21
21
  if (observer.current) {
22
22
  observer.current.disconnect();
23
23
  }
@@ -11,7 +11,7 @@ import TestQueryProvider from "../api/TestQueryProvider";
11
11
  import { useLicenseExpirationWarning } from ".";
12
12
  import { labelLicenseWarning } from "./translatedLabel";
13
13
 
14
- const getMockedResponse = (expirationDate): object => ({
14
+ const getMockedResponse = (expirationDate: dayjs.Dayjs): object => ({
15
15
  result: {
16
16
  module: {
17
17
  entities: [
@@ -83,7 +83,9 @@ const getMockedResponse = (expirationDate): object => ({
83
83
  status: true,
84
84
  });
85
85
 
86
- const mockRequest = ({ expirationDate }: { expirationDate }): void => {
86
+ const mockRequest = ({
87
+ expirationDate,
88
+ }: { expirationDate: dayjs.Dayjs }): void => {
87
89
  resetMocks();
88
90
  mockResponse({
89
91
  data: getMockedResponse(expirationDate),
@@ -1,4 +1,4 @@
1
- import { useSetAtom } from 'jotai';
1
+ import { type PrimitiveAtom, useSetAtom } from 'jotai';
2
2
  import { useLayoutEffect } from 'react';
3
3
 
4
4
  const loadImage = (imagePath: string): Promise<string> =>
@@ -10,7 +10,12 @@ const loadImage = (imagePath: string): Promise<string> =>
10
10
  image.onerror = reject;
11
11
  });
12
12
 
13
- export const useLoadImage = ({ imagePath, atom }): void => {
13
+ interface UseLoadImageProps {
14
+ atom: PrimitiveAtom<string | null>;
15
+ imagePath: string;
16
+ }
17
+
18
+ export const useLoadImage = ({ imagePath, atom }: UseLoadImageProps): void => {
14
19
  const setImage = useSetAtom(atom);
15
20
 
16
21
  useLayoutEffect(() => {
@@ -9,14 +9,13 @@ import timezonePlugin from "dayjs/plugin/timezone";
9
9
  import utcPlugin from "dayjs/plugin/utc";
10
10
  import { Provider, useSetAtom } from "jotai";
11
11
 
12
- import { useLocaleDateTimeFormat } from ".";
12
+ import { type LocaleDateTimeFormat, useLocaleDateTimeFormat } from ".";
13
13
 
14
14
  dayjs.extend(timezonePlugin);
15
15
  dayjs.extend(utcPlugin);
16
16
  dayjs.extend(localizedFormatPlugin);
17
17
 
18
- // biome-ignore lint/suspicious/noImplicitAnyLet: need it
19
- let context;
18
+ let context: LocaleDateTimeFormat;
20
19
 
21
20
  const TestComponent = (): JSX.Element => {
22
21
  const localeDateTimeFormat = useLocaleDateTimeFormat();
@@ -9,14 +9,13 @@ import timezonePlugin from "dayjs/plugin/timezone";
9
9
  import utcPlugin from "dayjs/plugin/utc";
10
10
  import { Provider, useSetAtom } from "jotai";
11
11
 
12
- import { useLocaleDateTimeFormat } from ".";
12
+ import { type LocaleDateTimeFormat, useLocaleDateTimeFormat } from ".";
13
13
 
14
14
  dayjs.extend(timezonePlugin);
15
15
  dayjs.extend(utcPlugin);
16
16
  dayjs.extend(localizedFormatPlugin);
17
17
 
18
- // biome-ignore lint/suspicious/noImplicitAnyLet: need it
19
- let context;
18
+ let context: LocaleDateTimeFormat;
20
19
 
21
20
  const TestComponent = (): JSX.Element => {
22
21
  const localeDateTimeFormat = useLocaleDateTimeFormat();
@@ -1,4 +1,4 @@
1
- import { ReactElement } from 'react';
1
+ import { ReactElement, ReactNode } from 'react';
2
2
 
3
3
  import {
4
4
  render as rtlRender,
@@ -12,16 +12,20 @@ import { ThemeMode } from '@centreon/ui-context';
12
12
  import ThemeProvider from '../src/StoryBookThemeProvider';
13
13
 
14
14
  interface Props {
15
- children: ReactElement;
15
+ children: ReactNode;
16
16
  }
17
17
 
18
18
  const ThemeProviderWrapper = ({ children }: Props): JSX.Element => {
19
- return <ThemeProvider themeMode={ThemeMode.light}>{children}</ThemeProvider>;
19
+ return (
20
+ <ThemeProvider themeMode={ThemeMode.light}>
21
+ {children as ReactElement}
22
+ </ThemeProvider>
23
+ );
20
24
  };
21
25
 
22
26
  const render = (ui: ReactElement, options?: RenderOptions): RenderResult =>
23
27
  rtlRender(ui, {
24
- wrapper: ThemeProviderWrapper as (props) => ReactElement | null,
28
+ wrapper: ThemeProviderWrapper,
25
29
  ...options
26
30
  });
27
31
 
@@ -49,7 +53,7 @@ export const resetMocks = (): void => {
49
53
  };
50
54
 
51
55
  export const getFetchCall = (
52
- index,
56
+ index: number,
53
57
  secondIndex = 0
54
58
  ): string | Request | undefined | RequestInit => {
55
59
  return fetchMock.mock.calls[index][secondIndex];