Skip to content

Commit 5078882

Browse files
Enhance filtering in Analysis tab (#2154)
1 parent a246580 commit 5078882

File tree

4 files changed

+32
-35
lines changed

4 files changed

+32
-35
lines changed

src/components/cylc/analysis/filter.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@
2626
* @return {boolean} Boolean determining if task should be displayed
2727
*/
2828
export function matchTask (task, tasksFilter) {
29-
let ret = true
30-
if (tasksFilter.name?.trim()) {
31-
ret &&= task.name.includes(tasksFilter.name)
29+
let ret = false
30+
if (tasksFilter.name?.length) {
31+
ret = tasksFilter.name.some((name) => task.name === name)
32+
} else {
33+
// If no name filter is applied, show all tasks
34+
ret = true
3235
}
3336
if (tasksFilter.platformOption.trim?.()) {
3437
ret &&= task.platform === tasksFilter.platformOption

src/views/Analysis.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2828
md="4"
2929
class="pr-md-2 mb-2 mb-md-0"
3030
>
31-
<v-text-field
31+
<v-combobox
3232
id="c-analysis-filter-task-name"
3333
clearable
34+
chips
35+
multiple
36+
closable-chips
3437
placeholder="Filter by task name"
35-
v-model.trim="tasksFilter.name"
38+
v-model="tasksFilter.name"
3639
ref="filterNameInput"
40+
:items="this.tasks.map(task => task.name)"
3741
:disabled="chartType === 'timeSeries'"
3842
/>
3943
</v-col>
@@ -259,7 +263,7 @@ export default {
259263
* The task name, timing option and platform filter state.
260264
* @type {import('vue').Ref<object>}
261265
*/
262-
const tasksFilter = useInitialOptions('tasksFilter', { props, emit }, { name: '', timingOption: 'totalTimes', platformOption: -1 })
266+
const tasksFilter = useInitialOptions('tasksFilter', { props, emit }, { name: [], timingOption: 'totalTimes', platformOption: -1 })
263267
264268
/**
265269
* Determines the Analysis type ('table' | 'box' | 'timeSeries')

tests/e2e/specs/analysis.cy.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ describe('Analysis view', () => {
6363
.should('be.visible')
6464
cy
6565
.get('#c-analysis-filter-task-name')
66-
.type('wait')
66+
.click()
67+
.get('.v-list-item')
68+
.contains('waiting')
69+
.click({ force: true })
6770
cy
6871
.get('td')
6972
.contains('waiting')
@@ -181,7 +184,10 @@ describe('Analysis view', () => {
181184
// Show task names containing 'wait'
182185
cy
183186
.get('#c-analysis-filter-task-name')
184-
.type('wait')
187+
.click()
188+
.get('.v-list-item')
189+
.contains('waiting')
190+
.click({ force: true })
185191
cy
186192
.get('td')
187193
.contains('waiting')
@@ -462,7 +468,10 @@ describe('Filters and Options save state', () => {
462468
// Set queue task name filter options
463469
cy
464470
.get('#c-analysis-filter-task-name')
465-
.type('wait')
471+
.click()
472+
.get('.v-list-item')
473+
.contains('waiting')
474+
.click({ force: true })
466475

467476
// Set task times filter options
468477
cy

tests/unit/components/cylc/analysis/filter.spec.js

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ describe('matchTask', () => {
2828

2929
it('should match with default or matching filter values', () => {
3030
const filters = [
31-
{ name: '', platformOption: -1 },
32-
{ name: 'task_name', platformOption: -1 },
33-
{ name: '', platformOption: 'task_platform' },
34-
{ name: 'task_name', platformOption: 'task_platform' }
31+
{ name: [], platformOption: -1 },
32+
{ name: ['task_name'], platformOption: -1 },
33+
{ name: [], platformOption: 'task_platform' },
34+
{ name: ['task_name'], platformOption: 'task_platform' }
3535
]
3636
filters.forEach(filter => {
3737
expect(matchTask(task, filter)).to.equal(true)
@@ -40,33 +40,14 @@ describe('matchTask', () => {
4040

4141
it('should not match if at least one of the filter options does not match', () => {
4242
const filters = [
43-
{ name: 'task_name', platformOption: 'wrong_platform' },
44-
{ name: 'wrong_task', platformOption: 'task_platform' },
45-
{ name: 'wrong_task', platformOption: 'wrong_platform' }
43+
{ name: ['task_name'], platformOption: 'wrong_platform' },
44+
{ name: ['wrong_task'], platformOption: 'task_platform' },
45+
{ name: ['wrong_task'], platformOption: 'wrong_platform' }
4646
]
4747
filters.forEach(filter => {
4848
expect(matchTask(task, filter)).to.equal(false)
4949
})
5050
})
51-
52-
it('should allow partial matches of names but not platforms', () => {
53-
const filterNames = [
54-
{ name: 'task_', platformOption: -1 },
55-
{ name: '_name', platformOption: -1 },
56-
{ name: 'sk_na', platformOption: -1 }
57-
]
58-
const filterPlatforms = [
59-
{ name: '', platformOption: 'platform' },
60-
{ name: '', platformOption: 'form_1' },
61-
{ name: '', platformOption: 'form' }
62-
]
63-
filterNames.forEach(filter => {
64-
expect(matchTask(task, filter)).to.equal(true)
65-
})
66-
filterPlatforms.forEach(filter => {
67-
expect(matchTask(task, filter)).to.equal(false)
68-
})
69-
})
7051
})
7152

7253
describe('platformOptions', () => {

0 commit comments

Comments
 (0)