@centreon/ui 26.3.3 → 26.3.5

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@centreon/ui",
3
- "version": "26.3.3",
3
+ "version": "26.3.5",
4
4
  "description": "Centreon UI Components",
5
5
  "scripts": {
6
6
  "update:deps": "pnpx npm-check-updates -i --format group",
@@ -1,4 +1,4 @@
1
- import { memo, ReactElement } from 'react';
1
+ import { ReactElement, memo } from 'react';
2
2
 
3
3
  import { ScaleType, scaleBand } from '@visx/scale';
4
4
  import { BarRounded } from '@visx/shape';
@@ -123,10 +123,10 @@ const BarStack = ({
123
123
  const barY =
124
124
  isNegativeValue && isStacked && !shouldApplyRadiusOnBottom
125
125
  ? getPadding({
126
- isNegativeValue,
127
- padding: bar.y,
128
- size: bar.height
129
- })
126
+ isNegativeValue,
127
+ padding: bar.y,
128
+ size: bar.height
129
+ })
130
130
  : bar.y;
131
131
 
132
132
  return (
@@ -139,10 +139,10 @@ const BarStack = ({
139
139
  barWidth,
140
140
  y: isHorizontal
141
141
  ? getPadding({
142
- isNegativeValue,
143
- padding: bar.y,
144
- size: bar.height
145
- })
142
+ isNegativeValue,
143
+ padding: bar.y,
144
+ size: bar.height
145
+ })
146
146
  : barPadding,
147
147
  isFirstBar: shouldApplyRadiusOnBottom,
148
148
  isHorizontal,
@@ -157,19 +157,19 @@ const BarStack = ({
157
157
  isHorizontal
158
158
  ? barPadding
159
159
  : getPadding({
160
- isNegativeValue,
161
- padding: bar.x,
162
- size: bar.width
163
- })
160
+ isNegativeValue,
161
+ padding: bar.x,
162
+ size: bar.width
163
+ })
164
164
  }
165
165
  y={isHorizontal ? barY : barPadding}
166
166
  onMouseEnter={
167
167
  isTooltipHidden
168
168
  ? undefined
169
169
  : hoverBar({
170
- barIndex,
171
- highlightedMetric: Number(bar.key)
172
- })
170
+ barIndex,
171
+ highlightedMetric: Number(bar.key)
172
+ })
173
173
  }
174
174
  onMouseLeave={isTooltipHidden ? undefined : exitBar}
175
175
  />
@@ -59,17 +59,22 @@ const MemoizedGroup = ({
59
59
  const linesBar = isStackedBar
60
60
  ? stackedLinesTimeSeriesPerStackKeyAndUnit[bar.key].lines
61
61
  : (notStackedLines.find(({ metric_id }) =>
62
- equals(metric_id, Number(bar.key))
63
- ) as Line);
62
+ equals(metric_id, Number(bar.key))
63
+ ) as Line);
64
64
  const timeSeriesBar = isStackedBar
65
65
  ? stackedLinesTimeSeriesPerStackKeyAndUnit[bar.key].timeSeries
66
66
  : notStackedTimeSeries.map((timeSerie) => ({
67
- timeTick: timeSerie.timeTick,
68
- [bar.key]: timeSerie[Number(bar.key)]
69
- }));
67
+ timeTick: timeSerie.timeTick,
68
+ [bar.key]: timeSerie[Number(bar.key)]
69
+ }));
70
70
 
71
- const unit = isStackedBar ? bar.key.split('-')[1] : (linesBar as Line).unit;
72
- const yScale = unit === '' && yScalesPerUnit[unit] === undefined ? yScalesPerUnit[undefined] : yScalesPerUnit[unit];
71
+ const unit = isStackedBar
72
+ ? bar.key.split('-')[1]
73
+ : (linesBar as Line).unit;
74
+ const yScale =
75
+ unit === '' && yScalesPerUnit[unit] === undefined
76
+ ? yScalesPerUnit[undefined]
77
+ : yScalesPerUnit[unit];
73
78
 
74
79
  return isStackedBar ? (
75
80
  <BarStack
@@ -13,6 +13,7 @@ import {
13
13
  type
14
14
  } from 'ramda';
15
15
 
16
+ import { ReactElement } from 'react';
16
17
  import { getDates, getTime } from '../../../../common/timeSeries';
17
18
  import { Line, TimeValue } from '../../../../common/timeSeries/models';
18
19
  import {
@@ -27,7 +28,6 @@ import { StackValue } from '../../../InteractiveComponents/AnchorPoint/models';
27
28
  import { getCurveFactory, getFillColor } from '../../../common';
28
29
  import { LineStyle } from '../../../models';
29
30
  import Point from '../Point';
30
- import { ReactElement } from 'react';
31
31
 
32
32
  interface Props {
33
33
  areaTransparency?: number;
@@ -135,9 +135,9 @@ const StackLines = ({
135
135
  equals(style?.showArea, false)
136
136
  ? 'transparent'
137
137
  : getFillColor({
138
- areaColor: areaColor || lineColor,
139
- transparency: formattedTransparency
140
- })
138
+ areaColor: areaColor || lineColor,
139
+ transparency: formattedTransparency
140
+ })
141
141
  }
142
142
  opacity={highlight === false ? 0.3 : 1}
143
143
  stroke={lineColor}
@@ -103,13 +103,18 @@ const Lines = ({
103
103
  {Object.entries(stackedLinesData).map(
104
104
  ([stackedKey, { lines, timeSeries: stackedTimeSeries }]) => {
105
105
  const [, unit] = stackedKey.split('-');
106
+ const yScale =
107
+ unit === '' && yScalesPerUnit[unit] === undefined
108
+ ? yScalesPerUnit[undefined]
109
+ : yScalesPerUnit[unit];
110
+
106
111
  return (
107
112
  <StackedLines
108
113
  lineStyle={lineStyle}
109
114
  key={`stacked-${unit}`}
110
115
  lines={lines}
111
116
  timeSeries={stackedTimeSeries}
112
- yScale={yScalesPerUnit[unit ?? undefined]}
117
+ yScale={yScale}
113
118
  {...commonStackedLinesProps}
114
119
  />
115
120
  );
@@ -128,7 +133,10 @@ const Lines = ({
128
133
  invert: '1',
129
134
  scale,
130
135
  scaleLogarithmicBase,
131
- unit: unit ?? undefined,
136
+ unit:
137
+ unit === '' && yScalesPerUnit[unit] === undefined
138
+ ? undefined
139
+ : unit,
132
140
  yScalesPerUnit
133
141
  })}
134
142
  {...commonStackedLinesProps}
@@ -152,107 +160,107 @@ const Lines = ({
152
160
 
153
161
  {displayAreaRegularLines
154
162
  ? regularLines.map(
155
- ({
156
- areaColor,
157
- transparency,
158
- lineColor,
159
- filled,
160
- unit,
161
- highlight,
162
- invert,
163
- metric_id,
164
- ...rest
165
- }) => {
166
- const yScale = getYScale({
167
- invert,
168
- scale,
169
- scaleLogarithmicBase,
163
+ ({
164
+ areaColor,
165
+ transparency,
166
+ lineColor,
167
+ filled,
170
168
  unit,
171
- yScalesPerUnit
172
- });
173
- const relatedTimeSeries = getTimeSeriesForLines({
169
+ highlight,
174
170
  invert,
175
- lines: [
176
- {
177
- areaColor,
178
- filled,
179
- highlight,
180
- invert,
181
- lineColor,
182
- metric_id,
183
- transparency,
184
- unit,
185
- ...rest
186
- }
187
- ],
188
- timeSeries
189
- });
171
+ metric_id,
172
+ ...rest
173
+ }) => {
174
+ const yScale = getYScale({
175
+ invert,
176
+ scale,
177
+ scaleLogarithmicBase,
178
+ unit,
179
+ yScalesPerUnit
180
+ });
181
+ const relatedTimeSeries = getTimeSeriesForLines({
182
+ invert,
183
+ lines: [
184
+ {
185
+ areaColor,
186
+ filled,
187
+ highlight,
188
+ invert,
189
+ lineColor,
190
+ metric_id,
191
+ transparency,
192
+ unit,
193
+ ...rest
194
+ }
195
+ ],
196
+ timeSeries
197
+ });
190
198
 
191
- const style = getStyle({
192
- style: lineStyle,
193
- metricId: metric_id
194
- }) as LineStyle;
199
+ const style = getStyle({
200
+ style: lineStyle,
201
+ metricId: metric_id
202
+ }) as LineStyle;
195
203
 
196
- return (
197
- <g key={metric_id}>
198
- {displayGuidingLines && (
199
- <RegularAnchorPoint
204
+ return (
205
+ <g key={metric_id}>
206
+ {displayGuidingLines && (
207
+ <RegularAnchorPoint
208
+ areaColor={areaColor || lineColor}
209
+ lineColor={lineColor}
210
+ metric_id={metric_id}
211
+ timeSeries={relatedTimeSeries}
212
+ transparency={transparency}
213
+ xScale={xScale}
214
+ yScale={yScale}
215
+ maxLeftAxisCharacters={maxLeftAxisCharacters}
216
+ hasSecondUnit={hasSecondUnit}
217
+ />
218
+ )}
219
+ {style?.showPoints &&
220
+ getDates(relatedTimeSeries).map((timeTick) => (
221
+ <Point
222
+ key={timeTick.toString()}
223
+ lineColor={lineColor}
224
+ metric_id={metric_id}
225
+ radius={getPointRadius(style?.lineWidth)}
226
+ timeSeries={relatedTimeSeries}
227
+ timeTick={timeTick}
228
+ xScale={xScale}
229
+ yPoint={getYAnchorPoint({
230
+ metric_id,
231
+ timeSeries: relatedTimeSeries,
232
+ timeTick,
233
+ yScale
234
+ })}
235
+ yScale={yScale}
236
+ />
237
+ ))}
238
+ <RegularLine
200
239
  areaColor={areaColor || lineColor}
240
+ curve={style?.curve || 'linear'}
241
+ dashLength={style?.dashLength}
242
+ dashOffset={style?.dashOffset}
243
+ dotOffset={style?.dotOffset}
244
+ filled={isNil(style?.showArea) ? filled : style.showArea}
245
+ graphHeight={height}
246
+ highlight={highlight}
201
247
  lineColor={lineColor}
248
+ lineWidth={style?.lineWidth || 2}
202
249
  metric_id={metric_id}
203
250
  timeSeries={relatedTimeSeries}
204
- transparency={transparency}
251
+ transparency={
252
+ isNil(style?.areaTransparency)
253
+ ? transparency || 80
254
+ : style.areaTransparency
255
+ }
256
+ unit={unit}
205
257
  xScale={xScale}
206
258
  yScale={yScale}
207
- maxLeftAxisCharacters={maxLeftAxisCharacters}
208
- hasSecondUnit={hasSecondUnit}
209
259
  />
210
- )}
211
- {style?.showPoints &&
212
- getDates(relatedTimeSeries).map((timeTick) => (
213
- <Point
214
- key={timeTick.toString()}
215
- lineColor={lineColor}
216
- metric_id={metric_id}
217
- radius={getPointRadius(style?.lineWidth)}
218
- timeSeries={relatedTimeSeries}
219
- timeTick={timeTick}
220
- xScale={xScale}
221
- yPoint={getYAnchorPoint({
222
- metric_id,
223
- timeSeries: relatedTimeSeries,
224
- timeTick,
225
- yScale
226
- })}
227
- yScale={yScale}
228
- />
229
- ))}
230
- <RegularLine
231
- areaColor={areaColor || lineColor}
232
- curve={style?.curve || 'linear'}
233
- dashLength={style?.dashLength}
234
- dashOffset={style?.dashOffset}
235
- dotOffset={style?.dotOffset}
236
- filled={isNil(style?.showArea) ? filled : style.showArea}
237
- graphHeight={height}
238
- highlight={highlight}
239
- lineColor={lineColor}
240
- lineWidth={style?.lineWidth || 2}
241
- metric_id={metric_id}
242
- timeSeries={relatedTimeSeries}
243
- transparency={
244
- isNil(style?.areaTransparency)
245
- ? transparency || 80
246
- : style.areaTransparency
247
- }
248
- unit={unit}
249
- xScale={xScale}
250
- yScale={yScale}
251
- />
252
- </g>
253
- );
254
- }
255
- )
260
+ </g>
261
+ );
262
+ }
263
+ )
256
264
  : null}
257
265
  </g>
258
266
  );
@@ -81,17 +81,17 @@ const MainLegend = ({
81
81
 
82
82
  const contextMenuClick =
83
83
  (metricId: number) =>
84
- (event: MouseEvent): void => {
85
- if (!secondaryClick) {
86
- return;
87
- }
88
- event.preventDefault();
89
- secondaryClick({
90
- element: event.target,
91
- metricId,
92
- position: [event.pageX, event.pageY]
93
- });
94
- };
84
+ (event: MouseEvent): void => {
85
+ if (!secondaryClick) {
86
+ return;
87
+ }
88
+ event.preventDefault();
89
+ secondaryClick({
90
+ element: event.target,
91
+ metricId,
92
+ position: [event.pageX, event.pageY]
93
+ });
94
+ };
95
95
 
96
96
  const selectMetric = ({
97
97
  event,
@@ -18,7 +18,7 @@ import { Metric } from '../common/timeSeries/models';
18
18
  import { useTooltipStyles } from '../common/useTooltipStyles';
19
19
  import { getColorFromDataAndTresholds } from '../common/utils';
20
20
 
21
- import { barHeights } from './ThresholdLine';
21
+ import { barHeights, lineMargins } from './ThresholdLine';
22
22
  import Thresholds, { groupMargin } from './Thresholds';
23
23
  import { SingleBarProps } from './models';
24
24
 
@@ -36,7 +36,9 @@ const ResponsiveSingleBar = ({
36
36
  baseColor,
37
37
  size = 'medium',
38
38
  showLabels = true,
39
- max
39
+ max,
40
+ direction = 'column',
41
+ textWidth
40
42
  }: Props): JSX.Element => {
41
43
  const { classes } = useTooltipStyles();
42
44
  const theme = useTheme();
@@ -79,16 +81,26 @@ const ResponsiveSingleBar = ({
79
81
 
80
82
  const textHeight = isSmall ? 46 : 27;
81
83
 
84
+ const textY = useMemo(() => {
85
+ if (direction === 'row' && isSmall) {
86
+ return 2;
87
+ }
88
+ if (direction === 'row' && !isSmall) {
89
+ return 22;
90
+ }
91
+ return isSmall ? 10 : 25;
92
+ }, [direction, isSmall]);
93
+
82
94
  const text = showLabels && (
83
95
  <text
84
- dominantBaseline="middle"
96
+ dominantBaseline={direction === 'row' ? 'hanging' : 'middle'}
85
97
  style={{
86
98
  fill: barColor,
87
99
  ...textStyle
88
100
  }}
89
- textAnchor="middle"
90
- x="50%"
91
- y={isSmall ? 10 : 25}
101
+ textAnchor={direction === 'row' ? 'start' : 'middle'}
102
+ x={direction === 'row' ? 0 : '50%'}
103
+ y={textY}
92
104
  >
93
105
  {formatMetricValueWithUnit({
94
106
  base: 1000,
@@ -99,13 +111,18 @@ const ResponsiveSingleBar = ({
99
111
  </text>
100
112
  );
101
113
 
114
+ const widthMargin = useMemo(
115
+ () => (direction === 'row' && textWidth) || 0,
116
+ [direction, textWidth]
117
+ );
118
+
102
119
  const xScale = useMemo(
103
120
  () =>
104
121
  scaleLinear<number>({
105
122
  domain: [0, adaptedMaxValue],
106
- range: [0, width - 10 || 0]
123
+ range: [0, width - widthMargin - 10 || 0]
107
124
  }),
108
- [width, adaptedMaxValue]
125
+ [width, adaptedMaxValue, widthMargin]
109
126
  );
110
127
 
111
128
  const metricBarWidth = useMemo(
@@ -119,7 +136,10 @@ const ResponsiveSingleBar = ({
119
136
 
120
137
  const springStyle = useSpring({ width: metricBarWidth });
121
138
 
122
- const barY = groupMargin + (isSmall ? 0 : 2 * margins.top);
139
+ const barY =
140
+ direction === 'row'
141
+ ? lineMargins[size] / 2
142
+ : groupMargin + (isSmall ? 0 : 2 * margins.top);
123
143
 
124
144
  const realBarHeight = !isSmall
125
145
  ? clamp(
@@ -161,7 +181,7 @@ const ResponsiveSingleBar = ({
161
181
  height={realBarHeight}
162
182
  rx={4}
163
183
  style={springStyle}
164
- x={5}
184
+ x={direction === 'row' ? textWidth : 5}
165
185
  y={barY}
166
186
  />
167
187
  <Bar
@@ -171,7 +191,7 @@ const ResponsiveSingleBar = ({
171
191
  ry={4}
172
192
  stroke={alpha(theme.palette.text.primary, 0.3)}
173
193
  width={maxBarWidth}
174
- x={5}
194
+ x={direction === 'row' ? textWidth : 5}
175
195
  y={barY}
176
196
  />
177
197
  {thresholds.enabled && (
@@ -183,6 +203,8 @@ const ResponsiveSingleBar = ({
183
203
  size={size}
184
204
  thresholds={thresholds}
185
205
  xScale={xScale}
206
+ direction={direction}
207
+ textWidth={textWidth}
186
208
  />
187
209
  )}
188
210
  </Group.Group>
@@ -118,4 +118,29 @@ describe('Single bar', () => {
118
118
 
119
119
  cy.makeSnapshot();
120
120
  });
121
+
122
+ it('displays the value on the left of the bar when the corresponding prop is set', () => {
123
+ initialize({
124
+ thresholds: successThresholds,
125
+ direction: 'row',
126
+ textWidth: 100
127
+ });
128
+
129
+ cy.contains('0.41 s').should('be.visible');
130
+
131
+ cy.makeSnapshot();
132
+ });
133
+
134
+ it('displays the value on the left of the bar when the corresponding prop is set and the size is mall', () => {
135
+ initialize({
136
+ thresholds: criticalThresholds,
137
+ direction: 'row',
138
+ textWidth: 70,
139
+ size: 'small'
140
+ });
141
+
142
+ cy.contains('0.41 s').should('be.visible');
143
+
144
+ cy.makeSnapshot();
145
+ });
121
146
  });
@@ -12,7 +12,7 @@ export default meta;
12
12
  type Story = StoryObj<typeof SingleBar>;
13
13
 
14
14
  const Template = (props): JSX.Element => (
15
- <div style={{ height: '500px', width: '500px' }}>
15
+ <div style={{ height: '500px', width: '200px' }}>
16
16
  <SingleBar {...props} />
17
17
  </div>
18
18
  );
@@ -230,3 +230,52 @@ export const smallDisplay: Story = {
230
230
  },
231
231
  render: SmallTemplate
232
232
  };
233
+
234
+ export const RowDirection: Story = {
235
+ args: {
236
+ data: dataLastWeek,
237
+ direction: 'row',
238
+ textWidth: 100,
239
+ thresholds: {
240
+ critical: [
241
+ {
242
+ label: 'Critical',
243
+ value: 0.6
244
+ }
245
+ ],
246
+ enabled: true,
247
+ warning: [
248
+ {
249
+ label: 'Warning',
250
+ value: 0.5
251
+ }
252
+ ]
253
+ }
254
+ },
255
+ render: Template
256
+ };
257
+
258
+ export const RowDirectionSmall: Story = {
259
+ args: {
260
+ data: dataLastWeek,
261
+ size: 'small',
262
+ direction: 'row',
263
+ textWidth: 70,
264
+ thresholds: {
265
+ critical: [
266
+ {
267
+ label: 'Critical',
268
+ value: 0.6
269
+ }
270
+ ],
271
+ enabled: true,
272
+ warning: [
273
+ {
274
+ label: 'Warning',
275
+ value: 0.5
276
+ }
277
+ ]
278
+ }
279
+ },
280
+ render: Template
281
+ };
@@ -4,7 +4,9 @@ import { useTheme } from '@mui/material';
4
4
 
5
5
  import { margins } from '../common/margins';
6
6
 
7
+ import { useMemo } from 'react';
7
8
  import { groupMargin } from './Thresholds';
9
+ import { SingleBarProps } from './models';
8
10
 
9
11
  export const barHeights = {
10
12
  medium: 72,
@@ -12,12 +14,12 @@ export const barHeights = {
12
14
  };
13
15
  export const margin = 40;
14
16
 
15
- const lineMargins = {
17
+ export const lineMargins = {
16
18
  medium: 10,
17
19
  small: 5
18
20
  };
19
21
 
20
- interface Props {
22
+ interface Props extends Pick<SingleBarProps, 'direction'> {
21
23
  barHeight: number;
22
24
  hideTooltip: () => void;
23
25
  isSmall: boolean;
@@ -27,6 +29,7 @@ interface Props {
27
29
  thresholdType: string;
28
30
  value: number;
29
31
  xScale: (value: number) => number;
32
+ textWidth?: number;
30
33
  }
31
34
 
32
35
  export const ThresholdLine = ({
@@ -38,11 +41,13 @@ export const ThresholdLine = ({
38
41
  hideTooltip,
39
42
  size,
40
43
  barHeight,
41
- isSmall
44
+ isSmall,
45
+ direction,
46
+ textWidth
42
47
  }: Props): JSX.Element => {
43
48
  const theme = useTheme();
44
49
 
45
- const scaledValue = xScale(value) || 0;
50
+ const scaledValue = xScale(value) + (textWidth || 0) || 0;
46
51
 
47
52
  const lineMargin = lineMargins[size];
48
53
 
@@ -55,25 +60,35 @@ export const ThresholdLine = ({
55
60
  ? theme.palette.warning.main
56
61
  : theme.palette.error.main;
57
62
 
63
+ const lineY1 = useMemo(() => {
64
+ if (direction === 'row') {
65
+ return 0;
66
+ }
67
+ return isSmall
68
+ ? groupMargin - lineMargin
69
+ : groupMargin + lineMargin + margins.top;
70
+ }, [direction, isSmall, groupMargin, lineMargin, margins]);
71
+
72
+ const lineY2 = useMemo(() => {
73
+ if (direction === 'row') {
74
+ return barHeight + lineMargin;
75
+ }
76
+ return isSmall
77
+ ? barHeight + groupMargin - lineMargin + margins.top - 6
78
+ : barHeight + groupMargin + lineMargin + 2 * margins.top;
79
+ }, [direction, isSmall, groupMargin, lineMargin, margins]);
80
+
58
81
  return (
59
82
  <>
60
83
  <line
61
84
  data-testid={`${thresholdType}-line-${value}`}
62
85
  stroke={lineColor}
63
- strokeDasharray="6, 6"
86
+ strokeDasharray="6, 5"
64
87
  strokeWidth={2}
65
88
  x1={scaledValue}
66
89
  x2={scaledValue + 1}
67
- y1={
68
- isSmall
69
- ? groupMargin - lineMargin
70
- : groupMargin + lineMargin + margins.top
71
- }
72
- y2={
73
- isSmall
74
- ? barHeight + groupMargin - lineMargin + margins.top - 6
75
- : barHeight + groupMargin + lineMargin + 2 * margins.top
76
- }
90
+ y1={lineY1}
91
+ y2={lineY2}
77
92
  />
78
93
  <line
79
94
  data-testid={`${thresholdType}-line-${value}-tooltip`}
@@ -81,16 +96,8 @@ export const ThresholdLine = ({
81
96
  strokeWidth={5}
82
97
  x1={scaledValue}
83
98
  x2={scaledValue + 1}
84
- y1={
85
- isSmall
86
- ? groupMargin - lineMargin
87
- : groupMargin + lineMargin + margins.top
88
- }
89
- y2={
90
- isSmall
91
- ? barHeight + groupMargin - lineMargin + margins.top - 6
92
- : barHeight + groupMargin + lineMargin + 2 * margins.top
93
- }
99
+ y1={lineY1}
100
+ y2={lineY2}
94
101
  onMouseEnter={onMouseEnter}
95
102
  onMouseLeave={hideTooltip}
96
103
  />
@@ -1,10 +1,11 @@
1
1
  import { Thresholds as ThresholdsModel } from '../common/models';
2
+ import { SingleBarProps } from './models';
2
3
 
3
4
  import { ThresholdLine } from './ThresholdLine';
4
5
 
5
6
  export const groupMargin = 25;
6
7
 
7
- interface Props {
8
+ interface Props extends Pick<SingleBarProps, 'direction'> {
8
9
  barHeight: number;
9
10
  hideTooltip: () => void;
10
11
  isSmall: boolean;
@@ -12,6 +13,7 @@ interface Props {
12
13
  size: 'small' | 'medium';
13
14
  thresholds: ThresholdsModel;
14
15
  xScale: (value: number) => number;
16
+ textWidth?: number;
15
17
  }
16
18
 
17
19
  const Thresholds = ({
@@ -21,7 +23,9 @@ const Thresholds = ({
21
23
  hideTooltip,
22
24
  size,
23
25
  barHeight,
24
- isSmall
26
+ isSmall,
27
+ direction,
28
+ textWidth
25
29
  }: Props): JSX.Element => (
26
30
  <>
27
31
  {thresholds.warning.map(({ value, label }) => (
@@ -36,6 +40,8 @@ const Thresholds = ({
36
40
  thresholdType="warning"
37
41
  value={value}
38
42
  xScale={xScale}
43
+ direction={direction}
44
+ textWidth={textWidth}
39
45
  />
40
46
  ))}
41
47
  {thresholds.critical.map(({ value, label }) => (
@@ -50,6 +56,8 @@ const Thresholds = ({
50
56
  thresholdType="critical"
51
57
  value={value}
52
58
  xScale={xScale}
59
+ direction={direction}
60
+ textWidth={textWidth}
53
61
  />
54
62
  ))}
55
63
  </>
@@ -8,4 +8,6 @@ export interface SingleBarProps {
8
8
  size?: 'medium' | 'small';
9
9
  thresholds: Thresholds;
10
10
  max?: number;
11
+ direction?: 'column' | 'row';
12
+ textWidth?: number; // Applied only when the direction is row
11
13
  }
@@ -35,8 +35,8 @@ interface Props {
35
35
  limitLegend?: number | false;
36
36
  lines: Array<Line>;
37
37
  setLines:
38
- | Dispatch<SetStateAction<Array<Line> | null>>
39
- | Dispatch<SetStateAction<Array<Line>>>;
38
+ | Dispatch<SetStateAction<Array<Line> | null>>
39
+ | Dispatch<SetStateAction<Array<Line>>>;
40
40
  title: string;
41
41
  graphHeight: number;
42
42
  }
@@ -93,8 +93,8 @@ const BaseChart = ({
93
93
  className={cx(
94
94
  classes.legendContainer,
95
95
  equals(legend?.placement, 'right') &&
96
- !isHorizontal &&
97
- classes.legendContainerVerticalSide
96
+ !isHorizontal &&
97
+ classes.legendContainerVerticalSide
98
98
  )}
99
99
  ref={legendRef}
100
100
  >
@@ -2,13 +2,13 @@ import { MutableRefObject, ReactElement } from 'react';
2
2
 
3
3
  import { Group } from '@visx/visx';
4
4
  import { equals } from 'ramda';
5
+ import { margin } from '../../Chart/common';
5
6
  import { ChartAxis } from '../../Chart/models';
6
7
  import Axes from '../Axes';
7
8
  import Grids from '../Grids';
8
9
  import { Line, TimeValue } from '../timeSeries/models';
9
10
  import { useMarginTop } from '../useMarginTop';
10
11
  import { computeGElementMarginLeft } from '../utils';
11
- import { margin } from '../../Chart/common';
12
12
 
13
13
  interface Props {
14
14
  allUnits: Array<string>;
@@ -52,21 +52,21 @@ export const useComputeBaseChartDimensions = ({
52
52
 
53
53
  const legendBoundingHeight =
54
54
  !equals(legendDisplay, false) &&
55
- (isNil(legendPlacement) || equals(legendPlacement, 'bottom'))
55
+ (isNil(legendPlacement) || equals(legendPlacement, 'bottom'))
56
56
  ? currentLegendHeight
57
57
  : 0;
58
58
  const legendBoundingWidth =
59
59
  !equals(legendDisplay, false) &&
60
- (equals(legendPlacement, 'left') || equals(legendPlacement, 'right'))
60
+ (equals(legendPlacement, 'left') || equals(legendPlacement, 'right'))
61
61
  ? legendRefWidth || 0
62
62
  : 0;
63
63
 
64
64
  const graphWidth =
65
65
  width > 0
66
66
  ? width -
67
- (hasSecondUnit ? maxAxisCharacters * 2 : maxAxisCharacters) * 6 -
68
- (hasSecondUnit ? margins.left * 0.8 : margin.left) -
69
- legendBoundingWidth
67
+ (hasSecondUnit ? maxAxisCharacters * 2 : maxAxisCharacters) * 6 -
68
+ (hasSecondUnit ? margins.left * 0.8 : margin.left) -
69
+ legendBoundingWidth
70
70
  : 0;
71
71
  const graphHeight =
72
72
  (height || 0) > 0
@@ -20,6 +20,7 @@ import {
20
20
  includes,
21
21
  isEmpty,
22
22
  isNil,
23
+ isNotNil,
23
24
  keys,
24
25
  last,
25
26
  lt,
@@ -33,8 +34,7 @@ import {
33
34
  reject,
34
35
  sortBy,
35
36
  split,
36
- uniq,
37
- isNotNil
37
+ uniq
38
38
  } from 'ramda';
39
39
 
40
40
  import { margin } from '../../Chart/common';
@@ -161,8 +161,8 @@ const getMetrics = (timeValue: TimeValue): Array<string> =>
161
161
 
162
162
  const getValueForMetric =
163
163
  (timeValue: TimeValue) =>
164
- (metric_id: number): number =>
165
- prop(metric_id, timeValue) as number;
164
+ (metric_id: number): number =>
165
+ prop(metric_id, timeValue) as number;
166
166
 
167
167
  const getUnits = (lines: Array<Line>): Array<string> =>
168
168
  pipe(map(prop('unit')), uniq)(lines);
@@ -309,8 +309,8 @@ const getTimeSeriesForLines = ({
309
309
  ...acc,
310
310
  [metric_id]:
311
311
  invert &&
312
- metricsValue[metric_id] &&
313
- gt(metricsValue[metric_id], 0)
312
+ metricsValue[metric_id] &&
313
+ gt(metricsValue[metric_id], 0)
314
314
  ? negate(metricsValue[metric_id])
315
315
  : metricsValue[metric_id]
316
316
  };
@@ -343,10 +343,10 @@ const getYScale = ({
343
343
 
344
344
  return invert
345
345
  ? getScaleType(scale)({
346
- base: scaleLogarithmicBase,
347
- domain: yScale.domain().reverse(),
348
- range: yScale.range().reverse()
349
- })
346
+ base: scaleLogarithmicBase,
347
+ domain: yScale.domain().reverse(),
348
+ range: yScale.range().reverse()
349
+ })
350
350
  : yScale;
351
351
  };
352
352
 
@@ -391,40 +391,40 @@ const getScale = ({
391
391
  const sanitizedValuesForMinimum = min
392
392
  ? [min]
393
393
  : getSanitizedValues([
394
- invert && graphValues.every(lt(0))
395
- ? negate(getMax(graphValues))
396
- : getMin(graphValues),
397
- !isEmpty(stackedValues) &&
398
- !equals(stackedValues, [0]) &&
399
- getMin(stackedValues),
400
- Math.min(...thresholds)
401
- ]);
394
+ invert && graphValues.every(lt(0))
395
+ ? negate(getMax(graphValues))
396
+ : getMin(graphValues),
397
+ !isEmpty(stackedValues) &&
398
+ !equals(stackedValues, [0]) &&
399
+ getMin(stackedValues),
400
+ Math.min(...thresholds)
401
+ ]);
402
402
  const minValue = Math.min(...sanitizedValuesForMinimum.filter(isNotNil));
403
403
 
404
404
  const sanitizedValuesForMaximum = max
405
405
  ? [max]
406
406
  : getSanitizedValues([
407
- getMax(graphValues),
408
- getMax(stackedValues),
409
- hasOnlyZeroesHasValue(graphValues) ? 1 : null,
410
- Math.max(...thresholds)
411
- ]);
407
+ getMax(graphValues),
408
+ getMax(stackedValues),
409
+ hasOnlyZeroesHasValue(graphValues) ? 1 : null,
410
+ Math.max(...thresholds)
411
+ ]);
412
412
  const maxValue = Math.max(...sanitizedValuesForMaximum.filter(isNotNil));
413
413
 
414
414
  const minValueWithMargin =
415
415
  (hasDisplayAsBar && minValue > 0) ||
416
- (hasLineFilled &&
417
- Math.max(maxValue, minValue) > minValue &&
418
- minValue > 0) ||
419
- (hasStackedLines && minValue > maxValue)
416
+ (hasLineFilled &&
417
+ Math.max(maxValue, minValue) > minValue &&
418
+ minValue > 0) ||
419
+ (hasStackedLines && minValue > maxValue)
420
420
  ? 0
421
421
  : minValue - Math.abs(minValue) * 0.05;
422
422
  const maxValueWithMargin =
423
423
  (hasDisplayAsBar && maxValue < 0) ||
424
- (hasLineFilled &&
425
- Math.min(maxValue, minValue) < maxValue &&
426
- maxValue < 0) ||
427
- (hasStackedLines && minValue > maxValue)
424
+ (hasLineFilled &&
425
+ Math.min(maxValue, minValue) < maxValue &&
426
+ maxValue < 0) ||
427
+ (hasStackedLines && minValue > maxValue)
428
428
  ? 0
429
429
  : maxValue + Math.abs(maxValue) * 0.05;
430
430
 
@@ -521,11 +521,11 @@ const getYScaleUnit = ({
521
521
 
522
522
  const stackedValues = hasStackedLines
523
523
  ? getStackedMetricValues({
524
- lines: getSortedStackedLines(dataLines).filter(
525
- ({ unit: stackedUnit }) => equals(unit, stackedUnit)
526
- ),
527
- timeSeries: dataTimeSeries
528
- })
524
+ lines: getSortedStackedLines(dataLines).filter(
525
+ ({ unit: stackedUnit }) => equals(unit, stackedUnit)
526
+ ),
527
+ timeSeries: dataTimeSeries
528
+ })
529
529
  : [];
530
530
 
531
531
  return getScale({
@@ -538,8 +538,8 @@ const getYScaleUnit = ({
538
538
  ),
539
539
  hasLineFilled: isNil(isFilled)
540
540
  ? dataLines.some(
541
- ({ unit: lineUnit, filled }) => equals(unit, lineUnit) && filled
542
- )
541
+ ({ unit: lineUnit, filled }) => equals(unit, lineUnit) && filled
542
+ )
543
543
  : isFilled,
544
544
  hasStackedLines: dataLines.some(
545
545
  ({ unit: lineUnit, stackKey, stackOrder }) =>
@@ -55,12 +55,6 @@ const useStyles = makeStyles<{ toolbarPositions: 'start' | 'end' }>()(
55
55
  bold: {
56
56
  fontWeight: theme.typography.fontWeightBold
57
57
  },
58
- container: equals(toolbarPositions, 'end')
59
- ? {
60
- display: 'flex',
61
- flexDirection: 'column-reverse'
62
- }
63
- : {},
64
58
  error: {
65
59
  color: theme.palette.error.main,
66
60
  fontSize: theme.spacing(1.5),
@@ -190,7 +184,9 @@ const RichTextEditor = ({
190
184
 
191
185
  return (
192
186
  <LexicalComposer initialConfig={initialConfig}>
193
- <div className={classes.container}>
187
+ <div
188
+ className={`flex ${toolbarPositions === 'end' ? 'flex-col-reverse' : 'flex-col'}`}
189
+ >
194
190
  <div className={classes.toolbar}>
195
191
  <ToolbarPlugin
196
192
  className={toolbarClassName}
@@ -1,7 +1,6 @@
1
- import { makeStyles } from 'tss-react/mui';
2
-
3
1
  import { Divider } from '@mui/material';
4
2
 
3
+ import { ReactElement } from 'react';
5
4
  import AlignPicker from './AlignPicker';
6
5
  import BlockButtons from './BlockButtons';
7
6
  import FormatButtons from './FormatButtons';
@@ -18,26 +17,17 @@ interface Props {
18
17
  editable: boolean;
19
18
  }
20
19
 
21
- export const useStyles = makeStyles()((theme) => ({
22
- container: {
23
- alignItems: 'center',
24
- columnGap: theme.spacing(1),
25
- display: 'flex',
26
- marginBottom: theme.spacing(1)
27
- }
28
- }));
29
-
30
20
  const ToolbarPlugin = ({
31
21
  editable,
32
22
  displayMacrosButton,
33
23
  disabled,
34
24
  displayBlockButtons,
35
25
  className
36
- }: Props): JSX.Element | null => {
37
- const { cx, classes } = useStyles();
38
-
26
+ }: Props): ReactElement | null => {
39
27
  return editable ? (
40
- <div className={cx(classes.container, className)}>
28
+ <div
29
+ className={`flex items-center gap-2 mb-2 overflow-y-auto ${className}`}
30
+ >
41
31
  <UndoRedoButtons disabled={disabled} />
42
32
  {displayBlockButtons && (
43
33
  <>
@@ -1,6 +1,5 @@
1
1
  import toRawQueryParameters from '../../queryParameters';
2
2
  import { QueryParameter } from '../../queryParameters/models';
3
-
4
3
  import { getSearchQueryParameterValue } from './getSearchQueryParameterValue';
5
4
  import { BuildListingEndpointParameters, Parameters } from './models';
6
5
 
@@ -27,11 +26,25 @@ const buildEndpoint = ({ baseEndpoint, queryParameters }): string => {
27
26
  return `${baseEndpoint}?${toRawQueryParameters(queryParameters)}`;
28
27
  };
29
28
 
29
+ const buildCustomEndpoint = ({ baseEndpoint, queryParameters }): string => {
30
+ return `${baseEndpoint}&${toRawQueryParameters(queryParameters)}`;
31
+ };
32
+
30
33
  const buildListingEndpoint = ({
31
34
  baseEndpoint,
32
35
  parameters,
33
- customQueryParameters
36
+ customQueryParameters,
37
+ isCustomEndpoint = false
34
38
  }: BuildListingEndpointParameters): string => {
39
+ if (isCustomEndpoint) {
40
+ return buildCustomEndpoint({
41
+ baseEndpoint,
42
+ queryParameters: [
43
+ ...getQueryParameters({ ...parameters, customQueryParameters })
44
+ ]
45
+ });
46
+ }
47
+
35
48
  return buildEndpoint({
36
49
  baseEndpoint,
37
50
  queryParameters: [
@@ -4,6 +4,7 @@ export interface BuildListingEndpointParameters {
4
4
  baseEndpoint?: string;
5
5
  customQueryParameters?: Array<QueryParameter>;
6
6
  parameters: Parameters;
7
+ isCustomEndpoint?: boolean;
7
8
  }
8
9
 
9
10
  export interface SearchMatch {
@@ -19,6 +19,8 @@ export type Props = {
19
19
  labelAdd?: string;
20
20
  onAddItem?: () => void;
21
21
  secondaryLabel?: string;
22
+ isAddButtonSticky?: boolean;
23
+ addButtonClassName?: string;
22
24
  };
23
25
 
24
26
  export const ItemComposition = ({
@@ -29,8 +31,10 @@ export const ItemComposition = ({
29
31
  addButtonHidden,
30
32
  IconAdd,
31
33
  displayItemsAsLinked,
32
- secondaryLabel
33
- }: Props): JSX.Element => {
34
+ secondaryLabel,
35
+ isAddButtonSticky,
36
+ addButtonClassName
37
+ }: Props): ReactElement => {
34
38
  const { classes } = useItemCompositionStyles();
35
39
 
36
40
  const hasMoreThanOneChildren = gt(children.length, 1);
@@ -45,7 +49,9 @@ export const ItemComposition = ({
45
49
  </div>
46
50
  )}
47
51
  </div>
48
- <div className={classes.buttonAndSecondaryLabel}>
52
+ <div
53
+ className={`flex justify-between items-center w-full ${isAddButtonSticky && 'bg-background-paper sticky bottom-0 z-2'} ${addButtonClassName}`}
54
+ >
49
55
  {!addButtonHidden && (
50
56
  <Button
51
57
  aria-label={labelAdd}
@@ -12,7 +12,12 @@ const useStyles = makeStyles<{
12
12
  padding: theme.spacing(2.5)
13
13
  },
14
14
  '&[data-size="fullscreen"]': {
15
- zIndex: 0
15
+ zIndex: 0,
16
+ margin: 0,
17
+ marginLeft: props?.left ?? 0,
18
+ marginRight: props?.right ?? 0,
19
+ marginTop: props?.top ?? 0,
20
+ marginBottom: props?.bottom ?? 0
16
21
  },
17
22
  '&[data-size="fullscreen"] .MuiBackdrop-root': {
18
23
  display: 'none'
@@ -20,18 +25,18 @@ const useStyles = makeStyles<{
20
25
  '&[data-size="fullscreen"] .MuiDialog-container': {
21
26
  alignItems: 'flex-end',
22
27
  height: '100vh',
23
- justifyContent: 'flex-end'
28
+ justifyContent: 'flex-end',
29
+ position: 'relative'
24
30
  },
25
31
  '&[data-size="fullscreen"] .MuiDialog-paper': {
26
- bottom: props?.bottom ?? 0,
27
- height: 'calc(100vh - 90px)',
28
- left: props?.left ?? 0,
32
+ bottom: 0,
33
+ left: 0,
29
34
  margin: 0,
30
35
  maxWidth: 'unset',
31
36
  paddingBottom: theme.spacing(8),
32
37
  position: 'absolute',
33
- right: props?.right ?? 0,
34
- top: props?.top ?? 0,
38
+ right: 0,
39
+ top: 0,
35
40
  transition: theme.transitions.create('left')
36
41
  },
37
42
  '&[data-size="large"] .MuiDialog-paper': {
@@ -46,15 +51,13 @@ const useStyles = makeStyles<{
46
51
  },
47
52
  '&[data-size="xlarge"] .MuiDialog-paper': {
48
53
  maxWidth: '900px',
49
- width: 'calc(100% - 64px)'
54
+ width: 'calc(100% - 78px)'
50
55
  }
51
56
  },
52
57
  modalActions: {
53
58
  '&[data-fixed="true"]': {
54
- background: theme.palette.background.paper,
55
59
  padding: theme.spacing(1, 2.5, 2.5, 0),
56
- position: 'fixed',
57
- width: '100%'
60
+ position: 'fixed'
58
61
  },
59
62
  bottom: 0,
60
63
  display: 'flex',
@@ -64,14 +67,6 @@ const useStyles = makeStyles<{
64
67
  padding: theme.spacing(1, 0, 0, 0),
65
68
  right: 0,
66
69
  zIndex: theme.zIndex.modal
67
- },
68
- modalCloseButton: {
69
- position: 'absolute',
70
- right: theme.spacing(1),
71
- svg: {
72
- opacity: 0.6
73
- },
74
- top: theme.spacing(1)
75
70
  }
76
71
  }));
77
72
 
@@ -61,7 +61,7 @@ const Modal = ({
61
61
  {...attr}
62
62
  >
63
63
  {hasCloseButton && (
64
- <div className={classes.modalCloseButton}>
64
+ <div className="absolute top-2 right-3 opacity-60">
65
65
  <IconButton
66
66
  aria-label="close"
67
67
  icon={<CloseIcon />}
@@ -12,5 +12,4 @@
12
12
  overflow-y: auto;
13
13
  overflow-x: hidden;
14
14
  height: 100%;
15
- padding-right: var(--spacing-4); /* To prevent scrollbar from overlapping content */
16
15
  }