Skip to content

Commit edb758c

Browse files
Merge pull request #124 from MetRonnie/gscan-modifiers
Gscan modifiers
2 parents e1d2613 + 03845c1 commit edb758c

File tree

7 files changed

+56
-64
lines changed

7 files changed

+56
-64
lines changed

src/components/cylc/TaskStateBadge.vue

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,12 @@
1717

1818
<template>
1919
<div
20-
class="task-state-badge d-flex justify-center align-center font-weight-medium"
20+
class="task-state-badge d-flex justify-center align-center px-1 font-weight-medium"
2121
:class="state"
2222
>
23-
<v-icon v-if="isModifier" >{{ icon }}</v-icon>
24-
{{ isModifier ? '' : value }}
25-
<v-tooltip
26-
location="top"
27-
:open-delay="400"
28-
>
29-
{{ displayText }}
23+
{{ value }}
24+
<v-tooltip>
25+
{{ value }} {{ displayName }} task{{ value > 1 ? 's': '' }}.
3026
<template v-if="latestTasks?.length">
3127
Latest:
3228
<span
@@ -43,7 +39,6 @@
4339

4440
<script setup>
4541
import { computed } from 'vue'
46-
import { taskHeld, taskRetry } from '@/utils/icons'
4742
4843
const props = defineProps({
4944
state: {
@@ -60,28 +55,7 @@ const props = defineProps({
6055
},
6156
})
6257
63-
const icons = {
64-
held: taskHeld,
65-
retry: taskRetry,
66-
}
67-
68-
const isModifier = computed(
69-
() => ['held', 'retry'].includes(props.state)
70-
)
71-
7258
const displayName = computed(
7359
() => props.state === 'submitted' ? 'preparing/submitted' : props.state
7460
)
75-
76-
const displayText = computed(
77-
() => isModifier.value
78-
? `One or more ${props.state} task(s).`
79-
: `${props.value} ${displayName.value} task${props.value > 1 ? 's' : ''}`
80-
)
81-
82-
const icon = computed(
83-
() => isModifier.value
84-
? icons[props.state]
85-
: null
86-
)
8761
</script>

src/components/cylc/WarningIcon.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
3333
:activator="null"
3434
location="bottom"
3535
:disabled="!workflow.node.logRecords?.length"
36-
:open-delay="400"
3736
>
3837
<template
3938
v-slot:activator="{ props }"

src/components/cylc/gscan/GScan.vue

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
9595
v-else
9696
class="c-gscan-workflows flex-grow-1 pl-2"
9797
>
98-
<Tree
99-
:workflows="workflows"
100-
:node-filter-func="filterNode"
101-
tree-item-component="GScanTreeItem"
102-
class="c-gscan-workflow"
103-
ref="tree"
104-
v-bind="{ filterState }"
105-
/>
98+
<v-defaults-provider :defaults="{
99+
VTooltip: {
100+
location: 'top',
101+
openDelay: 400,
102+
eager: false,
103+
}
104+
}">
105+
<Tree
106+
:workflows="workflows"
107+
:node-filter-func="filterNode"
108+
tree-item-component="GScanTreeItem"
109+
class="c-gscan-workflow"
110+
ref="tree"
111+
v-bind="{ filterState }"
112+
/>
113+
</v-defaults-provider>
106114
</div>
107115
<!-- when no workflows are returned in the GraphQL query -->
108116
<div v-if="!workflows.length">

src/components/cylc/tree/GScanTreeItem.vue

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
3838
<div class="c-gscan-workflow-name flex-grow-1">
3939
<span>
4040
{{ node.name || node.id }}
41-
<v-tooltip
42-
location="top"
43-
style="overflow-wrap: anywhere;"
44-
>
41+
<v-tooltip style="overflow-wrap: anywhere;">
4542
{{ node.id }}
4643
</v-tooltip>
4744
</span>
4845
</div>
49-
<div class="d-flex c-gscan-workflow-states flex-grow-0">
46+
<div class="d-flex c-gscan-workflow-states flex-grow-0 align-center">
47+
<v-icon
48+
v-for="modifier in statesInfo.modifiers"
49+
:key="modifier"
50+
:icon="modifierIcons[modifier]"
51+
v-tooltip="`Has ${modifier} tasks.`"
52+
size="1em"
53+
class="modifier-badge"
54+
:class="modifier"
55+
/>
5056
<TaskStateBadge
5157
v-for="(value, state) in statesInfo.stateTotals"
5258
:key="state"
@@ -85,6 +91,7 @@ import WarningIcon from '@/components/cylc/WarningIcon.vue'
8591
import TaskState from '@/model/TaskState.model'
8692
import { WorkflowState } from '@/model/WorkflowState.model'
8793
import { useWorkflowWarnings } from '@/composables/localStorage'
94+
import { taskHeld, taskRetry } from '@/utils/icons'
8895
8996
const nodeTypes = ['workflow-part', 'workflow']
9097
@@ -96,32 +103,38 @@ const taskStatesOrdered = [
96103
TaskState.RUNNING.name,
97104
]
98105
106+
const modifierIcons = {
107+
held: taskHeld,
108+
retrying: taskRetry,
109+
}
110+
99111
/**
100112
* Get aggregated task state totals for all descendents of a node.
101113
*
102114
* Also get latest state tasks for workflow nodes.
103115
*
104116
* @param {Object} node
105117
* @param {Record<string, number>} stateTotals - Accumulator for state totals.
118+
* @param {Set<string>} modifiers - Accumulator for modifier states.
106119
*/
107-
function getStatesInfo (node, stateTotals = {}) {
120+
function getStatesInfo (node, stateTotals = {}, modifiers = new Set()) {
108121
const latestTasks = {}
109122
// if we aren't at the end of the node tree, continue recurse until we hit something other then a workflow part
110123
if (node.type === 'workflow-part' && node.children) {
111124
// at every branch, recurse all child nodes except stopped workflows
112125
for (const child of node.children) {
113126
if (child.node.status !== WorkflowState.STOPPED.name) {
114-
getStatesInfo(child, stateTotals, latestTasks)
127+
getStatesInfo(child, stateTotals, modifiers)
115128
}
116129
}
117130
} else if (node.type === 'workflow' && node.node.stateTotals) {
118131
// if we hit a workflow node, stop and merge state
119132
120133
if (node.node.containsHeld) {
121-
stateTotals.held = true
134+
modifiers.add('held')
122135
}
123136
if (node.node.containsRetry) {
124-
stateTotals.retry = true
137+
modifiers.add('retrying')
125138
}
126139
127140
// the non-zero state totals from this node with all the others from the tree
@@ -143,7 +156,7 @@ function getStatesInfo (node, stateTotals = {}) {
143156
}
144157
}
145158
}
146-
return { stateTotals, latestTasks }
159+
return { stateTotals, latestTasks, modifiers }
147160
}
148161
149162
const workflowWarnings = useWorkflowWarnings()

src/components/cylc/workspace/Toolbar.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
142142
:icon="$options.icons.info"
143143
id="info-icon"
144144
/>
145-
<v-tooltip v-if="isRunning" activator="#info-icon">
145+
<v-tooltip
146+
v-if="isRunning"
147+
activator="#info-icon"
148+
:eager="false"
149+
>
146150
<dl>
147151
<dt><strong>Owner:</strong> {{ currentWorkflow.node.owner }}</dt>
148152
<dt><strong>Host:</strong> {{ currentWorkflow.node.host }}</dt>

src/styles/cylc/_job.scss

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,11 @@ $cjob: ".c-job .job rect";
3939
min-width: $height;
4040
border-radius: $height;
4141
border: 0.2em solid;
42-
margin: 0 0.1em;
4342
line-height: normal;
43+
margin: 0 1px;
44+
}
45+
.modifier-badge {
46+
margin: 0 2px;
4447
}
4548

4649
$teal: rgb(109,213,194);
@@ -102,12 +105,3 @@ $themes: (
102105
}
103106
}
104107
}
105-
106-
.task-state-badge.retry, .task-state-badge.held {
107-
font-size: 0.8em;
108-
min-width: 0;
109-
background: none;
110-
border: none;
111-
padding: 0 0 0.2em 0;
112-
margin: none;
113-
}

tests/e2e/specs/gscan.cy.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,11 @@ describe('GScan component', () => {
196196
it('displays retry and held icons', () => {
197197
cy.get('.c-gscan')
198198
.find('[data-node-name="one"]').as('parent')
199-
.find('.node:first .task-state-badge:first')
200-
.should('have.class', 'held')
199+
.find('.node:first .modifier-badge.held')
200+
.should('be.visible')
201201
// child run2 contributes the running tasks
202-
cy.get('@parent').find('.node:first .task-state-badge:nth-child(2)')
203-
.should('have.class', 'retry')
202+
cy.get('@parent').find('.node:first .modifier-badge.retrying')
203+
.should('be.visible')
204204
})
205205
})
206206

0 commit comments

Comments
 (0)