Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(fulltext-search): filter out deactivated projects and system projects #1015

Merged
merged 2 commits into from Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -33,7 +33,6 @@
<button
mat-menu-item
class="project-item"
*ngIf="!doNotDisplay.includes(project.id)"
(click)="setProject(project); changeFocus()"
[matTooltip]="project.longname"
[matTooltipPosition]="'after'"
Expand Down Expand Up @@ -168,7 +167,6 @@
<span *ngFor="let project of projects">
<button
mat-menu-item
*ngIf="!doNotDisplay.includes(project.id)"
(click)="setProject(project); changeFocus()"
>
{{ project.shortname }}
Expand Down
Expand Up @@ -183,7 +183,7 @@ describe('FulltextSearchComponent', () => {
).toHaveBeenCalledTimes(1);

expect(testHostComponent.fulltextSearch.projects).toBeDefined();
expect(testHostComponent.fulltextSearch.projects.length).toEqual(8);
expect(testHostComponent.fulltextSearch.projects.length).toEqual(5);
expect(testHostComponent.fulltextSearch.projectfilter).toEqual(true);
expect(testHostComponent.fulltextSearch.projectLabel).toEqual(
'All projects'
Expand Down
Expand Up @@ -125,7 +125,7 @@ export class FulltextSearchComponent implements OnInit, OnChanges, OnDestroy {
overlayRef: OverlayRef;

// do not show the following projects: default system projects from knora
doNotDisplay: string[] = [
hiddenProjects: string[] = [
Constants.SystemProjectIRI,
Constants.DefaultSharedOntologyIRI,
];
Expand Down Expand Up @@ -210,15 +210,16 @@ export class FulltextSearchComponent implements OnInit, OnChanges, OnDestroy {
getAllProjects(): void {
this._dspApiConnection.admin.projectsEndpoint.getProjects().subscribe(
(response: ApiResponseData<ProjectsResponse>) => {
this.projects = response.body.projects;
// this.loadSystem = false;
// filter out deactivated projects and system projects
this.projects = response.body.projects.filter(p => p.status === true && !this.hiddenProjects.includes(p.id));

if (localStorage.getItem('currentProject') !== null) {
this.project = JSON.parse(
localStorage.getItem('currentProject')
);
}
this.projects = this._sortingService.keySortByAlphabetical(
response.body.projects,
this.projects,
'shortname'
);
},
Expand Down