Skip to content

Commit 2abcd99

Browse files
Fix cleanup plan filter
1 parent 57152fd commit 2abcd99

4 files changed

Lines changed: 95 additions & 96 deletions

File tree

Lines changed: 50 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,54 @@
11
<template>
22
<v-list
3-
v-if="value && value.length"
4-
v-model:selected="selected"
3+
v-if="cleanupPlans && cleanupPlans.length"
4+
v-model:selected="internalSelectedPlans"
55
select-strategy="multiple"
66
>
7-
<template
8-
v-for="(cleanupPlan, idx) in value"
7+
<v-list-item
8+
v-for="cleanupPlan in cleanupPlans"
99
:key="cleanupPlan.id.toNumber()"
10+
:value="cleanupPlan.id.toNumber()"
1011
>
11-
<v-list-item
12-
:value="cleanupPlan.id.toNumber()"
13-
>
14-
<template v-slot:prepend="{ isSelected }">
15-
<v-icon v-if="isSelected">
16-
mdi-checkbox-marked
17-
</v-icon>
18-
<v-icon v-else-if="notAllSelected[cleanupPlan.id]">
19-
mdi-checkbox-intermediate
20-
</v-icon>
21-
<v-icon v-else>
22-
mdi-checkbox-blank-outline
23-
</v-icon>
24-
</template>
25-
26-
<v-list-item-title class="font-weight-bold">
27-
{{ cleanupPlan.name }}
28-
</v-list-item-title>
12+
<template v-slot:prepend="{ isActive }">
13+
<v-icon v-if="isActive">
14+
mdi-checkbox-marked
15+
</v-icon>
16+
<v-icon v-else-if="notAllSelected[cleanupPlan.id]">
17+
mdi-checkbox-intermediate
18+
</v-icon>
19+
<v-icon v-else>
20+
mdi-checkbox-blank-outline
21+
</v-icon>
22+
</template>
2923

30-
<v-list-item-subtitle
31-
v-if="cleanupPlan.closedAt"
32-
>
33-
<v-icon
34-
size="small"
35-
>
36-
mdi-calendar-blank
37-
</v-icon>
38-
Closed on
39-
{{ fromUnixTime(cleanupPlan.closedAt, "yyyy-MM-dd") }}
40-
</v-list-item-subtitle>
24+
<v-list-item-title class="font-weight-bold">
25+
{{ cleanupPlan.name }}
26+
</v-list-item-title>
4127

42-
<v-list-item-subtitle
43-
v-else-if="cleanupPlan.dueDate"
28+
<v-list-item-subtitle
29+
v-if="cleanupPlan.closedAt"
30+
>
31+
<v-icon
32+
size="small"
4433
>
45-
<due-date :value="cleanupPlan.dueDate" />
46-
</v-list-item-subtitle>
34+
mdi-calendar-blank
35+
</v-icon>
36+
Closed on
37+
{{ fromUnixTime(cleanupPlan.closedAt, "yyyy-MM-dd") }}
38+
</v-list-item-subtitle>
4739

48-
<v-list-item-subtitle
49-
v-else
50-
>
51-
No due date
52-
</v-list-item-subtitle>
53-
</v-list-item>
40+
<v-list-item-subtitle
41+
v-else-if="cleanupPlan.dueDate"
42+
>
43+
<due-date :value="cleanupPlan.dueDate" />
44+
</v-list-item-subtitle>
5445

55-
<v-divider
56-
v-if="idx < value.length - 1"
57-
:key="idx"
58-
/>
59-
</template>
46+
<v-list-item-subtitle
47+
v-else
48+
>
49+
No due date
50+
</v-list-item-subtitle>
51+
</v-list-item>
6052
</v-list>
6153

6254
<v-list v-else disabled>
@@ -71,15 +63,19 @@ import { computed } from "vue";
7163
import DueDate from "./DueDate";
7264
7365
const props = defineProps({
74-
value: { type: Array, default: null },
75-
selectedItems: { type: Array, default: () => [] },
66+
cleanupPlans: { type: Array, default: null },
67+
selectedPlans: { type: Array, default: () => [] },
7668
notAllSelected: { type: Object, default: () => ({}) }
7769
});
7870
79-
const emit = defineEmits([ "update:selected-items" ]);
71+
const emit = defineEmits([ "update:selectedPlans" ]);
8072
81-
const selected = computed({
82-
get: () => props.selectedItems,
83-
set: val => emit("update:selected-items", val)
73+
const internalSelectedPlans = computed({
74+
get() {
75+
return props.selectedPlans;
76+
},
77+
set(value) {
78+
emit("update:selectedPlans", value);
79+
}
8480
});
8581
</script>

web/server/vue-cli/src/components/Report/CleanupPlan/SetCleanupPlanBtn.vue

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
:close-on-content-click="false"
66
:nudge-width="100"
77
>
8-
<template v-slot:activator="{ props: bindProps }">
8+
<template v-slot:activator="{ props: activatorProps }">
99
<div class="d-flex align-center">
1010
<v-btn
11-
v-bind="bindProps"
11+
v-bind="activatorProps"
1212
color="primary"
1313
class="set-cleanup-plan-btn"
1414
variant="outlined"
@@ -53,19 +53,19 @@
5353
>
5454
<template v-slot:open>
5555
<cleanup-plan-list
56-
:value="cleanupPlan.openCleanupPlans.value"
57-
:selected-items="changedSelectedItems"
56+
:cleanup-plans="cleanupPlan.openCleanupPlans.value"
57+
:selected-plans="changedSelectedItems"
5858
:not-all-selected="changedNotAllSelected"
59-
@update:selected-items="updateSelectedCleanupPlans"
59+
@update:selected-plans="updateSelectedCleanupPlans"
6060
/>
6161
</template>
6262

6363
<template v-slot:closed>
6464
<cleanup-plan-list
65-
:value="cleanupPlan.closedCleanupPlans.value"
66-
:selected-items="changedSelectedItems"
65+
:cleanup-plans="cleanupPlan.closedCleanupPlans.value"
66+
:selected-plans="changedSelectedItems"
6767
:not-all-selected="changedNotAllSelected"
68-
@update:selected-items="updateSelectedCleanupPlans"
68+
@update:selected-plans="updateSelectedCleanupPlans"
6969
/>
7070
</template>
7171
</cleanup-plan-tab>
@@ -95,7 +95,8 @@ const cleanupPlan = useCleanupPlan();
9595
const selectedTab = ref(0);
9696
9797
const selectedReportHashes = computed(() => {
98-
return [ ...new Set(props.value.map(v => v.bugHash)) ];
98+
const hashes = Array.from(new Set(props.value));
99+
return hashes;
99100
});
100101
101102
watch(menu, () => {
@@ -122,13 +123,19 @@ function reset() {
122123
123124
function save() {
124125
getCheckedCleanups().forEach(cleanupPlanId => {
125-
ccService.getClient().setCleanupPlan(cleanupPlanId,
126-
selectedReportHashes.value, handleThriftError());
126+
ccService.getClient().setCleanupPlan(
127+
cleanupPlanId,
128+
selectedReportHashes.value,
129+
handleThriftError()
130+
);
127131
});
128132
129133
getUncheckedCleanups().forEach(cleanupPlanId => {
130-
ccService.getClient().unsetCleanupPlan(cleanupPlanId,
131-
selectedReportHashes.value, handleThriftError());
134+
ccService.getClient().unsetCleanupPlan(
135+
cleanupPlanId,
136+
selectedReportHashes.value,
137+
handleThriftError()
138+
);
132139
});
133140
}
134141
@@ -157,36 +164,36 @@ function getUncheckedCleanups() {
157164
return _removeFromCleanups;
158165
}
159166
160-
// Initialize selected items.
161-
function onFetchFinished(_cleanupPlans) {
162-
_cleanupPlans.forEach(_cleanupPlan => {
163-
const _id = _cleanupPlan.id.toNumber();
167+
function onFetchFinished(cleanupPlans) {
168+
cleanupPlans.forEach(plan => {
169+
const planId = plan.id.toNumber();
164170
165-
const _commonReportHashes = selectedReportHashes.value.filter(
166-
_reportHash => _cleanupPlan.reportHashes.includes(_reportHash));
171+
const planHashes = new Set(plan.reportHashes);
172+
const commonReportHashes = selectedReportHashes.value.filter(
173+
reportHash => planHashes.has(reportHash));
167174
168175
if (
169-
_commonReportHashes.length === selectedReportHashes.value.length
176+
commonReportHashes.length === selectedReportHashes.value.length
170177
) {
171178
// Every selected report hashes are in the current cleanup plan so
172179
// mark it as active.
173-
if (!origSelectedItems.value.includes(_id)) {
174-
origSelectedItems.value.push(_id);
175-
changedSelectedItems.value.push(_id);
180+
if (!origSelectedItems.value.includes(planId)) {
181+
origSelectedItems.value.push(planId);
182+
changedSelectedItems.value.push(planId);
176183
}
177-
} else if (_commonReportHashes.length !== 0) {
184+
} else if (commonReportHashes.length !== 0) {
178185
// Not all selected report hashes are in the cleanup plan, so mark
179186
// it differently.
180-
origNotAllSelected.value[_id] = true;
181-
changedNotAllSelected.value[_id] = true;
187+
origNotAllSelected.value[planId] = true;
188+
changedNotAllSelected.value[planId] = true;
182189
}
183190
});
184191
}
185192
186193
function updateSelectedCleanupPlans(_cleanupPlanIds) {
187-
_cleanupPlanIds.forEach(_id => {
188-
if (!changedSelectedItems.value.includes(_id)) {
189-
delete changedNotAllSelected.value[_id];
194+
_cleanupPlanIds.forEach(id => {
195+
if (!changedSelectedItems.value.includes(id)) {
196+
delete changedNotAllSelected.value[id];
190197
}
191198
});
192199

web/server/vue-cli/src/components/Report/ReportFilter/Filters/CleanupPlanFilter.vue

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
v-model="dialog"
44
>
55
<select-option
6-
:id="id.value"
6+
:id="id"
77
title="Cleanup plan"
88
:bus="baseSelectOptionFilter.bus"
99
:fetch-items="fetchItems"
@@ -60,16 +60,16 @@ const baseSelectOptionFilter =
6060
baseSelectOptionFilter.fetchItems.value = fetchItems;
6161
baseSelectOptionFilter.updateReportFilter.value = updateReportFilter;
6262
63-
const id = ref("cleanup-plan");
64-
// eslint-disable-next-line vue/no-ref-object-reactivity-loss
65-
baseSelectOptionFilter.id.value = id.value;
63+
baseSelectOptionFilter.bus.on("update:url", () => {
64+
emit("update:url");
65+
});
6666
67-
const dialog = ref(false);
67+
const id = "cleanup-plan";
68+
baseSelectOptionFilter.id.value = id;
6869
70+
const dialog = ref(false);
6971
const store = useStore();
70-
7172
const currentProduct = computed(() => store.getters.currentProduct);
72-
7373
const administrating = computed(() => {
7474
return currentProduct.value?.administrating;
7575
});
@@ -82,10 +82,6 @@ watch(dialog, value => {
8282
baseSelectOptionFilter.bus.emit("update");
8383
});
8484
85-
baseSelectOptionFilter.bus.on("update:url", () => {
86-
emit("update:url");
87-
});
88-
8985
function updateReportFilter() {
9086
baseSelectOptionFilter.setReportFilter({
9187
cleanupPlanNames:

web/server/vue-cli/src/views/Reports.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
:must-sort="true"
2828
show-select
2929
:mobile-breakpoint="1100"
30-
item-value="$id"
30+
item-value="bugHash"
3131
@update:expanded="itemExpanded"
3232
>
3333
<template v-slot:top>
@@ -375,7 +375,7 @@ const formattedReports = computed(function() {
375375
return {
376376
..._report,
377377
"$detectionStatusTitle": _detectionStatusTitle,
378-
"$id": _id,
378+
"id": _id,
379379
"sameReports": _report.sameReports,
380380
"timestamp": _report.annotations["timestamp"],
381381
"testcase": _report.annotations["testcase"],

0 commit comments

Comments
 (0)