Skip to content

Commit b17fe7f

Browse files
committed
feat(testcases): add dropdown filters
user、repo、package、kind、TestPass、MiriPass、MiriTimedOut close #147
1 parent 5bb5c56 commit b17fe7f

File tree

3 files changed

+101
-24
lines changed

3 files changed

+101
-24
lines changed

os-checks/components/DropDownSimple.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<script lang="ts" setup>
2-
const { tag, options } = defineProps<{
2+
const { tag, options, showClear } = defineProps<{
33
tag: string,
44
options: string[],
5+
showClear?: boolean
56
}>();
67
78
const selected = defineModel<string | null>({ default: null });
@@ -10,7 +11,7 @@ const selected = defineModel<string | null>({ default: null });
1011
<template>
1112
<span class="input">{{ tag }}:</span>
1213
<span class="select">
13-
<Select v-model="selected" filter :options="options" />
14+
<Select v-model="selected" filter :showClear="showClear" :options="options" />
1415
</span>
1516
</template>
1617

os-checks/pages/file-tree.vue

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ import type { Basic } from '~/shared/types';
3636
useHead({ title: 'Issue File Tree' });
3737
highlightRust();
3838
39-
const label = (a: string) => a;
40-
4139
const selected = reactive<{
4240
user: string | null,
4341
repo: string | null,
@@ -316,17 +314,3 @@ watch(lockURL, lock => {
316314
router_params.value = query;
317315
});
318316
</script>
319-
320-
<!-- FIXME: remove these -->
321-
<style scoped>
322-
.input {
323-
font-size: 14.5px;
324-
font-weight: bold;
325-
padding-right: 10px;
326-
color: var(--p-button-primary-background);
327-
}
328-
329-
.select {
330-
padding-right: 10px;
331-
}
332-
</style>

os-checks/pages/testcases.vue

Lines changed: 98 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22

3-
<DataTable :value="testcases" scrollable :scrollHeight="tableHeight" showGridlines selectionMode="single"
3+
<DataTable :value="testcasesFiltered" scrollable :scrollHeight="tableHeight" showGridlines selectionMode="single"
44
v-model:selection="selectedTest" v-model:filters="selected.text" :multiSortMeta="selected.sorts"
55
@update:multiSortMeta="sortsChanged" sortMode="multiple" removableSort paginator :rows="10"
66
:rowsPerPageOptions="[5, 10, 20, 50, 100, 200, 1000]"
@@ -9,15 +9,20 @@
99
<template #empty><b> No testcases found. </b></template>
1010
<template #header>
1111
<div style="display: flex; justify-content: space-between;">
12-
<div style="display: flex; gap: 10px;">
13-
<!-- <MultiSelect v-model="selected.categories" display="chip" :options="categories" filter :maxSelectedLabels="4" -->
14-
<!-- placeholder="Select Categories" /> -->
12+
<div style="display: flex; align-items: center;">
13+
<DropDownSimple tag="user" :options="options.val.user" v-model="selected.user" showClear />
14+
<DropDownSimple tag="repo" :options="options.val.repo" v-model="selected.repo" showClear />
15+
<DropDownSimple tag="pkg" :options="options.val.pkg" v-model="selected.pkg" showClear />
16+
<DropDownSimple tag="test_pass" :options="options.val.test_pass" v-model="selected.test_pass" showClear />
17+
<DropDownSimple tag="miri_pass" :options="options.val.miri_pass" v-model="selected.miri_pass" showClear />
18+
<DropDownSimple tag="miri_timeout" :options="options.val.miri_timeout" v-model="selected.miri_timeout"
19+
showClear />
1520
</div>
1621

1722
<div>
1823
<IconField>
1924
<InputIcon> <i class="pi pi-search" /> </InputIcon>
20-
<InputText style="width: 300px" v-model="selected.text['global'].value" placeholder="Search" />
25+
<InputText style="width: 200px" v-model="selected.text['global'].value" placeholder="Search" />
2126
</IconField>
2227
</div>
2328

@@ -93,6 +98,9 @@
9398
import type { DataTableSortMeta } from 'primevue/datatable';
9499
import { FilterMatchMode } from '@primevue/core/api';
95100
import type { PkgInfo } from '~/shared/info';
101+
import { cloneDeep, uniq } from 'es-toolkit/compat';
102+
103+
useHead({ title: 'Test Cases' });
96104
97105
// styling
98106
const { viewportHeight } = storeToRefs(useStyleStore());
@@ -108,6 +116,7 @@ const ptColumnRight = ref({
108116
highlightRust();
109117
110118
const testcases = ref<TestResult[]>([]);
119+
const testcasesFiltered = ref<TestResult[]>([]);
111120
const selectedTest = ref<TestResult | null>(null);
112121
113122
// pop up details
@@ -118,6 +127,7 @@ githubFetch<PkgInfo[]>({
118127
path: "plugin/cargo/info/summaries.json"
119128
}).then(val => {
120129
testcases.value = summariesToTestResult(val);
130+
testcasesFiltered.value = cloneDeep(testcases.value);
121131
});
122132
123133
type TestResult = {
@@ -174,12 +184,94 @@ function sortsChanged(meta?: DataTableSortMeta[] | null) {
174184
}
175185
176186
const selected = reactive<{
187+
user: string | null,
188+
repo: string | null,
189+
pkg: string | null,
190+
kind: string | null,
191+
test_pass: string | null,
192+
miri_pass: string | null,
193+
miri_timeout: string | null,
177194
text: any,
178195
sorts: DataTableSortMeta[],
179196
}>({
197+
user: null,
198+
repo: null,
199+
pkg: null,
200+
kind: null,
201+
test_pass: null,
202+
miri_pass: null,
203+
miri_timeout: null,
180204
text: { global: { value: null, matchMode: FilterMatchMode.CONTAINS }, },
181205
sorts: [],
182206
});
183207
184-
useHead({ title: 'Test Cases' });
208+
type Options = {
209+
user: string[],
210+
repo: string[],
211+
pkg: string[],
212+
kind: string[],
213+
test_pass: string[],
214+
miri_pass: string[],
215+
miri_timeout: string[],
216+
};
217+
function defaultOptions(): Options {
218+
return {
219+
user: [],
220+
repo: [],
221+
pkg: [],
222+
kind: [],
223+
test_pass: [],
224+
miri_pass: [],
225+
miri_timeout: [],
226+
};
227+
}
228+
const options = reactive<{ val: Options }>({ val: defaultOptions() });
229+
230+
// init options
231+
watch(testcases, tc => options.val = testcasesToOptions(tc));
232+
233+
// update table when filter selection changes
234+
watch(
235+
selected,
236+
({ user, repo, pkg, kind, test_pass, miri_pass, miri_timeout }) => {
237+
// for simplicity, the data of testcases are supposed to remain unchanged
238+
const chosen_testcases = testcases.value.filter(test => {
239+
let chosen = true;
240+
if (user) chosen &&= test.user === user;
241+
if (repo) chosen &&= test.repo === repo;
242+
if (pkg) chosen &&= test.pkg === pkg;
243+
if (kind) chosen &&= test.kind === repo;
244+
if (test_pass) chosen &&= test.test_pass === test_pass;
245+
if (miri_pass) chosen &&= test.miri_pass === miri_pass;
246+
if (miri_timeout || miri_timeout === "") chosen &&= test.miri_timeout === miri_timeout;
247+
return chosen;
248+
});
249+
testcasesFiltered.value = chosen_testcases.map((tc, idx) => {
250+
tc.idx = idx;
251+
return tc;
252+
});
253+
// options.val = testcasesToOptions(chosen_testcases);
254+
});
255+
256+
function testcasesToOptions(tc: TestResult[]): Options {
257+
let opts = defaultOptions();
258+
for (const test of tc) {
259+
opts.user.push(test.user);
260+
opts.repo.push(test.repo);
261+
opts.pkg.push(test.pkg);
262+
opts.kind.push(test.kind);
263+
opts.test_pass.push(test.test_pass);
264+
opts.miri_pass.push(test.miri_pass);
265+
opts.miri_timeout.push(test.miri_timeout);
266+
}
267+
268+
opts.user = uniq(opts.user).sort();
269+
opts.repo = uniq(opts.repo).sort();
270+
opts.pkg = uniq(opts.pkg).sort();
271+
opts.kind = uniq(opts.kind).sort();
272+
opts.test_pass = uniq(opts.test_pass).sort();
273+
opts.miri_pass = uniq(opts.miri_pass).sort();
274+
opts.miri_timeout = uniq(opts.miri_timeout).sort();
275+
return opts;
276+
}
185277
</script>

0 commit comments

Comments
 (0)