mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix: handle better case when workflow id is missing
This commit is contained in:
parent
2db0b140bd
commit
9d6f0c5dec
|
@ -3,6 +3,8 @@ import { convertToDisplayDate } from '@/utils/formatters/dateFormatter';
|
||||||
import { useI18n } from '@/composables/useI18n';
|
import { useI18n } from '@/composables/useI18n';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import { VIEWS } from '@/constants';
|
import { VIEWS } from '@/constants';
|
||||||
|
import { useExecutionsStore } from '@/stores/executions.store';
|
||||||
|
import { useToast } from './useToast';
|
||||||
|
|
||||||
export interface IExecutionUIData {
|
export interface IExecutionUIData {
|
||||||
name: string;
|
name: string;
|
||||||
|
@ -17,6 +19,8 @@ export interface IExecutionUIData {
|
||||||
export function useExecutionHelpers() {
|
export function useExecutionHelpers() {
|
||||||
const i18n = useI18n();
|
const i18n = useI18n();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const executionsStore = useExecutionsStore();
|
||||||
|
const toast = useToast();
|
||||||
|
|
||||||
function getUIDetails(execution: ExecutionSummary): IExecutionUIData {
|
function getUIDetails(execution: ExecutionSummary): IExecutionUIData {
|
||||||
const status = {
|
const status = {
|
||||||
|
@ -72,8 +76,7 @@ export function useExecutionHelpers() {
|
||||||
return ['crashed', 'error'].includes(execution.status) && !execution.retrySuccessId;
|
return ['crashed', 'error'].includes(execution.status) && !execution.retrySuccessId;
|
||||||
}
|
}
|
||||||
|
|
||||||
function openExecutionInNewTab(executionId: string, workflowId?: string) {
|
function openInNewTab(executionId: string, workflowId: string) {
|
||||||
// todo this does not work when workflowId is not set
|
|
||||||
const route = router.resolve({
|
const route = router.resolve({
|
||||||
name: VIEWS.EXECUTION_PREVIEW,
|
name: VIEWS.EXECUTION_PREVIEW,
|
||||||
params: { name: workflowId, executionId },
|
params: { name: workflowId, executionId },
|
||||||
|
@ -81,6 +84,29 @@ export function useExecutionHelpers() {
|
||||||
window.open(route.href, '_blank');
|
window.open(route.href, '_blank');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function openExecutionById(executionId: string): Promise<void> {
|
||||||
|
try {
|
||||||
|
const execution = (await executionsStore.fetchExecution(executionId)) as ExecutionSummary;
|
||||||
|
|
||||||
|
openInNewTab(executionId, execution.workflowId);
|
||||||
|
} catch (e) {
|
||||||
|
toast.showMessage({
|
||||||
|
type: 'error',
|
||||||
|
message: i18n.baseText('nodeView.showError.openExecution.title'),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function openExecutionInNewTab(executionId: string, workflowId?: string): void {
|
||||||
|
// todo this does not work when workflowId is not set
|
||||||
|
if (!workflowId) {
|
||||||
|
void openExecutionById(executionId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
openInNewTab(executionId, workflowId);
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
getUIDetails,
|
getUIDetails,
|
||||||
formatDate,
|
formatDate,
|
||||||
|
|
|
@ -2614,7 +2614,7 @@
|
||||||
"executionUsage.button.upgrade": "Upgrade plan",
|
"executionUsage.button.upgrade": "Upgrade plan",
|
||||||
"executionUsage.expired.text": "Your trial is over. Upgrade now to keep your data.",
|
"executionUsage.expired.text": "Your trial is over. Upgrade now to keep your data.",
|
||||||
"executionUsage.ranOutOfExecutions.text": "You’re out of executions. Upgrade your plan to keep automating.",
|
"executionUsage.ranOutOfExecutions.text": "You’re out of executions. Upgrade your plan to keep automating.",
|
||||||
"executionsView.missingExeuctionId": "Could not find execution. Make sure workflow saving is turned on.",
|
"openExecution.missingExeuctionId": "Could not find execution. Make sure workflow saving is turned on.",
|
||||||
"type.string": "String",
|
"type.string": "String",
|
||||||
"type.number": "Number",
|
"type.number": "Number",
|
||||||
"type.dateTime": "Date & Time",
|
"type.dateTime": "Date & Time",
|
||||||
|
|
|
@ -25,6 +25,7 @@ const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
const { callDebounced } = useDebounce();
|
const { callDebounced } = useDebounce();
|
||||||
|
|
||||||
const workflowHelpers = useWorkflowHelpers({ router });
|
const workflowHelpers = useWorkflowHelpers({ router });
|
||||||
const nodeHelpers = useNodeHelpers();
|
const nodeHelpers = useNodeHelpers();
|
||||||
|
|
||||||
|
@ -104,8 +105,10 @@ async function fetchExecution() {
|
||||||
if (!currentExecution.value) {
|
if (!currentExecution.value) {
|
||||||
toast.showMessage({
|
toast.showMessage({
|
||||||
type: 'error',
|
type: 'error',
|
||||||
message: i18n.baseText('executionsView.missingExeuctionId'),
|
message: i18n.baseText('openExecution.missingExeuctionId'),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue