110889: Added config to disable community/collection sidebar

This commit is contained in:
Alexandre Vryghem
2024-02-17 20:10:23 +01:00
parent 0bee02a501
commit 7bf7ee0ba7
9 changed files with 75 additions and 4 deletions

View File

@@ -75,7 +75,7 @@ cache:
anonymousCache:
# Maximum number of pages to cache. Default is zero (0) which means anonymous user cache is disabled.
# As all pages are cached in server memory, increasing this value will increase memory needs.
# Individual cached pages are usually small (<100KB), so a value of max=1000 would only require ~100MB of memory.
# Individual cached pages are usually small (<100KB), so a value of max=1000 would only require ~100MB of memory.
max: 0
# Amount of time after which cached pages are considered stale (in ms). After becoming stale, the cached
# copy is automatically refreshed on the next request.
@@ -279,8 +279,17 @@ item:
# settings menu. See pageSizeOptions in 'pagination-component-options.model.ts'.
pageSize: 5
# Community Page Config
community:
# Search tab config
searchSection:
showSidebar: true
# Collection Page Config
collection:
# Search tab config
searchSection:
showSidebar: true
edit:
undoTimeout: 10000 # 10 seconds
@@ -376,7 +385,7 @@ vocabularies:
vocabulary: 'srsc'
enabled: true
# Default collection/community sorting order at Advanced search, Create/update community and collection when there are not a query.
# Default collection/community sorting order at Advanced search, Create/update community and collection when there are not a query.
comcolSelectionSort:
sortField: 'dc.title'
sortDirection: 'ASC'
sortDirection: 'ASC'

View File

@@ -1,4 +1,5 @@
<ds-themed-search
[showSidebar]="showSidebar$ | async"
[showScopeSelector]="false"
[hideScopeInUrl]="true"
[scope]="(comcol$ | async)?.id">

View File

@@ -2,6 +2,8 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ComcolSearchSectionComponent } from './comcol-search-section.component';
import { ActivatedRoute } from '@angular/router';
import { ActivatedRouteStub } from '../../../testing/active-router.stub';
import { APP_CONFIG } from '../../../../../config/app-config.interface';
import { environment } from '../../../../../environments/environment.test';
describe('ComcolSearchSectionComponent', () => {
let component: ComcolSearchSectionComponent;
@@ -17,6 +19,7 @@ describe('ComcolSearchSectionComponent', () => {
ComcolSearchSectionComponent,
],
providers: [
{ provide: APP_CONFIG, useValue: environment },
{ provide: ActivatedRoute, useValue: route },
],
}).compileComponents();

View File

@@ -1,4 +1,4 @@
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, Inject } from '@angular/core';
import { Observable } from 'rxjs';
import { ActivatedRoute, Data } from '@angular/router';
import { map } from 'rxjs/operators';
@@ -7,7 +7,12 @@ import { SearchConfigurationService } from '../../../../core/shared/search/searc
import { RemoteData } from '../../../../core/data/remote-data';
import { Community } from '../../../../core/shared/community.model';
import { Collection } from '../../../../core/shared/collection.model';
import { APP_CONFIG, AppConfig } from '../../../../../config/app-config.interface';
import { hasValue } from '../../../empty.util';
/**
* The search tab on community & collection pages
*/
@Component({
selector: 'ds-comcol-search-section',
templateUrl: './comcol-search-section.component.html',
@@ -23,7 +28,10 @@ export class ComcolSearchSectionComponent implements OnInit {
comcol$: Observable<Community | Collection>;
showSidebar$: Observable<boolean>;
constructor(
@Inject(APP_CONFIG) public appConfig: AppConfig,
protected route: ActivatedRoute,
) {
}
@@ -32,6 +40,9 @@ export class ComcolSearchSectionComponent implements OnInit {
this.comcol$ = this.route.data.pipe(
map((data: Data) => (data.dso as RemoteData<Community | Collection>).payload),
);
this.showSidebar$ = this.comcol$.pipe(
map((comcol: Community | Collection) => hasValue(comcol) && this.appConfig[comcol.type as any].searchSection.showSidebar),
);
}
}

View File

@@ -8,6 +8,7 @@ import { SubmissionConfig } from './submission-config.interface';
import { FormConfig } from './form-config.interfaces';
import { LangConfig } from './lang-config.interface';
import { ItemConfig } from './item-config.interface';
import { CommunityPageConfig } from './community-page-config.interface';
import { CollectionPageConfig } from './collection-page-config.interface';
import { ThemeConfig } from './theme.model';
import { AuthConfig } from './auth-config.interfaces';
@@ -39,6 +40,7 @@ interface AppConfig extends Config {
communityList: CommunityListConfig;
homePage: HomeConfig;
item: ItemConfig;
community: CommunityPageConfig;
collection: CollectionPageConfig;
themes: ThemeConfig[];
mediaViewer: MediaViewerConfig;

View File

@@ -1,7 +1,18 @@
import { Config } from './config.interface';
/**
* Collection Page Config
*/
export interface CollectionPageConfig extends Config {
searchSection: CollectionSearchSectionConfig;
edit: {
undoTimeout: number;
};
}
/**
* Config related to the collection's search tab
*/
export interface CollectionSearchSectionConfig {
showSidebar: boolean;
}

View File

@@ -0,0 +1,15 @@
import { Config } from './config.interface';
/**
* Community Page Config
*/
export interface CommunityPageConfig extends Config {
searchSection: CommunitySearchSectionConfig;
}
/**
* Config related to the community's search tab
*/
export interface CommunitySearchSectionConfig {
showSidebar: boolean;
}

View File

@@ -22,6 +22,7 @@ import { HomeConfig } from './homepage-config.interface';
import { MarkdownConfig } from './markdown-config.interface';
import { FilterVocabularyConfig } from './filter-vocabulary-config';
import { DiscoverySortConfig } from './discovery-sort.config';
import { CommunityPageConfig } from './community-page-config.interface';
export class DefaultAppConfig implements AppConfig {
production = false;
@@ -287,8 +288,18 @@ export class DefaultAppConfig implements AppConfig {
}
};
// Community Page Config
community: CommunityPageConfig = {
searchSection: {
showSidebar: true,
},
};
// Collection Page Config
collection: CollectionPageConfig = {
searchSection: {
showSidebar: true,
},
edit: {
undoTimeout: 10000 // 10 seconds
}

View File

@@ -257,7 +257,15 @@ export const environment: BuildConfig = {
pageSize: 5
}
},
community: {
searchSection: {
showSidebar: true,
},
},
collection: {
searchSection: {
showSidebar: true,
},
edit: {
undoTimeout: 10000 // 10 seconds
}