Skip to content

Commit 8ca0008

Browse files
committed
Fix tests and task/cycle menu
1 parent 78ba7ff commit 8ca0008

File tree

6 files changed

+36
-9
lines changed

6 files changed

+36
-9
lines changed

src/components/cylc/cylcObject/Menu.vue

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ import Mutation from '@/components/cylc/Mutation'
136136
import {
137137
mdiPencil
138138
} from '@mdi/js'
139-
import { mapState } from 'vuex'
139+
import { mapGetters, mapState } from 'vuex'
140140
141141
export default {
142142
name: 'CylcObjectMenu',
@@ -160,6 +160,7 @@ export default {
160160
dialogKey: false,
161161
expanded: false,
162162
node: null,
163+
workflowStatus: null,
163164
mutations: [],
164165
isLoadingMutations: true,
165166
showMenu: false,
@@ -181,6 +182,7 @@ export default {
181182
},
182183
183184
computed: {
185+
...mapGetters('workflows', ['getNodes']),
184186
primaryMutations () {
185187
return this.$workflowService.primaryMutations[this.node.type] || []
186188
},
@@ -239,7 +241,15 @@ export default {
239241
}
240242
},
241243
isDisabled (mutation, authorised) {
242-
if (((!mutation._validStates.includes(this.node.node.status))) || !authorised) {
244+
if (this.node.type !== 'workflow') {
245+
this.workflowStatus = this.getNodes(
246+
'workflow', [this.node.tokens.workflow_id])[0].node.status
247+
} else {
248+
this.workflowStatus = this.node.node.status
249+
}
250+
if (
251+
(!mutation._validStates.includes(this.workflowStatus)) ||
252+
!authorised) {
243253
return true
244254
}
245255
return false

src/services/mock/json/IntrospectionQuery.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1427,7 +1427,7 @@
14271427
"fields": [
14281428
{
14291429
"name": "broadcast",
1430-
"description": "Override `[runtime]` configurations in a running workflow.\n\nUses for broadcast include making temporary changes to task\nbehaviour, and task-to-downstream-task communication via\nenvironment variables.\n\nA broadcast can set/override any `[runtime]` configuration for all\ncycles or for a specific cycle. If a task is affected by\nspecific-cycle and all-cycle broadcasts at the same time, the\nspecific takes precedence.\n\nBroadcasts can also target all tasks, specific tasks or families of\ntasks. If a task is affected by broadcasts to multiple ancestor\nnamespaces (tasks it inherits from), the result is determined by\nnormal `[runtime]` inheritance.\n\nBroadcasts are applied at the time of job submission.\n\nBroadcasts persist, even across restarts. Broadcasts made to\nspecific cycle points will expire when the cycle point is older\nthan the oldest active cycle point in the workflow.\n\nActive broadcasts can be revoked using the \"clear\" mode.\nAny broadcasts matching the specified cycle points and\nnamespaces will be revoked.\n\nNote: a \"clear\" broadcast for a specific cycle or namespace does\n*not* clear all-cycle or all-namespace broadcasts.",
1430+
"description": "Override `[runtime]` configurations in a running workflow.\n\nUses for broadcast include making temporary changes to task\nbehaviour, and task-to-downstream-task communication via\nenvironment variables.\n\nA broadcast can set/override any `[runtime]` configuration for all\ncycles or for a specific cycle. If a task is affected by\nspecific-cycle and all-cycle broadcasts at the same time, the\nspecific takes precedence.\n\nBroadcasts can also target all tasks, specific tasks or families of\ntasks. If a task is affected by broadcasts to multiple ancestor\nnamespaces (tasks it inherits from), the result is determined by\nnormal `[runtime]` inheritance.\n\nBroadcasts are applied at the time of job submission.\n\nBroadcasts persist, even across restarts. Broadcasts made to\nspecific cycle points will expire when the cycle point is older\nthan the oldest active cycle point in the workflow.\n\nActive broadcasts can be revoked using the \"clear\" mode.\nAny broadcasts matching the specified cycle points and\nnamespaces will be revoked.\n\nNote: a \"clear\" broadcast for a specific cycle or namespace does\n*not* clear all-cycle or all-namespace broadcasts.\n Valid for: paused, running workflows.",
14311431
"args": [
14321432
{
14331433
"name": "cutoff",

src/utils/aotf.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import {
5050
import Alert from '@/model/Alert.model'
5151
import store from '@/store/index'
5252
import { Tokens } from '@/utils/uid'
53+
import { WorkflowState } from '@/model/WorkflowState.model'
5354

5455
// Typedef imports
5556
/* eslint-disable no-unused-vars, no-duplicate-imports */
@@ -444,15 +445,20 @@ export function processMutations (mutations, types) {
444445
* @return {Array<String>}
445446
*/
446447
export function getStates (text) {
447-
const defaultStates = ['running', 'paused', 'stopping', 'stopped']
448+
const defaultStates = [
449+
WorkflowState.RUNNING.name,
450+
WorkflowState.PAUSED.name,
451+
WorkflowState.STOPPING.name,
452+
WorkflowState.STOPPED.name
453+
]
448454
if (!text) {
449455
return defaultStates
450456
}
451457
const re = /Valid\sfor:\s(.*)\sworkflows./
452458
// default to all workflow states
453459
const validStates = text.match(re)
454460
if (validStates) {
455-
return validStates[1]
461+
return validStates[1].replace(/\s/g, '').split(',')
456462
}
457463
return defaultStates
458464
}

tests/e2e/support/graphql.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const MUTATIONS = [
2727
in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
2828
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui
2929
officia deserunt mollit anim id est laborum.
30+
Valid for: running workflows.
3031
`,
3132
args: [
3233
{
@@ -43,6 +44,7 @@ const MUTATIONS = [
4344
_title: 'Unauthorised Mutation',
4445
description: `
4546
A mutation user will not be authorised for.
47+
Valid for: running workflows.
4648
`,
4749
args: [
4850
{

tests/unit/components/cylc/tree/tree.data.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ const simpleWorkflowTree4Nodes = [
2626
type: 'workflow',
2727
node: {
2828
__typename: 'Workflow',
29-
state: 'running'
29+
state: 'running',
30+
node: {
31+
status: 'running'
32+
}
3033
},
3134
children: [
3235
{

tests/unit/utils/aotf.spec.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,26 @@ describe('aotf (Api On The Fly)', () => {
5959
})
6060
})
6161

62+
describe('getStates', () => {
63+
it('gets valid states', () => {
64+
expect(aotf.getStates('Valid for: running, stopped workflows.')).to.deep.equal(['running', 'stopped'])
65+
})
66+
})
67+
6268
describe('processMutations', () => {
6369
it('should add computed fields', () => {
6470
const input = {
6571
name: 'fooBar',
66-
description: 'Short description.\n\nLong\ndescription.\nValid for: stopped workflows.',
72+
description: 'Short description.\n\nLong\ndescription.\nValid for: stopped, paused workflows.',
6773
args: []
6874
}
6975
const output = {
7076
...input,
7177
_title: 'Foo Bar',
7278
_icon: aotf.mutationIcons[''],
7379
_shortDescription: 'Short description.',
74-
_help: 'Long\ndescription.\nValid for: stopped workflows.',
75-
_validStates: 'stopped'
80+
_help: 'Long\ndescription.\nValid for: stopped, paused workflows.',
81+
_validStates: ['stopped', 'paused']
7682
}
7783
aotf.processMutations([input], null)
7884
expect(input).to.deep.equal(output)

0 commit comments

Comments
 (0)