-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
feat(filters): Add new tag filtering modes AND
, EXACT
& NOT
(@TristanMarion)
#6388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
13c26e6
24ab797
5ca9d9f
f5c5235
851ddd1
9faac20
9d040c4
967d66d
52fdf83
16cbe34
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -450,18 +450,70 @@ async function fillContent(): Promise<void> { | |
|
||
if (validTags === undefined) return; | ||
|
||
result.tags.forEach((tag) => { | ||
//check if i even need to check tags anymore | ||
if (!tagHide) return; | ||
//check if tag is valid | ||
if (validTags?.includes(tag)) { | ||
//tag valid, check if filter is on | ||
if (ResultFilters.getFilter("tags", tag)) tagHide = false; | ||
if (ResultFilters.getTagsFilterMode() === "or") { | ||
result.tags.forEach((tag) => { | ||
//check if i even need to check tags anymore | ||
if (!tagHide) return; | ||
//check if tag is valid | ||
if (validTags?.includes(tag)) { | ||
//tag valid, check if filter is on | ||
if (ResultFilters.getFilter("tags", tag)) tagHide = false; | ||
} else { | ||
//tag not found in valid tags, meaning probably deleted | ||
if (ResultFilters.getFilter("tags", "none")) tagHide = false; | ||
} | ||
}); | ||
} else if (ResultFilters.getTagsFilterMode() === "and") { | ||
// AND mode - show results that match ALL selected tags | ||
// First, identify all the enabled tags using validTags | ||
const enabledTagIds: string[] = []; | ||
|
||
// Loop through all valid tags to find which ones are enabled in the filter | ||
validTags.forEach((tagId) => { | ||
if (tagId !== "none" && ResultFilters.getFilter("tags", tagId)) { | ||
enabledTagIds.push(tagId); | ||
} | ||
}); | ||
|
||
if (enabledTagIds.length === 0) { | ||
// No tag filters enabled, show everything | ||
tagHide = false; | ||
Comment on lines
+478
to
+480
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since "none" does not get pushed to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed, TBH I did not know how to handle this edge case, do you think we should display only the tests with no tags at all ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, behavior-wise, only results with no tags should be shown imo. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually this is already done in the existing code and this block won't be reachable if the result has no tag so I will remove this part and ensure we have the correct behavior anyway |
||
} else { | ||
//tag not found in valid tags, meaning probably deleted | ||
if (ResultFilters.getFilter("tags", "none")) tagHide = false; | ||
// Check if result has ALL the enabled tag filters | ||
const resultHasAllTags = enabledTagIds.every((tagId) => | ||
result.tags?.includes(tagId) | ||
); | ||
Comment on lines
+483
to
+485
This comment was marked as resolved.
Sorry, something went wrong. |
||
|
||
if (resultHasAllTags) { | ||
tagHide = false; | ||
} | ||
} | ||
}); | ||
} else if (ResultFilters.getTagsFilterMode() === "exact") { | ||
// EXACT mode - show results where tags exactly match the selected filters | ||
// First, identify all the enabled tags | ||
const enabledTagIds: string[] = []; | ||
|
||
// Loop through all valid tags to find which ones are enabled in the filter | ||
validTags.forEach((tagId) => { | ||
if (tagId !== "none" && ResultFilters.getFilter("tags", tagId)) { | ||
enabledTagIds.push(tagId); | ||
} | ||
}); | ||
|
||
if (enabledTagIds.length === 0) { | ||
// No tag filters enabled, show everything | ||
tagHide = false; | ||
} else { | ||
// Check if result tags exactly match the enabled filters (same number and same tags) | ||
const resultHasExactTags = | ||
result.tags.length === enabledTagIds.length && | ||
enabledTagIds.every((tagId) => result.tags?.includes(tagId)); | ||
|
||
if (resultHasExactTags) { | ||
tagHide = false; | ||
} | ||
} | ||
} | ||
} | ||
|
||
if (tagHide) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can merge this condition with the previous one as they contain the same code, let me know what you prefer