Skip to content

Commit 296d5b4

Browse files
feat(editor): Show specific content when 0 data on insights (#14609)
1 parent 9c34e3d commit 296d5b4

File tree

4 files changed

+44
-1
lines changed

4 files changed

+44
-1
lines changed

packages/frontend/editor-ui/src/features/insights/components/InsightsSummary.test.ts

+9
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,15 @@ describe('InsightsSummary', () => {
8282
{ id: 'averageRunTime', value: 2.5, deviation: null, unit: 's', deviationUnit: 's' },
8383
],
8484
],
85+
[
86+
[
87+
{ id: 'total', value: 0, deviation: 0, unit: '', deviationUnit: '%' },
88+
{ id: 'failed', value: 0, deviation: 0, unit: '', deviationUnit: '%' },
89+
{ id: 'failureRate', value: 0, deviation: 0, unit: '%', deviationUnit: 'pp' },
90+
{ id: 'timeSaved', value: 0, deviation: 0, unit: 'h', deviationUnit: 'h' },
91+
{ id: 'averageRunTime', value: 0, deviation: 0, unit: 's', deviationUnit: 's' },
92+
],
93+
],
8594
])('should render the summary correctly', (summary) => {
8695
const { html } = renderComponent({
8796
props: {

packages/frontend/editor-ui/src/features/insights/components/InsightsSummary.vue

+21-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ const summaryTitles = computed<Record<keyof InsightsSummary, string>>(() => ({
3232
averageRunTime: i18n.baseText('insights.banner.title.averageRunTime'),
3333
}));
3434
35+
const summaryHasNoData = computed(() => {
36+
const summaryValues = Object.values(props.summary);
37+
return summaryValues.length > 0 && summaryValues.every((summary) => !summary.value);
38+
});
39+
3540
const summaryWithRouteLocations = computed(() =>
3641
props.summary.map((s) => ({
3742
...s,
@@ -82,7 +87,15 @@ const trackTabClick = (insightType: keyof InsightsSummary) => {
8287
<small :class="$style.days">{{
8388
i18n.baseText('insights.lastNDays', { interpolate: { count: lastNDays } })
8489
}}</small>
85-
<span v-if="value === 0 && id === 'timeSaved'" :class="$style.empty">
90+
<span v-if="summaryHasNoData" :class="$style.noData">
91+
<N8nTooltip placement="bottom">
92+
<template #content>
93+
{{ i18n.baseText('insights.banner.noData.tooltip') }}
94+
</template>
95+
<em>{{ i18n.baseText('insights.banner.noData') }}</em>
96+
</N8nTooltip>
97+
</span>
98+
<span v-else-if="value === 0 && id === 'timeSaved'" :class="$style.empty">
8699
<em>--</em>
87100
<small>
88101
<N8nTooltip placement="bottom">
@@ -243,6 +256,13 @@ const trackTabClick = (insightType: keyof InsightsSummary) => {
243256
}
244257
}
245258
}
259+
260+
.noData {
261+
em {
262+
color: var(--color-text-light);
263+
font-size: var(--font-size-m);
264+
}
265+
}
246266
}
247267
248268
.positive {

packages/frontend/editor-ui/src/features/insights/components/__snapshots__/InsightsSummary.test.ts.snap

+12
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,15 @@ exports[`InsightsSummary > should render the summary correctly 5`] = `
9898
</ul>
9999
</div>"
100100
`;
101+
102+
exports[`InsightsSummary > should render the summary correctly 6`] = `
103+
"<div class="insights">
104+
<ul data-test-id="insights-summary-tabs">
105+
<li data-test-id="insights-summary-tab-total"><a to="[object Object]" exact-active-class="activeTab"><strong><span class="el-only-child__content el-tooltip__trigger el-tooltip__trigger"> Prod. executions</span><!--teleport start--><!--teleport end--></strong><small class="days">Last 7 days</small><span class="noData"><em class="el-tooltip__trigger">Collecting...</em><!--teleport start--><!--teleport end--></span></a></li>
106+
<li data-test-id="insights-summary-tab-failed"><a to="[object Object]" exact-active-class="activeTab"><strong><span class="el-only-child__content el-tooltip__trigger el-tooltip__trigger"> Failed prod. executions</span><!--teleport start--><!--teleport end--></strong><small class="days">Last 7 days</small><span class="noData"><em class="el-tooltip__trigger">Collecting...</em><!--teleport start--><!--teleport end--></span></a></li>
107+
<li data-test-id="insights-summary-tab-failureRate"><a to="[object Object]" exact-active-class="activeTab"><strong><span class="el-only-child__content el-tooltip__trigger el-tooltip__trigger"> Failure rate</span><!--teleport start--><!--teleport end--></strong><small class="days">Last 7 days</small><span class="noData"><em class="el-tooltip__trigger">Collecting...</em><!--teleport start--><!--teleport end--></span></a></li>
108+
<li data-test-id="insights-summary-tab-timeSaved"><a to="[object Object]" exact-active-class="activeTab"><strong><span class="el-only-child__content el-tooltip__trigger el-tooltip__trigger"> Time saved</span><!--teleport start--><!--teleport end--></strong><small class="days">Last 7 days</small><span class="noData"><em class="el-tooltip__trigger">Collecting...</em><!--teleport start--><!--teleport end--></span></a></li>
109+
<li data-test-id="insights-summary-tab-averageRunTime"><a to="[object Object]" exact-active-class="activeTab"><strong><span class="el-only-child__content el-tooltip__trigger el-tooltip__trigger"> Run time (avg.)</span><!--teleport start--><!--teleport end--></strong><small class="days">Last 7 days</small><span class="noData"><em class="el-tooltip__trigger">Collecting...</em><!--teleport start--><!--teleport end--></span></a></li>
110+
</ul>
111+
</div>"
112+
`;

packages/frontend/editor-ui/src/plugins/i18n/locales/en.json

+2
Original file line numberDiff line numberDiff line change
@@ -3081,6 +3081,8 @@
30813081
"insights.lastNDays": "Last {count} days",
30823082
"insights.banner.timeSaved.tooltip": "No estimate available yet. To see potential time savings, {link} to each workflow from workflow settings.",
30833083
"insights.banner.timeSaved.tooltip.link.text": "add time estimates",
3084+
"insights.banner.noData": "Collecting...",
3085+
"insights.banner.noData.tooltip": "Metrics can take up to 24 hours to appear. If you have just updated or started using n8n, please check back later.",
30843086
"insights.banner.title.total": "Prod. executions",
30853087
"insights.banner.title.failed": "Failed prod. executions",
30863088
"insights.banner.title.failureRate": "Failure rate",

0 commit comments

Comments
 (0)