Skip to content

Commit 990178b

Browse files
Andrea BarbassoFrancescoMolinaro
authored andcommitted
Merged in task/dspace-cris-2025_02_x/DSC-2676 (pull request DSpace#4024)
Task/dspace cris 2025 02 x/DSC-2676 Approved-by: Francesco Molinaro
2 parents 7a864f8 + f625a4b commit 990178b

13 files changed

Lines changed: 311 additions & 7 deletions

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
"test:lint": "npm run build:lint && npm run test:lint:nobuild",
2929
"test:lint:nobuild": "jasmine --config=lint/jasmine.json",
3030
"lint": "npm run build:lint && npm run lint:nobuild",
31-
"lint:nobuild": "npm run ng-high-memory --lint",
32-
"lint-fix": "npm run build:lint && npm run ng-high-memory --lint --fix=true",
31+
"lint:nobuild": "npm run ng-high-memory -- lint",
32+
"lint-fix": "npm run build:lint && npm run ng-high-memory -- lint --fix=true",
3333
"docs:lint": "ts-node --project ./lint/tsconfig.json ./lint/generate-docs.ts",
3434
"e2e": "cross-env NODE_ENV=production ng e2e",
3535
"clean:dev:config": "rimraf src/assets/config.json",

src/app/app.menus.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ 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';
1212
import { AdminSearchMenuProvider } from './shared/menu/providers/admin-search.menu';
13-
import { BrowseMenuProvider } from './shared/menu/providers/browse.menu';
1413
import { CoarNotifyMenuProvider } from './shared/menu/providers/coar-notify.menu';
1514
import { SubscribeMenuProvider } from './shared/menu/providers/comcol-subscribe.menu';
1615
import { CommunityListMenuProvider } from './shared/menu/providers/community-list.menu';
@@ -19,18 +18,21 @@ import { CurationMenuProvider } from './shared/menu/providers/curation.menu';
1918
import { DSpaceObjectEditMenuProvider } from './shared/menu/providers/dso-edit.menu';
2019
import { DsoOptionMenuProvider } from './shared/menu/providers/dso-option.menu';
2120
import { EditMenuProvider } from './shared/menu/providers/edit.menu';
21+
import { ExploreMenuProvider } from './shared/menu/providers/explore.menu';
2222
import { ExportMenuProvider } from './shared/menu/providers/export.menu';
2323
import { HealthMenuProvider } from './shared/menu/providers/health.menu';
2424
import { ImportMenuProvider } from './shared/menu/providers/import.menu';
2525
import { ClaimMenuProvider } from './shared/menu/providers/item-claim.menu';
2626
import { OrcidMenuProvider } from './shared/menu/providers/item-orcid.menu';
2727
import { VersioningMenuProvider } from './shared/menu/providers/item-versioning.menu';
28+
import { MetadataCmsMenuProvider } from './shared/menu/providers/metadata-cms.menu';
2829
import { NewMenuProvider } from './shared/menu/providers/new.menu';
2930
import { NotificationsMenuProvider } from './shared/menu/providers/notifications.menu';
3031
import { ProcessesMenuProvider } from './shared/menu/providers/processes.menu';
3132
import { RegistriesMenuProvider } from './shared/menu/providers/registries.menu';
3233
import { StatisticsMenuProvider } from './shared/menu/providers/statistics.menu';
3334
import { SystemWideAlertMenuProvider } from './shared/menu/providers/system-wide-alert.menu';
35+
import { UserAgreementMenuProvider } from './shared/menu/providers/user-agreement.menu';
3436
import { WithdrawnReinstateItemMenuProvider } from './shared/menu/providers/withdrawn-reinstate-item.menu';
3537
import { WorkflowMenuProvider } from './shared/menu/providers/workflow.menu';
3638

@@ -53,7 +55,7 @@ import { WorkflowMenuProvider } from './shared/menu/providers/workflow.menu';
5355
export const MENUS = buildMenuStructure({
5456
[MenuID.PUBLIC]: [
5557
CommunityListMenuProvider,
56-
BrowseMenuProvider,
58+
ExploreMenuProvider,
5759
StatisticsMenuProvider,
5860
],
5961
[MenuID.ADMIN]: [
@@ -72,6 +74,8 @@ export const MENUS = buildMenuStructure({
7274
HealthMenuProvider,
7375
SystemWideAlertMenuProvider,
7476
CoarNotifyMenuProvider,
77+
UserAgreementMenuProvider,
78+
MetadataCmsMenuProvider,
7579
],
7680
[MenuID.DSO_EDIT]: [
7781
DsoOptionMenuProvider.withSubs([

src/app/shared/menu/providers/community-list.menu.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('CommunityListMenuProvider', () => {
1818
visible: true,
1919
model: {
2020
type: MenuItemType.LINK,
21-
text: `menu.section.browse_global_communities_and_collections`,
21+
text: `menu.section.communities_and_collections`,
2222
link: `/community-list`,
2323
},
2424
icon: 'diagram-project',

src/app/shared/menu/providers/community-list.menu.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class CommunityListMenuProvider extends AbstractMenuProvider {
2929
visible: true,
3030
model: {
3131
type: MenuItemType.LINK,
32-
text: `menu.section.browse_global_communities_and_collections`,
32+
text: `menu.section.communities_and_collections`,
3333
link: `/community-list`,
3434
},
3535
icon: 'diagram-project',
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* The contents of this file are subject to the license and copyright
3+
* detailed in the LICENSE and NOTICE files at the root of the source
4+
* tree and available online at
5+
*
6+
* http://www.dspace.org/license/
7+
*/
8+
9+
import { TestBed } from '@angular/core/testing';
10+
11+
import { APP_CONFIG } from '../../../../config/app-config.interface';
12+
import { environment } from '../../../../environments/environment';
13+
import { SectionDataService } from '../../../core/layout/section-data.service';
14+
import { createSuccessfulRemoteDataObject$ } from '../../remote-data.utils';
15+
import { createPaginatedList } from '../../testing/utils.test';
16+
import { ExploreMenuProvider } from './explore.menu';
17+
18+
describe('ExploreMenuProvider', () => {
19+
20+
let provider: ExploreMenuProvider;
21+
let sectionDataServiceStub = {
22+
findVisibleSections: () => createSuccessfulRemoteDataObject$(createPaginatedList([])),
23+
};
24+
25+
beforeEach(() => {
26+
TestBed.configureTestingModule({
27+
providers: [
28+
ExploreMenuProvider,
29+
{ provide: APP_CONFIG, useValue: environment },
30+
{ provide: SectionDataService, useValue: sectionDataServiceStub },
31+
],
32+
});
33+
provider = TestBed.inject(ExploreMenuProvider);
34+
});
35+
36+
it('should be created', () => {
37+
expect(provider).toBeTruthy();
38+
});
39+
});
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/**
2+
* The contents of this file are subject to the license and copyright
3+
* detailed in the LICENSE and NOTICE files at the root of the source
4+
* tree and available online at
5+
*
6+
* http://www.dspace.org/license/
7+
*/
8+
9+
import { Injectable } from '@angular/core';
10+
import { Observable } from 'rxjs';
11+
import { map } from 'rxjs/operators';
12+
13+
import { PaginatedList } from '../../../core/data/paginated-list.model';
14+
import { RemoteData } from '../../../core/data/remote-data';
15+
import { Section } from '../../../core/layout/models/section.model';
16+
import { SectionDataService } from '../../../core/layout/section-data.service';
17+
import { getFirstSucceededRemoteData } from '../../../core/shared/operators';
18+
import { MenuItemType } from '../menu-item-type.model';
19+
import {
20+
AbstractMenuProvider,
21+
PartialMenuSection,
22+
} from '../menu-provider.model';
23+
24+
/**
25+
* Menu provider to create the explore menu sections in the public navbar
26+
*/
27+
@Injectable()
28+
export class ExploreMenuProvider extends AbstractMenuProvider {
29+
constructor(
30+
protected sectionDataService: SectionDataService,
31+
) {
32+
super();
33+
}
34+
35+
/**
36+
* Retrieves subsections by fetching the browse definitions from the backend and mapping them to partial menu sections.
37+
*/
38+
getSections(): Observable<PartialMenuSection[]> {
39+
return this.sectionDataService.findVisibleSections().pipe(
40+
getFirstSucceededRemoteData(),
41+
map((rd: RemoteData<PaginatedList<Section>>) => {
42+
return [
43+
...rd.payload.page.map((browseDef) => {
44+
return {
45+
visible: true,
46+
model: {
47+
type: MenuItemType.LINK,
48+
text: `menu.section.explore_${browseDef.id}`,
49+
link: `/explore/${browseDef.id}`,
50+
},
51+
};
52+
}),
53+
];
54+
}),
55+
);
56+
}
57+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* The contents of this file are subject to the license and copyright
3+
* detailed in the LICENSE and NOTICE files at the root of the source
4+
* tree and available online at
5+
*
6+
* http://www.dspace.org/license/
7+
*/
8+
9+
import { TestBed } from '@angular/core/testing';
10+
import { of } from 'rxjs';
11+
12+
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
13+
import { AuthorizationDataServiceStub } from '../../testing/authorization-service.stub';
14+
import { MetadataCmsMenuProvider } from './metadata-cms.menu';
15+
16+
describe('MetadataCmsMenuProvider', () => {
17+
18+
let provider: MetadataCmsMenuProvider;
19+
let authorizationServiceStub = new AuthorizationDataServiceStub();
20+
21+
beforeEach(() => {
22+
spyOn(authorizationServiceStub, 'isAuthorized').and.returnValue(
23+
of(true),
24+
);
25+
TestBed.configureTestingModule({
26+
providers: [
27+
MetadataCmsMenuProvider,
28+
{ provide: AuthorizationDataService, useValue: authorizationServiceStub },
29+
],
30+
});
31+
provider = TestBed.inject(MetadataCmsMenuProvider);
32+
});
33+
34+
it('should be created', () => {
35+
expect(provider).toBeTruthy();
36+
});
37+
});
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/**
2+
* The contents of this file are subject to the license and copyright
3+
* detailed in the LICENSE and NOTICE files at the root of the source
4+
* tree and available online at
5+
*
6+
* http://www.dspace.org/license/
7+
*/
8+
9+
import { Injectable } from '@angular/core';
10+
import {
11+
combineLatest,
12+
Observable,
13+
} from 'rxjs';
14+
import { map } from 'rxjs/operators';
15+
16+
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
17+
import { FeatureID } from '../../../core/data/feature-authorization/feature-id';
18+
import { MenuItemType } from '../menu-item-type.model';
19+
import {
20+
AbstractMenuProvider,
21+
PartialMenuSection,
22+
} from '../menu-provider.model';
23+
24+
/**
25+
* Menu provider to create the user agreement menu sections in the public navbar
26+
*/
27+
@Injectable()
28+
export class MetadataCmsMenuProvider extends AbstractMenuProvider {
29+
constructor(
30+
protected authorizationService: AuthorizationDataService,
31+
) {
32+
super();
33+
}
34+
35+
/**
36+
* Retrieves subsections by fetching the browse definitions from the backend and mapping them to partial menu sections.
37+
*/
38+
getSections(): Observable<PartialMenuSection[]> {
39+
return combineLatest([
40+
this.authorizationService.isAuthorized(FeatureID.AdministratorOf),
41+
]).pipe(
42+
map(([isSiteAdmin]) => {
43+
return [
44+
{
45+
id: 'metadata_cms_edit',
46+
active: false,
47+
visible: isSiteAdmin,
48+
model: {
49+
type: MenuItemType.LINK,
50+
text: 'menu.section.cms_metadata_edit',
51+
link: '/admin/edit-cms-metadata',
52+
},
53+
icon: 'edit',
54+
},
55+
] as PartialMenuSection[];
56+
}),
57+
);
58+
}
59+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* The contents of this file are subject to the license and copyright
3+
* detailed in the LICENSE and NOTICE files at the root of the source
4+
* tree and available online at
5+
*
6+
* http://www.dspace.org/license/
7+
*/
8+
9+
import { TestBed } from '@angular/core/testing';
10+
import { of } from 'rxjs';
11+
12+
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
13+
import { AuthorizationDataServiceStub } from '../../testing/authorization-service.stub';
14+
import { UserAgreementMenuProvider } from './user-agreement.menu';
15+
16+
describe('UserAgreementMenuProvider', () => {
17+
18+
let provider: UserAgreementMenuProvider;
19+
let authorizationServiceStub = new AuthorizationDataServiceStub();
20+
21+
beforeEach(() => {
22+
spyOn(authorizationServiceStub, 'isAuthorized').and.returnValue(
23+
of(true),
24+
);
25+
TestBed.configureTestingModule({
26+
providers: [
27+
UserAgreementMenuProvider,
28+
{ provide: AuthorizationDataService, useValue: authorizationServiceStub },
29+
],
30+
});
31+
provider = TestBed.inject(UserAgreementMenuProvider);
32+
});
33+
34+
it('should be created', () => {
35+
expect(provider).toBeTruthy();
36+
});
37+
});
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/**
2+
* The contents of this file are subject to the license and copyright
3+
* detailed in the LICENSE and NOTICE files at the root of the source
4+
* tree and available online at
5+
*
6+
* http://www.dspace.org/license/
7+
*/
8+
9+
import { Injectable } from '@angular/core';
10+
import {
11+
combineLatest,
12+
Observable,
13+
} from 'rxjs';
14+
import { map } from 'rxjs/operators';
15+
16+
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
17+
import { FeatureID } from '../../../core/data/feature-authorization/feature-id';
18+
import { MenuItemType } from '../menu-item-type.model';
19+
import {
20+
AbstractMenuProvider,
21+
PartialMenuSection,
22+
} from '../menu-provider.model';
23+
24+
/**
25+
* Menu provider to create the user agreement menu sections in the public navbar
26+
*/
27+
@Injectable()
28+
export class UserAgreementMenuProvider extends AbstractMenuProvider {
29+
constructor(
30+
protected authorizationService: AuthorizationDataService,
31+
) {
32+
super();
33+
}
34+
35+
/**
36+
* Retrieves subsections by fetching the browse definitions from the backend and mapping them to partial menu sections.
37+
*/
38+
getSections(): Observable<PartialMenuSection[]> {
39+
return combineLatest([
40+
this.authorizationService.isAuthorized(FeatureID.AdministratorOf),
41+
]).pipe(
42+
map(([isSiteAdmin]) => {
43+
return [
44+
{
45+
id: 'user_agreement_edit',
46+
active: false,
47+
visible: isSiteAdmin,
48+
model: {
49+
type: MenuItemType.LINK,
50+
text: 'menu.section.edit_user_agreement',
51+
link: '/admin/edit-user-agreement',
52+
},
53+
icon: 'list-alt',
54+
},
55+
] as PartialMenuSection[];
56+
}),
57+
);
58+
}
59+
}

0 commit comments

Comments
 (0)