Skip to content

Commit d1ab193

Browse files
authored
Merge pull request #1001 from atmire/Item-page-redirects
DS-4283: (Google Scholar) Provide Entity Type Label/Name as part of URL path
2 parents b5c1b8c + 4280475 commit d1ab193

110 files changed

Lines changed: 880 additions & 228 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/app/+admin/admin-access-control/group-registry/group-form/members-list/members-list.component.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ import {
77
of as observableOf,
88
Subscription,
99
BehaviorSubject,
10-
combineLatest as observableCombineLatest, ObservedValueOf,
10+
combineLatest as observableCombineLatest,
11+
ObservedValueOf,
1112
} from 'rxjs';
1213
import { map, mergeMap, switchMap, take } from 'rxjs/operators';
13-
import {buildPaginatedList, PaginatedList} from '../../../../../core/data/paginated-list.model';
14+
import { buildPaginatedList, PaginatedList } from '../../../../../core/data/paginated-list.model';
1415
import { RemoteData } from '../../../../../core/data/remote-data';
1516
import { EPersonDataService } from '../../../../../core/eperson/eperson-data.service';
1617
import { GroupDataService } from '../../../../../core/eperson/group-data.service';
@@ -19,11 +20,12 @@ import { Group } from '../../../../../core/eperson/models/group.model';
1920
import {
2021
getRemoteDataPayload,
2122
getFirstSucceededRemoteData,
22-
getFirstCompletedRemoteData, getAllCompletedRemoteData
23+
getFirstCompletedRemoteData,
24+
getAllCompletedRemoteData
2325
} from '../../../../../core/shared/operators';
2426
import { NotificationsService } from '../../../../../shared/notifications/notifications.service';
2527
import { PaginationComponentOptions } from '../../../../../shared/pagination/pagination-component-options.model';
26-
import {EpersonDtoModel} from '../../../../../core/eperson/models/eperson-dto.model';
28+
import { EpersonDtoModel } from '../../../../../core/eperson/models/eperson-dto.model';
2729

2830
/**
2931
* Keys to keep track of specific subscriptions

src/app/+admin/admin-search-page/admin-search-results/item-admin-search-result-actions.component.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,19 @@ describe('ItemAdminSearchResultActionsComponent', () => {
5656
it('should render an edit button with the correct link', () => {
5757
const button = fixture.debugElement.query(By.css('a.edit-link'));
5858
const link = button.nativeElement.href;
59-
expect(link).toContain(getItemEditRoute(id));
59+
expect(link).toContain(getItemEditRoute(item));
6060
});
6161

6262
it('should render a delete button with the correct link', () => {
6363
const button = fixture.debugElement.query(By.css('a.delete-link'));
6464
const link = button.nativeElement.href;
65-
expect(link).toContain(new URLCombiner(getItemEditRoute(id), ITEM_EDIT_DELETE_PATH).toString());
65+
expect(link).toContain(new URLCombiner(getItemEditRoute(item), ITEM_EDIT_DELETE_PATH).toString());
6666
});
6767

6868
it('should render a move button with the correct link', () => {
6969
const a = fixture.debugElement.query(By.css('a.move-link'));
7070
const link = a.nativeElement.href;
71-
expect(link).toContain(new URLCombiner(getItemEditRoute(id), ITEM_EDIT_MOVE_PATH).toString());
71+
expect(link).toContain(new URLCombiner(getItemEditRoute(item), ITEM_EDIT_MOVE_PATH).toString());
7272
});
7373

7474
describe('when the item is not withdrawn', () => {
@@ -80,7 +80,7 @@ describe('ItemAdminSearchResultActionsComponent', () => {
8080
it('should render a withdraw button with the correct link', () => {
8181
const a = fixture.debugElement.query(By.css('a.withdraw-link'));
8282
const link = a.nativeElement.href;
83-
expect(link).toContain(new URLCombiner(getItemEditRoute(id), ITEM_EDIT_WITHDRAW_PATH).toString());
83+
expect(link).toContain(new URLCombiner(getItemEditRoute(item), ITEM_EDIT_WITHDRAW_PATH).toString());
8484
});
8585

8686
it('should not render a reinstate button with the correct link', () => {
@@ -103,7 +103,7 @@ describe('ItemAdminSearchResultActionsComponent', () => {
103103
it('should render a reinstate button with the correct link', () => {
104104
const a = fixture.debugElement.query(By.css('a.reinstate-link'));
105105
const link = a.nativeElement.href;
106-
expect(link).toContain(new URLCombiner(getItemEditRoute(id), ITEM_EDIT_REINSTATE_PATH).toString());
106+
expect(link).toContain(new URLCombiner(getItemEditRoute(item), ITEM_EDIT_REINSTATE_PATH).toString());
107107
});
108108
});
109109

@@ -116,7 +116,7 @@ describe('ItemAdminSearchResultActionsComponent', () => {
116116
it('should render a make private button with the correct link', () => {
117117
const a = fixture.debugElement.query(By.css('a.private-link'));
118118
const link = a.nativeElement.href;
119-
expect(link).toContain(new URLCombiner(getItemEditRoute(id), ITEM_EDIT_PRIVATE_PATH).toString());
119+
expect(link).toContain(new URLCombiner(getItemEditRoute(item), ITEM_EDIT_PRIVATE_PATH).toString());
120120
});
121121

122122
it('should not render a make public button with the correct link', () => {
@@ -139,7 +139,7 @@ describe('ItemAdminSearchResultActionsComponent', () => {
139139
it('should render a make private button with the correct link', () => {
140140
const a = fixture.debugElement.query(By.css('a.public-link'));
141141
const link = a.nativeElement.href;
142-
expect(link).toContain(new URLCombiner(getItemEditRoute(id), ITEM_EDIT_PUBLIC_PATH).toString());
142+
expect(link).toContain(new URLCombiner(getItemEditRoute(item), ITEM_EDIT_PUBLIC_PATH).toString());
143143
});
144144
});
145145
});

src/app/+admin/admin-search-page/admin-search-results/item-admin-search-result-actions.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class ItemAdminSearchResultActionsComponent {
3434
* Returns the path to the edit page of this item
3535
*/
3636
getEditRoute(): string {
37-
return getItemEditRoute(this.item.uuid);
37+
return getItemEditRoute(this.item);
3838
}
3939

4040
/**

src/app/+bitstream-page/edit-bitstream-page/edit-bitstream-page.component.spec.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,14 @@ import { hasValue } from '../../shared/empty.util';
1818
import { FormControl, FormGroup } from '@angular/forms';
1919
import { FileSizePipe } from '../../shared/utils/file-size-pipe';
2020
import { VarDirective } from '../../shared/utils/var.directive';
21-
import { createSuccessfulRemoteDataObject, createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
21+
import {
22+
createSuccessfulRemoteDataObject,
23+
createSuccessfulRemoteDataObject$
24+
} from '../../shared/remote-data.utils';
2225
import { RouterStub } from '../../shared/testing/router.stub';
23-
import { getItemEditRoute } from '../../+item-page/item-page-routing-paths';
26+
import { getEntityEditRoute, getItemEditRoute } from '../../+item-page/item-page-routing-paths';
2427
import { createPaginatedList } from '../../shared/testing/utils.test';
28+
import { Item } from '../../core/shared/item.model';
2529

2630
const infoNotification: INotification = new Notification('id', NotificationType.Info, 'info');
2731
const warningNotification: INotification = new Notification('id', NotificationType.Warning, 'warning');
@@ -109,9 +113,9 @@ describe('EditBitstreamPageComponent', () => {
109113
self: 'bitstream-selflink'
110114
},
111115
bundle: createSuccessfulRemoteDataObject$({
112-
item: createSuccessfulRemoteDataObject$({
116+
item: createSuccessfulRemoteDataObject$(Object.assign(new Item(), {
113117
uuid: 'some-uuid'
114-
})
118+
}))
115119
})
116120
});
117121
bitstreamService = jasmine.createSpyObj('bitstreamService', {
@@ -237,14 +241,14 @@ describe('EditBitstreamPageComponent', () => {
237241
it('should redirect to the item edit page on the bitstreams tab with the itemId from the component', () => {
238242
comp.itemId = 'some-uuid1';
239243
comp.navigateToItemEditBitstreams();
240-
expect(routerStub.navigate).toHaveBeenCalledWith([getItemEditRoute('some-uuid1'), 'bitstreams']);
244+
expect(routerStub.navigate).toHaveBeenCalledWith([getEntityEditRoute(null, 'some-uuid1'), 'bitstreams']);
241245
});
242246
});
243247
describe('when navigateToItemEditBitstreams is called, and the component does not have an itemId', () => {
244248
it('should redirect to the item edit page on the bitstreams tab with the itemId from the bundle links ', () => {
245249
comp.itemId = undefined;
246250
comp.navigateToItemEditBitstreams();
247-
expect(routerStub.navigate).toHaveBeenCalledWith([getItemEditRoute('some-uuid'), 'bitstreams']);
251+
expect(routerStub.navigate).toHaveBeenCalledWith([getEntityEditRoute(null, 'some-uuid'), 'bitstreams']);
248252
});
249253
});
250254
});

src/app/+bitstream-page/edit-bitstream-page/edit-bitstream-page.component.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ import { Metadata } from '../../core/shared/metadata.utils';
3333
import { Location } from '@angular/common';
3434
import { RemoteData } from '../../core/data/remote-data';
3535
import { PaginatedList } from '../../core/data/paginated-list.model';
36-
import { getItemEditRoute } from '../../+item-page/item-page-routing-paths';
36+
import { getEntityEditRoute, getItemEditRoute } from '../../+item-page/item-page-routing-paths';
3737
import { Bundle } from '../../core/shared/bundle.model';
38-
import { Item } from '../../core/shared/item.model';
3938

4039
@Component({
4140
selector: 'ds-edit-bitstream-page',
@@ -264,9 +263,17 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
264263
/**
265264
* The ID of the item the bitstream originates from
266265
* Taken from the current query parameters when present
266+
* This will determine the route of the item edit page to return to
267267
*/
268268
itemId: string;
269269

270+
/**
271+
* The entity type of the item the bitstream originates from
272+
* Taken from the current query parameters when present
273+
* This will determine the route of the item edit page to return to
274+
*/
275+
entityType: string;
276+
270277
/**
271278
* Array to track all subscriptions and unsubscribe them onDestroy
272279
* @type {Array}
@@ -293,6 +300,7 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
293300
this.formGroup = this.formService.createFormGroup(this.formModel);
294301

295302
this.itemId = this.route.snapshot.queryParams.itemId;
303+
this.entityType = this.route.snapshot.queryParams.entityType;
296304
this.bitstreamRD$ = this.route.data.pipe(map((data) => data.bitstream));
297305
this.bitstreamFormatsRD$ = this.bitstreamFormatService.findAll(this.findAllOptions);
298306

@@ -499,10 +507,10 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
499507
*/
500508
navigateToItemEditBitstreams() {
501509
if (hasValue(this.itemId)) {
502-
this.router.navigate([getItemEditRoute(this.itemId), 'bitstreams']);
510+
this.router.navigate([getEntityEditRoute(this.entityType, this.itemId), 'bitstreams']);
503511
} else {
504512
this.bitstream.bundle.pipe(getFirstSucceededRemoteDataPayload(),
505-
mergeMap((bundle: Bundle) => bundle.item.pipe(getFirstSucceededRemoteDataPayload(), map((item: Item) => item.uuid))))
513+
mergeMap((bundle: Bundle) => bundle.item.pipe(getFirstSucceededRemoteDataPayload())))
506514
.subscribe((item) => {
507515
this.router.navigate(([getItemEditRoute(item), 'bitstreams']));
508516
});

src/app/+collection-page/collection-page.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
</ds-comcol-page-content>
3636
</header>
3737
<div class="pl-2">
38-
<ds-dso-page-edit-button [pageRoutePrefix]="'collections'" [dso]="collection" [tooltipMsg]="'collection.page.edit'"></ds-dso-page-edit-button>
38+
<ds-dso-page-edit-button [pageRoute]="collectionPageRoute$ | async" [dso]="collection" [tooltipMsg]="'collection.page.edit'"></ds-dso-page-edit-button>
3939
</div>
4040
</div>
4141
<section class="comcol-page-browse-section">

src/app/+collection-page/collection-page.component.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,19 @@ import { Bitstream } from '../core/shared/bitstream.model';
1515
import { Collection } from '../core/shared/collection.model';
1616
import { DSpaceObjectType } from '../core/shared/dspace-object-type.model';
1717
import { Item } from '../core/shared/item.model';
18-
import { getFirstSucceededRemoteData, redirectOn4xx, toDSpaceObjectListRD } from '../core/shared/operators';
18+
import {
19+
getAllSucceededRemoteDataPayload,
20+
getFirstSucceededRemoteData,
21+
redirectOn4xx,
22+
toDSpaceObjectListRD
23+
} from '../core/shared/operators';
1924

2025
import { fadeIn, fadeInOut } from '../shared/animations/fade';
2126
import { hasValue, isNotEmpty } from '../shared/empty.util';
2227
import { PaginationComponentOptions } from '../shared/pagination/pagination-component-options.model';
2328
import { AuthService } from '../core/auth/auth.service';
2429
import {PaginationChangeEvent} from '../shared/pagination/paginationChangeEvent.interface';
30+
import { getCollectionPageRoute } from './collection-page-routing-paths';
2531

2632
@Component({
2733
selector: 'ds-collection-page',
@@ -44,6 +50,11 @@ export class CollectionPageComponent implements OnInit {
4450
sortConfig: SortOptions
4551
}>;
4652

53+
/**
54+
* Route to the community page
55+
*/
56+
collectionPageRoute$: Observable<string>;
57+
4758
constructor(
4859
private collectionDataService: CollectionDataService,
4960
private searchService: SearchService,
@@ -94,6 +105,11 @@ export class CollectionPageComponent implements OnInit {
94105
)
95106
);
96107

108+
this.collectionPageRoute$ = this.collectionRD$.pipe(
109+
getAllSucceededRemoteDataPayload(),
110+
map((collection) => getCollectionPageRoute(collection.id))
111+
);
112+
97113
this.route.queryParams.pipe(take(1)).subscribe((params) => {
98114
this.metadata.processRemoteData(this.collectionRD$);
99115
});

src/app/+community-page/community-page.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
</ds-comcol-page-content>
2222
</header>
2323
<div class="pl-2">
24-
<ds-dso-page-edit-button [pageRoutePrefix]="'communities'" [dso]="communityPayload" [tooltipMsg]="'community.page.edit'"></ds-dso-page-edit-button>
24+
<ds-dso-page-edit-button [pageRoute]="communityPageRoute$ | async" [dso]="communityPayload" [tooltipMsg]="'community.page.edit'"></ds-dso-page-edit-button>
2525
</div>
2626
</div>
2727
<section class="comcol-page-browse-section">

src/app/+community-page/community-page.component.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ import { MetadataService } from '../core/metadata/metadata.service';
1313

1414
import { fadeInOut } from '../shared/animations/fade';
1515
import { hasValue } from '../shared/empty.util';
16-
import { redirectOn4xx } from '../core/shared/operators';
16+
import { getAllSucceededRemoteDataPayload, redirectOn4xx } from '../core/shared/operators';
1717
import { AuthService } from '../core/auth/auth.service';
18+
import { getCommunityPageRoute } from './community-page-routing-paths';
1819

1920
@Component({
2021
selector: 'ds-community-page',
@@ -36,6 +37,12 @@ export class CommunityPageComponent implements OnInit {
3637
* The logo of this community
3738
*/
3839
logoRD$: Observable<RemoteData<Bitstream>>;
40+
41+
/**
42+
* Route to the community page
43+
*/
44+
communityPageRoute$: Observable<string>;
45+
3946
constructor(
4047
private communityDataService: CommunityDataService,
4148
private metadata: MetadataService,
@@ -55,6 +62,10 @@ export class CommunityPageComponent implements OnInit {
5562
map((rd: RemoteData<Community>) => rd.payload),
5663
filter((community: Community) => hasValue(community)),
5764
mergeMap((community: Community) => community.logo));
65+
this.communityPageRoute$ = this.communityRD$.pipe(
66+
getAllSucceededRemoteDataPayload(),
67+
map((community) => getCommunityPageRoute(community.id))
68+
);
5869
}
5970

6071
}

src/app/+item-page/bitstreams/upload/upload-bitstream.component.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { getFirstSucceededRemoteDataPayload } from '../../../core/shared/operato
1717
import { UploaderComponent } from '../../../shared/uploader/uploader.component';
1818
import { RequestService } from '../../../core/data/request.service';
1919
import { getBitstreamModuleRoute } from '../../../app-routing-paths';
20-
import { getItemEditRoute } from '../../item-page-routing-paths';
20+
import { getEntityEditRoute } from '../../item-page-routing-paths';
2121

2222
@Component({
2323
selector: 'ds-upload-bitstream',
@@ -37,6 +37,12 @@ export class UploadBitstreamComponent implements OnInit, OnDestroy {
3737
*/
3838
itemId: string;
3939

40+
/**
41+
* The entity type of the item
42+
* This is fetched from the current URL and will determine the item's page route
43+
*/
44+
entityType: string;
45+
4046
/**
4147
* The item to upload a bitstream to
4248
*/
@@ -100,6 +106,7 @@ export class UploadBitstreamComponent implements OnInit, OnDestroy {
100106
*/
101107
ngOnInit(): void {
102108
this.itemId = this.route.snapshot.params.id;
109+
this.entityType = this.route.snapshot.params['entity-type'];
103110
this.itemRD$ = this.route.data.pipe(map((data) => data.dso));
104111
this.bundlesRD$ = this.itemRD$.pipe(
105112
switchMap((itemRD: RemoteData<Item>) => itemRD.payload.bundles)
@@ -167,7 +174,7 @@ export class UploadBitstreamComponent implements OnInit, OnDestroy {
167174
});
168175

169176
// Bring over the item ID as a query parameter
170-
const queryParams = { itemId: this.itemId };
177+
const queryParams = { itemId: this.itemId, entityType: this.entityType };
171178
this.router.navigate([getBitstreamModuleRoute(), bitstream.id, 'edit'], { queryParams: queryParams });
172179
}
173180

@@ -193,7 +200,7 @@ export class UploadBitstreamComponent implements OnInit, OnDestroy {
193200
* When cancel is clicked, navigate back to the item's edit bitstreams page
194201
*/
195202
onCancel() {
196-
this.router.navigate([getItemEditRoute(this.itemId), 'bitstreams']);
203+
this.router.navigate([getEntityEditRoute(this.entityType, this.itemId), 'bitstreams']);
197204
}
198205

199206
/**

0 commit comments

Comments
 (0)