mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-09 11:03:05 +00:00
Resolve post-merge issues
- Menu providers weren't included because main configuration is no longer a module - Route definitions didn't get merged because they're no longer modules - Removed old resolver & service (they're providers now)
This commit is contained in:
@@ -34,7 +34,6 @@ import { forgotPasswordCheckGuard } from './core/rest-property/forgot-password-c
|
|||||||
import { ServerCheckGuard } from './core/server-check/server-check.guard';
|
import { ServerCheckGuard } from './core/server-check/server-check.guard';
|
||||||
import { ThemedForbiddenComponent } from './forbidden/themed-forbidden.component';
|
import { ThemedForbiddenComponent } from './forbidden/themed-forbidden.component';
|
||||||
import { ITEM_MODULE_PATH } from './item-page/item-page-routing-paths';
|
import { ITEM_MODULE_PATH } from './item-page/item-page-routing-paths';
|
||||||
import { menuResolver } from './menuResolver';
|
|
||||||
import { provideSuggestionNotificationsState } from './notifications/provide-suggestion-notifications-state';
|
import { provideSuggestionNotificationsState } from './notifications/provide-suggestion-notifications-state';
|
||||||
import { ThemedPageErrorComponent } from './page-error/themed-page-error.component';
|
import { ThemedPageErrorComponent } from './page-error/themed-page-error.component';
|
||||||
import { ThemedPageInternalServerErrorComponent } from './page-internal-server-error/themed-page-internal-server-error.component';
|
import { ThemedPageInternalServerErrorComponent } from './page-internal-server-error/themed-page-internal-server-error.component';
|
||||||
@@ -50,7 +49,6 @@ export const APP_ROUTES: Route[] = [
|
|||||||
path: '',
|
path: '',
|
||||||
canActivate: [authBlockingGuard],
|
canActivate: [authBlockingGuard],
|
||||||
canActivateChild: [ServerCheckGuard],
|
canActivateChild: [ServerCheckGuard],
|
||||||
resolve: [menuResolver],
|
|
||||||
children: [
|
children: [
|
||||||
{ path: '', redirectTo: '/home', pathMatch: 'full' },
|
{ path: '', redirectTo: '/home', pathMatch: 'full' },
|
||||||
{
|
{
|
||||||
|
@@ -38,6 +38,7 @@ import { StoreDevModules } from '../config/store/devtools';
|
|||||||
import { environment } from '../environments/environment';
|
import { environment } from '../environments/environment';
|
||||||
import { EagerThemesModule } from '../themes/eager-themes.module';
|
import { EagerThemesModule } from '../themes/eager-themes.module';
|
||||||
import { appEffects } from './app.effects';
|
import { appEffects } from './app.effects';
|
||||||
|
import { MENUS } from './app.menus';
|
||||||
import {
|
import {
|
||||||
appMetaReducers,
|
appMetaReducers,
|
||||||
debugMetaReducers,
|
debugMetaReducers,
|
||||||
@@ -156,6 +157,10 @@ export const commonAppConfig: ApplicationConfig = {
|
|||||||
},
|
},
|
||||||
// register the dynamic matcher used by form. MUST be provided by the app module
|
// register the dynamic matcher used by form. MUST be provided by the app module
|
||||||
...DYNAMIC_MATCHER_PROVIDERS,
|
...DYNAMIC_MATCHER_PROVIDERS,
|
||||||
|
|
||||||
|
// DI-composable menus
|
||||||
|
...MENUS,
|
||||||
|
|
||||||
provideCore(),
|
provideCore(),
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
@@ -8,16 +8,14 @@ import { communityBreadcrumbResolver } from '../core/breadcrumbs/community-bread
|
|||||||
import { i18nBreadcrumbResolver } from '../core/breadcrumbs/i18n-breadcrumb.resolver';
|
import { i18nBreadcrumbResolver } from '../core/breadcrumbs/i18n-breadcrumb.resolver';
|
||||||
import { ComcolBrowseByComponent } from '../shared/comcol/sections/comcol-browse-by/comcol-browse-by.component';
|
import { ComcolBrowseByComponent } from '../shared/comcol/sections/comcol-browse-by/comcol-browse-by.component';
|
||||||
import { ComcolSearchSectionComponent } from '../shared/comcol/sections/comcol-search-section/comcol-search-section.component';
|
import { ComcolSearchSectionComponent } from '../shared/comcol/sections/comcol-search-section/comcol-search-section.component';
|
||||||
import { dsoEditMenuResolver } from '../shared/dso-page/dso-edit-menu.resolver';
|
import { MenuRoute } from '../shared/menu/menu-route.model';
|
||||||
import { LinkMenuItemModel } from '../shared/menu/menu-item/models/link.model';
|
|
||||||
import { MenuItemType } from '../shared/menu/menu-item-type.model';
|
|
||||||
import { collectionPageResolver } from './collection-page.resolver';
|
|
||||||
import { collectionPageAdministratorGuard } from './collection-page-administrator.guard';
|
import { collectionPageAdministratorGuard } from './collection-page-administrator.guard';
|
||||||
import {
|
import {
|
||||||
COLLECTION_CREATE_PATH,
|
COLLECTION_CREATE_PATH,
|
||||||
COLLECTION_EDIT_PATH,
|
COLLECTION_EDIT_PATH,
|
||||||
ITEMTEMPLATE_PATH,
|
ITEMTEMPLATE_PATH,
|
||||||
} from './collection-page-routing-paths';
|
} from './collection-page-routing-paths';
|
||||||
|
import { collectionPageResolver } from './collection-page.resolver';
|
||||||
import { CreateCollectionPageComponent } from './create-collection-page/create-collection-page.component';
|
import { CreateCollectionPageComponent } from './create-collection-page/create-collection-page.component';
|
||||||
import { createCollectionPageGuard } from './create-collection-page/create-collection-page.guard';
|
import { createCollectionPageGuard } from './create-collection-page/create-collection-page.guard';
|
||||||
import { DeleteCollectionPageComponent } from './delete-collection-page/delete-collection-page.component';
|
import { DeleteCollectionPageComponent } from './delete-collection-page/delete-collection-page.component';
|
||||||
@@ -82,8 +80,8 @@ export const ROUTES: Route[] = [
|
|||||||
{
|
{
|
||||||
path: '',
|
path: '',
|
||||||
component: ThemedCollectionPageComponent,
|
component: ThemedCollectionPageComponent,
|
||||||
resolve: {
|
data: {
|
||||||
menu: dsoEditMenuResolver,
|
menuRoute: MenuRoute.SIMPLE_COLLECTION_PAGE,
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
@@ -104,20 +102,5 @@ export const ROUTES: Route[] = [
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
data: {
|
|
||||||
menu: {
|
|
||||||
public: [{
|
|
||||||
id: 'statistics_collection_:id',
|
|
||||||
active: true,
|
|
||||||
visible: true,
|
|
||||||
index: 2,
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.LINK,
|
|
||||||
text: 'menu.section.statistics',
|
|
||||||
link: 'statistics/collections/:id/',
|
|
||||||
} as LinkMenuItemModel,
|
|
||||||
}],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
@@ -7,15 +7,13 @@ import { communityBreadcrumbResolver } from '../core/breadcrumbs/community-bread
|
|||||||
import { i18nBreadcrumbResolver } from '../core/breadcrumbs/i18n-breadcrumb.resolver';
|
import { i18nBreadcrumbResolver } from '../core/breadcrumbs/i18n-breadcrumb.resolver';
|
||||||
import { ComcolBrowseByComponent } from '../shared/comcol/sections/comcol-browse-by/comcol-browse-by.component';
|
import { ComcolBrowseByComponent } from '../shared/comcol/sections/comcol-browse-by/comcol-browse-by.component';
|
||||||
import { ComcolSearchSectionComponent } from '../shared/comcol/sections/comcol-search-section/comcol-search-section.component';
|
import { ComcolSearchSectionComponent } from '../shared/comcol/sections/comcol-search-section/comcol-search-section.component';
|
||||||
import { dsoEditMenuResolver } from '../shared/dso-page/dso-edit-menu.resolver';
|
import { MenuRoute } from '../shared/menu/menu-route.model';
|
||||||
import { LinkMenuItemModel } from '../shared/menu/menu-item/models/link.model';
|
|
||||||
import { MenuItemType } from '../shared/menu/menu-item-type.model';
|
|
||||||
import { communityPageResolver } from './community-page.resolver';
|
|
||||||
import { communityPageAdministratorGuard } from './community-page-administrator.guard';
|
import { communityPageAdministratorGuard } from './community-page-administrator.guard';
|
||||||
import {
|
import {
|
||||||
COMMUNITY_CREATE_PATH,
|
COMMUNITY_CREATE_PATH,
|
||||||
COMMUNITY_EDIT_PATH,
|
COMMUNITY_EDIT_PATH,
|
||||||
} from './community-page-routing-paths';
|
} from './community-page-routing-paths';
|
||||||
|
import { communityPageResolver } from './community-page.resolver';
|
||||||
import { CreateCommunityPageComponent } from './create-community-page/create-community-page.component';
|
import { CreateCommunityPageComponent } from './create-community-page/create-community-page.component';
|
||||||
import { createCommunityPageGuard } from './create-community-page/create-community-page.guard';
|
import { createCommunityPageGuard } from './create-community-page/create-community-page.guard';
|
||||||
import { DeleteCommunityPageComponent } from './delete-community-page/delete-community-page.component';
|
import { DeleteCommunityPageComponent } from './delete-community-page/delete-community-page.component';
|
||||||
@@ -69,8 +67,8 @@ export const ROUTES: Route[] = [
|
|||||||
{
|
{
|
||||||
path: '',
|
path: '',
|
||||||
component: ThemedCommunityPageComponent,
|
component: ThemedCommunityPageComponent,
|
||||||
resolve: {
|
data: {
|
||||||
menu: dsoEditMenuResolver,
|
menuRoute: MenuRoute.SIMPLE_COMMUNITY_PAGE,
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
@@ -100,20 +98,5 @@ export const ROUTES: Route[] = [
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
data: {
|
|
||||||
menu: {
|
|
||||||
public: [{
|
|
||||||
id: 'statistics_community_:id',
|
|
||||||
active: true,
|
|
||||||
visible: true,
|
|
||||||
index: 2,
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.LINK,
|
|
||||||
text: 'menu.section.statistics',
|
|
||||||
link: 'statistics/communities/:id/',
|
|
||||||
} as LinkMenuItemModel,
|
|
||||||
}],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
@@ -3,23 +3,21 @@ import { Route } from '@angular/router';
|
|||||||
import { REQUEST_COPY_MODULE_PATH } from '../app-routing-paths';
|
import { REQUEST_COPY_MODULE_PATH } from '../app-routing-paths';
|
||||||
import { authenticatedGuard } from '../core/auth/authenticated.guard';
|
import { authenticatedGuard } from '../core/auth/authenticated.guard';
|
||||||
import { itemBreadcrumbResolver } from '../core/breadcrumbs/item-breadcrumb.resolver';
|
import { itemBreadcrumbResolver } from '../core/breadcrumbs/item-breadcrumb.resolver';
|
||||||
import { dsoEditMenuResolver } from '../shared/dso-page/dso-edit-menu.resolver';
|
import { MenuRoute } from '../shared/menu/menu-route.model';
|
||||||
import { LinkMenuItemModel } from '../shared/menu/menu-item/models/link.model';
|
|
||||||
import { MenuItemType } from '../shared/menu/menu-item-type.model';
|
|
||||||
import { BitstreamRequestACopyPageComponent } from './bitstreams/request-a-copy/bitstream-request-a-copy-page.component';
|
import { BitstreamRequestACopyPageComponent } from './bitstreams/request-a-copy/bitstream-request-a-copy-page.component';
|
||||||
import { UploadBitstreamComponent } from './bitstreams/upload/upload-bitstream.component';
|
import { UploadBitstreamComponent } from './bitstreams/upload/upload-bitstream.component';
|
||||||
import { ThemedFullItemPageComponent } from './full/themed-full-item-page.component';
|
import { ThemedFullItemPageComponent } from './full/themed-full-item-page.component';
|
||||||
import { itemPageResolver } from './item-page.resolver';
|
|
||||||
import {
|
import {
|
||||||
ITEM_EDIT_PATH,
|
ITEM_EDIT_PATH,
|
||||||
ORCID_PATH,
|
ORCID_PATH,
|
||||||
UPLOAD_BITSTREAM_PATH,
|
UPLOAD_BITSTREAM_PATH,
|
||||||
} from './item-page-routing-paths';
|
} from './item-page-routing-paths';
|
||||||
|
import { itemPageResolver } from './item-page.resolver';
|
||||||
import { OrcidPageComponent } from './orcid-page/orcid-page.component';
|
import { OrcidPageComponent } from './orcid-page/orcid-page.component';
|
||||||
import { orcidPageGuard } from './orcid-page/orcid-page.guard';
|
import { orcidPageGuard } from './orcid-page/orcid-page.guard';
|
||||||
import { ThemedItemPageComponent } from './simple/themed-item-page.component';
|
import { ThemedItemPageComponent } from './simple/themed-item-page.component';
|
||||||
import { versionResolver } from './version-page/version.resolver';
|
|
||||||
import { VersionPageComponent } from './version-page/version-page/version-page.component';
|
import { VersionPageComponent } from './version-page/version-page/version-page.component';
|
||||||
|
import { versionResolver } from './version-page/version.resolver';
|
||||||
|
|
||||||
export const ROUTES: Route[] = [
|
export const ROUTES: Route[] = [
|
||||||
{
|
{
|
||||||
@@ -34,16 +32,18 @@ export const ROUTES: Route[] = [
|
|||||||
path: '',
|
path: '',
|
||||||
component: ThemedItemPageComponent,
|
component: ThemedItemPageComponent,
|
||||||
pathMatch: 'full',
|
pathMatch: 'full',
|
||||||
resolve: {
|
data: {
|
||||||
menu: dsoEditMenuResolver,
|
menuRoute: MenuRoute.SIMPLE_ITEM_PAGE,
|
||||||
},
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'full',
|
path: 'full',
|
||||||
component: ThemedFullItemPageComponent,
|
component: ThemedFullItemPageComponent,
|
||||||
resolve: {
|
data: {
|
||||||
menu: dsoEditMenuResolver,
|
menuRoute: MenuRoute.FULL_ITEM_PAGE,
|
||||||
},
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: ITEM_EDIT_PATH,
|
path: ITEM_EDIT_PATH,
|
||||||
@@ -65,21 +65,6 @@ export const ROUTES: Route[] = [
|
|||||||
canActivate: [authenticatedGuard, orcidPageGuard],
|
canActivate: [authenticatedGuard, orcidPageGuard],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
data: {
|
|
||||||
menu: {
|
|
||||||
public: [{
|
|
||||||
id: 'statistics_item_:id',
|
|
||||||
active: true,
|
|
||||||
visible: true,
|
|
||||||
index: 2,
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.LINK,
|
|
||||||
text: 'menu.section.statistics',
|
|
||||||
link: 'statistics/items/:id/',
|
|
||||||
} as LinkMenuItemModel,
|
|
||||||
}],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'version',
|
path: 'version',
|
||||||
|
@@ -1,21 +0,0 @@
|
|||||||
import { inject } from '@angular/core';
|
|
||||||
import {
|
|
||||||
ActivatedRouteSnapshot,
|
|
||||||
ResolveFn,
|
|
||||||
RouterStateSnapshot,
|
|
||||||
} from '@angular/router';
|
|
||||||
import { Observable } from 'rxjs';
|
|
||||||
|
|
||||||
import { MenuResolverService } from './menu-resolver.service';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize all menus
|
|
||||||
*/
|
|
||||||
export const menuResolver: ResolveFn<boolean> = (
|
|
||||||
route: ActivatedRouteSnapshot,
|
|
||||||
state: RouterStateSnapshot,
|
|
||||||
menuResolverService: MenuResolverService = inject(MenuResolverService),
|
|
||||||
): Observable<boolean> => {
|
|
||||||
return menuResolverService.resolve(route, state);
|
|
||||||
};
|
|
@@ -1,324 +0,0 @@
|
|||||||
import { Injectable } from '@angular/core';
|
|
||||||
import {
|
|
||||||
ActivatedRouteSnapshot,
|
|
||||||
RouterStateSnapshot,
|
|
||||||
} from '@angular/router';
|
|
||||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
|
||||||
import {
|
|
||||||
combineLatest,
|
|
||||||
Observable,
|
|
||||||
of as observableOf,
|
|
||||||
} from 'rxjs';
|
|
||||||
import {
|
|
||||||
map,
|
|
||||||
switchMap,
|
|
||||||
} from 'rxjs/operators';
|
|
||||||
|
|
||||||
import { getDSORoute } from '../../app-routing-paths';
|
|
||||||
import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.service';
|
|
||||||
import { AuthorizationDataService } from '../../core/data/feature-authorization/authorization-data.service';
|
|
||||||
import { FeatureID } from '../../core/data/feature-authorization/feature-id';
|
|
||||||
import { ResearcherProfileDataService } from '../../core/profile/researcher-profile-data.service';
|
|
||||||
import { Collection } from '../../core/shared/collection.model';
|
|
||||||
import { Community } from '../../core/shared/community.model';
|
|
||||||
import { Item } from '../../core/shared/item.model';
|
|
||||||
import {
|
|
||||||
getFirstCompletedRemoteData,
|
|
||||||
getRemoteDataPayload,
|
|
||||||
} from '../../core/shared/operators';
|
|
||||||
import { CorrectionTypeDataService } from '../../core/submission/correctiontype-data.service';
|
|
||||||
import { URLCombiner } from '../../core/url-combiner/url-combiner';
|
|
||||||
import {
|
|
||||||
hasNoValue,
|
|
||||||
hasValue,
|
|
||||||
isNotEmpty,
|
|
||||||
} from '../empty.util';
|
|
||||||
import { MenuService } from '../menu/menu.service';
|
|
||||||
import { MenuID } from '../menu/menu-id.model';
|
|
||||||
import { LinkMenuItemModel } from '../menu/menu-item/models/link.model';
|
|
||||||
import { OnClickMenuItemModel } from '../menu/menu-item/models/onclick.model';
|
|
||||||
import { MenuItemType } from '../menu/menu-item-type.model';
|
|
||||||
import { MenuSection } from '../menu/menu-section.model';
|
|
||||||
import { NotificationsService } from '../notifications/notifications.service';
|
|
||||||
import { SubscriptionModalComponent } from '../subscriptions/subscription-modal/subscription-modal.component';
|
|
||||||
import { DsoVersioningModalService } from './dso-versioning-modal-service/dso-versioning-modal.service';
|
|
||||||
import {
|
|
||||||
DsoWithdrawnReinstateModalService,
|
|
||||||
REQUEST_REINSTATE,
|
|
||||||
REQUEST_WITHDRAWN,
|
|
||||||
} from './dso-withdrawn-reinstate-service/dso-withdrawn-reinstate-modal.service';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates the menus for the dspace object pages
|
|
||||||
*/
|
|
||||||
@Injectable({
|
|
||||||
providedIn: 'root',
|
|
||||||
})
|
|
||||||
export class DSOEditMenuResolverService {
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
protected dSpaceObjectDataService: DSpaceObjectDataService,
|
|
||||||
protected menuService: MenuService,
|
|
||||||
protected authorizationService: AuthorizationDataService,
|
|
||||||
protected modalService: NgbModal,
|
|
||||||
protected dsoVersioningModalService: DsoVersioningModalService,
|
|
||||||
protected researcherProfileService: ResearcherProfileDataService,
|
|
||||||
protected notificationsService: NotificationsService,
|
|
||||||
protected translate: TranslateService,
|
|
||||||
protected dsoWithdrawnReinstateModalService: DsoWithdrawnReinstateModalService,
|
|
||||||
private correctionTypeDataService: CorrectionTypeDataService,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialise all dspace object related menus
|
|
||||||
*/
|
|
||||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<{ [key: string]: MenuSection[] }> {
|
|
||||||
let id = route.params.id;
|
|
||||||
if (hasNoValue(id) && hasValue(route.queryParams.scope)) {
|
|
||||||
id = route.queryParams.scope;
|
|
||||||
}
|
|
||||||
if (hasNoValue(id)) {
|
|
||||||
// If there's no ID, we're not on a DSO homepage, so pass on any pre-existing menu route data
|
|
||||||
return observableOf({ ...route.data?.menu });
|
|
||||||
} else {
|
|
||||||
return this.dSpaceObjectDataService.findById(id, true, false).pipe(
|
|
||||||
getFirstCompletedRemoteData(),
|
|
||||||
switchMap((dsoRD) => {
|
|
||||||
if (dsoRD.hasSucceeded) {
|
|
||||||
const dso = dsoRD.payload;
|
|
||||||
return combineLatest(this.getDsoMenus(dso, route, state)).pipe(
|
|
||||||
// Menu sections are retrieved as an array of arrays and flattened into a single array
|
|
||||||
map((combinedMenus) => [].concat.apply([], combinedMenus)),
|
|
||||||
map((menus) => this.addDsoUuidToMenuIDs(menus, dso)),
|
|
||||||
map((menus) => {
|
|
||||||
return {
|
|
||||||
...route.data?.menu,
|
|
||||||
[MenuID.DSO_EDIT]: menus,
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return observableOf({ ...route.data?.menu });
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return all the menus for a dso based on the route and state
|
|
||||||
*/
|
|
||||||
getDsoMenus(dso, route, state): Observable<MenuSection[]>[] {
|
|
||||||
return [
|
|
||||||
this.getItemMenu(dso),
|
|
||||||
this.getComColMenu(dso),
|
|
||||||
this.getCommonMenu(dso, state),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the common menus between all dspace objects
|
|
||||||
*/
|
|
||||||
protected getCommonMenu(dso, state): Observable<MenuSection[]> {
|
|
||||||
return combineLatest([
|
|
||||||
this.authorizationService.isAuthorized(FeatureID.CanEditMetadata, dso.self),
|
|
||||||
]).pipe(
|
|
||||||
map(([canEditItem]) => {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
id: 'edit-dso',
|
|
||||||
active: false,
|
|
||||||
visible: canEditItem,
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.LINK,
|
|
||||||
text: this.getDsoType(dso) + '.page.edit',
|
|
||||||
link: new URLCombiner(getDSORoute(dso), 'edit', 'metadata').toString(),
|
|
||||||
} as LinkMenuItemModel,
|
|
||||||
icon: 'pencil-alt',
|
|
||||||
index: 2,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get item specific menus
|
|
||||||
*/
|
|
||||||
protected getItemMenu(dso): Observable<MenuSection[]> {
|
|
||||||
if (dso instanceof Item) {
|
|
||||||
return combineLatest([
|
|
||||||
this.authorizationService.isAuthorized(FeatureID.CanCreateVersion, dso.self),
|
|
||||||
this.dsoVersioningModalService.isNewVersionButtonDisabled(dso),
|
|
||||||
this.dsoVersioningModalService.getVersioningTooltipMessage(dso, 'item.page.version.hasDraft', 'item.page.version.create'),
|
|
||||||
this.authorizationService.isAuthorized(FeatureID.CanSynchronizeWithORCID, dso.self),
|
|
||||||
this.authorizationService.isAuthorized(FeatureID.CanClaimItem, dso.self),
|
|
||||||
this.correctionTypeDataService.findByItem(dso.uuid, true).pipe(
|
|
||||||
getFirstCompletedRemoteData(),
|
|
||||||
getRemoteDataPayload()),
|
|
||||||
]).pipe(
|
|
||||||
map(([canCreateVersion, disableVersioning, versionTooltip, canSynchronizeWithOrcid, canClaimItem, correction]) => {
|
|
||||||
const isPerson = this.getDsoType(dso) === 'person';
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
id: 'orcid-dso',
|
|
||||||
active: false,
|
|
||||||
visible: isPerson && canSynchronizeWithOrcid,
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.LINK,
|
|
||||||
text: 'item.page.orcid.tooltip',
|
|
||||||
link: new URLCombiner(getDSORoute(dso), 'orcid').toString(),
|
|
||||||
} as LinkMenuItemModel,
|
|
||||||
icon: 'orcid fab fa-lg',
|
|
||||||
index: 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'version-dso',
|
|
||||||
active: false,
|
|
||||||
visible: canCreateVersion,
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.ONCLICK,
|
|
||||||
text: versionTooltip,
|
|
||||||
disabled: disableVersioning,
|
|
||||||
function: () => {
|
|
||||||
this.dsoVersioningModalService.openCreateVersionModal(dso);
|
|
||||||
},
|
|
||||||
} as OnClickMenuItemModel,
|
|
||||||
icon: 'code-branch',
|
|
||||||
index: 1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'claim-dso',
|
|
||||||
active: false,
|
|
||||||
visible: isPerson && canClaimItem,
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.ONCLICK,
|
|
||||||
text: 'item.page.claim.button',
|
|
||||||
function: () => {
|
|
||||||
this.claimResearcher(dso);
|
|
||||||
},
|
|
||||||
} as OnClickMenuItemModel,
|
|
||||||
icon: 'hand-paper',
|
|
||||||
index: 3,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'withdrawn-item',
|
|
||||||
active: false,
|
|
||||||
visible: dso.isArchived && correction?.page.some((c) => c.topic === REQUEST_WITHDRAWN),
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.ONCLICK,
|
|
||||||
text:'item.page.withdrawn',
|
|
||||||
function: () => {
|
|
||||||
this.dsoWithdrawnReinstateModalService.openCreateWithdrawnReinstateModal(dso, 'request-withdrawn', dso.isArchived);
|
|
||||||
},
|
|
||||||
} as OnClickMenuItemModel,
|
|
||||||
icon: 'eye-slash',
|
|
||||||
index: 4,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'reinstate-item',
|
|
||||||
active: false,
|
|
||||||
visible: dso.isWithdrawn && correction?.page.some((c) => c.topic === REQUEST_REINSTATE),
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.ONCLICK,
|
|
||||||
text:'item.page.reinstate',
|
|
||||||
function: () => {
|
|
||||||
this.dsoWithdrawnReinstateModalService.openCreateWithdrawnReinstateModal(dso, 'request-reinstate', dso.isArchived);
|
|
||||||
},
|
|
||||||
} as OnClickMenuItemModel,
|
|
||||||
icon: 'eye',
|
|
||||||
index: 5,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return observableOf([]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Community/Collection-specific menus
|
|
||||||
*/
|
|
||||||
protected getComColMenu(dso): Observable<MenuSection[]> {
|
|
||||||
if (dso instanceof Community || dso instanceof Collection) {
|
|
||||||
return combineLatest([
|
|
||||||
this.authorizationService.isAuthorized(FeatureID.CanSubscribe, dso.self),
|
|
||||||
]).pipe(
|
|
||||||
map(([canSubscribe]) => {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
id: 'subscribe',
|
|
||||||
active: false,
|
|
||||||
visible: canSubscribe,
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.ONCLICK,
|
|
||||||
text: 'subscriptions.tooltip',
|
|
||||||
function: () => {
|
|
||||||
const modalRef = this.modalService.open(SubscriptionModalComponent);
|
|
||||||
modalRef.componentInstance.dso = dso;
|
|
||||||
},
|
|
||||||
} as OnClickMenuItemModel,
|
|
||||||
icon: 'bell',
|
|
||||||
index: 4,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return observableOf([]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Claim a researcher by creating a profile
|
|
||||||
* Shows notifications and/or hides the menu section on success/error
|
|
||||||
*/
|
|
||||||
protected claimResearcher(dso) {
|
|
||||||
this.researcherProfileService.createFromExternalSourceAndReturnRelatedItemId(dso.self)
|
|
||||||
.subscribe((id: string) => {
|
|
||||||
if (isNotEmpty(id)) {
|
|
||||||
this.notificationsService.success(this.translate.get('researcherprofile.success.claim.title'),
|
|
||||||
this.translate.get('researcherprofile.success.claim.body'));
|
|
||||||
this.authorizationService.invalidateAuthorizationsRequestCache();
|
|
||||||
this.menuService.hideMenuSection(MenuID.DSO_EDIT, 'claim-dso-' + dso.uuid);
|
|
||||||
} else {
|
|
||||||
this.notificationsService.error(
|
|
||||||
this.translate.get('researcherprofile.error.claim.title'),
|
|
||||||
this.translate.get('researcherprofile.error.claim.body'));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve the dso or entity type for an object to be used in generic messages
|
|
||||||
*/
|
|
||||||
protected getDsoType(dso) {
|
|
||||||
const renderType = dso.getRenderTypes()[0];
|
|
||||||
if (typeof renderType === 'string' || renderType instanceof String) {
|
|
||||||
return renderType.toLowerCase();
|
|
||||||
} else {
|
|
||||||
return dso.type.toString().toLowerCase();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add the dso uuid to all provided menu ids and parent ids
|
|
||||||
*/
|
|
||||||
protected addDsoUuidToMenuIDs(menus, dso) {
|
|
||||||
return menus.map((menu) => {
|
|
||||||
Object.assign(menu, {
|
|
||||||
id: menu.id + '-' + dso.uuid,
|
|
||||||
});
|
|
||||||
if (hasValue(menu.parentID)) {
|
|
||||||
Object.assign(menu, {
|
|
||||||
parentID: menu.parentID + '-' + dso.uuid,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return menu;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -41,6 +41,19 @@ export const ROUTES: Route[] = [
|
|||||||
component: ThemedItemStatisticsPageComponent,
|
component: ThemedItemStatisticsPageComponent,
|
||||||
canActivate: [statisticsAdministratorGuard],
|
canActivate: [statisticsAdministratorGuard],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: `entities/:entityType/:id`,
|
||||||
|
resolve: {
|
||||||
|
scope: itemResolver,
|
||||||
|
breadcrumb: i18nBreadcrumbResolver,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
title: 'statistics.title',
|
||||||
|
breadcrumbKey: 'statistics',
|
||||||
|
},
|
||||||
|
component: ThemedItemStatisticsPageComponent,
|
||||||
|
canActivate: [statisticsAdministratorGuard],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: `collections/:id`,
|
path: `collections/:id`,
|
||||||
resolve: {
|
resolve: {
|
||||||
|
Reference in New Issue
Block a user