@centreon/ui 24.5.7 → 24.5.9
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.
- package/package.json +4 -8
- package/public/mockServiceWorker.js +100 -81
- package/src/ActionsList/index.stories.tsx +1 -7
- package/src/Dashboard/Dashboard.styles.ts +2 -3
- package/src/Dashboard/Item.tsx +5 -39
- package/src/Dashboard/Layout.tsx +2 -4
- package/src/Graph/BarStack/BarStack.stories.tsx +6 -8
- package/src/Graph/BarStack/ResponsiveBarStack.tsx +3 -3
- package/src/Graph/HeatMap/HeatMap.stories.tsx +0 -20
- package/src/Graph/LineChart/BasicComponents/Lines/RegularLines/index.tsx +7 -10
- package/src/Graph/LineChart/BasicComponents/Lines/StackedLines/index.tsx +4 -5
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/BasicThreshold.tsx +2 -1
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/ThresholdWithPatternLines.tsx +2 -1
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/ThresholdWithVariation.tsx +2 -1
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/index.tsx +2 -1
- package/src/Graph/LineChart/BasicComponents/Lines/index.tsx +2 -1
- package/src/Graph/LineChart/BasicComponents/Lines/models.ts +3 -0
- package/src/Graph/LineChart/LineChart.tsx +2 -1
- package/src/Graph/LineChart/common/index.ts +1 -15
- package/src/Graph/LineChart/index.stories.tsx +3 -2
- package/src/Graph/LineChart/index.tsx +4 -2
- package/src/Graph/PieChart/PieChart.stories.tsx +15 -11
- package/src/Graph/PieChart/ResponsivePie.tsx +1 -1
- package/src/Graph/Tree/DescendantNodes.tsx +0 -1
- package/src/Graph/Tree/Links.tsx +2 -15
- package/src/Graph/Tree/Tree.cypress.spec.tsx +0 -24
- package/src/Graph/Tree/Tree.stories.tsx +1 -17
- package/src/Graph/Tree/models.ts +0 -3
- package/src/Listing/Cell/index.tsx +23 -17
- package/src/TimePeriods/index.stories.tsx +12 -7
- package/src/TopCounterElements/TopCounterLayout.tsx +4 -3
- package/src/api/QueryProvider.tsx +1 -1
- package/src/api/useFetchQuery/index.test.ts +5 -0
- package/src/api/useFetchQuery/index.ts +7 -12
- package/src/api/useGraphQuery/index.ts +2 -9
- package/src/api/useMutationQuery/index.ts +5 -2
- package/src/api/useRequest/index.test.ts +3 -0
- package/src/api/useRequest/index.ts +6 -3
- package/src/components/Form/AccessRights/AccessRights.cypress.spec.tsx +13 -27
- package/src/components/Form/AccessRights/AccessRights.stories.tsx +19 -0
- package/src/components/Form/AccessRights/AccessRights.styles.ts +1 -1
- package/src/components/Form/AccessRights/AccessRights.tsx +5 -6
- package/src/components/Form/AccessRights/Actions/Actions.styles.ts +7 -3
- package/src/components/Form/AccessRights/Actions/Actions.tsx +32 -15
- package/src/components/Form/AccessRights/Actions/useActions.ts +37 -4
- package/src/components/Form/AccessRights/ShareInput/ShareInput.tsx +0 -1
- package/src/components/Form/AccessRights/models.ts +3 -0
- package/src/components/Form/AccessRights/storiesData.ts +3 -0
- package/src/components/Form/Dashboard/DashboardForm.stories.ts +39 -0
- package/src/components/Form/Dashboard/translatedLabels.ts +1 -0
- package/src/components/List/Item/ListItem.styles.ts +2 -2
- package/src/components/Modal/Modal.styles.ts +5 -5
- package/src/components/Zoom/Minimap.tsx +2 -4
- package/src/components/Zoom/Zoom.cypress.spec.tsx +13 -13
- package/src/components/Zoom/Zoom.tsx +1 -4
- package/src/components/Zoom/ZoomContent.tsx +2 -5
- package/src/components/index.ts +0 -1
- package/src/index.ts +1 -1
- package/src/utils/index.ts +0 -1
- package/src/utils/usePluralizedTranslation.ts +3 -20
- package/src/Dashboard/Dashboard.cypress.spec.tsx +0 -68
- package/src/api/logger.ts +0 -11
- package/src/components/Form/AccessRights/useAccessRightsChange.ts +0 -30
- package/src/components/Form/AccessRights/utils.ts +0 -18
- package/src/components/Tabs/Tab.styles.ts +0 -25
- package/src/components/Tabs/TabPanel.tsx +0 -22
- package/src/components/Tabs/Tabs.cypress.spec.tsx +0 -70
- package/src/components/Tabs/Tabs.stories.tsx +0 -55
- package/src/components/Tabs/Tabs.tsx +0 -55
- package/src/components/Tabs/index.ts +0 -6
- package/src/utils/resourcesStatusURL.ts +0 -166
- package/src/utils/usePluralizedTranslation.test.ts +0 -159
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
VariationThreshold
|
|
8
8
|
} from '../../../models';
|
|
9
9
|
import { TimeValue } from '../../../../common/timeSeries/models';
|
|
10
|
+
import { CurveType } from '../models';
|
|
10
11
|
|
|
11
12
|
import BasicThreshold from './BasicThreshold';
|
|
12
13
|
import Circle from './Circle';
|
|
@@ -16,7 +17,7 @@ import { WrapperThresholdLinesModel } from './models';
|
|
|
16
17
|
import useScaleThreshold from './useScaleThreshold';
|
|
17
18
|
|
|
18
19
|
interface Props extends WrapperThresholdLinesModel {
|
|
19
|
-
curve:
|
|
20
|
+
curve: CurveType;
|
|
20
21
|
graphHeight: number;
|
|
21
22
|
timeSeries: Array<TimeValue>;
|
|
22
23
|
}
|
|
@@ -23,9 +23,10 @@ import {
|
|
|
23
23
|
canDisplayThreshold,
|
|
24
24
|
requiredNumberLinesThreshold
|
|
25
25
|
} from './Threshold/models';
|
|
26
|
+
import { CurveType } from './models';
|
|
26
27
|
|
|
27
28
|
interface Props extends GlobalAreaLines {
|
|
28
|
-
curve:
|
|
29
|
+
curve: CurveType;
|
|
29
30
|
displayAnchor?: DisplayAnchor;
|
|
30
31
|
displayedLines: Array<Line>;
|
|
31
32
|
graphSvgRef: MutableRefObject<SVGSVGElement | null>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ScaleLinear } from 'd3-scale';
|
|
2
|
+
import { curveBasis } from '@visx/curve';
|
|
2
3
|
|
|
3
4
|
import { Line, TimeValue } from '../../../common/timeSeries/models';
|
|
4
5
|
import { LineChartData } from '../../../common/models';
|
|
@@ -40,3 +41,5 @@ export interface Shape {
|
|
|
40
41
|
areaStackedLines: AreaStackedLines;
|
|
41
42
|
areaThreshold: AreaThreshold;
|
|
42
43
|
}
|
|
44
|
+
|
|
45
|
+
export type CurveType = typeof curveBasis;
|
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
LegendModel
|
|
31
31
|
} from './models';
|
|
32
32
|
import { useIntersection } from './useLineChartIntersection';
|
|
33
|
+
import { CurveType } from './BasicComponents/Lines/models';
|
|
33
34
|
import Thresholds from './BasicComponents/Thresholds';
|
|
34
35
|
import { legendWidth } from './Legend/Legend.styles';
|
|
35
36
|
import GraphValueTooltip from './InteractiveComponents/GraphValueTooltip/GraphValueTooltip';
|
|
@@ -37,7 +38,7 @@ import GraphValueTooltip from './InteractiveComponents/GraphValueTooltip/GraphVa
|
|
|
37
38
|
const extraMargin = 10;
|
|
38
39
|
|
|
39
40
|
interface Props extends LineChartProps {
|
|
40
|
-
curve:
|
|
41
|
+
curve: CurveType;
|
|
41
42
|
graphData: Data;
|
|
42
43
|
graphInterval: GraphInterval;
|
|
43
44
|
graphRef: MutableRefObject<HTMLDivElement | null>;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import * as Curve from '@visx/curve';
|
|
2
|
-
import { always, cond, equals } from 'ramda';
|
|
3
|
-
|
|
4
1
|
import { alpha } from '@mui/material';
|
|
5
2
|
|
|
6
3
|
const commonTickLabelProps = {
|
|
@@ -27,16 +24,6 @@ const timeFormat = 'LT';
|
|
|
27
24
|
const dateTimeFormat = `${dateFormat} ${timeFormat}`;
|
|
28
25
|
const maxLinesDisplayedLegend = 11;
|
|
29
26
|
|
|
30
|
-
const getCurveFactory = (
|
|
31
|
-
curve: 'linear' | 'step' | 'natural'
|
|
32
|
-
): typeof Curve.curveLinear => {
|
|
33
|
-
return cond([
|
|
34
|
-
[equals('linear'), always(Curve.curveLinear)],
|
|
35
|
-
[equals('step'), always(Curve.curveStep)],
|
|
36
|
-
[equals('natural'), always(Curve.curveCatmullRom)]
|
|
37
|
-
])(curve);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
27
|
export {
|
|
41
28
|
commonTickLabelProps,
|
|
42
29
|
margin,
|
|
@@ -44,6 +31,5 @@ export {
|
|
|
44
31
|
dateFormat,
|
|
45
32
|
timeFormat,
|
|
46
33
|
dateTimeFormat,
|
|
47
|
-
maxLinesDisplayedLegend
|
|
48
|
-
getCurveFactory
|
|
34
|
+
maxLinesDisplayedLegend
|
|
49
35
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
import { Meta, StoryObj } from '@storybook/react';
|
|
4
|
+
import { Curve } from '@visx/visx';
|
|
4
5
|
|
|
5
6
|
import { Button } from '@mui/material';
|
|
6
7
|
import ButtonGroup from '@mui/material/ButtonGroup';
|
|
@@ -341,7 +342,7 @@ export const LineChartWithStepCurve: Story = {
|
|
|
341
342
|
argTypes,
|
|
342
343
|
args: {
|
|
343
344
|
...argumentsData,
|
|
344
|
-
curve:
|
|
345
|
+
curve: Curve.curveStep
|
|
345
346
|
}
|
|
346
347
|
};
|
|
347
348
|
|
|
@@ -353,7 +354,7 @@ export const LineChartWithTimePeriod: Story = {
|
|
|
353
354
|
start: defaultStart
|
|
354
355
|
},
|
|
355
356
|
parameters: {
|
|
356
|
-
chromatic: {
|
|
357
|
+
chromatic: { diffThreshold: 0.1 }
|
|
357
358
|
}
|
|
358
359
|
};
|
|
359
360
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { MutableRefObject, useRef } from 'react';
|
|
2
2
|
|
|
3
|
+
import { Curve } from '@visx/visx';
|
|
3
4
|
import dayjs from 'dayjs';
|
|
4
5
|
import 'dayjs/locale/en';
|
|
5
6
|
import 'dayjs/locale/es';
|
|
@@ -16,13 +17,14 @@ import LineChart from './LineChart';
|
|
|
16
17
|
import LoadingSkeleton from './LoadingSkeleton';
|
|
17
18
|
import { GlobalAreaLines, LineChartProps, LegendModel } from './models';
|
|
18
19
|
import useLineChartData from './useLineChartData';
|
|
20
|
+
import { CurveType } from './BasicComponents/Lines/models';
|
|
19
21
|
|
|
20
22
|
dayjs.extend(localizedFormat);
|
|
21
23
|
dayjs.extend(utcPlugin);
|
|
22
24
|
dayjs.extend(timezonePlugin);
|
|
23
25
|
|
|
24
26
|
interface Props extends Partial<LineChartProps> {
|
|
25
|
-
curve?:
|
|
27
|
+
curve?: CurveType;
|
|
26
28
|
data?: LineChartData;
|
|
27
29
|
end: string;
|
|
28
30
|
legend: LegendModel;
|
|
@@ -50,7 +52,7 @@ const WrapperLineChart = ({
|
|
|
50
52
|
annotationEvent,
|
|
51
53
|
legend,
|
|
52
54
|
header,
|
|
53
|
-
curve =
|
|
55
|
+
curve = Curve.curveLinear,
|
|
54
56
|
thresholds,
|
|
55
57
|
thresholdUnit,
|
|
56
58
|
limitLegend
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Meta, StoryObj } from '@storybook/react';
|
|
2
2
|
|
|
3
3
|
import { ArcType } from './models';
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
import { PieChart } from '.';
|
|
5
6
|
|
|
6
7
|
const data = [
|
|
7
8
|
{ color: '#88B922', label: 'Ok', value: 148 },
|
|
@@ -17,20 +18,19 @@ const dataWithBigNumbers = [
|
|
|
17
18
|
{ color: '#FF6666', label: 'Down', value: 122222 }
|
|
18
19
|
];
|
|
19
20
|
|
|
20
|
-
const meta: Meta<typeof
|
|
21
|
-
component:
|
|
22
|
-
parameters: {
|
|
23
|
-
chromatic: {
|
|
24
|
-
delay: 1000
|
|
25
|
-
}
|
|
26
|
-
}
|
|
21
|
+
const meta: Meta<typeof PieChart> = {
|
|
22
|
+
component: PieChart
|
|
27
23
|
};
|
|
28
24
|
|
|
29
25
|
export default meta;
|
|
30
|
-
type Story = StoryObj<typeof
|
|
26
|
+
type Story = StoryObj<typeof PieChart>;
|
|
31
27
|
|
|
32
28
|
const Template = (args): JSX.Element => {
|
|
33
|
-
return
|
|
29
|
+
return (
|
|
30
|
+
<div style={{ height: '350px', width: '350px' }}>
|
|
31
|
+
<PieChart {...args} />
|
|
32
|
+
</div>
|
|
33
|
+
);
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
export const Pie: Story = {
|
|
@@ -141,7 +141,11 @@ export const DonutWithTooltip: Story = {
|
|
|
141
141
|
};
|
|
142
142
|
|
|
143
143
|
const TemplateForSmallDimensions = (args): JSX.Element => {
|
|
144
|
-
return
|
|
144
|
+
return (
|
|
145
|
+
<div style={{ height: '130px', width: '130px' }}>
|
|
146
|
+
<PieChart {...args} />
|
|
147
|
+
</div>
|
|
148
|
+
);
|
|
145
149
|
};
|
|
146
150
|
|
|
147
151
|
export const PieWithSmallDimensions: Story = {
|
package/src/Graph/Tree/Links.tsx
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
LinkHorizontal,
|
|
3
|
-
LinkHorizontalStep,
|
|
4
|
-
LinkHorizontalLine
|
|
5
|
-
} from '@visx/shape';
|
|
1
|
+
import { LinkHorizontal } from '@visx/shape';
|
|
6
2
|
import { HierarchyPointLink } from '@visx/hierarchy/lib/types';
|
|
7
|
-
import { always, cond, equals, T } from 'ramda';
|
|
8
3
|
|
|
9
4
|
import { useTheme } from '@mui/material';
|
|
10
5
|
|
|
@@ -14,12 +9,6 @@ interface Props<TData> extends Pick<TreeProps<TData>, 'treeLink'> {
|
|
|
14
9
|
links: Array<HierarchyPointLink<Node<TData>>>;
|
|
15
10
|
}
|
|
16
11
|
|
|
17
|
-
const getLinkComponent = cond([
|
|
18
|
-
[equals('line'), always(LinkHorizontalLine)],
|
|
19
|
-
[equals('step'), always(LinkHorizontalStep)],
|
|
20
|
-
[T, always(LinkHorizontal)]
|
|
21
|
-
]);
|
|
22
|
-
|
|
23
12
|
const Links = <TData extends BaseProp>({
|
|
24
13
|
links,
|
|
25
14
|
treeLink
|
|
@@ -35,12 +24,10 @@ const Links = <TData extends BaseProp>({
|
|
|
35
24
|
.descendants()
|
|
36
25
|
.map((ancestor) => ancestor.data.data.id);
|
|
37
26
|
|
|
38
|
-
const LinkComponent = getLinkComponent(treeLink?.type);
|
|
39
|
-
|
|
40
27
|
const key = `${link.source.data.data.id}-${link.source.data.data.name}-${ancestorIds}_${link.target.data.data.id}-${link.target.data.data.name}-${descendantIds}`;
|
|
41
28
|
|
|
42
29
|
return (
|
|
43
|
-
<
|
|
30
|
+
<LinkHorizontal
|
|
44
31
|
data={link}
|
|
45
32
|
data-testid={`${link.source.data.data.id}_to_${link.target.data.data.id}`}
|
|
46
33
|
fill="none"
|
|
@@ -168,28 +168,4 @@ describe('Complex data tree', () => {
|
|
|
168
168
|
|
|
169
169
|
cy.makeSnapshot();
|
|
170
170
|
});
|
|
171
|
-
|
|
172
|
-
it('displays the tree with step links when a prop is set', () => {
|
|
173
|
-
initializeStandaloneTree({
|
|
174
|
-
treeLink: {
|
|
175
|
-
type: 'step'
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
cy.contains('T').should('be.visible');
|
|
180
|
-
|
|
181
|
-
cy.makeSnapshot();
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
it('displays the tree with line links when a prop is set', () => {
|
|
185
|
-
initializeStandaloneTree({
|
|
186
|
-
treeLink: {
|
|
187
|
-
type: 'line'
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
cy.contains('T').should('be.visible');
|
|
192
|
-
|
|
193
|
-
cy.makeSnapshot();
|
|
194
|
-
});
|
|
195
171
|
});
|
|
@@ -82,21 +82,6 @@ export const WithDefaultExpandFilter: Story = {
|
|
|
82
82
|
render: StandaloneTreeTemplate
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
-
export const WithStepLink: Story = {
|
|
86
|
-
args: {
|
|
87
|
-
children: SimpleContent,
|
|
88
|
-
node: {
|
|
89
|
-
height: 90,
|
|
90
|
-
width: 90
|
|
91
|
-
},
|
|
92
|
-
tree: simpleData,
|
|
93
|
-
treeLink: {
|
|
94
|
-
type: 'step'
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
render: StandaloneTreeTemplate
|
|
98
|
-
};
|
|
99
|
-
|
|
100
85
|
export const WithCustomLinks: Story = {
|
|
101
86
|
args: {
|
|
102
87
|
children: SimpleContent,
|
|
@@ -110,8 +95,7 @@ export const WithCustomLinks: Story = {
|
|
|
110
95
|
getStrokeDasharray: ({ target }) =>
|
|
111
96
|
target.status === 'ok' ? '5,5' : '0',
|
|
112
97
|
getStrokeOpacity: ({ target }) => (target.status === 'ok' ? 0.8 : 1),
|
|
113
|
-
getStrokeWidth: ({ target }) => (target.status === 'ok' ? 1 : 2)
|
|
114
|
-
type: 'line'
|
|
98
|
+
getStrokeWidth: ({ target }) => (target.status === 'ok' ? 1 : 2)
|
|
115
99
|
}
|
|
116
100
|
},
|
|
117
101
|
render: StandaloneTreeTemplate
|
package/src/Graph/Tree/models.ts
CHANGED
|
@@ -14,8 +14,6 @@ export interface BaseProp {
|
|
|
14
14
|
name: string;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export type Link = 'curve' | 'line' | 'step';
|
|
18
|
-
|
|
19
17
|
export interface ChildrenProps<TData> {
|
|
20
18
|
ancestors: Array<Node<TData>>;
|
|
21
19
|
depth: number;
|
|
@@ -50,6 +48,5 @@ export interface TreeProps<TData> {
|
|
|
50
48
|
) => string | number | undefined;
|
|
51
49
|
getStrokeOpacity?: (props: LinkProps<TData>) => string | number | undefined;
|
|
52
50
|
getStrokeWidth?: (props: LinkProps<TData>) => string | number | undefined;
|
|
53
|
-
type?: Link;
|
|
54
51
|
};
|
|
55
52
|
}
|
|
@@ -95,6 +95,9 @@ const useStyles = makeStyles<StylesProps>()(
|
|
|
95
95
|
caretMore: {
|
|
96
96
|
transform: 'rotate3d(0,0,1,180deg)'
|
|
97
97
|
},
|
|
98
|
+
fakeCaret: {
|
|
99
|
+
marginLeft: theme.spacing(3)
|
|
100
|
+
},
|
|
98
101
|
root: {
|
|
99
102
|
alignItems: 'center',
|
|
100
103
|
backgroundColor: getBackgroundColor({
|
|
@@ -195,23 +198,26 @@ const Cell = ({
|
|
|
195
198
|
props
|
|
196
199
|
)}
|
|
197
200
|
>
|
|
198
|
-
{displaySubItemsCaret &&
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
201
|
+
{displaySubItemsCaret &&
|
|
202
|
+
(hasSubItems ? (
|
|
203
|
+
<IconButton
|
|
204
|
+
ariaLabel={`${isSubItemsExpanded ? labelCollapse : labelExpand} ${
|
|
205
|
+
props.row.id
|
|
206
|
+
}`}
|
|
207
|
+
size="small"
|
|
208
|
+
onClick={click}
|
|
209
|
+
>
|
|
210
|
+
<ExpandMoreIcon
|
|
211
|
+
className={cx(
|
|
212
|
+
classes.caret,
|
|
213
|
+
isSubItemsExpanded ? classes.caretMore : classes.caretLess
|
|
214
|
+
)}
|
|
215
|
+
fontSize="small"
|
|
216
|
+
/>
|
|
217
|
+
</IconButton>
|
|
218
|
+
) : (
|
|
219
|
+
<div className={classes.fakeCaret} />
|
|
220
|
+
))}
|
|
215
221
|
{children}
|
|
216
222
|
</TableCell>
|
|
217
223
|
);
|
|
@@ -10,9 +10,6 @@ import TimePeriod from '.';
|
|
|
10
10
|
|
|
11
11
|
const meta: Meta<typeof TimePeriod> = {
|
|
12
12
|
component: TimePeriod,
|
|
13
|
-
parameters: {
|
|
14
|
-
chromatic: { disableSnapshot: true }
|
|
15
|
-
},
|
|
16
13
|
tags: ['autodocs']
|
|
17
14
|
};
|
|
18
15
|
|
|
@@ -91,20 +88,27 @@ const args = {
|
|
|
91
88
|
]
|
|
92
89
|
};
|
|
93
90
|
|
|
91
|
+
const parameters = {
|
|
92
|
+
chromatic: { diffThreshold: 0.1 }
|
|
93
|
+
};
|
|
94
|
+
|
|
94
95
|
export const BasicTimePeriod: Story = {
|
|
95
96
|
...Template,
|
|
96
|
-
argTypes
|
|
97
|
+
argTypes,
|
|
98
|
+
parameters
|
|
97
99
|
};
|
|
98
100
|
|
|
99
101
|
export const WithExtraTimePeriods: Story = {
|
|
100
102
|
...Template,
|
|
101
103
|
argTypes,
|
|
102
|
-
args
|
|
104
|
+
args,
|
|
105
|
+
parameters
|
|
103
106
|
};
|
|
104
107
|
|
|
105
108
|
export const WithExternalComponent: Story = {
|
|
106
109
|
...TemplateWithExternalComponent,
|
|
107
|
-
argTypes
|
|
110
|
+
argTypes,
|
|
111
|
+
parameters
|
|
108
112
|
};
|
|
109
113
|
|
|
110
114
|
export const SimpleTimePeriod: StorySimpleTimePeriod = {
|
|
@@ -112,5 +116,6 @@ export const SimpleTimePeriod: StorySimpleTimePeriod = {
|
|
|
112
116
|
args: {
|
|
113
117
|
endDate: dayjs(Date.now()).toDate(),
|
|
114
118
|
startDate: dayjs(Date.now()).subtract(29, 'day').toDate()
|
|
115
|
-
}
|
|
119
|
+
},
|
|
120
|
+
parameters
|
|
116
121
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
2
|
|
|
3
3
|
import { makeStyles } from 'tss-react/mui';
|
|
4
4
|
|
|
5
|
-
import ExpandLessIcon from '@mui/icons-material/ExpandLess';
|
|
6
5
|
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
|
7
|
-
import
|
|
6
|
+
import ExpandLessIcon from '@mui/icons-material/ExpandLess';
|
|
8
7
|
import { Badge, ClickAwayListener } from '@mui/material';
|
|
8
|
+
import type { SvgIcon } from '@mui/material';
|
|
9
9
|
|
|
10
10
|
import useCloseOnLegacyPage from './useCloseOnLegacyPage';
|
|
11
11
|
|
|
@@ -115,6 +115,7 @@ const TopCounterLayout = ({
|
|
|
115
115
|
}: TopCounterLayoutProps): JSX.Element => {
|
|
116
116
|
const { classes, cx } = useStyles();
|
|
117
117
|
const [toggled, setToggled] = useState(false);
|
|
118
|
+
|
|
118
119
|
const subMenuId = title.replace(/[^A-Za-z]/, '-');
|
|
119
120
|
useCloseOnLegacyPage({ setToggled });
|
|
120
121
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { renderHook, waitFor, RenderHookResult } from '@testing-library/react';
|
|
2
2
|
import fetchMock from 'jest-fetch-mock';
|
|
3
|
+
import anyLogger from 'anylogger';
|
|
3
4
|
|
|
4
5
|
import TestQueryProvider from '../TestQueryProvider';
|
|
5
6
|
|
|
@@ -76,6 +77,8 @@ describe('useFetchQuery', () => {
|
|
|
76
77
|
expect(mockedShowErrorMessage).toHaveBeenCalledWith('custom message');
|
|
77
78
|
});
|
|
78
79
|
|
|
80
|
+
expect(anyLogger().error).toHaveBeenCalledWith('custom message');
|
|
81
|
+
|
|
79
82
|
await waitFor(() => {
|
|
80
83
|
expect(result.current.error).toStrictEqual({
|
|
81
84
|
additionalInformation: {
|
|
@@ -99,6 +102,8 @@ describe('useFetchQuery', () => {
|
|
|
99
102
|
await waitFor(() => {
|
|
100
103
|
expect(mockedShowErrorMessage).toHaveBeenCalledWith('error');
|
|
101
104
|
});
|
|
105
|
+
|
|
106
|
+
expect(anyLogger().error).toHaveBeenCalledWith('error');
|
|
102
107
|
});
|
|
103
108
|
|
|
104
109
|
it('shows a default failure message via the Snackbar as fallback', async () => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useEffect, useMemo, useRef } from 'react';
|
|
2
2
|
|
|
3
|
+
import 'ulog';
|
|
3
4
|
import {
|
|
4
5
|
QueryKey,
|
|
5
6
|
QueryObserverBaseResult,
|
|
@@ -8,12 +9,12 @@ import {
|
|
|
8
9
|
UseQueryOptions
|
|
9
10
|
} from '@tanstack/react-query';
|
|
10
11
|
import { JsonDecoder } from 'ts.data.json';
|
|
11
|
-
import
|
|
12
|
+
import anylogger from 'anylogger';
|
|
13
|
+
import { has, includes, isNil, not, omit } from 'ramda';
|
|
12
14
|
|
|
13
15
|
import { CatchErrorProps, customFetch, ResponseError } from '../customFetch';
|
|
14
16
|
import useSnackbar from '../../Snackbar/useSnackbar';
|
|
15
17
|
import { useDeepCompare } from '../../utils';
|
|
16
|
-
import { errorLog } from '../logger';
|
|
17
18
|
|
|
18
19
|
export interface UseFetchQueryProps<T> {
|
|
19
20
|
baseEndpoint?: string;
|
|
@@ -32,7 +33,6 @@ export interface UseFetchQueryProps<T> {
|
|
|
32
33
|
UseQueryOptions<T | ResponseError, Error, T | ResponseError, QueryKey>,
|
|
33
34
|
'queryKey' | 'queryFn'
|
|
34
35
|
>;
|
|
35
|
-
useLongCache?: boolean;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
export type UseFetchQueryState<T> = {
|
|
@@ -48,6 +48,8 @@ export interface PrefetchEndpointParams {
|
|
|
48
48
|
page: number;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
const log = anylogger('API Request');
|
|
52
|
+
|
|
51
53
|
const useFetchQuery = <T extends object>({
|
|
52
54
|
getEndpoint,
|
|
53
55
|
getQueryKey,
|
|
@@ -59,18 +61,12 @@ const useFetchQuery = <T extends object>({
|
|
|
59
61
|
queryOptions,
|
|
60
62
|
httpCodesBypassErrorSnackbar = [],
|
|
61
63
|
baseEndpoint,
|
|
62
|
-
doNotCancelCallsOnUnmount = false
|
|
63
|
-
useLongCache
|
|
64
|
+
doNotCancelCallsOnUnmount = false
|
|
64
65
|
}: UseFetchQueryProps<T>): UseFetchQueryState<T> => {
|
|
65
66
|
const dataRef = useRef<T | undefined>(undefined);
|
|
66
67
|
|
|
67
68
|
const { showErrorMessage } = useSnackbar();
|
|
68
69
|
|
|
69
|
-
const isCypressTest = equals(window.Cypress?.testingType, 'component');
|
|
70
|
-
|
|
71
|
-
const cacheOptions =
|
|
72
|
-
!isCypressTest && useLongCache ? { gcTime: 60 * 1000 } : {};
|
|
73
|
-
|
|
74
70
|
const queryData = useQuery<T | ResponseError, Error>({
|
|
75
71
|
queryFn: ({ signal }): Promise<T | ResponseError> =>
|
|
76
72
|
customFetch<T>({
|
|
@@ -83,7 +79,6 @@ const useFetchQuery = <T extends object>({
|
|
|
83
79
|
signal
|
|
84
80
|
}),
|
|
85
81
|
queryKey: getQueryKey(),
|
|
86
|
-
...cacheOptions,
|
|
87
82
|
...queryOptions
|
|
88
83
|
});
|
|
89
84
|
|
|
@@ -92,7 +87,7 @@ const useFetchQuery = <T extends object>({
|
|
|
92
87
|
const manageError = (): void => {
|
|
93
88
|
const data = queryData.data as ResponseError | undefined;
|
|
94
89
|
if (data?.isError) {
|
|
95
|
-
|
|
90
|
+
log.error(data.message);
|
|
96
91
|
const hasACorrespondingHttpCode = includes(
|
|
97
92
|
data?.statusCode || 0,
|
|
98
93
|
httpCodesBypassErrorSnackbar
|
|
@@ -24,7 +24,6 @@ interface CustomTimePeriod {
|
|
|
24
24
|
interface UseMetricsQueryProps {
|
|
25
25
|
baseEndpoint: string;
|
|
26
26
|
bypassMetricsExclusion?: boolean;
|
|
27
|
-
bypassQueryParams?: boolean;
|
|
28
27
|
includeAllResources?: boolean;
|
|
29
28
|
metrics: Array<Metric>;
|
|
30
29
|
refreshCount?: number;
|
|
@@ -91,8 +90,7 @@ const useGraphQuery = ({
|
|
|
91
90
|
timePeriodType: 1
|
|
92
91
|
},
|
|
93
92
|
refreshInterval = false,
|
|
94
|
-
refreshCount
|
|
95
|
-
bypassQueryParams = false
|
|
93
|
+
refreshCount
|
|
96
94
|
}: UseMetricsQueryProps): UseMetricsQueryState => {
|
|
97
95
|
const timePeriodToUse = equals(timePeriod?.timePeriodType, -1)
|
|
98
96
|
? {
|
|
@@ -116,10 +114,6 @@ const useGraphQuery = ({
|
|
|
116
114
|
isLoading
|
|
117
115
|
} = useFetchQuery<PerformanceGraphData>({
|
|
118
116
|
getEndpoint: () => {
|
|
119
|
-
if (bypassQueryParams) {
|
|
120
|
-
return baseEndpoint;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
117
|
const endpoint = buildListingEndpoint({
|
|
124
118
|
baseEndpoint,
|
|
125
119
|
parameters: {
|
|
@@ -149,8 +143,7 @@ const useGraphQuery = ({
|
|
|
149
143
|
enabled: areResourcesFullfilled(resources) && !isEmpty(definedMetrics),
|
|
150
144
|
refetchInterval: refreshInterval,
|
|
151
145
|
suspense: false
|
|
152
|
-
}
|
|
153
|
-
useLongCache: true
|
|
146
|
+
}
|
|
154
147
|
});
|
|
155
148
|
|
|
156
149
|
const data = useRef<PerformanceGraphData | undefined>(undefined);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import 'ulog';
|
|
1
2
|
import { useEffect } from 'react';
|
|
2
3
|
|
|
3
4
|
import {
|
|
@@ -6,12 +7,12 @@ import {
|
|
|
6
7
|
UseMutationResult
|
|
7
8
|
} from '@tanstack/react-query';
|
|
8
9
|
import { JsonDecoder } from 'ts.data.json';
|
|
10
|
+
import anylogger from 'anylogger';
|
|
9
11
|
import { includes, omit } from 'ramda';
|
|
10
12
|
|
|
11
13
|
import { CatchErrorProps, customFetch, ResponseError } from '../customFetch';
|
|
12
14
|
import useSnackbar from '../../Snackbar/useSnackbar';
|
|
13
15
|
import { useDeepCompare } from '../../utils';
|
|
14
|
-
import { errorLog } from '../logger';
|
|
15
16
|
|
|
16
17
|
export enum Method {
|
|
17
18
|
DELETE = 'DELETE',
|
|
@@ -51,6 +52,8 @@ export type UseMutationQueryProps<T, TMeta> = {
|
|
|
51
52
|
'mutationFn' | 'onError' | 'onMutate' | 'onSuccess' | 'mutateAsync' | 'mutate'
|
|
52
53
|
>;
|
|
53
54
|
|
|
55
|
+
const log = anylogger('API Request');
|
|
56
|
+
|
|
54
57
|
export type UseMutationQueryState<T, TMeta> = Omit<
|
|
55
58
|
UseMutationResult<T | ResponseError>,
|
|
56
59
|
'isError' | 'mutate' | 'mutateAsync'
|
|
@@ -124,7 +127,7 @@ const useMutationQuery = <T extends object, TMeta>({
|
|
|
124
127
|
const manageError = (): void => {
|
|
125
128
|
const data = queryData.data as ResponseError | undefined;
|
|
126
129
|
if (data?.isError) {
|
|
127
|
-
|
|
130
|
+
log.error(data.message);
|
|
128
131
|
const hasACorrespondingHttpCode = includes(
|
|
129
132
|
data?.statusCode || 0,
|
|
130
133
|
httpCodesBypassErrorSnackbar
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
|
+
import anyLogger from 'anylogger';
|
|
2
3
|
import { RenderHookResult, renderHook, act } from '@testing-library/react';
|
|
3
4
|
|
|
4
5
|
import useRequest, { RequestResult, RequestParams } from '.';
|
|
@@ -76,6 +77,8 @@ describe(useRequest, () => {
|
|
|
76
77
|
});
|
|
77
78
|
});
|
|
78
79
|
|
|
80
|
+
expect(anyLogger().error).toHaveBeenCalledWith(response);
|
|
81
|
+
|
|
79
82
|
expect(mockedShowErrorMessage).toHaveBeenCalledWith('failure');
|
|
80
83
|
});
|
|
81
84
|
|