From 14e4ede54155120e2156334583e5bf5029036a15 Mon Sep 17 00:00:00 2001 From: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com> Date: Fri, 29 Apr 2022 18:11:55 +0100 Subject: [PATCH] aotf: fix mutations in workflow toolbar --- src/components/cylc/workflow/Toolbar.vue | 33 +++++++++++++----------- src/services/workflow.service.js | 15 ++++++----- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/src/components/cylc/workflow/Toolbar.vue b/src/components/cylc/workflow/Toolbar.vue index 3c1590bd6..5f3102a31 100644 --- a/src/components/cylc/workflow/Toolbar.vue +++ b/src/components/cylc/workflow/Toolbar.vue @@ -260,31 +260,34 @@ export default { }, methods: { onClickPlay () { - const ret = this.$workflowService.mutate( + this.$workflowService.mutate( 'play', this.currentWorkflow.id - ) - if (ret[0] === mutationStatus.SUCCEEDED) { - this.expecting.play = !this.isRunning - } + ).then(ret => { + if (ret[0] === mutationStatus.SUCCEEDED) { + this.expecting.play = !this.isRunning + } + }) }, onClickReleaseHold () { - const ret = this.$workflowService.mutate( + this.$workflowService.mutate( this.isPaused ? 'resume' : 'pause', this.currentWorkflow.id - ) - if (ret[0] === mutationStatus.SUCCEEDED) { - this.expecting.paused = !this.isPaused - } + ).then(ret => { + if (ret[0] === mutationStatus.SUCCEEDED) { + this.expecting.paused = !this.isPaused + } + }) }, async onClickStop () { - const ret = this.$workflowService.mutate( + this.$workflowService.mutate( 'stop', this.currentWorkflow.id - ) - if (ret[0] === mutationStatus.SUCCEEDED) { - this.expecting.stop = WorkflowState.STOPPING - } + ).then(ret => { + if (ret[0] === mutationStatus.SUCCEEDED) { + this.expecting.stop = WorkflowState.STOPPING + } + }) }, toggleExtended () { this.extended = !this.extended diff --git a/src/services/workflow.service.js b/src/services/workflow.service.js index eecf5de9d..ad6ad6392 100644 --- a/src/services/workflow.service.js +++ b/src/services/workflow.service.js @@ -67,7 +67,6 @@ class WorkflowService { this.subscriptions = {} // mutations defaults - this.associations = null this.primaryMutations = primaryMutations this.mutationsAndTypes = this.loadMutations() @@ -85,11 +84,11 @@ class WorkflowService { * * @param {String} mutationName * @param {String} id - * @returns {Promise} + * @returns {Promise} */ - mutate (mutationName, id) { - const mutation = this.getMutation(mutationName) - return mutate( + async mutate (mutationName, id) { + const mutation = await this.getMutation(mutationName) + return await mutate( mutation, getMutationArgsFromTokens( mutation, @@ -121,9 +120,11 @@ class WorkflowService { * Return a mutation by name. * * @param {String} mutationName + * @returns {Promise} */ - getMutation (mutationName) { - return this.mutations.find(mutation => mutation.name === mutationName) + async getMutation (mutationName) { + const { mutations } = await this.mutationsAndTypes + return mutations.find(mutation => mutation.name === mutationName) } // --- GraphQL query subscriptions