diff --git a/src/app/collection-page/collection-page-routing.module.ts b/src/app/collection-page/collection-page-routing.module.ts index 678c745c01..8db7cf7021 100644 --- a/src/app/collection-page/collection-page-routing.module.ts +++ b/src/app/collection-page/collection-page-routing.module.ts @@ -21,14 +21,32 @@ import { CollectionPageAdministratorGuard } from './collection-page-administrato import { LinkMenuItemModel } from '../shared/menu/menu-item/models/link.model'; import { ThemedCollectionPageComponent } from './themed-collection-page.component'; import { MenuItemType } from '../shared/menu/menu-item-type.model'; +import { CommunityBreadcrumbResolver } from '../core/breadcrumbs/community-breadcrumb.resolver'; @NgModule({ imports: [ RouterModule.forChild([ { path: COLLECTION_CREATE_PATH, - component: CreateCollectionPageComponent, - canActivate: [AuthenticatedGuard, CreateCollectionPageGuard] + children: [ + { + path: '', + component: CreateCollectionPageComponent, + resolve: { + breadcrumb: I18nBreadcrumbResolver, + }, + data: { + breadcrumbKey: 'collection.create', + }, + }, + ], + canActivate: [AuthenticatedGuard, CreateCollectionPageGuard], + data: { + breadcrumbQueryParam: 'parent', + }, + resolve: { + breadcrumb: CommunityBreadcrumbResolver, + }, }, { path: ':id', @@ -90,7 +108,8 @@ import { MenuItemType } from '../shared/menu/menu-item-type.model'; DSOBreadcrumbsService, LinkService, CreateCollectionPageGuard, - CollectionPageAdministratorGuard + CollectionPageAdministratorGuard, + CommunityBreadcrumbResolver, ] }) export class CollectionPageRoutingModule { diff --git a/src/app/community-page/community-page-routing.module.ts b/src/app/community-page/community-page-routing.module.ts index 25326448a8..242b85bc01 100644 --- a/src/app/community-page/community-page-routing.module.ts +++ b/src/app/community-page/community-page-routing.module.ts @@ -14,14 +14,32 @@ import { CommunityPageAdministratorGuard } from './community-page-administrator. import { LinkMenuItemModel } from '../shared/menu/menu-item/models/link.model'; import { ThemedCommunityPageComponent } from './themed-community-page.component'; import { MenuItemType } from '../shared/menu/menu-item-type.model'; +import { I18nBreadcrumbResolver } from '../core/breadcrumbs/i18n-breadcrumb.resolver'; @NgModule({ imports: [ RouterModule.forChild([ { path: COMMUNITY_CREATE_PATH, - component: CreateCommunityPageComponent, - canActivate: [AuthenticatedGuard, CreateCommunityPageGuard] + children: [ + { + path: '', + component: CreateCommunityPageComponent, + resolve: { + breadcrumb: I18nBreadcrumbResolver, + }, + data: { + breadcrumbKey: 'community.create', + }, + } + ], + canActivate: [AuthenticatedGuard, CreateCommunityPageGuard], + data: { + breadcrumbQueryParam: 'parent', + }, + resolve: { + breadcrumb: CommunityBreadcrumbResolver, + }, }, { path: ':id', diff --git a/src/app/core/breadcrumbs/community-breadcrumb.resolver.ts b/src/app/core/breadcrumbs/community-breadcrumb.resolver.ts index 309927771d..ea96f6d43a 100644 --- a/src/app/core/breadcrumbs/community-breadcrumb.resolver.ts +++ b/src/app/core/breadcrumbs/community-breadcrumb.resolver.ts @@ -5,6 +5,10 @@ import { CommunityDataService } from '../data/community-data.service'; import { Community } from '../shared/community.model'; import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model'; import { COMMUNITY_PAGE_LINKS_TO_FOLLOW } from '../../community-page/community-page.resolver'; +import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; +import { Observable } from 'rxjs'; +import { BreadcrumbConfig } from '../../breadcrumbs/breadcrumb/breadcrumb-config.model'; +import { hasValue } from '../../shared/empty.util'; /** * The class that resolves the BreadcrumbConfig object for a Community @@ -17,6 +21,23 @@ export class CommunityBreadcrumbResolver extends DSOBreadcrumbResolver> { + if (hasValue(route.data.breadcrumbQueryParam) && hasValue(route.queryParams[route.data.breadcrumbQueryParam])) { + return this.resolveById(route.queryParams[route.data.breadcrumbQueryParam]); + } else { + return super.resolve(route, state); + } + } + /** * Method that returns the follow links to already resolve * The self links defined in this list are expected to be requested somewhere in the near future diff --git a/src/app/core/breadcrumbs/dso-breadcrumb.resolver.spec.ts b/src/app/core/breadcrumbs/dso-breadcrumb.resolver.spec.ts index e35e26e46f..d7d63669f1 100644 --- a/src/app/core/breadcrumbs/dso-breadcrumb.resolver.spec.ts +++ b/src/app/core/breadcrumbs/dso-breadcrumb.resolver.spec.ts @@ -18,7 +18,10 @@ describe('DSOBreadcrumbResolver', () => { uuid = '1234-65487-12354-1235'; breadcrumbUrl = '/collections/' + uuid; currentUrl = breadcrumbUrl + '/edit'; - testCollection = Object.assign(new Collection(), { uuid }); + testCollection = Object.assign(new Collection(), { + uuid: uuid, + type: 'collection', + }); dsoBreadcrumbService = {}; collectionService = { findById: (id: string) => createSuccessfulRemoteDataObject$(testCollection) diff --git a/src/app/core/breadcrumbs/dso-breadcrumb.resolver.ts b/src/app/core/breadcrumbs/dso-breadcrumb.resolver.ts index 8be4e5e099..165cfd0382 100644 --- a/src/app/core/breadcrumbs/dso-breadcrumb.resolver.ts +++ b/src/app/core/breadcrumbs/dso-breadcrumb.resolver.ts @@ -10,6 +10,7 @@ import { ChildHALResource } from '../shared/child-hal-resource.model'; import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model'; import { hasValue } from '../../shared/empty.util'; import { IdentifiableDataService } from '../data/base/identifiable-data.service'; +import { getDSORoute } from '../../app-routing-paths'; /** * The class that resolves the BreadcrumbConfig object for a DSpaceObject @@ -31,15 +32,22 @@ export abstract class DSOBreadcrumbResolver> { - const uuid = route.params.id; + return this.resolveById(route.params.id); + } + + /** + * Method for resolving a breadcrumb by id + * + * @param uuid The uuid to resolve + * @returns BreadcrumbConfig object + */ + resolveById(uuid: string): Observable> { return this.dataService.findById(uuid, true, false, ...this.followLinks).pipe( getFirstCompletedRemoteData(), getRemoteDataPayload(), map((object: T) => { if (hasValue(object)) { - const fullPath = state.url; - const url = fullPath.substr(0, fullPath.indexOf(uuid)) + uuid; - return { provider: this.breadcrumbService, key: object, url: url }; + return { provider: this.breadcrumbService, key: object, url: getDSORoute(object) }; } else { return undefined; } diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index 597f226cc7..7afcf8b27d 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -781,6 +781,7 @@ "chips.remove": "Remove chip", + "collection.create.breadcrumbs": "Create collection", "collection.create.head": "Create a Collection", @@ -1053,6 +1054,8 @@ + "community.create.breadcrumbs": "Create Community", + "community.create.head": "Create a Community", "community.create.notifications.success": "Successfully created the Community",