-
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?
Changes from all commits
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ import { Observable } from 'rxjs'; | |
import { map } from 'rxjs/operators'; | ||
import { GithubUser } from '../../models/github-user.model'; | ||
import { Issue } from '../../models/issue.model'; | ||
import { FiltersService } from '../filters.service'; | ||
import { GithubService } from '../github.service'; | ||
import { GroupingStrategy } from './grouping-strategy.interface'; | ||
|
||
|
@@ -13,7 +14,7 @@ import { GroupingStrategy } from './grouping-strategy.interface'; | |
providedIn: 'root' | ||
}) | ||
export class AssigneeGroupingStrategy implements GroupingStrategy { | ||
constructor(private githubService: GithubService) {} | ||
constructor(private githubService: GithubService, private filtersService: FiltersService) {} | ||
|
||
/** | ||
* Retrieves data for a specific assignee. | ||
|
@@ -45,7 +46,13 @@ export class AssigneeGroupingStrategy implements GroupingStrategy { | |
* hidden group list if empty. | ||
*/ | ||
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 | ||
Comment on lines
48
to
+55
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. Should groups be forced into the hidden list? |
||
} | ||
|
||
private getDataAssignedToUser(issues: Issue[], user: GithubUser): Issue[] { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. This change will break when grouping by milestone. |
||
this.addToHiddenGroups(target); | ||
} else { | ||
this.removeFromHiddenGroups(target); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,9 @@ | |
*ngFor="let group of this.groupService.groups" | ||
class="issue-table" | ||
#card | ||
[ngStyle]="{ display: card.isLoading || card.issueLength > 0 ? 'initial' : 'none' }" | ||
[ngStyle]="{ | ||
display: card.isLoading || (card.issueLength > 0 && !groupService.hiddenGroups.includes(card.group)) ? 'initial' : 'none' | ||
}" | ||
Comment on lines
+14
to
+16
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. Should the group service be used as a condition to hide cards? |
||
[group]="group" | ||
[headers]="this.displayedColumns" | ||
(issueLengthChange)="this.groupService.updateHiddenGroups($event, group)" | ||
|
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
andgetMilestonesForCurrentlyActive
. 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.