Skip to content

Commit

Permalink
Fix for no milestone case (#326)
Browse files Browse the repository at this point in the history
When there are no milestones in the repo,
the issue viewer shows nothing.

Change is made so that if there is no milestone
in the milestone service, do not apply the milestone filter.
  • Loading branch information
nknguyenhc authored Mar 30, 2024
1 parent 2eb2aba commit 3ce551e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/app/issues-viewer/card-view/card-view.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { Issue } from '../../core/models/issue.model';
import { FiltersService } from '../../core/services/filters.service';
import { GroupBy, GroupingContextService } from '../../core/services/grouping/grouping-context.service';
import { IssueService } from '../../core/services/issue.service';
import { MilestoneService } from '../../core/services/milestone.service';
import { FilterableComponent, FilterableSource } from '../../shared/issue-tables/filterableTypes';
import { IssuesDataTable } from '../../shared/issue-tables/IssuesDataTable';

Expand Down Expand Up @@ -57,14 +58,16 @@ export class CardViewComponent implements OnInit, AfterViewInit, OnDestroy, Filt
public element: ElementRef,
public issueService: IssueService,
public groupingContextService: GroupingContextService,
private filtersService: FiltersService
private filtersService: FiltersService,
private milestoneService: MilestoneService
) {}

ngOnInit() {
this.issues = new IssuesDataTable(
this.issueService,
this.groupingContextService,
this.filtersService,
this.milestoneService,
this.paginator,
this.headers,
this.group,
Expand Down
4 changes: 3 additions & 1 deletion src/app/shared/issue-tables/IssuesDataTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Issue } from '../../core/models/issue.model';
import { Filter, FiltersService } from '../../core/services/filters.service';
import { GroupingContextService } from '../../core/services/grouping/grouping-context.service';
import { IssueService } from '../../core/services/issue.service';
import { MilestoneService } from '../../core/services/milestone.service';
import { applyDropdownFilter } from './dropdownfilter';
import { FilterableSource } from './filterableTypes';
import { paginateData } from './issue-paginator';
Expand All @@ -25,6 +26,7 @@ export class IssuesDataTable extends DataSource<Issue> implements FilterableSour
private issueService: IssueService,
private groupingContextService: GroupingContextService,
private filtersService: FiltersService,
private milestoneService: MilestoneService,
private paginator: MatPaginator,
private displayedColumn: string[],
private group?: Group,
Expand Down Expand Up @@ -67,7 +69,7 @@ export class IssuesDataTable extends DataSource<Issue> implements FilterableSour
data = this.groupingContextService.getDataForGroup(data, this.group);

// Apply Filters
data = applyDropdownFilter(this.filter, data);
data = applyDropdownFilter(this.filter, data, !this.milestoneService.hasNoMilestones);

data = applySearchFilter(this.filter.title, this.displayedColumn, this.issueService, data);
this.count = data.length;
Expand Down
4 changes: 2 additions & 2 deletions src/app/shared/issue-tables/dropdownfilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const infoFromStatus = (statusString: string): StatusInfo => {
* This module exports a single function applyDropDownFilter which is called by IssueList.
* This functions returns the data passed in after all the filters of dropdownFilters are applied
*/
export function applyDropdownFilter(filter: Filter, data: Issue[]): Issue[] {
export function applyDropdownFilter(filter: Filter, data: Issue[], isFilteringByMilestone: boolean): Issue[] {
const filteredData: Issue[] = data.filter((issue) => {
let ret = true;

Expand All @@ -38,7 +38,7 @@ export function applyDropdownFilter(filter: Filter, data: Issue[]): Issue[] {
ret = ret && issue.issueOrPr === 'PullRequest';
}

ret = ret && filter.milestones.some((milestone) => issue.milestone.title === milestone);
ret = ret && (!isFilteringByMilestone || filter.milestones.some((milestone) => issue.milestone.title === milestone));
ret = ret && issue.labels.every((label) => !filter.deselectedLabels.has(label));
return ret && filter.labels.every((label) => issue.labels.includes(label));
});
Expand Down

0 comments on commit 3ce551e

Please sign in to comment.