Skip to content

Commit 27d87b7

Browse files
[web] Fix timing issue in run filter
Run filter was getting the run name and tag from the global store which made it lose sync and not getting a valid result before setting the URL. This change returns the run id and tag to the update URL function without the need for global store to return the data in time.
1 parent 82b9230 commit 27d87b7

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

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

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ const selectTagMenu = ref(false);
183183
const selectTagForRun = ref(null);
184184
const prevSelectedRuns = ref([]);
185185
const prevSelectedTagItems = ref([]);
186+
const selectedRunIds = ref([]);
187+
const selectedTagIds = ref([]);
186188
const search = ref({
187189
placeHolder: "Search for run names (e.g.: myrun*)...",
188190
regexLabel: "Filter by wildcard pattern (e.g.: myrun*)",
@@ -313,6 +315,7 @@ async function initByUrl() {
313315
if (_runs.length || _tags.length) {
314316
let _selectedTags = [];
315317
if (_tags.length) {
318+
selectedTagIds.value = _tags;
316319
_selectedTags = await getSelectedTagItems(_tags);
317320
318321
// Add runs related to tags.
@@ -322,6 +325,7 @@ async function initByUrl() {
322325
_runs = [ ...new Set(_runs) ];
323326
}
324327
328+
selectedRunIds.value = _runs;
325329
const _selectedRuns = await getSelectedRunItems(_runs);
326330
prevSelectedRuns.value = _selectedRuns;
327331
prevSelectedTagItems.value = _selectedTags;
@@ -351,6 +355,8 @@ function applyTagSelection(selected) {
351355
}
352356
353357
async function clear(updateUrl) {
358+
selectedRunIds.value = [];
359+
selectedTagIds.value = [];
354360
await setSelectedItems([], [], updateUrl);
355361
}
356362
@@ -359,17 +365,27 @@ function selectRunTags(selectedItems) {
359365
}
360366
361367
function getUrlState() {
362-
const _runState = baseSelectOptionFilter.selectedItems.value.map(
368+
let _runState = selectedRunIds.value;
369+
const _newRunState = baseSelectOptionFilter.selectedItems.value.map(
363370
item => baseSelectOptionFilter.encodeValue.value(item.id)
364371
);
365372
366-
const _tagState = runFilter.selectedTagItems.value.map(item => item.id);
373+
if (_newRunState.length) {
374+
_runState = _newRunState;
375+
}
376+
377+
let _tagState = selectedTagIds.value;
378+
const _newTagState = runFilter.selectedTagItems.value.map(item => item.id);
379+
380+
if (_newTagState.length) {
381+
_tagState = _newTagState;
382+
}
367383
368384
return {
369385
[id]: _runState.length ? _runState : undefined,
370386
[runTagId.value]: _tagState.length ? _tagState : undefined
371387
};
372-
}
388+
};
373389
374390
async function setSelectedItems(runItems, tagItems, updateUrl=true) {
375391
baseSelectOptionFilter.selectedItems.value = runItems;

0 commit comments

Comments
 (0)