fix: Handle error when workflow does not exist or is inaccessible (#4831)

This commit is contained in:
Alex Grozav 2022-12-06 14:35:57 +02:00 committed by GitHub
parent 4528f34462
commit b71295e4de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2187,7 +2187,7 @@ export default mixins(
const executionId = this.$route.params.id; const executionId = this.$route.params.id;
await this.openExecution(executionId); await this.openExecution(executionId);
} else { } else {
const result = this.uiStore.stateIsDirty;; const result = this.uiStore.stateIsDirty;
if (result) { if (result) {
const confirmModal = await this.confirmModal( const confirmModal = await this.confirmModal(
this.$locale.baseText('generic.unsavedWork.confirmMessage.message'), this.$locale.baseText('generic.unsavedWork.confirmMessage.message'),
@ -2210,17 +2210,18 @@ export default mixins(
workflowId = this.$route.params.name; workflowId = this.$route.params.name;
} }
if (workflowId !== null) { if (workflowId !== null) {
const workflow = await this.restApi().getWorkflow(workflowId); let workflow;
if (!workflow) { try {
workflow = await this.restApi().getWorkflow(workflowId);
} catch (error) {
this.$showError(error, this.$locale.baseText('openWorkflow.workflowNotFoundError'));
this.$router.push({ this.$router.push({
name: VIEWS.NEW_WORKFLOW, name: VIEWS.NEW_WORKFLOW,
}); });
this.$showMessage({ }
title: 'Error',
message: this.$locale.baseText('openWorkflow.workflowNotFoundError'), if (workflow) {
type: 'error',
});
} else {
this.$titleSet(workflow.name, 'IDLE'); this.$titleSet(workflow.name, 'IDLE');
// Open existing workflow // Open existing workflow
await this.openWorkflow(workflowId); await this.openWorkflow(workflowId);