Skip to content

Commit

Permalink
Merge branch 'main' into 297-split-milestone
Browse files Browse the repository at this point in the history
  • Loading branch information
MadLamprey authored Mar 25, 2024
2 parents b6d0a9e + a65bb59 commit 34405f0
Show file tree
Hide file tree
Showing 42 changed files with 710 additions and 341 deletions.
19 changes: 19 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
categories:
- title: 'Features'
labels:
- 'category.Feature'
- 'category.Enhancement'
- title: 'Bug Fixes'
labels:
- 'category.Bug'
- title: 'Maintenance'
label: 'category.Chore'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.

template: |
## Changelog
$CHANGES
6 changes: 3 additions & 3 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ import { GithubEventService } from './core/services/githubevent.service';
import { IssueService } from './core/services/issue.service';
import { LabelService } from './core/services/label.service';
import { LoggingService } from './core/services/logging.service';
import { PhaseService } from './core/services/phase.service';
import { RepoSessionStorageService } from './core/services/repo-session-storage.service';
import { UserService } from './core/services/user.service';
import { ViewService } from './core/services/view.service';
import { IssuesViewerModule } from './issues-viewer/issues-viewer.module';
import { LabelDefinitionPopupComponent } from './shared/label-definition-popup/label-definition-popup.component';
import { HeaderComponent } from './shared/layout';
Expand Down Expand Up @@ -64,7 +64,7 @@ import { SharedModule } from './shared/shared.module';
UserService,
IssueService,
LabelService,
PhaseService,
ViewService,
GithubEventService,
Title,
ErrorHandlingService,
Expand All @@ -74,7 +74,7 @@ import { SharedModule } from './shared/shared.module';
{
provide: IssueService,
useFactory: IssueServiceFactory,
deps: [GithubService, UserService, PhaseService]
deps: [GithubService, UserService, ViewService]
},
{
provide: ErrorHandler,
Expand Down
8 changes: 4 additions & 4 deletions src/app/auth/auth.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { AuthService, AuthState } from '../core/services/auth.service';
import { ErrorHandlingService } from '../core/services/error-handling.service';
import { ErrorMessageService } from '../core/services/error-message.service';
import { LoggingService } from '../core/services/logging.service';
import { PhaseService } from '../core/services/phase.service';
import { UserService } from '../core/services/user.service';
import { ViewService } from '../core/services/view.service';

@Component({
selector: 'app-auth',
Expand All @@ -33,7 +33,7 @@ export class AuthComponent implements OnInit, OnDestroy {
private userService: UserService,
private errorHandlingService: ErrorHandlingService,
private router: Router,
private phaseService: PhaseService,
private viewService: ViewService,
private ngZone: NgZone,
private activatedRoute: ActivatedRoute,
private logger: LoggingService
Expand All @@ -46,7 +46,7 @@ export class AuthComponent implements OnInit, OnDestroy {
const state = this.activatedRoute.snapshot.queryParamMap.get('state');

if (this.authService.isAuthenticated()) {
this.router.navigate([this.phaseService.currentPhase]);
this.router.navigate([this.viewService.currentView]);
return;
}
this.initAccessTokenSubscription();
Expand Down Expand Up @@ -141,7 +141,7 @@ export class AuthComponent implements OnInit, OnDestroy {
}

isRepoSet(): boolean {
return this.phaseService.isRepoSet();
return this.viewService.isRepoSet();
}

get currentSessionOrg(): string {
Expand Down
49 changes: 48 additions & 1 deletion src/app/core/models/github-user.model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
export interface GithubUser {
import { Group } from './github/group.interface';

/**
* Represents raw data returned from the GitHub API about a user.
*/
export interface RawGithubUser {
avatar_url: string;
created_at: string;
html_url: string;
Expand All @@ -11,3 +16,45 @@ export interface GithubUser {
updated_at: string;
url: string;
}

/**
* Represents a GitHub user in WATcher
*/
export class GithubUser implements RawGithubUser, Group {
static NO_ASSIGNEE: GithubUser = new GithubUser({
avatar_url: '',
created_at: '',
html_url: '',
login: 'Unassigned',
name: '',
node_id: '',
two_factor_authentication: false,
site_admin: false,
type: '',
updated_at: '',
url: ''
});

avatar_url: string;
created_at: string;
html_url: string;
login: string;
name: string;
node_id: string;
two_factor_authentication: boolean;
site_admin: false;
type: string;
updated_at: string;
url: string;

constructor(rawData: RawGithubUser) {
Object.assign(this, rawData);
}

equals(other: any) {
if (!(other instanceof GithubUser)) {
return false;
}
return this.login === other.login;
}
}
8 changes: 8 additions & 0 deletions src/app/core/models/github/group.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Represents a group used for grouping purposes.
* Groups can be used to organize issues/prs based on certain criteria,
* such as milestones, assignees, or other properties.
*/
export interface Group {
equals(other: any): boolean;
}
2 changes: 1 addition & 1 deletion src/app/core/models/issue.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class Issue {
author: string;
isDraft: boolean;

/** Depending on the phase, assignees attribute can be derived from Github's assignee feature OR from the Github's issue description */
/** Depending on the view, assignees attribute can be derived from Github's assignee feature OR from the Github's issue description */
assignees?: string[];
labels?: string[];
githubLabels?: GithubLabel[];
Expand Down
8 changes: 0 additions & 8 deletions src/app/core/models/phase.model.ts

This file was deleted.

7 changes: 7 additions & 0 deletions src/app/core/models/repo-change-response.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Represents the response of the repo-change-form component
*/
export type RepoChangeResponse = {
repo: string;
keepFilters: boolean;
};
26 changes: 13 additions & 13 deletions src/app/core/models/session.model.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { pipe } from 'rxjs';
import { throwIfFalse } from '../../shared/lib/custom-ops';
import { Phase } from './phase.model';
import { Repo } from './repo.model';
import { View } from './view.model';

/**
* Session repository comprises the phase and its corresponding repository array.
* Session repository comprises the view and its corresponding repository array.
*/
export interface SessionRepo {
phase: Phase;
view: View;
repos: Repo[];
}

Expand All @@ -20,8 +20,8 @@ export interface SessionData {

export const SESSION_DATA_UNAVAILABLE = 'Session data does not exist.';
export const SESSION_DATA_MISSING_FIELDS = 'Session data does not contain any repositories.';
export const NO_VALID_OPEN_PHASES = 'Invalid phases in Session data.';
export const OPENED_PHASE_REPO_UNDEFINED = 'Phase has no repo defined.';
export const NO_VALID_OPEN_VIEWS = 'Invalid views in Session data.';
export const OPENED_VIEW_REPO_UNDEFINED = 'View has no repo defined.';

export function assertSessionDataIntegrity() {
return pipe(
Expand All @@ -30,8 +30,8 @@ export function assertSessionDataIntegrity() {
() => new Error(SESSION_DATA_UNAVAILABLE)
),
throwIfFalse(hasSessionRepo, () => new Error(SESSION_DATA_MISSING_FIELDS)),
throwIfFalse(arePhasesValid, () => new Error(NO_VALID_OPEN_PHASES)),
throwIfFalse(areReposDefined, () => new Error(OPENED_PHASE_REPO_UNDEFINED))
throwIfFalse(areViewsValid, () => new Error(NO_VALID_OPEN_VIEWS)),
throwIfFalse(areReposDefined, () => new Error(OPENED_VIEW_REPO_UNDEFINED))
);
}

Expand All @@ -44,24 +44,24 @@ function hasSessionRepo(sessionData: SessionData): boolean {
}

/**
* Checks if Phases belong to a pre-defined Phase.
* Checks if Views belong to a pre-defined View.
* @param sessionData
*/
function arePhasesValid(sessionData: SessionData): boolean {
function areViewsValid(sessionData: SessionData): boolean {
return sessionData.sessionRepo.reduce(
(isPhaseValidSoFar: boolean, currentPhaseRepo: SessionRepo) => isPhaseValidSoFar && currentPhaseRepo.phase in Phase,
(isViewValidSoFar: boolean, currentViewRepo: SessionRepo) => isViewValidSoFar && currentViewRepo.view in View,
true
);
}

/**
* Checks if each Phase has an associated repo defined as well.
* Checks if each View has an associated repo defined as well.
* @param sessionData
*/
function areReposDefined(sessionData: SessionData): boolean {
return sessionData.sessionRepo.reduce(
(isPhaseRepoDefinedSoFar: boolean, currentPhaseRepo: SessionRepo) =>
isPhaseRepoDefinedSoFar && !!currentPhaseRepo.repos && Array.isArray(currentPhaseRepo.repos) && currentPhaseRepo.repos.length > 0,
(isViewRepoDefinedSoFar: boolean, currentViewRepo: SessionRepo) =>
isViewRepoDefinedSoFar && !!currentViewRepo.repos && Array.isArray(currentViewRepo.repos) && currentViewRepo.repos.length > 0,
true
);
}
4 changes: 4 additions & 0 deletions src/app/core/models/view.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export enum View {
issuesViewer = 'issuesViewer',
activityDashboard = 'activityDashboard'
}
29 changes: 14 additions & 15 deletions src/app/core/services/auth.service.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import { Injectable } from '@angular/core';
import { NgZone } from '@angular/core';
import { Injectable, NgZone } from '@angular/core';
import { Title } from '@angular/platform-browser';
import { Router, RouterStateSnapshot } from '@angular/router';
import { BehaviorSubject, from, Observable, of } from 'rxjs';
import { catchError, map, mergeMap } from 'rxjs/operators';
import { AppConfig } from '../../../environments/environment';
import { generateSessionId } from '../../shared/lib/session';
import { uuid } from '../../shared/lib/uuid';
import { Phase } from '../models/phase.model';
import { View } from '../models/view.model';
import { ErrorHandlingService } from './error-handling.service';
import { GithubService } from './github.service';
import { GithubEventService } from './githubevent.service';
import { IssueService } from './issue.service';
import { LabelService } from './label.service';
import { LoggingService } from './logging.service';
import { PhaseService } from './phase.service';
import { UserService } from './user.service';
import { ViewService } from './view.service';

export enum AuthState {
'NotAuthenticated',
Expand Down Expand Up @@ -50,7 +49,7 @@ export class AuthService {
private userService: UserService,
private issueService: IssueService,
private labelService: LabelService,
private phaseService: PhaseService,
private viewService: ViewService,
private githubEventService: GithubEventService,
private titleService: Title,
private errorHandlingService: ErrorHandlingService,
Expand Down Expand Up @@ -118,7 +117,7 @@ export class AuthService {
*/
redirectToNext() {
const next = sessionStorage.getItem(AuthService.SESSION_NEXT_KEY);
this.phaseService
this.viewService
.setupFromUrl(next)
.pipe(
mergeMap(() => this.setRepo()),
Expand Down Expand Up @@ -156,17 +155,17 @@ export class AuthService {
this.userService.reset();
this.issueService.reset(true);
this.labelService.reset();
this.phaseService.reset();
this.viewService.reset();
this.githubEventService.reset();
this.logger.reset();
this.setLandingPageTitle();
this.issueService.setIssueTeamFilter('All Teams');
this.reset();
}

setTitleWithPhaseDetail(): void {
setTitleWithViewDetail(): void {
const appSetting = require('../../../../package.json');
const title = `${appSetting.name} ${appSetting.version} - ${this.phaseService.getCurrentRepositoryURL()}`;
const title = `${appSetting.name} ${appSetting.version} - ${this.viewService.getCurrentRepositoryURL()}`;
this.logger.info(`AuthService: Setting Title as ${title}`);
this.titleService.setTitle(title);
}
Expand Down Expand Up @@ -234,10 +233,10 @@ export class AuthService {
* Handles the clean up required after authentication and setting up of repository is completed.
*/
handleSetRepoSuccess(repoName: string) {
this.setTitleWithPhaseDetail();
this.router.navigate([Phase.issuesViewer], {
this.setTitleWithViewDetail();
this.router.navigate([View.issuesViewer], {
queryParams: {
[PhaseService.REPO_QUERY_PARAM_KEY]: repoName
[ViewService.REPO_QUERY_PARAM_KEY]: repoName
}
});
}
Expand All @@ -246,13 +245,13 @@ export class AuthService {
* Setup repository after authentication.
*/
setRepo(): Observable<boolean> {
return from(this.phaseService.initializeCurrentRepository()).pipe(
return from(this.viewService.initializeCurrentRepository()).pipe(
map(() => {
if (!this.phaseService.currentRepo) {
if (!this.viewService.currentRepo) {
return false;
}
this.githubEventService.setLatestChangeEvent();
this.handleSetRepoSuccess(this.phaseService.currentRepo.toString());
this.handleSetRepoSuccess(this.viewService.currentRepo.toString());
return true;
}),
catchError((error) => {
Expand Down
8 changes: 4 additions & 4 deletions src/app/core/services/factories/factory.auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { IssueService } from '../issue.service';
import { LabelService } from '../label.service';
import { LoggingService } from '../logging.service';
// import { MockAuthService } from '../mocks/mock.auth.service';
import { PhaseService } from '../phase.service';
import { UserService } from '../user.service';
import { ViewService } from '../view.service';

export function AuthServiceFactory(
router: Router,
Expand All @@ -20,7 +20,7 @@ export function AuthServiceFactory(
userService: UserService,
issueService: IssueService,
labelService: LabelService,
phaseService: PhaseService,
viewService: ViewService,
githubEventService: GithubEventService,
titleService: Title,
errorHandlingService: ErrorHandlingService,
Expand All @@ -35,7 +35,7 @@ export function AuthServiceFactory(
// userService,
// issueService,
// labelService,
// phaseService,
// viewService,
// githubEventService,
// titleService,
// logger
Expand All @@ -48,7 +48,7 @@ export function AuthServiceFactory(
userService,
issueService,
labelService,
phaseService,
viewService,
githubEventService,
titleService,
errorHandlingService,
Expand Down
Loading

0 comments on commit 34405f0

Please sign in to comment.