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

The number of people and groups on access control page are now configurable #1956

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions config/config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,18 @@ collection:
edit:
undoTimeout: 10000 # 10 seconds

accesscontrol:
epeople:
# Number of entries in the epeople list in the access controll page.
# Rounded to the nearest size in the list of selectable sizes on the
# settings menu. See pageSizeOptions in 'pagination-component-options.model.ts'.
pageSize: 5
groups:
# Number of entries in the group list in the access controll page.
# Rounded to the nearest size in the list of selectable sizes on the
# settings menu. See pageSizeOptions in 'pagination-component-options.model.ts'.
pageSize: 5

# Theme Config
themes:
# Add additional themes here. In the case where multiple themes match a route, the first one
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ <h3 id="search" class="border-bottom pb-2">{{labelPrefix + 'search.head' | trans
</div>
</form>

<ds-themed-loading *ngIf="searching$ | async"></ds-themed-loading>
<ds-pagination
*ngIf="(pageInfoState$ | async)?.totalElements > 0 && !(searching$ | async)"
[paginationOptions]="config"
[pageInfoState]="pageInfoState$"
[collectionSize]="(pageInfoState$ | async)?.totalElements"
[hideGear]="true"
[hidePagerWhenSinglePage]="true">
<ds-themed-loading *ngIf="searching$ | async"></ds-themed-loading>
<ds-pagination
*ngIf="(pageInfoState$ | async)?.totalElements > 0 && !(searching$ | async)"
[paginationOptions]="paginationConfig"
[pageInfoState]="pageInfoState$"
[collectionSize]="(pageInfoState$ | async)?.totalElements"
[hideGear]="true"
[hidePagerWhenSinglePage]="true">

<div class="table-responsive">
<table id="epeople" class="table table-striped table-hover table-bordered">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import { RequestService } from '../../core/data/request.service';
import { PaginationService } from '../../core/pagination/pagination.service';
import { PaginationServiceStub } from '../../shared/testing/pagination-service.stub';
import { FindListOptions } from '../../core/data/find-list-options.model';
import { APP_CONFIG } from 'src/config/app-config.interface';
import { environment } from 'src/environments/environment';

describe('EPeopleRegistryComponent', () => {
let component: EPeopleRegistryComponent;
Expand Down Expand Up @@ -139,7 +141,8 @@ describe('EPeopleRegistryComponent', () => {
{ provide: FormBuilderService, useValue: builderService },
{ provide: Router, useValue: new RouterStub() },
{ provide: RequestService, useValue: jasmine.createSpyObj('requestService', ['removeByHrefSubstring']) },
{ provide: PaginationService, useValue: paginationService }
{ provide: PaginationService, useValue: paginationService },
{ provide: APP_CONFIG, useValue: environment }
],
schemas: [NO_ERRORS_SCHEMA]
}).compileComponents();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnDestroy, OnInit } from '@angular/core';
import { Component, OnDestroy, OnInit, Inject } from '@angular/core';
import { UntypedFormBuilder } from '@angular/forms';
import { Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
Expand All @@ -22,6 +22,7 @@ import { PageInfo } from '../../core/shared/page-info.model';
import { NoContent } from '../../core/shared/NoContent.model';
import { PaginationService } from '../../core/pagination/pagination.service';
import { DSONameService } from '../../core/breadcrumbs/dso-name.service';
import { AppConfig, APP_CONFIG } from 'src/config/app-config.interface';
import { getEPersonEditRoute, getEPersonsRoute } from '../access-control-routing-paths';

@Component({
Expand Down Expand Up @@ -59,11 +60,7 @@ export class EPeopleRegistryComponent implements OnInit, OnDestroy {
/**
* Pagination config used to display the list of epeople
*/
config: PaginationComponentOptions = Object.assign(new PaginationComponentOptions(), {
id: 'elp',
pageSize: 5,
currentPage: 1
});
paginationConfig: PaginationComponentOptions;

// The search form
searchForm;
Expand Down Expand Up @@ -92,13 +89,18 @@ export class EPeopleRegistryComponent implements OnInit, OnDestroy {
private paginationService: PaginationService,
public requestService: RequestService,
public dsoNameService: DSONameService,
) {
@Inject(APP_CONFIG) protected appConfig: AppConfig) {
this.currentSearchQuery = '';
this.currentSearchScope = 'metadata';
this.searchForm = this.formBuilder.group(({
scope: 'metadata',
query: '',
}));
this.paginationConfig = Object.assign(new PaginationComponentOptions(), {
id: 'elp',
pageSize: this.appConfig.accesscontrol.epeople.pageSize,
currentPage: 1
});
}

ngOnInit() {
Expand Down Expand Up @@ -145,7 +147,7 @@ export class EPeopleRegistryComponent implements OnInit, OnDestroy {
if (hasValue(this.findListOptionsSub)) {
this.findListOptionsSub.unsubscribe();
}
this.findListOptionsSub = this.paginationService.getCurrentPagination(this.config.id, this.config).pipe(
this.findListOptionsSub = this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig).pipe(
switchMap((findListOptions) => {
const query: string = data.query;
const scope: string = data.scope;
Expand All @@ -154,14 +156,14 @@ export class EPeopleRegistryComponent implements OnInit, OnDestroy {
queryParamsHandling: 'merge'
});
this.currentSearchQuery = query;
this.paginationService.resetPage(this.config.id);
this.paginationService.resetPage(this.paginationConfig.id);
}
if (scope != null && this.currentSearchScope !== scope) {
void this.router.navigate([getEPersonsRoute()], {
queryParamsHandling: 'merge'
});
this.currentSearchScope = scope;
this.paginationService.resetPage(this.config.id);
this.paginationService.resetPage(this.paginationConfig.id);

}
return this.epersonService.searchByScope(this.currentSearchScope, this.currentSearchQuery, {
Expand Down Expand Up @@ -229,7 +231,7 @@ export class EPeopleRegistryComponent implements OnInit, OnDestroy {
*/
ngOnDestroy(): void {
this.cleanupSubscribes();
this.paginationService.clearPagination(this.config.id);
this.paginationService.clearPagination(this.paginationConfig.id);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h3 id="search" class="border-bottom pb-2">{{messagePrefix + 'search.head' | tra
<ds-themed-loading *ngIf="loading$ | async"></ds-themed-loading>
<ds-pagination
*ngIf="(pageInfoState$ | async)?.totalElements > 0 && !(loading$ | async)"
[paginationOptions]="config"
[paginationOptions]="paginationConfig"
[pageInfoState]="pageInfoState$"
[collectionSize]="(pageInfoState$ | async)?.totalElements"
[hideGear]="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import { FeatureID } from '../../core/data/feature-authorization/feature-id';
import { NoContent } from '../../core/shared/NoContent.model';
import { DSONameService } from '../../core/breadcrumbs/dso-name.service';
import { DSONameServiceMock, UNDEFINED_NAME } from '../../shared/mocks/dso-name.service.mock';
import { environment } from 'src/environments/environment';
import { APP_CONFIG } from 'src/config/app-config.interface';

describe('GroupsRegistryComponent', () => {
let component: GroupsRegistryComponent;
Expand Down Expand Up @@ -182,7 +184,8 @@ describe('GroupsRegistryComponent', () => {
{ provide: Router, useValue: new RouterMock() },
{ provide: AuthorizationDataService, useValue: authorizationService },
{ provide: PaginationService, useValue: paginationService },
{ provide: RequestService, useValue: jasmine.createSpyObj('requestService', ['removeByHrefSubstring']) }
{ provide: RequestService, useValue: jasmine.createSpyObj('requestService', ['removeByHrefSubstring']) },
{ provide: APP_CONFIG, useValue: environment }
],
schemas: [NO_ERRORS_SCHEMA]
}).compileComponents();
Expand Down
24 changes: 13 additions & 11 deletions src/app/access-control/group-registry/groups-registry.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnDestroy, OnInit } from '@angular/core';
import { Component, Inject, OnDestroy, OnInit } from '@angular/core';
import { UntypedFormBuilder } from '@angular/forms';
import { Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
Expand Down Expand Up @@ -38,6 +38,7 @@ import { NoContent } from '../../core/shared/NoContent.model';
import { PaginationService } from '../../core/pagination/pagination.service';
import { followLink } from '../../shared/utils/follow-link-config.model';
import { DSONameService } from '../../core/breadcrumbs/dso-name.service';
import { APP_CONFIG, AppConfig } from 'src/config/app-config.interface';

@Component({
selector: 'ds-groups-registry',
Expand All @@ -54,11 +55,7 @@ export class GroupsRegistryComponent implements OnInit, OnDestroy {
/**
* Pagination config used to display the list of groups
*/
config: PaginationComponentOptions = Object.assign(new PaginationComponentOptions(), {
id: 'gl',
pageSize: 5,
currentPage: 1
});
paginationConfig: PaginationComponentOptions;

/**
* A BehaviorSubject with the list of GroupDtoModel objects made from the Groups in the repository or
Expand Down Expand Up @@ -107,11 +104,16 @@ export class GroupsRegistryComponent implements OnInit, OnDestroy {
private paginationService: PaginationService,
public requestService: RequestService,
public dsoNameService: DSONameService,
) {
@Inject(APP_CONFIG) protected appConfig: AppConfig) {
this.currentSearchQuery = '';
this.searchForm = this.formBuilder.group(({
query: this.currentSearchQuery,
}));
this.paginationConfig = Object.assign(new PaginationComponentOptions(), {
id: 'elp',
pageSize: this.appConfig.accesscontrol.groups.pageSize,
currentPage: 1
});
}

ngOnInit() {
Expand All @@ -127,13 +129,13 @@ export class GroupsRegistryComponent implements OnInit, OnDestroy {
this.searchSub.unsubscribe();
this.subs = this.subs.filter((sub: Subscription) => sub !== this.searchSub);
}
this.searchSub = this.paginationService.getCurrentPagination(this.config.id, this.config).pipe(
this.searchSub = this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig).pipe(
tap(() => this.loading$.next(true)),
switchMap((paginationOptions) => {
const query: string = data.query;
if (query != null && this.currentSearchQuery !== query) {
this.currentSearchQuery = query;
this.paginationService.updateRouteWithUrl(this.config.id, [], {page: 1});
this.paginationService.updateRouteWithUrl(this.paginationConfig.id, [], {page: 1});
}
return this.groupService.searchGroups(this.currentSearchQuery.trim(), {
currentPage: paginationOptions.currentPage,
Expand Down Expand Up @@ -267,7 +269,7 @@ export class GroupsRegistryComponent implements OnInit, OnDestroy {
*/
ngOnDestroy(): void {
this.cleanupSubscribes();
this.paginationService.clearPagination(this.config.id);
this.paginationService.clearPagination(this.paginationConfig.id);
}


Expand All @@ -276,7 +278,7 @@ export class GroupsRegistryComponent implements OnInit, OnDestroy {
this.paginationSub.unsubscribe();
}
this.subs.filter((sub) => hasValue(sub)).forEach((sub) => sub.unsubscribe());
this.paginationService.clearPagination(this.config.id);
this.paginationService.clearPagination(this.paginationConfig.id);
}

}
26 changes: 26 additions & 0 deletions src/config/access-control-config.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Config } from './config.interface';

/**
* Config that determines the access control screen
*/
export interface AccessControlConfig extends Config {

epeople: {
/**
* Number of entries in the epeople list in the access controll page.
* Rounded to the nearest size in the list of selectable sizes on the settings
* menu. See pageSizeOptions in 'pagination-component-options.model.ts'.
*/
pageSize: number;
};

groups: {
/**
* Number of entries in the group list in the access controll page.
* Rounded to the nearest size in the list of selectable sizes on the settings
* menu. See pageSizeOptions in 'pagination-component-options.model.ts'.
*/
pageSize: number;
}

}
2 changes: 2 additions & 0 deletions src/config/app-config.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { InfoConfig } from './info-config.interface';
import { CommunityListConfig } from './community-list-config.interface';
import { HomeConfig } from './homepage-config.interface';
import { MarkdownConfig } from './markdown-config.interface';
import { AccessControlConfig } from './access-control-config.interface';
import { FilterVocabularyConfig } from './filter-vocabulary-config';
import { DiscoverySortConfig } from './discovery-sort.config';

Expand All @@ -40,6 +41,7 @@ interface AppConfig extends Config {
homePage: HomeConfig;
item: ItemConfig;
collection: CollectionPageConfig;
accesscontrol: AccessControlConfig;
themes: ThemeConfig[];
mediaViewer: MediaViewerConfig;
bundle: BundleConfig;
Expand Down
16 changes: 16 additions & 0 deletions src/config/default-app-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { InfoConfig } from './info-config.interface';
import { CommunityListConfig } from './community-list-config.interface';
import { HomeConfig } from './homepage-config.interface';
import { MarkdownConfig } from './markdown-config.interface';
import { AccessControlConfig } from './access-control-config.interface';
import { FilterVocabularyConfig } from './filter-vocabulary-config';
import { DiscoverySortConfig } from './discovery-sort.config';

Expand Down Expand Up @@ -296,6 +297,21 @@ export class DefaultAppConfig implements AppConfig {
}
};

accesscontrol: AccessControlConfig = {
epeople: {
// Number of entries in the epeople list in the access controll page.
// Rounded to the nearest size in the list of selectable sizes on the
// settings menu. See pageSizeOptions in 'pagination-component-options.model.ts'.
pageSize: 5
},
groups: {
// Number of entries in the groups list in the access controll page.
// Rounded to the nearest size in the list of selectable sizes on the
// settings menu. See pageSizeOptions in 'pagination-component-options.model.ts'.
pageSize: 5
}
};

// Theme Config
themes: ThemeConfig[] = [
// Add additional themes here. In the case where multiple themes match a route, the first one
Expand Down
14 changes: 14 additions & 0 deletions src/environments/environment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,20 @@ export const environment: BuildConfig = {
undoTimeout: 10000 // 10 seconds
}
},
accesscontrol: {
epeople: {
// Number of entries in the epeople list in the access controll page.
// Rounded to the nearest size in the list of selectable sizes on the
// settings menu. See pageSizeOptions in 'pagination-component-options.model.ts'.
pageSize: 5
},
groups: {
// Number of entries in the group list in the access controll page.
// Rounded to the nearest size in the list of selectable sizes on the
// settings menu. See pageSizeOptions in 'pagination-component-options.model.ts'.
pageSize: 5
}
},
themes: [
{
name: 'full-item-page-theme',
Expand Down
Loading