Skip to content

Commit 6cd68ef

Browse files
committed
Only show latest state tasks for workflows, not workflow dirs/groups
We cannot show the true latest tasks for groups, and it is unclear what workflow each task belongs to
1 parent 8f947c8 commit 6cd68ef

File tree

3 files changed

+15
-18
lines changed

3 files changed

+15
-18
lines changed

src/components/cylc/TaskStateBadge.vue

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626
:open-delay="400"
2727
>
2828
{{ value }} {{ displayName }} task{{ value > 1 ? 's': '' }}.
29-
<template v-if="latestTasks.length">
29+
<template v-if="latestTasks?.length">
3030
Latest:
3131
<span
32-
v-for="(task, index) in latestTasks.slice(0, maxLatestTasks)"
33-
:key="index"
32+
v-for="task in latestTasks"
33+
:key="task"
3434
class="text-grey-lighten-1"
3535
>
3636
<br/>{{ task }}
@@ -56,10 +56,6 @@ const props = defineProps({
5656
type: Array,
5757
default: () => [],
5858
},
59-
maxLatestTasks: {
60-
type: Number,
61-
default: 5,
62-
},
6359
})
6460
6561
const displayName = computed(

src/components/cylc/tree/GScanTreeItem.vue

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,13 @@ const taskStatesOrdered = [
9999
/**
100100
* Get aggregated task state totals for all descendents of a node.
101101
*
102+
* Also get latest state tasks for workflow nodes.
103+
*
102104
* @param {Object} node
103105
* @param {Record<string, number>} stateTotals - Accumulator for state totals.
104-
* @param {Record<string, string[]>} latestTasks - Accumulator for latest tasks.
105106
*/
106-
function getStatesInfo (node, stateTotals = {}, latestTasks = {}) {
107+
function getStatesInfo (node, stateTotals = {}) {
108+
const latestTasks = {}
107109
// if we aren't at the end of the node tree, continue recurse until we hit something other then a workflow part
108110
if (node.type === 'workflow-part' && node.children) {
109111
// at every branch, recurse all child nodes except stopped workflows
@@ -118,19 +120,19 @@ function getStatesInfo (node, stateTotals = {}, latestTasks = {}) {
118120
// the non-zero state totals from this node with all the others from the tree
119121
for (const state of taskStatesOrdered) {
120122
let nodeTotal = node.node.stateTotals[state]
121-
const nodeLatestTasks = Array.from(node.node.latestStateTasks?.[state] ?? [])
123+
let nodeLatestTasks = node.node.latestStateTasks?.[state] ?? []
122124
if (state === TaskState.SUBMITTED.name) { // include preparing tasks
123125
nodeTotal += node.node.stateTotals.preparing
124-
nodeLatestTasks.push(...(node.node.latestStateTasks?.preparing ?? []))
126+
nodeLatestTasks = [
127+
...nodeLatestTasks,
128+
...(node.node.latestStateTasks?.preparing ?? []),
129+
].slice(0, 5) // limit to 5 latest (submitted tasks take priority)
125130
}
126131
if (nodeTotal) {
127132
stateTotals[state] = (stateTotals[state] ?? 0) + nodeTotal
128133
}
129134
if (nodeLatestTasks.length) {
130-
latestTasks[state] = [
131-
...(latestTasks[state] ?? []),
132-
...nodeLatestTasks,
133-
].sort().reverse() // cycle point descending order
135+
latestTasks[state] = nodeLatestTasks
134136
}
135137
}
136138
}

tests/unit/components/cylc/tree/treeitem.vue.spec.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,8 @@ describe('GScanTreeItem', () => {
151151
filteredOutNodesCache: new WeakMap(),
152152
}
153153
})
154-
it('combines all descendant tasks', () => {
155-
expect(wrapper.vm.statesInfo.latestTasks.submitted.length).to.equal(20)
156-
expect(wrapper.vm.statesInfo.latestTasks.running.length).to.equal(10)
154+
it('does not combine descendant latest state tasks', () => {
155+
expect(wrapper.vm.statesInfo.latestTasks).to.deep.equal({})
157156
})
158157
it('combines all descendant task totals', () => {
159158
expect(wrapper.vm.statesInfo.stateTotals.submitted).to.equal(5)

0 commit comments

Comments
 (0)