-
Notifications
You must be signed in to change notification settings - Fork 29
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
Fix incorrect assignee filtering #389
base: main
Are you sure you want to change the base?
Conversation
@Arif-Khalid @Eclipse-Dominator please help to review whenever convenient, thanks! |
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.
A good effort at eradicating the bug that works effectively.
However, a number of responsibilities of the services are eroded by the implementation.
I would suggest a much simpler and structured fix by looking at ~/src/app/shared/issue-tables/dropdownfilter.ts
. It already has reference to both services and has a consolidated section where filters are applied.
Please follow up with any questions or concerns you might have.
isInHiddenList(group: GithubUser): boolean { | ||
return group !== GithubUser.NO_ASSIGNEE; | ||
return ( | ||
group !== GithubUser.NO_ASSIGNEE && // group is not "No Assignee" | ||
!this.filtersService | ||
.getAssignees() | ||
.map((assignee) => assignee.login) | ||
.includes(group.login) | ||
); // group is not selected |
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.
Should groups be forced into the hidden list?
The functionality of the hidden list is to display information about which groups happen to be hidden because of the filters selected.
The use of this function to specify unique behaviour for groups that shouldn't be shown in the hidden list even when they are empty, such as the NO_ASSIGNEE group.
Forcing groups into the hidden list goes against this single responsibility and erodes into the responsibility of the filters.
[ngStyle]="{ | ||
display: card.isLoading || (card.issueLength > 0 && !groupService.hiddenGroups.includes(card.group)) ? 'initial' : 'none' | ||
}" |
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.
Should the group service be used as a condition to hide cards?
Hiding based on the group service erodes into the function of filtering where group service is only meant to group, not filter.
|
||
getAssignees(): GithubUser[] { | ||
return this.assigneeService.assignees.filter((assignee) => this.filter$.value.assignees.includes(assignee.login)); | ||
} |
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.
Should the filtersService contain a method to return a list of filtered assignees?
The filters service has the single responsibility of housing filters used throughout the application. Therefore the most updated filters should already be within the filter$ observable, handled by the component updating the filter. This method goes against this responsibility and its implementation even outside the filters service shouldn't happen since it implies an error in the use of the filters service.
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 understand your following of the already implemented methods getAssigneesForCurrentlyActive
and getMilestonesForCurrentlyActive
. Those methods are exclusively used to populate the filters based on the preset view which is currently handled by the filters service.
As an aside, it might make more sense to move the preset view and the corresponding functions out of filters service in the future.
@Arif-Khalid Thank you for your review. Before this PR, I did attempt a solution through the aforementioned
However, I do agree that this PR's solution is indeed a bit hard-coded and rather unstructured. I will try to look deeper into it, if you have any other suggestions on how to proceed as well please do let me know, or feel free to contact me on the slack channel. Thanks! ** For clarity's sake, this is what i am referring to as an issue-card: |
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.
Good attempt, however, the filtered items breaks when grouping by milestone.
This can be solved by including back the issueLength == 0
check but will
in turn break grouping by user check. Therefore, this might not be a good solution to solve this bug.
After some exploring, grouping service updates their hidden and displayed groups from result of IssueDataTable filters. Since this issue is present only for the case of multiple assignees., It is probably best to approach from the filters.
Some initial ideas that come to mind are:
let IssueDataTable obtain a list of hidden assignees (from some service probably)
this.issueSubscription = merge(...displayDataChanges)
.pipe(
// maps each change in display value to new issue ordering or filtering
map(() => {
/* if this.group.equals matches any value in hidden assignees
=> immediately return [] as this datatable is guarenteed to be hidden
*/
// ....
let data = <Issue[]>Object.values(this.issueService.issues$.getValue()).reverse();
if (this.defaultFilter) {
data = data.filter(this.defaultFilter);
}
// Filter by assignee of issue
data = this.groupingContextService.getDataForGroup(data, this.group);
We can guarentee its correctness as group.equals will only return true when group is of type GithubUser type implying that it is grouping via assignees. Therefore, doing so will cause IssueDataTable to emit 0 length which means the given group will be hidden by updateHiddenGroups
from group.service.ts
.
This shouldnt break other parts of the program in the future since updateHiddenGroup
takes in number of items in a group which this doesnt violate i think.
You can apply some typescript syntax to work around group being undefined like
e.g. if (this.group?.equals(...))
<- conditional would be false if group is undefined, which works fine in this case since we are testing for positives.
@@ -30,7 +30,7 @@ export class GroupService { | |||
updateHiddenGroups(issueLength: number, target: Group) { | |||
// If the group is in the hidden list, add it if it has no issues. | |||
// Also add it if it is unchecked in the filter. | |||
if (issueLength === 0 && this.groupingContextService.isInHiddenList(target)) { | |||
if (this.groupingContextService.isInHiddenList(target)) { |
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.
This change will break when grouping by milestone.
When IssueDataTable
displays milestone, all milestones with issues/pr assigned will call isInHiddenList
under the milestone context and all issues that originally belong to each milestone will be move to hidden.
Summary:
Fixes bug #385
Type of change:
Changes Made:
Assignee filter now correctly removes Assignee columns when it is not selected in the filter:
![image](https://private-user-images.githubusercontent.com/53986507/402346647-a34a8cae-f214-4ad1-91d8-451216809a34.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0Njk4NDgsIm5iZiI6MTczOTQ2OTU0OCwicGF0aCI6Ii81Mzk4NjUwNy80MDIzNDY2NDctYTM0YThjYWUtZjIxNC00YWQxLTkxZDgtNDUxMjE2ODA5YTM0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEzVDE3NTkwOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTEyNjlhOGRjMGRhZjVlM2U3YzdkYTk5N2MwNmFjMjY1NDc2MTQ0NTBlODczYjUzMWMzZGRmNmY0NTI3YTVlNGImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.KJY6uHuctZjBCuF7BLre-zN507RgTZmqSuCZnM1G1To)
Proposed Commit Message:
Checklist: