Skip to content

Commit b79a1b2

Browse files
[DURACOM-508] refactor, fix home/explore config issue, fix nested menus, fix comm/coll menu, improve tests
1 parent 86eea4e commit b79a1b2

25 files changed

Lines changed: 644 additions & 200 deletions

config/config.example.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ homePage:
404404
# Enable or disable the Discover filters on the homepage
405405
showDiscoverFilters: false
406406
# Enable or disable the dynamic layout configuration on the homepage
407-
enableDynamicLayout: true
407+
enableDynamicLayout: false
408408

409409
# Item Config
410410
item:
@@ -713,7 +713,7 @@ accessibility:
713713
layout:
714714
# Enable or disable the explore pages feature (/explore/:id routes and their navbar menu entries).
715715
# When false, explore routes redirect to 404 and the explore menu is hidden.
716-
enableExplorePages: true
716+
enableExplorePages: false
717717
# Configuration of icons and styles to be used for each authority controlled link
718718
authorityRef:
719719
- entityType: DEFAULT

src/app/app.menus.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { buildMenuStructure } from './shared/menu/menu.structure';
99
import { MenuID } from './shared/menu/menu-id.model';
1010
import { MenuRoute } from './shared/menu/menu-route.model';
1111
import { AccessControlMenuProvider } from './shared/menu/providers/access-control.menu';
12+
import { AdminCommunityListMenuProvider } from './shared/menu/providers/admin-community-list.menu';
1213
import { AdminSearchMenuProvider } from './shared/menu/providers/admin-search.menu';
1314
import { AuditLogsMenuProvider } from './shared/menu/providers/audit-item.menu';
1415
import { AuditOverviewMenuProvider } from './shared/menu/providers/audit-overview.menu';
@@ -64,6 +65,7 @@ export const MENUS = buildMenuStructure({
6465
ExploreMenuProvider,
6566
],
6667
[MenuID.ADMIN]: [
68+
AdminCommunityListMenuProvider,
6769
NewMenuProvider,
6870
EditMenuProvider,
6971
ImportMenuProvider,

src/app/core/data/section-data.service.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,9 @@ import { DSONameService } from '../breadcrumbs/dso-name.service';
66
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
77
import { ObjectCacheService } from '../cache/object-cache.service';
88
import { Section } from '../layout/models/section.model';
9-
import { FollowLinkConfig } from '../shared/follow-link-config.model';
109
import { HALEndpointService } from '../shared/hal-endpoint.service';
11-
import { FindAllData } from './base/find-all-data';
1210
import { IdentifiableDataService } from './base/identifiable-data.service';
1311
import { SearchDataImpl } from './base/search-data';
14-
import { FindListOptions } from './find-list-options.model';
1512
import { PaginatedList } from './paginated-list.model';
1613
import { RemoteData } from './remote-data';
1714
import { RequestService } from './request.service';
@@ -23,7 +20,6 @@ import { RequestService } from './request.service';
2320
export class SectionDataService extends IdentifiableDataService<Section> {
2421

2522
protected linkPath = 'sections';
26-
private findAllData: FindAllData<Section>;
2723
private searchData: SearchDataImpl<Section>;
2824

2925
constructor(
@@ -39,12 +35,6 @@ export class SectionDataService extends IdentifiableDataService<Section> {
3935
this.searchData = new SearchDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, this.responseMsToLive);
4036
}
4137

42-
/**
43-
* Find all the configured sections.
44-
*/
45-
findAll(options?: FindListOptions, useCachedVersionIfAvailable?: boolean, reRequestOnStale?: boolean, ...linksToFollow: FollowLinkConfig<Section>[]): Observable<RemoteData<PaginatedList<Section>>> {
46-
return this.findAllData.findAll(options, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow);
47-
}
4838

4939
/**
5040
* Finds all sections configured to be visible in the top navigation bar.

src/app/explore-page/explore-page.component.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
[sectionId]="sectionId"
1111
[topSection]="$any(sectionComponent)"></ds-top-section>
1212
}
13+
@case ('multi-column-top') {
14+
<ds-multi-column-top-section
15+
[sectionId]="sectionId"
16+
[topSection]="$any(sectionComponent)"></ds-multi-column-top-section>
17+
}
1318
@case ('browse') {
1419
<ds-browse-section
1520
[sectionId]="sectionId"

src/app/explore-page/explore-page.component.spec.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import { RemoteData } from '../core/data/remote-data';
3333
import {
3434
BrowseSection,
3535
FacetSection,
36+
MultiColumnTopSection,
3637
SearchSection,
3738
Section,
3839
TopSection,
@@ -41,6 +42,7 @@ import {
4142
import { ThemedBrowseSectionComponent } from '../shared/explore/section-component/browse-section/themed-browse-section.component';
4243
import { ThemedCountersSectionComponent } from '../shared/explore/section-component/counters-section/themed-counters-section.component';
4344
import { ThemedFacetSectionComponent } from '../shared/explore/section-component/facet-section/themed-facet-section.component';
45+
import { ThemedMultiColumnTopSectionComponent } from '../shared/explore/section-component/multi-column-top-section/themed-multi-column-top-section.component';
4446
import { ThemedSearchSectionComponent } from '../shared/explore/section-component/search-section/themed-search-section.component';
4547
import { ThemedTextSectionComponent } from '../shared/explore/section-component/text-section/themed-text-section.component';
4648
import { ThemedTopSectionComponent } from '../shared/explore/section-component/top-section/themed-top-section.component';
@@ -87,14 +89,24 @@ describe('ExploreComponent', () => {
8789
facetsPerRow: 4,
8890
};
8991

92+
const multiColumnTopComponent: MultiColumnTopSection = {
93+
discoveryConfigurationName: 'publication',
94+
componentType: 'multi-column-top',
95+
style: 'col-md-12',
96+
order: 'desc',
97+
sortField: 'dc.date.accessioned',
98+
titleKey: 'lastPublications',
99+
columnList: [],
100+
};
101+
90102
beforeEach(waitForAsync(() => {
91103

92104
sectionDataServiceStub = {
93105
findById(id: string): Observable<RemoteData<Section>> {
94106
if (id === 'publications') {
95107
const section = new Section();
96108
section.id = 'publications';
97-
section.componentRows = [[browseComponent, searchComponent], [topComponent], [facetComponent]];
109+
section.componentRows = [[browseComponent, searchComponent], [topComponent], [facetComponent], [multiColumnTopComponent]];
98110
return createSuccessfulRemoteDataObject$(section);
99111
} else {
100112
return of(null);
@@ -119,7 +131,7 @@ describe('ExploreComponent', () => {
119131
{ provide: SectionDataService, useValue: sectionDataServiceStub },
120132
{ provide: ActivatedRoute, useValue: route }],
121133
schemas: [NO_ERRORS_SCHEMA],
122-
}).overrideComponent(ExplorePageComponent, { remove: { imports: [ThemedTopSectionComponent, ThemedBrowseSectionComponent, ThemedSearchSectionComponent, ThemedFacetSectionComponent, ThemedTextSectionComponent, ThemedCountersSectionComponent] } }).compileComponents();
134+
}).overrideComponent(ExplorePageComponent, { remove: { imports: [ThemedTopSectionComponent, ThemedMultiColumnTopSectionComponent, ThemedBrowseSectionComponent, ThemedSearchSectionComponent, ThemedFacetSectionComponent, ThemedTextSectionComponent, ThemedCountersSectionComponent] } }).compileComponents();
123135

124136
}));
125137

@@ -133,9 +145,9 @@ describe('ExploreComponent', () => {
133145
expect(comp).toBeDefined();
134146
}));
135147

136-
it('should place the sections on three rows', () => {
148+
it('should place the sections on four rows', () => {
137149
const container = fixture.debugElement.query(By.css('.container'));
138-
expect(container.children.length).toEqual(3);
150+
expect(container.children.length).toEqual(4);
139151

140152
const firstRow = container.children[0];
141153
expect(firstRow.children.length).toEqual(2);
@@ -150,6 +162,10 @@ describe('ExploreComponent', () => {
150162
expect(thirdRow.children.length).toEqual(1);
151163
expect(thirdRow.children[0].children[0].name).toEqual('ds-facet-section');
152164

165+
const fourthRow = container.children[3];
166+
expect(fourthRow.children.length).toEqual(1);
167+
expect(fourthRow.children[0].children[0].name).toEqual('ds-multi-column-top-section');
168+
153169
expect(component.sectionId).toEqual('publications');
154170
});
155171

src/app/explore-page/explore-page.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { getFirstSucceededRemoteDataPayload } from '../core/shared/operators';
1919
import { ThemedBrowseSectionComponent } from '../shared/explore/section-component/browse-section/themed-browse-section.component';
2020
import { ThemedCountersSectionComponent } from '../shared/explore/section-component/counters-section/themed-counters-section.component';
2121
import { ThemedFacetSectionComponent } from '../shared/explore/section-component/facet-section/themed-facet-section.component';
22+
import { ThemedMultiColumnTopSectionComponent } from '../shared/explore/section-component/multi-column-top-section/themed-multi-column-top-section.component';
2223
import { ThemedSearchSectionComponent } from '../shared/explore/section-component/search-section/themed-search-section.component';
2324
import { ThemedTextSectionComponent } from '../shared/explore/section-component/text-section/themed-text-section.component';
2425
import { ThemedTopSectionComponent } from '../shared/explore/section-component/top-section/themed-top-section.component';
@@ -28,7 +29,7 @@ import { ThemedTopSectionComponent } from '../shared/explore/section-component/t
2829
*
2930
* Fetches section configuration from the backend based on the current route parameter
3031
* and renders the configured sections as a responsive grid of section components.
31-
* Supported section types include: top, browse, search, facet, text-row, and counters.
32+
* Supported section types include: top, multi-column-top, browse, search, facet, text-row, and counters.
3233
*/
3334
@Component({
3435
selector: 'ds-explore',
@@ -39,6 +40,7 @@ import { ThemedTopSectionComponent } from '../shared/explore/section-component/t
3940
ThemedBrowseSectionComponent,
4041
ThemedCountersSectionComponent,
4142
ThemedFacetSectionComponent,
43+
ThemedMultiColumnTopSectionComponent,
4244
ThemedSearchSectionComponent,
4345
ThemedTextSectionComponent,
4446
ThemedTopSectionComponent,

src/app/home-page/home-page.component.html

Lines changed: 46 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,6 @@
11
@if (!isDynamicHomePageEnabled) {
2-
@if (homeHeaderMetadataValue$ | async; as homeHeaderMetadataValue) {
3-
<div class="container home-header">
4-
<ds-markdown-viewer [value]="homeHeaderMetadataValue"></ds-markdown-viewer>
5-
</div>
6-
}
7-
8-
<ds-home-coar></ds-home-coar>
9-
<ds-home-news></ds-home-news>
10-
11-
@if (showDiscoverFilters) {
12-
<ds-configuration-search-page
13-
[sideBarWidth]="3"
14-
[showViewModes]="false"
15-
[searchEnabled]="false"
16-
[inPlaceSearch]="false"
17-
[showScopeSelector]="false">
18-
<ng-container searchContentTop *ngTemplateOutlet="homeContent"></ng-container>
19-
</ds-configuration-search-page>
20-
}
21-
@if (!showDiscoverFilters) {
22-
<div class="container">
23-
<ng-container *ngTemplateOutlet="homeContent"></ng-container>
24-
</div>
25-
}
26-
<ds-suggestions-popup></ds-suggestions-popup>
27-
28-
<ng-template #homeContent>
29-
<ds-search-form [inPlaceSearch]="false"
30-
[searchPlaceholder]="'home.search-form.placeholder' | translate">
31-
</ds-search-form>
32-
<ds-top-level-community-list></ds-top-level-community-list>
33-
@if (recentSubmissionspageSize>0) {
34-
<ds-recent-item-list></ds-recent-item-list>
35-
}
36-
</ng-template>
37-
} @else {
2+
<ng-container *ngTemplateOutlet="staticHomePage"></ng-container>
3+
} @else if (hasConfiguredSections$ | async) {
384
@if ((site$.value && hasHomeHeaderMetadata)) {
395
<div id="home-header-wrapper">
406
<ds-text-section [sectionId]="'site'"
@@ -61,6 +27,11 @@
6127
[sectionId]="sectionId"
6228
[topSection]="$any(sectionComponent)"></ds-top-section>
6329
}
30+
@case ('multi-column-top') {
31+
<ds-multi-column-top-section
32+
[sectionId]="sectionId"
33+
[topSection]="$any(sectionComponent)"></ds-multi-column-top-section>
34+
}
6435
@case ('browse') {
6536
<ds-browse-section
6637
[sectionId]="sectionId"
@@ -98,6 +69,45 @@
9869

9970
<ds-suggestions-popup></ds-suggestions-popup>
10071

72+
} @else {
73+
<ng-container *ngTemplateOutlet="staticHomePage"></ng-container>
10174
}
10275

10376

77+
<ng-template #staticHomePage>
78+
@if (homeHeaderMetadataValue$ | async; as homeHeaderMetadataValue) {
79+
<div class="container home-header">
80+
<ds-markdown-viewer [value]="homeHeaderMetadataValue"></ds-markdown-viewer>
81+
</div>
82+
}
83+
84+
<ds-home-coar></ds-home-coar>
85+
<ds-home-news></ds-home-news>
86+
87+
@if (showDiscoverFilters) {
88+
<ds-configuration-search-page
89+
[sideBarWidth]="3"
90+
[showViewModes]="false"
91+
[searchEnabled]="false"
92+
[inPlaceSearch]="false"
93+
[showScopeSelector]="false">
94+
<ng-container searchContentTop *ngTemplateOutlet="homeContent"></ng-container>
95+
</ds-configuration-search-page>
96+
}
97+
@if (!showDiscoverFilters) {
98+
<div class="container">
99+
<ng-container *ngTemplateOutlet="homeContent"></ng-container>
100+
</div>
101+
}
102+
<ds-suggestions-popup></ds-suggestions-popup>
103+
104+
<ng-template #homeContent>
105+
<ds-search-form [inPlaceSearch]="false"
106+
[searchPlaceholder]="'home.search-form.placeholder' | translate">
107+
</ds-search-form>
108+
<ds-top-level-community-list></ds-top-level-community-list>
109+
@if (recentSubmissionspageSize>0) {
110+
<ds-recent-item-list></ds-recent-item-list>
111+
}
112+
</ng-template>
113+
</ng-template>

0 commit comments

Comments
 (0)