Skip to content

Commit

Permalink
Revert "Deploy v1.1.1 (CATcher-org#292)"
Browse files Browse the repository at this point in the history
This reverts commit 263426a.
  • Loading branch information
NereusWB922 committed Mar 31, 2024
1 parent 263426a commit 6c40fa0
Show file tree
Hide file tree
Showing 19 changed files with 269 additions and 341 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "WATcher",
"version": "1.1.1",
"version": "1.1.0",
"main": "main.js",
"scripts": {
"ng": "ng",
Expand All @@ -24,7 +24,7 @@
"husky": {
"hooks": {
"pre-commit": "pretty-quick --staged",
"pre-push": "npm run lint && npm run test"
"pre-push": "npm run lint"
}
},
"dependencies": {
Expand Down
8 changes: 5 additions & 3 deletions src/app/core/models/milestone.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
* Represents a milestone and its attributes fetched from Github.
*/
export class Milestone {
static DefaultMilestone: Milestone = new Milestone({ title: 'Without a milestone', state: null });
static DefaultMilestone: Milestone = new Milestone({ number: 'untracked', title: 'Without a milestone', state: null });
readonly number: string; // equivalent to the id of an issue e.g. milestone #1
title: string;
state: string;

constructor(milestone: { title: string; state: string }) {
constructor(milestone: { number: string; title: string; state: string }) {
this.number = milestone.number;
this.title = milestone.title;
this.state = milestone.state;
}

public equals(milestone: Milestone) {
return this.title === milestone.title;
return this.number === milestone.number;
}
}
38 changes: 10 additions & 28 deletions src/app/core/services/filters.service.ts
Original file line number Diff line number Diff line change
@@ -1,57 +1,39 @@
import { Injectable } from '@angular/core';
import { Sort } from '@angular/material/sort';
import { BehaviorSubject, pipe } from 'rxjs';

export type Filter = {
title: string;
status: string;
type: string;
sort: Sort;
labels: string[];
milestones: string[];
hiddenLabels?: Set<string>;
};

export const DEFAULT_FILTER: Filter = {
title: '',
status: 'all',
type: 'all',
sort: { active: 'id', direction: 'asc' },
labels: [],
milestones: []
};
import { DEFAULT_DROPDOWN_FILTER, DropdownFilter } from '../../shared/issue-tables/dropdownfilter';

@Injectable({
providedIn: 'root'
})

/**
* Responsible for centralising filters
* Filters are subscribed to and emitted from this service
*/
export class FiltersService {
public filter$ = new BehaviorSubject<Filter>(DEFAULT_FILTER);
public dropdownFilter$ = new BehaviorSubject<DropdownFilter>(DEFAULT_DROPDOWN_FILTER);

private _validateFilter = pipe(this.updateStatusPairing, this.updateTypePairing);

clearFilters(): void {
this.filter$.next(DEFAULT_FILTER);
this.dropdownFilter$.next(DEFAULT_DROPDOWN_FILTER);
}

updateFilters(newFilters: Partial<Filter>): void {
let nextDropdownFilter: Filter = {
...this.filter$.value,
updateFilters(newFilters: Partial<DropdownFilter>): void {
let nextDropdownFilter: DropdownFilter = {
...this.dropdownFilter$.value,
...newFilters
};

nextDropdownFilter = this._validateFilter(nextDropdownFilter);

this.filter$.next(nextDropdownFilter);
this.dropdownFilter$.next(nextDropdownFilter);
}

/**
* Changes type to a valid, default value when an incompatible combination of type and status is encountered.
*/
updateTypePairing(dropdownFilter: Filter): Filter {
updateTypePairing(dropdownFilter: DropdownFilter): DropdownFilter {
if (dropdownFilter.status === 'merged') {
dropdownFilter.type = 'pullrequest';
}
Expand All @@ -61,7 +43,7 @@ export class FiltersService {
/**
* Changes status to a valid, default value when an incompatible combination of type and status is encountered.
*/
updateStatusPairing(dropdownFilter: Filter): Filter {
updateStatusPairing(dropdownFilter: DropdownFilter): DropdownFilter {
if (dropdownFilter.status === 'merged' && dropdownFilter.type === 'issue') {
dropdownFilter.status = 'all';
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/issues-viewer/card-view/card-view.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<div class="scrollable-container-wrapper">
<div class="scrollable-container">
<div class="issue-pr-cards" *ngFor="let issue of this.issues$ | async; index as i">
<app-issue-pr-card [issue]="issue" [filter]="issues.filter"></app-issue-pr-card>
<app-issue-pr-card [issue]="issue" [dropdownFilter]="issues.dropdownFilter"></app-issue-pr-card>
</div>
<mat-card class="loading-spinner" *ngIf="this.issues.isLoading$ | async">
<mat-progress-spinner color="primary" mode="indeterminate" diameter="50" strokeWidth="5"></mat-progress-spinner>
Expand Down
12 changes: 6 additions & 6 deletions src/app/shared/filter-bar/filter-bar.component.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<mat-grid-list cols="7" rowHeight="80px">
<mat-grid-tile colspan="3">
<mat-form-field class="search-bar">
<input matInput (keyup)="this.filtersService.updateFilters({ title: $event.target.value })" placeholder="Search" />
<input matInput (keyup)="applyFilter($event.target.value)" placeholder="Search" />
</mat-form-field>
</mat-grid-tile>

<mat-grid-tile colspan="3">
<div class="dropdown-filters">
<mat-form-field appearance="standard">
<mat-label>Status</mat-label>
<mat-select [value]="this.filter.status" (selectionChange)="this.filtersService.updateFilters({ status: $event.value })">
<mat-select [value]="this.dropdownFilter.status" (selectionChange)="this.filtersService.updateFilters({ status: $event.value })">
<mat-option value="all">All</mat-option>
<mat-option value="open">Open</mat-option>
<mat-option value="closed">Closed</mat-option>
Expand All @@ -18,7 +18,7 @@
</mat-form-field>
<mat-form-field appearance="standard">
<mat-label>Type</mat-label>
<mat-select [value]="this.filter.type" (selectionChange)="this.filtersService.updateFilters({ type: $event.value })">
<mat-select [value]="this.dropdownFilter.type" (selectionChange)="this.filtersService.updateFilters({ type: $event.value })">
<mat-option value="all">All</mat-option>
<mat-option value="issue">Issue</mat-option>
<mat-option value="pullrequest">Pull Request</mat-option>
Expand All @@ -31,7 +31,7 @@
(matSortChange)="this.filtersService.updateFilters({ sort: $event })"
>
<mat-label>Sort</mat-label>
<mat-select [value]="this.filter.sort.active">
<mat-select [value]="this.dropdownFilter.sort.active">
<mat-option value="id">
<span mat-sort-header="id">ID</span>
</mat-option>
Expand All @@ -47,15 +47,15 @@
<mat-label>Milestone</mat-label>
<mat-select
#milestoneSelectorRef
[value]="this.filter.milestones"
[value]="this.dropdownFilter.milestones"
(selectionChange)="this.filtersService.updateFilters({ milestones: $event.value })"
[disabled]="this.milestoneService.hasNoMilestones"
multiple
>
<mat-select-trigger *ngIf="this.milestoneService.hasNoMilestones">
<span>No Milestones</span>
</mat-select-trigger>
<mat-option *ngFor="let milestone of this.milestoneService.milestones" [value]="milestone.title">
<mat-option *ngFor="let milestone of this.milestoneService.milestones" [value]="milestone.number">
{{ milestone.title }}
</mat-option>
</mat-select>
Expand Down
27 changes: 18 additions & 9 deletions src/app/shared/filter-bar/filter-bar.component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { AfterViewInit, Component, Input, OnDestroy, OnInit, QueryList, ViewChild } from '@angular/core';
import { MatSelect } from '@angular/material/select';
import { BehaviorSubject, Subscription } from 'rxjs';
import { DEFAULT_FILTER, Filter, FiltersService } from '../../core/services/filters.service';
import { FiltersService } from '../../core/services/filters.service';
import { LoggingService } from '../../core/services/logging.service';
import { MilestoneService } from '../../core/services/milestone.service';
import { PhaseService } from '../../core/services/phase.service';
import { DEFAULT_DROPDOWN_FILTER, DropdownFilter } from '../issue-tables/dropdownfilter';
import { FilterableComponent } from '../issue-tables/filterableTypes';
import { LabelFilterBarComponent } from './label-filter-bar/label-filter-bar.component';

Expand All @@ -23,7 +24,7 @@ export class FilterBarComponent implements OnInit, AfterViewInit, OnDestroy {
repoChangeSubscription: Subscription;

/** Selected dropdown filter value */
filter: Filter = DEFAULT_FILTER;
dropdownFilter: DropdownFilter = DEFAULT_DROPDOWN_FILTER;

/** Milestone subscription */
milestoneSubscription: Subscription;
Expand All @@ -46,9 +47,9 @@ export class FilterBarComponent implements OnInit, AfterViewInit, OnDestroy {
}

ngAfterViewInit(): void {
this.filtersService.filter$.subscribe((dropdownFilter) => {
this.filter = dropdownFilter;
this.applyFilter();
this.filtersService.dropdownFilter$.subscribe((dropdownFilter) => {
this.dropdownFilter = dropdownFilter;
this.applyDropdownFilter();
});
}

Expand All @@ -59,16 +60,24 @@ export class FilterBarComponent implements OnInit, AfterViewInit, OnDestroy {

/**
* Signals to IssuesDataTable that a change has occurred in filter.
* @param filterValue
*/
applyFilter() {
this.views$?.value?.forEach((v) => (v.retrieveFilterable().filter = this.filter));
applyFilter(filterValue: string) {
this.views$?.value?.forEach((v) => (v.retrieveFilterable().filter = filterValue));
}

/**
* Signals to IssuesDataTable that a change has occurred in dropdown filter.
*/
applyDropdownFilter() {
this.views$?.value?.forEach((v) => (v.retrieveFilterable().dropdownFilter = this.dropdownFilter));
}

/**
* Checks if program is filtering by type issue.
*/
isNotFilterIssue() {
return this.filter.type !== 'issue';
return this.dropdownFilter.type !== 'issue';
}

/**
Expand All @@ -79,7 +88,7 @@ export class FilterBarComponent implements OnInit, AfterViewInit, OnDestroy {
this.milestoneSubscription = this.milestoneService.fetchMilestones().subscribe(
(response) => {
this.logger.debug('IssuesViewerComponent: Fetched milestones from Github');
this.milestoneService.milestones.forEach((milestone) => this.filter.milestones.push(milestone.title));
this.milestoneService.milestones.forEach((milestone) => this.dropdownFilter.milestones.push(milestone.number));
},
(err) => {},
() => {}
Expand Down
2 changes: 1 addition & 1 deletion src/app/shared/issue-pr-card/issue-pr-card.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<app-issue-pr-card-header [issue]="issue"></app-issue-pr-card-header>
<mat-card-content>
<app-issue-pr-card-milestone [milestone]="issue.milestone"></app-issue-pr-card-milestone>
<app-issue-pr-card-labels [labels]="issue.githubLabels" [labelSet]="filter?.hiddenLabels"></app-issue-pr-card-labels>
<app-issue-pr-card-labels [labels]="issue.githubLabels" [labelSet]="dropdownFilter?.hiddenLabels"></app-issue-pr-card-labels>
</mat-card-content>
</span>
</a>
Expand Down
4 changes: 2 additions & 2 deletions src/app/shared/issue-pr-card/issue-pr-card.component.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Component, Input } from '@angular/core';
import { Issue } from '../../core/models/issue.model';
import { Filter } from '../../core/services/filters.service';
import { GithubService } from '../../core/services/github.service';
import { LabelService } from '../../core/services/label.service';
import { LoggingService } from '../../core/services/logging.service';
import { DropdownFilter } from '../issue-tables/dropdownfilter';

@Component({
selector: 'app-issue-pr-card',
Expand All @@ -12,7 +12,7 @@ import { LoggingService } from '../../core/services/logging.service';
})
export class IssuePrCardComponent {
@Input() issue: Issue;
@Input() filter?: Filter;
@Input() dropdownFilter?: DropdownFilter;

constructor(private logger: LoggingService, private githubService: GithubService, public labelService: LabelService) {}

Expand Down
33 changes: 23 additions & 10 deletions src/app/shared/issue-tables/IssuesDataTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ import { BehaviorSubject, merge, Observable, Subscription } from 'rxjs';
import { map } from 'rxjs/operators';
import { GithubUser } from '../../core/models/github-user.model';
import { Issue } from '../../core/models/issue.model';
import { DEFAULT_FILTER, Filter } from '../../core/services/filters.service';
import { IssueService } from '../../core/services/issue.service';
import { applyDropdownFilter } from './dropdownfilter';
import { applyDropdownFilter, DEFAULT_DROPDOWN_FILTER, DropdownFilter } from './dropdownfilter';
import { FilterableSource } from './filterableTypes';
import { paginateData } from './issue-paginator';
import { applySort } from './issue-sorter';
import { applySearchFilter } from './search-filter';

export class IssuesDataTable extends DataSource<Issue> implements FilterableSource {
public count = 0;
private filterChange = new BehaviorSubject(DEFAULT_FILTER);
private filterChange = new BehaviorSubject('');
private dropdownFilterChange = new BehaviorSubject(DEFAULT_DROPDOWN_FILTER);
private teamFilterChange = new BehaviorSubject('');
private issuesSubject = new BehaviorSubject<Issue[]>([]);
private issueSubscription: Subscription;

Expand All @@ -35,7 +36,9 @@ export class IssuesDataTable extends DataSource<Issue> implements FilterableSour
}

disconnect() {
this.dropdownFilterChange.complete();
this.filterChange.complete();
this.teamFilterChange.complete();
this.issuesSubject.complete();
this.issueSubscription.unsubscribe();
this.issueService.stopPollIssues();
Expand All @@ -47,7 +50,9 @@ export class IssuesDataTable extends DataSource<Issue> implements FilterableSour
page = this.paginator.page;
}

const displayDataChanges = [this.issueService.issues$, page, this.filterChange].filter((x) => x !== undefined);
const displayDataChanges = [this.issueService.issues$, page, this.filterChange, this.dropdownFilterChange].filter(
(x) => x !== undefined
);

this.issueService.startPollIssues();
this.issueSubscription = merge(...displayDataChanges)
Expand Down Expand Up @@ -75,13 +80,13 @@ export class IssuesDataTable extends DataSource<Issue> implements FilterableSour
});
}

// Apply Filters
data = applyDropdownFilter(this.filter, data);
// Dropdown Filters
data = applyDropdownFilter(this.dropdownFilter, data);

data = applySearchFilter(this.filter.title, this.displayedColumn, this.issueService, data);
data = applySearchFilter(this.filter, this.displayedColumn, this.issueService, data);
this.count = data.length;

data = applySort(this.filter.sort, data);
data = applySort(this.dropdownFilter.sort, data);

if (this.paginator !== undefined) {
data = paginateData(this.paginator, data);
Expand All @@ -94,11 +99,19 @@ export class IssuesDataTable extends DataSource<Issue> implements FilterableSour
});
}

get filter(): Filter {
get filter(): string {
return this.filterChange.value;
}

set filter(filter: Filter) {
set filter(filter: string) {
this.filterChange.next(filter);
}

get dropdownFilter(): DropdownFilter {
return this.dropdownFilterChange.value;
}

set dropdownFilter(filter: DropdownFilter) {
this.dropdownFilterChange.next(filter);
}
}
Loading

0 comments on commit 6c40fa0

Please sign in to comment.