diff --git a/src/app/core/services/phase.service.ts b/src/app/core/services/phase.service.ts
index 4d168f0a..196aa43c 100644
--- a/src/app/core/services/phase.service.ts
+++ b/src/app/core/services/phase.service.ts
@@ -90,7 +90,7 @@ export class PhaseService {
if (this.currentPhase === Phase.issuesViewer) {
/** Adds past repositories to phase */
- this.otherRepos.push(this.currentRepo);
+ (this.otherRepos || []).push(this.currentRepo);
}
this.setRepository(repo, this.otherRepos);
diff --git a/src/app/shared/layout/header.component.html b/src/app/shared/layout/header.component.html
index 0632a9aa..85de623f 100644
--- a/src/app/shared/layout/header.component.html
+++ b/src/app/shared/layout/header.component.html
@@ -39,9 +39,9 @@
- {{ this.currentRepo }}
+ {{ this.currentRepo || "No Repository Set"}}
-
diff --git a/src/app/shared/layout/header.component.ts b/src/app/shared/layout/header.component.ts
index 5755e381..fea4ede4 100644
--- a/src/app/shared/layout/header.component.ts
+++ b/src/app/shared/layout/header.component.ts
@@ -15,6 +15,7 @@ import { IssueService } from '../../core/services/issue.service';
import { LabelService } from '../../core/services/label.service';
import { LoggingService } from '../../core/services/logging.service';
import { PhaseDescription, PhaseService } from '../../core/services/phase.service';
+import { RepoUrlCacheService } from '../../core/services/repo-url-cache.service';
import { UserService } from '../../core/services/user.service';
const ISSUE_TRACKER_URL = 'https://github.com/CATcher-org/WATcher/issues';
@@ -50,6 +51,7 @@ export class HeaderComponent implements OnInit {
private location: Location,
private githubEventService: GithubEventService,
private issueService: IssueService,
+ private repoUrlCacheService: RepoUrlCacheService,
private labelService: LabelService,
private errorHandlingService: ErrorHandlingService,
private githubService: GithubService,
@@ -64,6 +66,12 @@ export class HeaderComponent implements OnInit {
this.prevUrl = e[0].urlAfterRedirects;
});
+ this.auth.currentAuthState.subscribe((state) => {
+ if (auth.isAuthenticated()) {
+ this.openChangeRepoDialog();
+ }
+ });
+
this.phaseService.repoSetState.subscribe((state) => {
if (auth.isAuthenticated() && phaseService.isRepoSet()) {
this.initializeRepoNameInTitle();
@@ -233,7 +241,30 @@ export class HeaderComponent implements OnInit {
}
const newRepo = Repo.of(res);
- this.changeRepositoryIfValid(newRepo, res);
+ if (this.phaseService.isRepoSet()) {
+ this.changeRepositoryIfValid(newRepo, res);
+ } else {
+ /**
+ * From session-selection.component.ts
+ *
+ * Persist repo information in local browser storage
+ * To retrieve after authentication redirects back to WATcher
+ *
+ * Since localStorage::setItem with an undefined value can result in
+ * the subsequent value being stored as a string being 'undefined', check
+ * if undefined before storing it. Let's reset the items before setting them.
+ */
+ window.localStorage.removeItem('org');
+ window.localStorage.removeItem('dataRepo');
+
+ if (newRepo) {
+ window.localStorage.setItem('org', newRepo.owner);
+ window.localStorage.setItem('dataRepo', newRepo.name);
+
+ this.repoUrlCacheService.cache(newRepo.toString());
+ }
+ this.auth.setRepo().subscribe();
+ }
});
}
}
diff --git a/src/app/shared/repo-change-form/repo-change-form.component.html b/src/app/shared/repo-change-form/repo-change-form.component.html
index 91f31049..8381630d 100644
--- a/src/app/shared/repo-change-form/repo-change-form.component.html
+++ b/src/app/shared/repo-change-form/repo-change-form.component.html
@@ -1,4 +1,4 @@
-
+
Cancel
- Change Repo
+ {{ data.repoName ? "Change Repo" : "Select Repo" }}
diff --git a/tests/app/auth/login/login.component.spec.ts b/tests/app/auth/login/login.component.spec.ts
index 2864135c..87e21328 100644
--- a/tests/app/auth/login/login.component.spec.ts
+++ b/tests/app/auth/login/login.component.spec.ts
@@ -1,4 +1,4 @@
-import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { LoginComponent } from '../../../../src/app/auth/login/login.component';
import { AuthService } from '../../../../src/app/core/services/auth.service';
import { ErrorHandlingService } from '../../../../src/app/core/services/error-handling.service';
@@ -11,7 +11,7 @@ describe('LoginComponent', () => {
let component: LoginComponent;
let fixture: ComponentFixture;
- beforeEach(async(() => {
+ beforeEach(waitForAsync(() => {
authService = jasmine.createSpyObj('AuthService', ['startOAuthProcess']);
logger = jasmine.createSpyObj('LoggingService', ['info']);
errorHandlingService = jasmine.createSpyObj('ErrorHandlingService', ['handleError']);