Skip to content

Commit 669fa07

Browse files
review amends
1 parent 3222512 commit 669fa07

File tree

4 files changed

+14
-47
lines changed

4 files changed

+14
-47
lines changed

src/components/cylc/ViewToolbar.vue

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,6 @@ export default {
151151
color = null
152152
callback = null
153153
disabled = false
154-
if (control.items && control.items.length) {
155-
disabled = control.items[0].disabled
156-
}
157154
// set callback and color
158155
switch (control.action) {
159156
case 'toggle':

src/services/mock/json/workflows/one.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
"_typename": "Family"
9090
}
9191
],
92-
"descendants": ["GOOD", "failed", "retrying"],
92+
"descendants": ["failed", "retrying"],
9393
"childTasks": [
9494
{
9595
"name": "failed",
@@ -133,7 +133,7 @@
133133
"_typename": "Family"
134134
}
135135
],
136-
"descendants": ["GOOD", "eventually_succeeded", "succeeded"],
136+
"descendants": ["eventually_succeeded", "succeeded"],
137137
"childTasks": [
138138
{
139139
"name": "eventually_succeeded",

src/views/Graph.vue

Lines changed: 12 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -432,20 +432,7 @@ export default {
432432
* @returns {Family[]} array containing nested structure of families
433433
*/
434434
treeDropDownFamily () {
435-
if (this.familyArrayStore.length) {
436-
const ret = []
437-
for (const rootFamily of this.getTree()) {
438-
ret.push(rootFamily)
439-
}
440-
return ret
441-
} else {
442-
return [
443-
{
444-
name: 'No families',
445-
disabled: true
446-
}
447-
]
448-
}
435+
return this.familyArrayStore.length ? this.getTree() : [{ name: 'No families', disabled: true }]
449436
},
450437
/**
451438
* Gets the array of cycles for use in vuetify toolbar drop down
@@ -563,7 +550,7 @@ export default {
563550
* @returns {String[]} array of family names
564551
*/
565552
familyArrayStore () {
566-
return this.namespaces.filter((family) => { return family.name !== 'root' }).map((family) => family.name)
553+
return this.namespaces.flatMap((family) => family.name !== 'root' ? family.name : [])
567554
},
568555
controlGroups () {
569556
return [
@@ -673,24 +660,15 @@ export default {
673660
* @returns {Family[]} array containing nested structure of families
674661
*/
675662
getTree () {
676-
const counter = {
677-
value: 0,
678-
next () {
679-
this.value = this.value + 1
680-
return this.value
681-
}
682-
}
683-
684663
const root = {
685-
id: counter.next(),
686664
name: 'root',
687665
children: []
688666
}
689667
if (this.workflows) {
690668
const tokens = this.workflows[0].tokens.clone({ cycle: '$namespace|root' })
691669
const node = this.cylcTree.$index[tokens.id]
692670
if (node) {
693-
return this.getTreeHelper(root, node, counter).children
671+
return this.getTreeHelper(root, node).children
694672
}
695673
}
696674
},
@@ -701,27 +679,23 @@ export default {
701679
* @property {number} counter - counter used for index
702680
* @returns {Family} nested structure of families
703681
*/
704-
getTreeHelper (store, node, counter) {
682+
getTreeHelper (store, node) {
705683
let tempItem
706684
const isParent = this.collapseFamily.includes(node.name)
707685
const isAncestor = this.allParentLookUp[node.name].some(element => {
708686
return this.collapseFamily.includes(element)
709687
})
710688
const disabled = isParent || isAncestor
711689
for (const childFamily of node.node.descendants) {
712-
if (this.namespaces.some((obj) => obj.name === childFamily)) {
713-
const childTokens = this.workflows[0].tokens.clone({ cycle: `$namespace|${childFamily}` })
714-
const childNode = this.cylcTree.$index[childTokens.id]
715-
if (childNode.node.firstParent.id === node.id) {
716-
tempItem = {
717-
id: counter.next(),
718-
name: childFamily,
719-
children: [],
720-
disabled
721-
}
722-
this.getTreeHelper(tempItem, childNode, counter)
723-
store.children.push(tempItem)
690+
const childNamespace = this.namespaces.find((obj) => obj.name === childFamily)
691+
if (childNamespace?.node.firstParent.id === node.id) {
692+
tempItem = {
693+
name: childFamily,
694+
children: [],
695+
disabled
724696
}
697+
this.getTreeHelper(tempItem, childNamespace)
698+
store.children.push(tempItem)
725699
}
726700
}
727701
return store

tests/unit/views/graph.vue.spec.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,26 +154,22 @@ describe('Graph view', () => {
154154
}
155155
})
156156

157-
// wrapper.vm.nextTick()
158157
expect(wrapper.vm.getTree()).toMatchObject(
159158
[
160159
{
161160
children: [
162161
{
163162
children: [],
164163
disabled: false,
165-
id: 3,
166164
name: 'SUCCEEDED',
167165
},
168166
],
169167
disabled: false,
170-
id: 2,
171168
name: 'GOOD',
172169
},
173170
{
174171
children: [],
175172
disabled: false,
176-
id: 4,
177173
name: 'BAD',
178174
},
179175
]

0 commit comments

Comments
 (0)