Files
Automata/packages/editor-ui/src/mixins/executionsHelpers.ts
Omar Ajoue 67b88f75f4 feat(core): Add a warning to error workflows that cannot be started due to permission or settings (#6961)
Github issue / Community forum post (link here to close automatically):

This PR aims to address an issue where an Error workflow cannot be
started, either due to insufficient permissions or because its settings
prevent it from being called.

The way of addressing this is by creating a failed execution for the
appointed error workflow stating the error, as can be seen below.

This means the execution itself won't start, as it's prevented before
the execution beings, but we save a "stub" execution to show the error.

![Screenshot 2023-08-17 at 16 17
02](https://github.com/n8n-io/n8n/assets/219272/d8ec0144-13c5-4b11-b91c-a6b440816ccf)
2023-08-22 15:26:33 +02:00

80 lines
2.5 KiB
TypeScript

import { defineComponent } from 'vue';
import { mapStores } from 'pinia';
import { useWorkflowsStore } from '@/stores/workflows.store';
import { i18n as locale } from '@/plugins/i18n';
import { genericHelpers } from './genericHelpers';
import type { IExecutionsSummary } from 'n8n-workflow';
export interface IExecutionUIData {
name: string;
label: string;
startTime: string;
runningTime: string;
}
export const executionHelpers = defineComponent({
mixins: [genericHelpers],
computed: {
...mapStores(useWorkflowsStore),
executionId(): string {
return this.$route.params.executionId;
},
workflowName(): string {
return this.workflowsStore.workflowName;
},
currentWorkflow(): string {
return this.$route.params.name || this.workflowsStore.workflowId;
},
executions(): IExecutionsSummary[] {
return this.workflowsStore.currentWorkflowExecutions;
},
activeExecution(): IExecutionsSummary | null {
return this.workflowsStore.activeWorkflowExecution;
},
},
methods: {
getExecutionUIDetails(execution: IExecutionsSummary): IExecutionUIData {
const status = {
name: 'unknown',
startTime: this.formatDate(execution.startedAt),
label: 'Status unknown',
runningTime: '',
};
if (execution.status === 'waiting') {
status.name = 'waiting';
status.label = this.$locale.baseText('executionsList.waiting');
} else if (execution.status === 'canceled') {
status.label = this.$locale.baseText('executionsList.canceled');
} else if (execution.status === 'running' || execution.status === 'new') {
status.name = 'running';
status.label = this.$locale.baseText('executionsList.running');
} else if (execution.status === 'success') {
status.name = 'success';
status.label = this.$locale.baseText('executionsList.succeeded');
} else if (execution.status === 'failed' || execution.status === 'crashed') {
status.name = 'error';
status.label = this.$locale.baseText('executionsList.error');
}
if (!execution.status) execution.status = 'unknown';
if (execution.startedAt && execution.stoppedAt) {
const stoppedAt = execution.stoppedAt
? new Date(execution.stoppedAt).getTime()
: Date.now();
status.runningTime = this.displayTimer(
stoppedAt - new Date(execution.startedAt).getTime(),
true,
);
}
return status;
},
formatDate(fullDate: Date | string | number) {
const { date, time } = this.convertToDisplayDate(fullDate);
return locale.baseText('executionsList.started', { interpolate: { time, date } });
},
},
});