|
6 | 6 | * http://www.dspace.org/license/ |
7 | 7 | */ |
8 | 8 | import { Injectable } from '@angular/core'; |
| 9 | +import { PaginatedList } from '@dspace/core/data/paginated-list.model'; |
| 10 | +import { RemoteData } from '@dspace/core/data/remote-data'; |
9 | 11 | import { DSpaceObject } from '@dspace/core/shared/dspace-object.model'; |
10 | | -import { |
11 | | - getAllSucceededRemoteDataPayload, |
12 | | - getPaginatedListPayload, |
13 | | -} from '@dspace/core/shared/operators'; |
| 12 | +import { getFirstCompletedRemoteData } from '@dspace/core/shared/operators'; |
14 | 13 | import { EditItemDataService } from '@dspace/core/submission/edititem-data.service'; |
15 | 14 | import { EditItemMode } from '@dspace/core/submission/models/edititem-mode.model'; |
16 | 15 | import { URLCombiner } from '@dspace/core/url-combiner/url-combiner'; |
@@ -40,20 +39,24 @@ export class EditItemMenuProvider extends DSpaceObjectPageMenuProvider { |
40 | 39 |
|
41 | 40 | public getSectionsForContext(dso: DSpaceObject): Observable<PartialMenuSection[]> { |
42 | 41 | return this.editItemService.searchEditModesById(dso.id).pipe( |
43 | | - getAllSucceededRemoteDataPayload(), |
44 | | - getPaginatedListPayload(), |
45 | | - map((editModes: EditItemMode[]) => { |
46 | | - return editModes.map(editMode => { |
47 | | - return { |
48 | | - model: { |
49 | | - type: MenuItemType.LINK, |
50 | | - text: `menu.section.${editMode.name}`, |
51 | | - link: new URLCombiner(getEditItemPageRoute(), `${dso.uuid}:${editMode.name}`).toString(), |
52 | | - }, |
53 | | - icon: 'pencil-alt', |
54 | | - visible: true, |
55 | | - }; |
56 | | - }); |
| 42 | + getFirstCompletedRemoteData(), |
| 43 | + map((editmodesRd: RemoteData<PaginatedList<EditItemMode>>) => { |
| 44 | + if (editmodesRd.hasSucceeded) { |
| 45 | + const editModes = editmodesRd.payload.page; |
| 46 | + return editModes.map(editMode => { |
| 47 | + return { |
| 48 | + model: { |
| 49 | + type: MenuItemType.LINK, |
| 50 | + text: `menu.section.${editMode.name}`, |
| 51 | + link: new URLCombiner(getEditItemPageRoute(), `${dso.uuid}:${editMode.name}`).toString(), |
| 52 | + }, |
| 53 | + icon: 'pencil-alt', |
| 54 | + visible: true, |
| 55 | + }; |
| 56 | + }); |
| 57 | + } else { |
| 58 | + return []; |
| 59 | + } |
57 | 60 | }), |
58 | 61 | catchError(() => of([])), |
59 | 62 | ); |
|
0 commit comments