diff --git a/src/app/user/overview/overview.component.spec.ts b/src/app/user/overview/overview.component.spec.ts index 88210da9a6..7502d7dbae 100644 --- a/src/app/user/overview/overview.component.spec.ts +++ b/src/app/user/overview/overview.component.spec.ts @@ -143,6 +143,7 @@ describe('OverviewComponent', () => { anythingProj.shortcode = '0001'; anythingProj.keywords = ['arbitrary test data', 'things']; anythingProj.shortname = 'anything'; + anythingProj.status = true; // add project to list of users projects loggedInUser.body.user.projects = [anythingProj]; @@ -272,7 +273,7 @@ describe('OverviewComponent', () => { it('should populate project lists correctly', () => { expect(testHostComponent.overviewComp.userProjects.length).toEqual(0); - expect(testHostComponent.overviewComp.otherProjects.length).toEqual(8); + expect(testHostComponent.overviewComp.otherProjects.length).toEqual(7); }); it('should NOT show the "Create new project" button', async () => { diff --git a/src/app/user/overview/overview.component.ts b/src/app/user/overview/overview.component.ts index 1f933b5695..23fbacd813 100644 --- a/src/app/user/overview/overview.component.ts +++ b/src/app/user/overview/overview.component.ts @@ -39,7 +39,7 @@ export class OverviewComponent implements OnInit { this.session = this._session.getSession(); // if session is null, user is not logged in - if(this.session) { + if (this.session) { this.username = this.session.user.name; this.sysAdmin = this.session.user.sysAdmin; } @@ -69,7 +69,13 @@ export class OverviewComponent implements OnInit { this.otherProjects = []; for (const project of response.body.projects) { - this.otherProjects.push(project); + // for not logged in user don't display deactivated projects + if (!this.session && project.status !== false) { + this.otherProjects.push(project); + } + if (this.sysAdmin) { + this.otherProjects.push(project); + } } this.loading = false; @@ -87,9 +93,11 @@ export class OverviewComponent implements OnInit { this.userProjects = []; this.otherProjects = []; - // get list of all projects the user is a member of + // get list of all projects the user is a member of except the deactivated ones for (const project of userResponse.body.user.projects) { - this.userProjects.push(project); + if (project.status !== false) { + this.userProjects.push(project); + } } this._dspApiConnection.admin.projectsEndpoint.getProjects().subscribe( @@ -97,7 +105,7 @@ export class OverviewComponent implements OnInit { // get list of all projects the user is NOT a member of for (const project of projectsResponse.body.projects) { - if(this.userProjects.findIndex(userProj => userProj.id === project.id) === -1){ + if (this.userProjects.findIndex(userProj => userProj.id === project.id) === -1) { this.otherProjects.push(project); } }