File tree Expand file tree Collapse file tree 3 files changed +33
-5
lines changed
components/cylc/cylcObject Expand file tree Collapse file tree 3 files changed +33
-5
lines changed Original file line number Diff line number Diff line change @@ -59,12 +59,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
59
59
<v-list-item
60
60
v-for =" { mutation, requiresInfo, authorised } in displayMutations"
61
61
:key =" mutation.name"
62
- :disabled =" ! authorised"
62
+ :disabled =" isDisabled(mutation, authorised) "
63
63
@click.stop =" enact(mutation, requiresInfo)"
64
64
class =" c-mutation"
65
65
>
66
66
<v-list-item-avatar >
67
- <v-icon :disabled =" ! authorised" large >
67
+ <v-icon :disabled =" isDisabled(mutation, authorised) " large >
68
68
{{ mutation._icon }}
69
69
</v-icon >
70
70
</v-list-item-avatar >
@@ -232,12 +232,18 @@ export default {
232
232
233
233
methods: {
234
234
isEditable (authorised , mutation ) {
235
- if (! authorised || mutation .name === ' log' ) {
235
+ if (mutation .name === ' log' || this . isDisabled (mutation, authorised) ) {
236
236
return true
237
237
} else {
238
238
return false
239
239
}
240
240
},
241
+ isDisabled (mutation , authorised ) {
242
+ if (((mutation ._validStates .indexOf (this .node .node .status )) === - 1 ) || ! authorised) {
243
+ return true
244
+ }
245
+ return false
246
+ },
241
247
openDialog (mutation ) {
242
248
if (mutation .name === ' log' ) {
243
249
this .showMenu = false
Original file line number Diff line number Diff line change @@ -432,9 +432,30 @@ export function processMutations (mutations, types) {
432
432
mutation . _icon = mutationIcons [ mutation . name ] || mutationIcons [ '' ]
433
433
mutation . _shortDescription = getMutationShortDesc ( mutation . description )
434
434
mutation . _help = getMutationExtendedDesc ( mutation . description )
435
+ mutation . _validStates = getStates ( mutation . description )
435
436
processArguments ( mutation , types )
436
437
}
437
438
}
439
+ /**
440
+ * Get the workflow states that the mutation is valid for.
441
+ *
442
+ * @export
443
+ * @param {string= } text - Full mutation description.
444
+ * @return {Array<String> }
445
+ */
446
+ export function getStates ( text ) {
447
+ const defaultStates = [ 'running' , 'paused' , 'stopping' , 'stopped' ]
448
+ if ( ! text ) {
449
+ return defaultStates
450
+ }
451
+ const re = / V a l i d \s f o r : \s ( .* ) \s w o r k f l o w s ./
452
+ // default to all workflow states
453
+ const validStates = text . match ( re )
454
+ if ( validStates ) {
455
+ return validStates [ 1 ]
456
+ }
457
+ return defaultStates
458
+ }
438
459
439
460
/**
440
461
* Get the first part of a mutation description (up to the first double newline).
Original file line number Diff line number Diff line change @@ -63,15 +63,16 @@ describe('aotf (Api On The Fly)', () => {
63
63
it ( 'should add computed fields' , ( ) => {
64
64
const input = {
65
65
name : 'fooBar' ,
66
- description : 'Short description.\n\nLong\ndescription.' ,
66
+ description : 'Short description.\n\nLong\ndescription.\nValid for: [\'stopped\'] workflows. ' ,
67
67
args : [ ]
68
68
}
69
69
const output = {
70
70
...input ,
71
71
_title : 'Foo Bar' ,
72
72
_icon : aotf . mutationIcons [ '' ] ,
73
73
_shortDescription : 'Short description.' ,
74
- _help : 'Long\ndescription.'
74
+ _help : 'Long\ndescription.\nValid for: [\'stopped\'] workflows.' ,
75
+ _validStates : "['stopped']"
75
76
}
76
77
aotf . processMutations ( [ input ] , null )
77
78
expect ( input ) . to . deep . equal ( output )
You can’t perform that action at this time.
0 commit comments