fix(core): Handle insights by workflow table for deleted workflows (#18496)

This commit is contained in:
Guillaume Jacquart
2025-08-18 17:49:21 +02:00
committed by GitHub
parent 9d48a44958
commit 741dd693a4
4 changed files with 47 additions and 22 deletions

View File

@@ -69,10 +69,7 @@ describe('insightsSummarySchema', () => {
});
describe('insightsByWorkflowSchema', () => {
test.each([
{
name: 'valid workflow insights',
value: {
const validInsightsByWorkflow = {
count: 2,
data: [
{
@@ -89,6 +86,25 @@ describe('insightsByWorkflowSchema', () => {
timeSaved: 50,
},
],
};
test.each([
{
name: 'valid workflow insights',
value: validInsightsByWorkflow,
expected: true,
},
{
name: 'workflow insights with nullable workflow id and project id',
value: {
...validInsightsByWorkflow,
data: [
{
...validInsightsByWorkflow.data[0],
workflowId: null,
projectId: null,
},
],
},
expected: true,
},

View File

@@ -48,9 +48,11 @@ export const insightsByWorkflowDataSchemas = {
data: z.array(
z
.object({
workflowId: z.string(),
// Workflow id will be null if the workflow has been deleted
workflowId: z.string().nullable(),
workflowName: z.string(),
projectId: z.string(),
// Project id will be null if the project has been deleted
projectId: z.string().nullable(),
projectName: z.string(),
total: z.number(),
succeeded: z.number(),

View File

@@ -30,9 +30,9 @@ const summaryParser = z
const aggregatedInsightsByWorkflowParser = z
.object({
workflowId: z.string(),
workflowId: z.string().nullable(),
workflowName: z.string(),
projectId: z.string(),
projectId: z.string().nullable(),
projectName: z.string(),
total: z.union([z.number(), z.string()]).transform((value) => Number(value)),
succeeded: z.union([z.number(), z.string()]).transform((value) => Number(value)),

View File

@@ -168,21 +168,28 @@ watch(sortBy, (newValue) => {
@update:options="emit('update:options', $event)"
>
<template #[`item.workflowName`]="{ item }">
<router-link
:to="getWorkflowLink(item)"
:class="$style.link"
@click="trackWorkflowClick(item)"
<component
:is="item.workflowId ? 'router-link' : 'div'"
v-bind="
item.workflowId
? {
to: getWorkflowLink(item),
class: $style.link,
onClick: () => trackWorkflowClick(item),
}
: {}
"
>
<N8nTooltip :content="item.workflowName" placement="top">
<div :class="$style.ellipsis">
{{ item.workflowName }}
</div>
</N8nTooltip>
</router-link>
</component>
</template>
<template #[`item.timeSaved`]="{ item, value }">
<router-link
v-if="!item.timeSaved"
v-if="!item.timeSaved && item.workflowId"
:to="getWorkflowLink(item, { settings: 'true' })"
:class="$style.link"
>