@centreon/ui 24.4.72 → 24.4.74

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 (131) hide show
  1. package/package.json +24 -23
  2. package/src/Checkbox/fonts/roboto-bold-webfont.ttf +0 -0
  3. package/src/Checkbox/fonts/roboto-bold-webfont.woff +0 -0
  4. package/src/Checkbox/fonts/roboto-bold-webfont.woff2 +0 -0
  5. package/src/Checkbox/fonts/roboto-light-webfont.ttf +0 -0
  6. package/src/Checkbox/fonts/roboto-light-webfont.woff +0 -0
  7. package/src/Checkbox/fonts/roboto-light-webfont.woff2 +0 -0
  8. package/src/Checkbox/fonts/roboto-medium-webfont.ttf +0 -0
  9. package/src/Checkbox/fonts/roboto-medium-webfont.woff +0 -0
  10. package/src/Checkbox/fonts/roboto-medium-webfont.woff2 +0 -0
  11. package/src/Checkbox/fonts/roboto-regular-webfont.ttf +0 -0
  12. package/src/Checkbox/fonts/roboto-regular-webfont.woff +0 -0
  13. package/src/Checkbox/fonts/roboto-regular-webfont.woff2 +0 -0
  14. package/src/Dashboard/Item.tsx +2 -11
  15. package/src/Dashboard/Layout.tsx +2 -4
  16. package/src/Dashboard/utils.ts +1 -1
  17. package/src/Form/Inputs/Grid.tsx +8 -4
  18. package/src/Form/Inputs/models.ts +15 -14
  19. package/src/Graph/BarStack/BarStack.cypress.spec.tsx +87 -9
  20. package/src/Graph/BarStack/BarStack.stories.tsx +4 -2
  21. package/src/Graph/BarStack/BarStack.styles.ts +59 -30
  22. package/src/Graph/BarStack/Graph.tsx +176 -0
  23. package/src/Graph/BarStack/GraphAndLegend.tsx +119 -0
  24. package/src/Graph/BarStack/ResponsiveBarStack.tsx +62 -157
  25. package/src/Graph/BarStack/constants.ts +5 -0
  26. package/src/Graph/BarStack/models.ts +1 -1
  27. package/src/Graph/BarStack/useGraphAndLegend.ts +86 -0
  28. package/src/Graph/BarStack/useResponsiveBarStack.ts +74 -99
  29. package/src/Graph/HeatMap/ResponsiveHeatMap.tsx +19 -2
  30. package/src/Graph/HeatMap/model.ts +5 -1
  31. package/src/Graph/Legend/Legend.styles.ts +10 -0
  32. package/src/Graph/Legend/Legend.tsx +6 -1
  33. package/src/Graph/LineChart/BasicComponents/Lines/RegularLines/index.tsx +2 -1
  34. package/src/Graph/LineChart/BasicComponents/Lines/StackedLines/index.tsx +3 -4
  35. package/src/Graph/LineChart/Icons/Downtime.tsx +3 -3
  36. package/src/Graph/LineChart/InteractiveComponents/ZoomPreview/index.tsx +2 -1
  37. package/src/Graph/LineChart/Legend/Legend.styles.ts +16 -5
  38. package/src/Graph/LineChart/Legend/LegendHeader.tsx +4 -1
  39. package/src/Graph/LineChart/Legend/index.tsx +12 -5
  40. package/src/Graph/LineChart/LineChart.cypress.spec.tsx +53 -0
  41. package/src/Graph/LineChart/LineChart.tsx +10 -9
  42. package/src/Graph/LineChart/index.stories.tsx +13 -0
  43. package/src/Graph/LineChart/mockedData/curvesWithSameColor.json +252 -0
  44. package/src/Graph/LineChart/useLineChartData.ts +68 -18
  45. package/src/Graph/PieChart/ResponsivePie.tsx +3 -1
  46. package/src/Graph/PieChart/models.ts +1 -0
  47. package/src/Graph/Tree/DescendantNodes.tsx +0 -1
  48. package/src/Graph/Tree/Links.tsx +2 -15
  49. package/src/Graph/Tree/Tree.cypress.spec.tsx +0 -24
  50. package/src/Graph/Tree/Tree.stories.tsx +1 -17
  51. package/src/Graph/Tree/models.ts +0 -3
  52. package/src/Graph/common/utils.ts +51 -2
  53. package/src/Icon/BaseIcon.tsx +32 -0
  54. package/src/Icon/DowntimeIcon.tsx +14 -0
  55. package/src/InputField/Select/Autocomplete/Connected/Multi/index.test.tsx +21 -1
  56. package/src/InputField/Select/Autocomplete/Connected/index.test.tsx +2 -2
  57. package/src/InputField/Select/Autocomplete/Connected/index.tsx +10 -7
  58. package/src/InputField/Select/Autocomplete/Multi/index.stories.tsx +19 -0
  59. package/src/InputField/Select/Autocomplete/Multi/index.tsx +8 -5
  60. package/src/InputField/Text/index.tsx +7 -5
  61. package/src/Listing/ActionBar/index.tsx +1 -0
  62. package/src/PopoverMenu/index.tsx +4 -4
  63. package/src/RichTextEditor/ContentEditable.tsx +195 -195
  64. package/src/StoryBookThemeProvider/index.tsx +35 -36
  65. package/src/ThemeProvider/index.tsx +12 -12
  66. package/src/ThemeProvider/palettes.ts +11 -8
  67. package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/PickersStartEndDate.tsx +2 -3
  68. package/src/TimePeriods/DateTimePickerInput.tsx +4 -1
  69. package/src/TopCounterElements/TopCounterLayout.tsx +4 -3
  70. package/src/TopCounterElements/useCloseOnLegacyPage.tsx +9 -6
  71. package/src/api/buildListingEndpoint/getSearchQueryParameterValue.ts +7 -1
  72. package/src/api/buildListingEndpoint/models.ts +1 -0
  73. package/src/api/useGraphQuery/index.ts +1 -7
  74. package/src/components/Form/AccessRights/AccessRights.cypress.spec.tsx +13 -27
  75. package/src/components/Form/AccessRights/AccessRights.stories.tsx +19 -0
  76. package/src/components/Form/AccessRights/AccessRights.styles.ts +1 -1
  77. package/src/components/Form/AccessRights/AccessRights.tsx +5 -6
  78. package/src/components/Form/AccessRights/Actions/Actions.styles.ts +7 -3
  79. package/src/components/Form/AccessRights/Actions/Actions.tsx +32 -15
  80. package/src/components/Form/AccessRights/Actions/useActions.ts +37 -4
  81. package/src/components/Form/AccessRights/models.ts +3 -0
  82. package/src/components/Form/AccessRights/storiesData.ts +3 -0
  83. package/src/components/List/Item/ListItem.styles.ts +2 -2
  84. package/src/components/Zoom/Minimap.tsx +2 -4
  85. package/src/components/Zoom/Zoom.cypress.spec.tsx +13 -13
  86. package/src/components/Zoom/Zoom.tsx +1 -4
  87. package/src/components/Zoom/ZoomContent.tsx +2 -5
  88. package/src/components/index.ts +0 -1
  89. package/src/fonts/roboto-bold-webfont.ttf +0 -0
  90. package/src/fonts/roboto-bold-webfont.woff +0 -0
  91. package/src/fonts/roboto-bold-webfont.woff2 +0 -0
  92. package/src/fonts/roboto-light-webfont.ttf +0 -0
  93. package/src/fonts/roboto-light-webfont.woff +0 -0
  94. package/src/fonts/roboto-light-webfont.woff2 +0 -0
  95. package/src/fonts/roboto-medium-webfont.ttf +0 -0
  96. package/src/fonts/roboto-medium-webfont.woff +0 -0
  97. package/src/fonts/roboto-medium-webfont.woff2 +0 -0
  98. package/src/fonts/roboto-regular-webfont.ttf +0 -0
  99. package/src/fonts/roboto-regular-webfont.woff +0 -0
  100. package/src/fonts/roboto-regular-webfont.woff2 +0 -0
  101. package/src/index.ts +1 -0
  102. package/src/utils/index.ts +25 -25
  103. package/src/utils/useFullscreen/Fullscreen.cypress.spec.tsx +3 -0
  104. package/src/utils/useInfiniteScrollListing.ts +6 -1
  105. package/src/utils/useLocale/index.ts +10 -0
  106. package/src/utils/useLocale/useLocale.cypress.spec.tsx +40 -0
  107. package/src/utils/useLocaleDateTimeFormat/index.ts +5 -2
  108. package/src/utils/usePluralizedTranslation.ts +4 -21
  109. package/src/@assets/icons/downtime.icon.svg +0 -1
  110. package/src/components/Form/AccessRights/useAccessRightsChange.ts +0 -30
  111. package/src/components/Form/AccessRights/utils.ts +0 -18
  112. package/src/components/Tabs/Tab.styles.ts +0 -25
  113. package/src/components/Tabs/TabPanel.tsx +0 -22
  114. package/src/components/Tabs/Tabs.cypress.spec.tsx +0 -70
  115. package/src/components/Tabs/Tabs.stories.tsx +0 -55
  116. package/src/components/Tabs/Tabs.tsx +0 -55
  117. package/src/components/Tabs/index.ts +0 -6
  118. package/src/utils/resourcesStatusURL.ts +0 -166
  119. package/src/utils/usePluralizedTranslation.test.ts +0 -159
  120. /package/{public → src/Button}/fonts/roboto-bold-webfont.ttf +0 -0
  121. /package/{public → src/Button}/fonts/roboto-bold-webfont.woff +0 -0
  122. /package/{public → src/Button}/fonts/roboto-bold-webfont.woff2 +0 -0
  123. /package/{public → src/Button}/fonts/roboto-light-webfont.ttf +0 -0
  124. /package/{public → src/Button}/fonts/roboto-light-webfont.woff +0 -0
  125. /package/{public → src/Button}/fonts/roboto-light-webfont.woff2 +0 -0
  126. /package/{public → src/Button}/fonts/roboto-medium-webfont.ttf +0 -0
  127. /package/{public → src/Button}/fonts/roboto-medium-webfont.woff +0 -0
  128. /package/{public → src/Button}/fonts/roboto-medium-webfont.woff2 +0 -0
  129. /package/{public → src/Button}/fonts/roboto-regular-webfont.ttf +0 -0
  130. /package/{public → src/Button}/fonts/roboto-regular-webfont.woff +0 -0
  131. /package/{public → src/Button}/fonts/roboto-regular-webfont.woff2 +0 -0
@@ -1,55 +0,0 @@
1
- import { Meta, StoryObj } from '@storybook/react';
2
-
3
- import { Typography } from '@mui/material';
4
-
5
- import { TabPanel } from './TabPanel';
6
-
7
- import { Tabs } from '.';
8
-
9
- const meta: Meta<typeof Tabs> = {
10
- component: Tabs
11
- };
12
-
13
- export default meta;
14
- type Story = StoryObj<typeof Tabs>;
15
-
16
- const generateTabs = (size: number): Array<{ label: string; value: string }> =>
17
- Array(size)
18
- .fill(0)
19
- .map((_, index) => ({ label: `Tab ${index}`, value: `tab ${index}` }));
20
-
21
- export const Default: Story = {
22
- args: {
23
- defaultTab: 'tab 0',
24
- tabs: generateTabs(2)
25
- },
26
- render: (args) => (
27
- <Tabs {...args}>
28
- {generateTabs(2).map(({ value, label }) => (
29
- <TabPanel key={value} value={value}>
30
- <Typography>{label}</Typography>
31
- </TabPanel>
32
- ))}
33
- </Tabs>
34
- )
35
- };
36
-
37
- export const WithTabListProps: Story = {
38
- args: {
39
- defaultTab: 'tab 0',
40
- tabList: {
41
- textColor: 'inherit',
42
- variant: 'fullWidth'
43
- },
44
- tabs: generateTabs(2)
45
- },
46
- render: (args) => (
47
- <Tabs {...args}>
48
- {generateTabs(2).map(({ value, label }) => (
49
- <TabPanel key={value} value={value}>
50
- <Typography>{label}</Typography>
51
- </TabPanel>
52
- ))}
53
- </Tabs>
54
- )
55
- };
@@ -1,55 +0,0 @@
1
- import { useCallback, useState } from 'react';
2
-
3
- import { TabContext, TabList, TabListProps } from '@mui/lab';
4
- import { Tab } from '@mui/material';
5
-
6
- import { useTabsStyles } from './Tab.styles';
7
-
8
- type Props = {
9
- children: Array<JSX.Element>;
10
- defaultTab: string;
11
- tabList?: TabListProps;
12
- tabs: Array<{
13
- label: string;
14
- value: string;
15
- }>;
16
- };
17
-
18
- export const Tabs = ({
19
- children,
20
- defaultTab,
21
- tabs,
22
- tabList
23
- }: Props): JSX.Element => {
24
- const { classes } = useTabsStyles();
25
-
26
- const [selectedTab, setSelectedTab] = useState(defaultTab);
27
-
28
- const changeTab = useCallback((_, newValue: string): void => {
29
- setSelectedTab(newValue);
30
- }, []);
31
-
32
- return (
33
- <TabContext value={selectedTab}>
34
- <TabList
35
- classes={{
36
- indicator: classes.indicator,
37
- root: classes.tabs
38
- }}
39
- onChange={changeTab}
40
- {...tabList}
41
- >
42
- {tabs.map(({ value, label }) => (
43
- <Tab
44
- aria-label={label}
45
- className={classes.tab}
46
- key={value}
47
- label={label}
48
- value={value}
49
- />
50
- ))}
51
- </TabList>
52
- {children}
53
- </TabContext>
54
- );
55
- };
@@ -1,6 +0,0 @@
1
- import { TabPanel } from './TabPanel';
2
- import { Tabs as TabsRoot } from './Tabs';
3
-
4
- export const Tabs = Object.assign(TabsRoot, {
5
- TabPanel
6
- });
@@ -1,166 +0,0 @@
1
- import {
2
- always,
3
- cond,
4
- equals,
5
- flatten,
6
- groupBy,
7
- identity,
8
- includes,
9
- map,
10
- pipe,
11
- T
12
- } from 'ramda';
13
-
14
- import { SelectEntry } from '..';
15
-
16
- import { centreonBaseURL } from './centreonBaseURL';
17
-
18
- export interface Resource {
19
- resourceType: string;
20
- resources: Array<SelectEntry>;
21
- }
22
-
23
- interface GetResourcesUrlProps {
24
- allResources: Array<Resource>;
25
- isForOneResource: boolean;
26
- resource?;
27
- states: Array<string>;
28
- statuses: Array<string>;
29
- type: string;
30
- }
31
-
32
- export const getDetailsPanelQueriers = ({ resource, type }): object => {
33
- const { id, parentId, uuid } = resource;
34
-
35
- const resourcesDetailsEndpoint = cond([
36
- [
37
- equals('host'),
38
- always(`${centreonBaseURL}/api/latest/monitoring/resources/hosts/${id}`)
39
- ],
40
- [
41
- equals('service'),
42
- always(
43
- `${centreonBaseURL}/api/latest/monitoring/resources/hosts/${parentId}/services/${id}`
44
- )
45
- ],
46
- [
47
- equals('metaservice'),
48
- always(
49
- `${centreonBaseURL}/api/latest/monitoring/resources/metaservices/${id}`
50
- )
51
- ],
52
- [
53
- equals('anomaly-detection'),
54
- always(
55
- `${centreonBaseURL}/api/latest/monitoring/resources/anomaly-detection/${id}`
56
- )
57
- ]
58
- ])(type);
59
-
60
- const queryParameters = {
61
- id,
62
- resourcesDetailsEndpoint,
63
- selectedTimePeriodId: 'last_24_h',
64
- tab: 'details',
65
- tabParameters: {},
66
- uuid
67
- };
68
-
69
- return queryParameters;
70
- };
71
-
72
- export const getResourcesUrl = ({
73
- type,
74
- statuses,
75
- states,
76
- allResources,
77
- isForOneResource,
78
- resource
79
- }: GetResourcesUrlProps): string => {
80
- const resourcesCriterias = equals(type, 'all')
81
- ? {
82
- name: 'resource_types',
83
- value: [
84
- { id: 'service', name: 'Service' },
85
- { id: 'host', name: 'Host' }
86
- ]
87
- }
88
- : {
89
- name: 'resource_types',
90
- value: [
91
- { id: type, name: `${type.charAt(0).toUpperCase()}${type.slice(1)}` }
92
- ]
93
- };
94
-
95
- const formattedStatuses = pipe(
96
- flatten,
97
- map((status: string) => {
98
- return {
99
- id: status.toLocaleUpperCase(),
100
- name: `${status.charAt(0).toUpperCase()}${status.slice(1)}`
101
- };
102
- })
103
- )(statuses);
104
-
105
- const formattedStates = states.map((state) => {
106
- return {
107
- id: state,
108
- name: `${state.charAt(0).toUpperCase()}${state.slice(1)}`
109
- };
110
- });
111
-
112
- const groupedResources = groupBy(
113
- ({ resourceType }) => resourceType,
114
- allResources
115
- );
116
-
117
- const resourcesFilters = Object.entries(groupedResources).map(
118
- ([resourceType, res]) => {
119
- const name = cond<Array<string>, string>([
120
- [equals('host'), always('parent_name')],
121
- [equals('service'), always('name')],
122
- [T, identity]
123
- ])(resourceType);
124
-
125
- return {
126
- name: name.replace('-', '_'),
127
- value: flatten(
128
- (res || []).map(({ resources: subResources }) => {
129
- return subResources.map(({ name: resourceName }) => ({
130
- id: includes(name, ['name', 'parent_name'])
131
- ? `\\b${resourceName}\\b`
132
- : resourceName,
133
- name: resourceName
134
- }));
135
- })
136
- )
137
- };
138
- }
139
- );
140
-
141
- const filterQueryParameter = {
142
- criterias: [
143
- resourcesCriterias,
144
- { name: 'statuses', value: formattedStatuses },
145
- { name: 'states', value: formattedStates },
146
- ...resourcesFilters,
147
- { name: 'search', value: '' }
148
- ]
149
- };
150
-
151
- const encodedFilterParams = encodeURIComponent(
152
- JSON.stringify(filterQueryParameter)
153
- );
154
-
155
- if (!isForOneResource) {
156
- return `/monitoring/resources?filter=${encodedFilterParams}&fromTopCounter=true`;
157
- }
158
-
159
- const detailsPanelQueriers = getDetailsPanelQueriers({ resource, type });
160
-
161
- const encodedDetailsParams = encodeURIComponent(
162
- JSON.stringify(detailsPanelQueriers)
163
- );
164
-
165
- return `/monitoring/resources?details=${encodedDetailsParams}&filter=${encodedFilterParams}&fromTopCounter=true`;
166
- };
@@ -1,159 +0,0 @@
1
- import { act, renderHook } from '@testing-library/react';
2
- import { useAtom } from 'jotai';
3
-
4
- import { ListingVariant, userAtom } from '@centreon/ui-context';
5
-
6
- import { usePluralizedTranslation } from './usePluralizedTranslation';
7
-
8
- const baseUser = {
9
- alias: 'admin',
10
- isExportButtonEnabled: false,
11
- name: 'admin',
12
- timezone: 'Europe/Paris',
13
- use_deprecated_pages: false,
14
- user_interface_density: ListingVariant.compact
15
- };
16
-
17
- describe('usePluralizedTranslation', () => {
18
- describe('English', () => {
19
- it('returns the plural of a word when the corresponding count is set', () => {
20
- const { result } = renderHook(() => {
21
- return {
22
- pluralizedTranslation: usePluralizedTranslation(),
23
- userAtom: useAtom(userAtom)
24
- };
25
- });
26
-
27
- act(() => {
28
- result.current.userAtom[1]({
29
- ...baseUser,
30
- locale: 'en'
31
- });
32
- });
33
-
34
- expect(
35
- result.current.pluralizedTranslation.pluralizedT({
36
- count: 2,
37
- label: 'House'
38
- })
39
- ).toEqual('Houses');
40
- });
41
-
42
- it('returns the singular of a word when the corresponding count is set', () => {
43
- const { result } = renderHook(() => {
44
- return {
45
- pluralizedTranslation: usePluralizedTranslation(),
46
- userAtom: useAtom(userAtom)
47
- };
48
- });
49
-
50
- act(() => {
51
- result.current.userAtom[1]({
52
- ...baseUser,
53
- locale: 'en'
54
- });
55
- });
56
-
57
- expect(
58
- result.current.pluralizedTranslation.pluralizedT({
59
- count: 1,
60
- label: 'House'
61
- })
62
- ).toEqual('House');
63
- });
64
-
65
- it('returns the plural of a word when the corresponding count is 0 and the language is english', () => {
66
- const { result } = renderHook(() => {
67
- return {
68
- pluralizedTranslation: usePluralizedTranslation(),
69
- userAtom: useAtom(userAtom)
70
- };
71
- });
72
-
73
- act(() => {
74
- result.current.userAtom[1]({
75
- ...baseUser,
76
- locale: 'en'
77
- });
78
- });
79
-
80
- expect(
81
- result.current.pluralizedTranslation.pluralizedT({
82
- count: 0,
83
- label: 'House'
84
- })
85
- ).toEqual('Houses');
86
- });
87
- });
88
-
89
- describe('French', () => {
90
- it('returns the plural of a word when the corresponding count is set', () => {
91
- const { result } = renderHook(() => {
92
- return {
93
- pluralizedTranslation: usePluralizedTranslation(),
94
- userAtom: useAtom(userAtom)
95
- };
96
- });
97
-
98
- act(() => {
99
- result.current.userAtom[1]({
100
- ...baseUser,
101
- locale: 'fr'
102
- });
103
- });
104
-
105
- expect(
106
- result.current.pluralizedTranslation.pluralizedT({
107
- count: 2,
108
- label: 'Maison'
109
- })
110
- ).toEqual('Maisons');
111
- });
112
-
113
- it('returns the singular of a word when the corresponding count is set', () => {
114
- const { result } = renderHook(() => {
115
- return {
116
- pluralizedTranslation: usePluralizedTranslation(),
117
- userAtom: useAtom(userAtom)
118
- };
119
- });
120
-
121
- act(() => {
122
- result.current.userAtom[1]({
123
- ...baseUser,
124
- locale: 'fr'
125
- });
126
- });
127
-
128
- expect(
129
- result.current.pluralizedTranslation.pluralizedT({
130
- count: 1,
131
- label: 'Maison'
132
- })
133
- ).toEqual('Maison');
134
- });
135
-
136
- it('returns the singular of a word when the corresponding count is 0 and the language is english', () => {
137
- const { result } = renderHook(() => {
138
- return {
139
- pluralizedTranslation: usePluralizedTranslation(),
140
- userAtom: useAtom(userAtom)
141
- };
142
- });
143
-
144
- act(() => {
145
- result.current.userAtom[1]({
146
- ...baseUser,
147
- locale: 'fr'
148
- });
149
- });
150
-
151
- expect(
152
- result.current.pluralizedTranslation.pluralizedT({
153
- count: 0,
154
- label: 'Maison'
155
- })
156
- ).toEqual('Maison');
157
- });
158
- });
159
- });