@allurereport/web-dashboard 3.0.0-beta.17 → 3.0.0-beta.19

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 (31) hide show
  1. package/dist/multi/app-b98a18c7d6561114f354.js +2 -0
  2. package/dist/multi/manifest.json +20 -20
  3. package/dist/multi/{styles-600a3c9312864071f88c.css → styles-83a09f6b14587b27ed9c.css} +2 -2
  4. package/dist/single/app-7bcc055d079abc1ab4eb.js +2 -0
  5. package/dist/single/manifest.json +1 -1
  6. package/package.json +5 -5
  7. package/src/components/Dashboard/index.tsx +53 -3
  8. package/src/components/Dashboard/styles.scss +2 -2
  9. package/src/stores/dashboard.ts +2 -166
  10. package/dist/multi/app-581d52a3d2d3c17644ee.js +0 -2
  11. package/dist/single/app-e1eede23fa367bd3d2ad.js +0 -2
  12. /package/dist/multi/{173.app-581d52a3d2d3c17644ee.js → 173.app-b98a18c7d6561114f354.js} +0 -0
  13. /package/dist/multi/{174.app-581d52a3d2d3c17644ee.js → 174.app-b98a18c7d6561114f354.js} +0 -0
  14. /package/dist/multi/{252.app-581d52a3d2d3c17644ee.js → 252.app-b98a18c7d6561114f354.js} +0 -0
  15. /package/dist/multi/{282.app-581d52a3d2d3c17644ee.js → 282.app-b98a18c7d6561114f354.js} +0 -0
  16. /package/dist/multi/{29.app-581d52a3d2d3c17644ee.js → 29.app-b98a18c7d6561114f354.js} +0 -0
  17. /package/dist/multi/{416.app-581d52a3d2d3c17644ee.js → 416.app-b98a18c7d6561114f354.js} +0 -0
  18. /package/dist/multi/{527.app-581d52a3d2d3c17644ee.js → 527.app-b98a18c7d6561114f354.js} +0 -0
  19. /package/dist/multi/{600.app-581d52a3d2d3c17644ee.js → 600.app-b98a18c7d6561114f354.js} +0 -0
  20. /package/dist/multi/{605.app-581d52a3d2d3c17644ee.js → 605.app-b98a18c7d6561114f354.js} +0 -0
  21. /package/dist/multi/{638.app-581d52a3d2d3c17644ee.js → 638.app-b98a18c7d6561114f354.js} +0 -0
  22. /package/dist/multi/{672.app-581d52a3d2d3c17644ee.js → 672.app-b98a18c7d6561114f354.js} +0 -0
  23. /package/dist/multi/{686.app-581d52a3d2d3c17644ee.js → 686.app-b98a18c7d6561114f354.js} +0 -0
  24. /package/dist/multi/{725.app-581d52a3d2d3c17644ee.js → 725.app-b98a18c7d6561114f354.js} +0 -0
  25. /package/dist/multi/{741.app-581d52a3d2d3c17644ee.js → 741.app-b98a18c7d6561114f354.js} +0 -0
  26. /package/dist/multi/{755.app-581d52a3d2d3c17644ee.js → 755.app-b98a18c7d6561114f354.js} +0 -0
  27. /package/dist/multi/{894.app-581d52a3d2d3c17644ee.js → 894.app-b98a18c7d6561114f354.js} +0 -0
  28. /package/dist/multi/{943.app-581d52a3d2d3c17644ee.js → 943.app-b98a18c7d6561114f354.js} +0 -0
  29. /package/dist/multi/{980.app-581d52a3d2d3c17644ee.js → 980.app-b98a18c7d6561114f354.js} +0 -0
  30. /package/dist/multi/{app-581d52a3d2d3c17644ee.js.LICENSE.txt → app-b98a18c7d6561114f354.js.LICENSE.txt} +0 -0
  31. /package/dist/single/{app-e1eede23fa367bd3d2ad.js.LICENSE.txt → app-7bcc055d079abc1ab4eb.js.LICENSE.txt} +0 -0
@@ -1,3 +1,3 @@
1
1
  {
2
- "main.js": "app-e1eede23fa367bd3d2ad.js"
2
+ "main.js": "app-7bcc055d079abc1ab4eb.js"
3
3
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allurereport/web-dashboard",
3
- "version": "3.0.0-beta.17",
3
+ "version": "3.0.0-beta.19",
4
4
  "description": "The static files for Allure Dashboard Report",
5
5
  "keywords": [
6
6
  "allure",
@@ -31,9 +31,9 @@
31
31
  "IE 11"
32
32
  ],
33
33
  "dependencies": {
34
- "@allurereport/core-api": "3.0.0-beta.17",
35
- "@allurereport/web-commons": "3.0.0-beta.17",
36
- "@allurereport/web-components": "3.0.0-beta.17",
34
+ "@allurereport/core-api": "3.0.0-beta.19",
35
+ "@allurereport/web-commons": "3.0.0-beta.19",
36
+ "@allurereport/web-components": "3.0.0-beta.19",
37
37
  "@preact/signals": "^1.3.0",
38
38
  "clsx": "^2.1.1",
39
39
  "i18next": "^24.0.2",
@@ -58,7 +58,7 @@
58
58
  "@typescript-eslint/parser": "^8.0.0",
59
59
  "@vitest/runner": "^2.1.9",
60
60
  "@vitest/snapshot": "^2.1.9",
61
- "allure-vitest": "^3.3.0",
61
+ "allure-vitest": "^3.3.3",
62
62
  "autoprefixer": "^10.4.20",
63
63
  "babel-loader": "^9.2.1",
64
64
  "babel-plugin-prismjs": "^2.1.0",
@@ -1,21 +1,26 @@
1
1
  /* eslint-disable @typescript-eslint/no-unsafe-argument */
2
- import { ChartType, capitalize } from "@allurereport/web-commons";
2
+ import { ChartType, capitalize } from "@allurereport/core-api";
3
+ import { type UIChartData } from "@allurereport/web-commons";
3
4
  import {
5
+ BarChartWidget,
6
+ ComingSoonChartWidget,
4
7
  Grid,
5
8
  GridItem,
9
+ HeatMapWidget,
6
10
  Loadable,
7
11
  PageLoader,
8
12
  SuccessRatePieChart,
13
+ TreeMapChartWidget,
9
14
  TrendChartWidget,
10
15
  Widget,
11
16
  } from "@allurereport/web-components";
12
17
  import { useEffect } from "preact/hooks";
13
- import { type ChartData, dashboardStore, fetchDashboardData } from "@/stores/dashboard";
18
+ import { dashboardStore, fetchDashboardData } from "@/stores/dashboard";
14
19
  import { useI18n } from "@/stores/locale";
15
20
  import * as styles from "./styles.scss";
16
21
 
17
22
  const getChartWidgetByType = (
18
- chartData: ChartData,
23
+ chartData: UIChartData,
19
24
  { t, empty }: Record<string, (key: string, options?: any) => string>,
20
25
  ) => {
21
26
  switch (chartData.type) {
@@ -48,6 +53,51 @@ const getChartWidgetByType = (
48
53
  </Widget>
49
54
  );
50
55
  }
56
+ case ChartType.Bar: {
57
+ const type = t(`bar.type.${chartData.dataType}`);
58
+ const title = chartData.title ?? t("bar.title", { type: capitalize(type) });
59
+
60
+ return (
61
+ <BarChartWidget
62
+ title={title}
63
+ mode={chartData.mode}
64
+ data={chartData.data}
65
+ keys={chartData.keys}
66
+ indexBy={chartData.indexBy}
67
+ colors={chartData.colors}
68
+ groupMode={chartData.groupMode}
69
+ translations={{ "no-results": empty("no-results") }}
70
+ />
71
+ );
72
+ }
73
+ case ChartType.TreeMap: {
74
+ return (
75
+ <TreeMapChartWidget
76
+ data={chartData.treeMap}
77
+ title={chartData.title}
78
+ formatLegend={chartData.formatLegend}
79
+ colors={chartData.colors}
80
+ legendDomain={chartData.legendDomain}
81
+ tooltipRows={chartData.tooltipRows}
82
+ translations={{ "no-results": empty("no-results") }}
83
+ />
84
+ );
85
+ }
86
+ case ChartType.HeatMap: {
87
+ return (
88
+ <HeatMapWidget
89
+ title={chartData.title}
90
+ data={chartData.data}
91
+ colors={chartData.colors}
92
+ translations={{ "no-results": empty("no-results") }}
93
+ />
94
+ );
95
+ }
96
+ default: {
97
+ const title = chartData.title ?? t(`charts.${chartData.type}.title`, { fallback: `${chartData.type} Chart` });
98
+
99
+ return <ComingSoonChartWidget title={title} />;
100
+ }
51
101
  }
52
102
  };
53
103
 
@@ -7,12 +7,12 @@
7
7
 
8
8
  .overview-grid {
9
9
  display: grid;
10
- gap: 24px;
10
+ gap: 12px;
11
11
  grid-template-columns: repeat(auto-fit, minmax(min(100%, calc(50% - 12px)), 1fr));
12
12
  }
13
13
 
14
14
  .overview-grid-item {
15
- padding: 12px;
15
+ padding: 4px;
16
16
  width: 100%;
17
17
  }
18
18
 
@@ -1,177 +1,13 @@
1
- import type { SeverityLevel, TestStatus } from "@allurereport/core-api";
2
- import { severityLevels, statusesList } from "@allurereport/core-api";
3
- import { ChartDataType, type ChartId, type ChartMode, ChartType, fetchReportJsonData } from "@allurereport/web-commons";
1
+ import { type ChartsResponse, type UIChartsData, createCharts, fetchReportJsonData } from "@allurereport/web-commons";
4
2
  import { signal } from "@preact/signals";
5
3
  import type { StoreSignalState } from "@/stores/types";
6
4
 
7
- interface Point {
8
- x: Date | string | number;
9
- y: number;
10
- }
11
-
12
- interface Slice {
13
- min: number;
14
- max: number;
15
- metadata: { executionId: string };
16
- }
17
-
18
- interface ResponseTrendChartData {
19
- type: ChartType.Trend;
20
- dataType: ChartDataType;
21
- mode: ChartMode;
22
- title?: string;
23
- min: number;
24
- max: number;
25
- points: Record<string, Point>;
26
- slices: Record<string, Slice>;
27
- series: Record<TestStatus | SeverityLevel, string[]>;
28
- }
29
-
30
- interface TrendChartItem {
31
- id: string;
32
- data: Point[];
33
- color: string;
34
- }
35
-
36
- export interface TrendChartData {
37
- type: ChartType.Trend;
38
- dataType: ChartDataType;
39
- mode: ChartMode;
40
- min: number;
41
- max: number;
42
- items: TrendChartItem[];
43
- slices: Slice[];
44
- title?: string;
45
- }
46
-
47
- interface PieSlice {
48
- status: TestStatus;
49
- count: number;
50
- d: string | null;
51
- }
52
-
53
- interface ResponsePieChartData {
54
- type: ChartType.Pie;
55
- title?: string;
56
- percentage: number;
57
- slices: PieSlice[];
58
- }
59
-
60
- export type PieChartData = ResponsePieChartData;
61
-
62
- export type ChartData = TrendChartData | PieChartData;
63
-
64
- type ChartsResponse = Partial<Record<ChartId, ResponseTrendChartData | ResponsePieChartData>>;
65
-
66
- type ChartsData = Record<ChartId, ChartData>;
67
-
68
- const statusColors: Record<TestStatus, string> = {
69
- failed: "var(--bg-support-capella)",
70
- broken: "var(--bg-support-atlas)",
71
- passed: "var(--bg-support-castor)",
72
- skipped: "var(--bg-support-rau)",
73
- unknown: "var(--bg-support-skat)",
74
- };
75
-
76
- const severityColors: Record<SeverityLevel, string> = {
77
- blocker: "var(--bg-support-capella)",
78
- critical: "var(--bg-support-atlas)",
79
- normal: "var(--bg-support-castor)",
80
- minor: "var(--bg-support-rau)",
81
- trivial: "var(--bg-support-skat)",
82
- };
83
-
84
- export const dashboardStore = signal<StoreSignalState<ChartsData>>({
5
+ export const dashboardStore = signal<StoreSignalState<UIChartsData>>({
85
6
  loading: true,
86
7
  error: undefined,
87
8
  data: undefined,
88
9
  });
89
10
 
90
- /**
91
- * Helper function to create chart data for different chart types
92
- *
93
- * @param getChart - Function to get the chart data
94
- * @param getGroups - Function to get the groups
95
- * @param getColor - Function to get the color
96
- * @returns TrendChartData or undefined if the chart data is not available
97
- */
98
- const createTrendChartData = <T extends TestStatus | SeverityLevel>(
99
- getChart: () => ResponseTrendChartData | undefined,
100
- getGroups: () => readonly T[],
101
- getColor: (group: T) => string,
102
- ): TrendChartData | undefined => {
103
- const chart = getChart();
104
- if (!chart) {
105
- return undefined;
106
- }
107
-
108
- const items = getGroups().reduce((acc, group) => {
109
- const pointsByGroupBy =
110
- chart.series[group]?.map((pointId) => ({
111
- x: chart.points[pointId].x,
112
- y: chart.points[pointId].y,
113
- })) ?? [];
114
-
115
- if (pointsByGroupBy.length) {
116
- acc.push({
117
- id: group.charAt(0).toUpperCase() + group.slice(1),
118
- data: pointsByGroupBy,
119
- color: getColor(group),
120
- });
121
- }
122
-
123
- return acc;
124
- }, [] as TrendChartItem[]);
125
-
126
- return {
127
- type: chart.type,
128
- dataType: chart.dataType,
129
- mode: chart.mode,
130
- title: chart.title,
131
- items,
132
- slices: Object.values(chart.slices),
133
- min: chart.min,
134
- max: chart.max,
135
- };
136
- };
137
-
138
- const createStatusTrendChartData = (chartId: ChartId, res: ChartsResponse): TrendChartData | undefined =>
139
- createTrendChartData(
140
- () => res[chartId] as ResponseTrendChartData | undefined,
141
- () => statusesList,
142
- (status) => statusColors[status],
143
- );
144
- const createSeverityTrendChartData = (chartId: ChartId, res: ChartsResponse): TrendChartData | undefined =>
145
- createTrendChartData(
146
- () => res[chartId] as ResponseTrendChartData | undefined,
147
- () => severityLevels,
148
- (severity) => severityColors[severity],
149
- );
150
-
151
- const createaTrendChartData = (
152
- chartId: string,
153
- chartData: ResponseTrendChartData,
154
- res: ChartsResponse,
155
- ): TrendChartData | undefined => {
156
- if (chartData.dataType === ChartDataType.Status) {
157
- return createStatusTrendChartData(chartId, res);
158
- } else if (chartData.dataType === ChartDataType.Severity) {
159
- return createSeverityTrendChartData(chartId, res);
160
- }
161
- };
162
-
163
- const createCharts = (res: ChartsResponse): ChartsData => {
164
- return Object.entries(res).reduce((acc, [chartId, chart]) => {
165
- if (chart.type === ChartType.Trend) {
166
- acc[chartId] = createaTrendChartData(chartId, chart, res);
167
- } else if (chart.type === ChartType.Pie) {
168
- acc[chartId] = chart;
169
- }
170
-
171
- return acc;
172
- }, {} as ChartsData);
173
- };
174
-
175
11
  export const fetchDashboardData = async () => {
176
12
  dashboardStore.value = {
177
13
  ...dashboardStore.value,