Skip to content

Commit 2349a7d

Browse files
committed
Merge branch 'master' into gscan-filter
2 parents 2a7c98a + 21b773b commit 2349a7d

30 files changed

+227
-217
lines changed

CHANGES.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,23 @@ creating a new release entry be sure to copy & paste the span tag with the
1010
`actions:bind` attribute, which is used by a regex to find the text to be
1111
updated. Only the first match gets replaced, so it's fine to leave the old
1212
ones in. -->
13-
14-
## __cylc-ui-1.5.0 (<span actions:bind='release-date'>Released 2023-01-16</span>)__
13+
-------------------------------------------------------------------------------
14+
## __cylc-ui-1.5.0 (<span actions:bind='release-date'>Upcoming</span>)__
1515

1616
### Enhancements
1717

1818
[#1184](https://github.com/cylc/cylc-ui/pull/1184) - Mean times for tasks
1919
in table changed to human readable ISO duration format.
2020

21+
[#1182](https://github.com/cylc/cylc-ui/pull/1182) - Allow filtering by
22+
cycle point and family in tree & table views.
23+
24+
### Fixes
25+
26+
[#1182](https://github.com/cylc/cylc-ui/pull/1182) - Fixes bug in filtering
27+
by task name.
28+
29+
-------------------------------------------------------------------------------
2130
## __cylc-ui-1.4.0 (<span actions:bind='release-date'>Released 2023-01-16</span>)__
2231

2332
### Enhancements

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
"sinon": "^15.0.0",
9191
"standard": "^17.0.0",
9292
"subscriptions-transport-ws": "^0.11.0",
93-
"utf-8-validate": "^5.0.9",
93+
"utf-8-validate": "^6.0.0",
9494
"vue-cli-plugin-vuetify": "^2.4.2",
9595
"vue-cli-plugin-vuetify-essentials": "^0.8.3",
9696
"vue-template-compiler": "^2.6.14",

src/components/core/Alert.vue

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -16,65 +16,61 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
-->
1717

1818
<template>
19-
<div v-if="alert">
20-
<v-alert
21-
:value="true"
22-
:type="alert.color"
23-
:icon="alert.icon"
24-
:class="getColor(alert.color)"
25-
dismissible
26-
tile
27-
light
28-
colored-border
29-
>
30-
<template v-slot:close="props">
31-
<v-icon @click="closeAlert(props.toggle)">{{ svgPaths.close }}</v-icon>
32-
</template>
33-
{{ alert.text }}
34-
</v-alert>
35-
</div>
19+
<v-snackbar
20+
v-if="alert"
21+
v-model="alert"
22+
:color="getColor(alert.color)"
23+
top
24+
timeout="-1"
25+
data-cy="alert-snack"
26+
>
27+
<template v-slot:action="{ attrs }">
28+
<v-btn
29+
icon
30+
v-bind="attrs"
31+
@click="closeAlert"
32+
data-cy="snack-close"
33+
>
34+
<v-icon>{{ $options.icons.mdiClose }}</v-icon>
35+
</v-btn>
36+
</template>
37+
{{ alert.text }}
38+
</v-snackbar>
3639
</template>
3740

3841
<script>
3942
import { mdiClose } from '@mdi/js'
4043
import { mapActions, mapState } from 'vuex'
4144
45+
// TODO: remove later when https://github.com/vuetifyjs/vuetify/issues/11021 is fixed
46+
const colors = new Map([
47+
['error', 'red'],
48+
['success', 'green'],
49+
['warning', 'amber']
50+
])
51+
4252
export default {
4353
name: 'Alert',
4454
45-
data () {
46-
return {
47-
// TODO: remove later when https://github.com/vuetifyjs/vuetify/issues/11021 is fixed
48-
colors: new Map([
49-
['error', 'red'],
50-
['success', 'green'],
51-
['warning', 'amber']
52-
]),
53-
svgPaths: {
54-
close: mdiClose
55-
}
56-
}
57-
},
58-
5955
computed: {
6056
...mapState(['alert'])
6157
},
6258
6359
methods: {
6460
...mapActions(['setAlert']),
6561
getColor (type) {
66-
return this.colors.get(type) || ''
62+
return colors.get(type) || ''
6763
},
6864
/**
6965
* Dismisses the alert from the UI, also removing it from the Vuex store.
70-
*
71-
* @param {Function} toggleFunction - the original Vuetify toggle function
72-
* @see https://vuetifyjs.com/en/api/v-alert/
7366
*/
74-
closeAlert (toggleFunction) {
67+
closeAlert () {
7568
this.setAlert(null)
76-
toggleFunction()
7769
}
70+
},
71+
72+
icons: {
73+
mdiClose
7874
}
7975
}
8076
</script>

src/components/cylc/Mutation.vue

Lines changed: 18 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -116,17 +116,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
116116
</v-tooltip>
117117
</v-card-actions>
118118
<v-snackbar
119-
v-model="showSnackbar"
120-
v-bind="snackbarProps"
121-
data-cy="response-snackbar"
119+
v-model="showWarning"
120+
timeout="4e3"
121+
color="amber accent-2"
122+
light
123+
data-cy="warning-snack"
122124
>
123-
{{ response.msg }}
125+
{{ warningMsg }}
124126
<template v-slot:action="{ attrs }">
125127
<v-btn
126-
@click="showSnackbar = false"
128+
@click="showWarning = false"
127129
icon
128130
v-bind="attrs"
129-
data-cy="snackbar-close"
131+
data-cy="snack-close"
130132
>
131133
<v-icon>
132134
{{ $options.icons.close }}
@@ -143,7 +145,8 @@ import EditRuntimeForm from '@/components/graphqlFormGenerator/EditRuntimeForm.v
143145
import Markdown from '@/components/Markdown'
144146
import {
145147
getMutationShortDesc,
146-
getMutationExtendedDesc
148+
getMutationExtendedDesc,
149+
mutationStatus
147150
} from '@/utils/aotf'
148151
import { mdiClose } from '@mdi/js'
149152
@@ -186,10 +189,7 @@ export default {
186189
data: () => ({
187190
isValid: false,
188191
submitting: false,
189-
response: {
190-
msg: null,
191-
level: 'warn'
192-
}
192+
warningMsg: null
193193
}),
194194
195195
computed: {
@@ -201,26 +201,13 @@ export default {
201201
extendedDescription () {
202202
return getMutationExtendedDesc(this.mutation.description)
203203
},
204-
showSnackbar: {
204+
showWarning: {
205205
get () {
206-
return Boolean(this.response.msg)
206+
return Boolean(this.warningMsg)
207207
},
208208
set (val) {
209-
if (!val) this.response.msg = null
209+
if (!val) this.warningMsg = null
210210
}
211-
},
212-
snackbarProps () {
213-
return this.response.level === 'error'
214-
? {
215-
timeout: -1,
216-
color: 'red accent-2',
217-
dark: true
218-
}
219-
: {
220-
timeout: 4e3,
221-
color: 'amber accent-2',
222-
light: true
223-
}
224211
}
225212
},
226213
@@ -230,16 +217,13 @@ export default {
230217
this.submitting = true
231218
this.$refs.form.submit().then(response => {
232219
this.submitting = false
233-
if (response.status.name.includes('failed')) {
234-
this.response.msg = response.message
235-
this.response.level = 'error'
236-
} else if (response.status.name === 'warn') {
237-
this.response.msg = response.message
238-
this.response.level = 'warn'
239-
} else {
220+
if (response.status === mutationStatus.SUCCEEDED) {
240221
// Close the form on success
241222
this.cancel()
223+
} else if (response.status === mutationStatus.WARN) {
224+
this.warningMsg = response.message
242225
}
226+
// else if error, an alert is generated by AOTF
243227
})
244228
}
245229
},

src/components/cylc/TaskFilter.vue

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2525
class="pr-md-2 mb-2 mb-md-0"
2626
>
2727
<v-text-field
28-
data-cy="filter-task-name"
28+
data-cy="filter-id"
2929
clearable
30+
:clear-icon="$options.icons.mdiClose"
3031
dense
3132
flat
3233
hide-details
3334
outlined
34-
placeholder="Filter by task name"
35-
v-model="localValue.name"
36-
ref="filterNameInput"
37-
></v-text-field>
35+
placeholder="Filter by ID"
36+
v-model="localValue.id"
37+
ref="filterIDInput"
38+
/>
3839
</v-col>
3940
<v-col
4041
cols="12"
@@ -45,6 +46,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
4546
data-cy="filter-task-states"
4647
:items="allStates"
4748
clearable
49+
:clear-icon="$options.icons.mdiClose"
4850
dense
4951
flat
5052
hide-details
@@ -76,14 +78,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
7678
<script>
7779
import Task from '@/components/cylc/Task'
7880
import { TaskStateUserOrder } from '@/model/TaskState.model'
81+
import { mdiClose } from '@mdi/js'
7982
8083
export default {
8184
name: 'TaskFilter',
8285
components: {
8386
Task
8487
},
8588
props: {
86-
value: Object // { name, states }
89+
value: Object // { id, states }
8790
},
8891
data () {
8992
return {
@@ -101,6 +104,10 @@ export default {
101104
this.$emit('input', value)
102105
}
103106
}
107+
},
108+
// Misc options
109+
icons: {
110+
mdiClose
104111
}
105112
}
106113
</script>

src/components/cylc/common/filter.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,21 @@
1818
/* Logic for filtering tasks. */
1919

2020
/**
21-
* Return true if a node has matches the specified name/state filter.
21+
* Return true if a node matches the specified id/state filter.
2222
*
2323
* @export
24-
* @param {{ name: string, state: string }} node
25-
* @param {?string} name
24+
* @param {Object} node
25+
* @param {?string} id
2626
* @param {?string[]} states
2727
* @return {boolean}
2828
*/
29-
export function matchNode (node, name, states) {
29+
export function matchNode (node, id, states) {
3030
let ret = true
31-
if (name?.trim()) {
32-
ret &&= node.name.includes(name)
31+
if (id?.trim()) {
32+
ret &&= node.tokens.relative_id.includes(id)
3333
}
3434
if (states?.length) {
35-
ret &&= states.includes(node.state)
35+
ret &&= states.includes(node.node.state)
3636
}
3737
return ret
3838
}

src/components/cylc/gscan/GScan.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2828
<v-text-field
2929
v-model="searchWorkflows"
3030
clearable
31+
:clear-icon="$options.icons.mdiClose"
3132
flat
3233
dense
3334
hide-details

src/components/cylc/table/Table.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ export default {
254254
},
255255
computed: {
256256
filteredTasks () {
257-
return this.tasks.filter(({ task }) => matchNode(task.node, this.tasksFilter.name, this.tasksFilter.states))
257+
return this.tasks.filter(({ task }) => matchNode(task, this.tasksFilter.id, this.tasksFilter.states))
258258
}
259259
},
260260
methods: {

src/components/cylc/tree/Tree.vue

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ export default {
202202
}
203203
},
204204
filterByTaskName () {
205-
return Boolean(this.tasksFilter.name?.trim())
205+
return Boolean(this.tasksFilter.id?.trim())
206206
},
207207
filterByTaskState () {
208208
return Boolean(this.tasksFilter.states?.length)
@@ -237,20 +237,31 @@ export default {
237237
this.filterNode(node)
238238
}
239239
},
240-
filterNode (node) {
241-
let filtered = false
240+
/**
241+
* Update tree cache entry for this node (and its children if applicable)
242+
* with whether the node matches the filters.
243+
*
244+
* @param {Object} node
245+
* @param {boolean} parentFiltered - whether the parent of this node
246+
* matches the filter.
247+
* @return {boolean} - whether this node matches the filter.
248+
*/
249+
filterNode (node, parentFiltered = false) {
250+
const isMatch = (
251+
matchNode(node, this.tasksFilter.id, this.tasksFilter.states) ||
252+
parentFiltered
253+
)
254+
let filtered = isMatch
242255
if (node.type === 'cycle') {
243256
// follow the family tree from cycle point nodes
244257
for (const child of node.familyTree[0]?.children || []) {
245-
filtered = this.filterNode(child) || filtered
258+
filtered = this.filterNode(child, isMatch) || filtered
246259
}
247260
} else if (['workflow', 'family'].includes(node.type)) {
248261
// follow children for workflow or family nodes
249262
for (const child of node.children) {
250-
filtered = this.filterNode(child) || filtered
263+
filtered = this.filterNode(child, isMatch) || filtered
251264
}
252-
} else if (node.type === 'task') {
253-
filtered = matchNode(node.node, this.tasksFilter.name, this.tasksFilter.states)
254265
}
255266
if (this.treeItemCache[node.id]) {
256267
this.treeItemCache[node.id].filtered = filtered

0 commit comments

Comments
 (0)