diff --git a/resources/i18n/en.json5 b/resources/i18n/en.json5 index 9dfcf50a76..8bfc282d73 100644 --- a/resources/i18n/en.json5 +++ b/resources/i18n/en.json5 @@ -745,6 +745,9 @@ + "item.edit.authorizations.title": "Edit item's Policies", + + "item.edit.delete.cancel": "Cancel", "item.edit.delete.confirm": "Delete", diff --git a/src/app/+item-page/edit-item-page/edit-item-page.module.ts b/src/app/+item-page/edit-item-page/edit-item-page.module.ts index 2cbd0c57d1..2b1248e61f 100644 --- a/src/app/+item-page/edit-item-page/edit-item-page.module.ts +++ b/src/app/+item-page/edit-item-page/edit-item-page.module.ts @@ -23,6 +23,7 @@ import { EditRelationshipListComponent } from './item-relationships/edit-relatio import { ItemMoveComponent } from './item-move/item-move.component'; import { VirtualMetadataComponent } from './virtual-metadata/virtual-metadata.component'; import { ItemVersionHistoryComponent } from './item-version-history/item-version-history.component'; +import { ItemAuthorizationsComponent } from './item-authorizations/item-authorizations.component'; /** * Module that contains all components related to the Edit Item page administrator functionality @@ -55,6 +56,7 @@ import { ItemVersionHistoryComponent } from './item-version-history/item-version ItemCollectionMapperComponent, ItemMoveComponent, VirtualMetadataComponent, + ItemAuthorizationsComponent ] }) export class EditItemPageModule { diff --git a/src/app/+item-page/edit-item-page/edit-item-page.routing.module.ts b/src/app/+item-page/edit-item-page/edit-item-page.routing.module.ts index e4b1b06730..b41df21eaf 100644 --- a/src/app/+item-page/edit-item-page/edit-item-page.routing.module.ts +++ b/src/app/+item-page/edit-item-page/edit-item-page.routing.module.ts @@ -14,6 +14,7 @@ import { ItemMoveComponent } from './item-move/item-move.component'; import { ItemRelationshipsComponent } from './item-relationships/item-relationships.component'; import { I18nBreadcrumbResolver } from '../../core/breadcrumbs/i18n-breadcrumb.resolver'; import { ItemVersionHistoryComponent } from './item-version-history/item-version-history.component'; +import { ItemAuthorizationsComponent } from './item-authorizations/item-authorizations.component'; export const ITEM_EDIT_WITHDRAW_PATH = 'withdraw'; export const ITEM_EDIT_REINSTATE_PATH = 'reinstate'; @@ -21,6 +22,7 @@ export const ITEM_EDIT_PRIVATE_PATH = 'private'; export const ITEM_EDIT_PUBLIC_PATH = 'public'; export const ITEM_EDIT_DELETE_PATH = 'delete'; export const ITEM_EDIT_MOVE_PATH = 'move'; +export const ITEM_EDIT_AUTHORIZATIONS_PATH = 'authorizations'; /** * Routing module that handles the routing for the Edit Item page administrator functionality @@ -111,6 +113,11 @@ export const ITEM_EDIT_MOVE_PATH = 'move'; path: ITEM_EDIT_MOVE_PATH, component: ItemMoveComponent, data: { title: 'item.edit.move.title' }, + }, + { + path: ITEM_EDIT_AUTHORIZATIONS_PATH, + component: ItemAuthorizationsComponent, + data: { title: 'item.edit.authorizations.title' }, } ] } diff --git a/src/app/+item-page/edit-item-page/item-authorizations/item-authorizations.component.html b/src/app/+item-page/edit-item-page/item-authorizations/item-authorizations.component.html new file mode 100644 index 0000000000..4ddf939631 --- /dev/null +++ b/src/app/+item-page/edit-item-page/item-authorizations/item-authorizations.component.html @@ -0,0 +1,3 @@ +
+ +
diff --git a/src/app/+item-page/edit-item-page/item-authorizations/item-authorizations.component.spec.ts b/src/app/+item-page/edit-item-page/item-authorizations/item-authorizations.component.spec.ts new file mode 100644 index 0000000000..940c5a0ef5 --- /dev/null +++ b/src/app/+item-page/edit-item-page/item-authorizations/item-authorizations.component.spec.ts @@ -0,0 +1,9 @@ +import { ComponentFixture } from '@angular/core/testing'; + +import { ItemAuthorizationsComponent } from './item-authorizations.component'; + +describe('ItemAuthorizationsComponent', () => { + let comp: ItemAuthorizationsComponent; + let fixture: ComponentFixture; + +}); diff --git a/src/app/+item-page/edit-item-page/item-authorizations/item-authorizations.component.ts b/src/app/+item-page/edit-item-page/item-authorizations/item-authorizations.component.ts new file mode 100644 index 0000000000..21971a09d5 --- /dev/null +++ b/src/app/+item-page/edit-item-page/item-authorizations/item-authorizations.component.ts @@ -0,0 +1,46 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +import { Observable } from 'rxjs'; +import { flatMap, map } from 'rxjs/operators'; + +import { ResourcePolicyService } from '../../../core/resource-policy/resource-policy.service'; +import { PaginatedList } from '../../../core/data/paginated-list'; +import { getFirstSucceededRemoteDataPayload } from '../../../core/shared/operators'; +import { RemoteData } from '../../../core/data/remote-data'; +import { Item } from '../../../core/shared/item.model'; +import { followLink } from '../../../shared/utils/follow-link-config.model'; +import { LinkService } from '../../../core/cache/builders/link.service'; +import { Bundle } from '../../../core/shared/bundle.model'; + +@Component({ + selector: 'ds-item-authorizations', + templateUrl: './item-authorizations.component.html' +}) +/** + * Component that handles the item Authorizations + */ +export class ItemAuthorizationsComponent implements OnInit { + + private bundles$: Observable>>; + private item$: Observable; + + constructor( + private linkService: LinkService, + private resourcePolicyService: ResourcePolicyService, + private route: ActivatedRoute + ) { + } + + ngOnInit(): void { + this.item$ = this.route.data.pipe( + map((data) => data.item), + getFirstSucceededRemoteDataPayload(), + map((item: Item) => this.linkService.resolveLink(item, followLink('bundles'))) + ) as Observable; + + this.bundles$ = this.item$.pipe(flatMap((item: Item) => item.bundles)); + + } + +} diff --git a/src/app/+item-page/edit-item-page/item-status/item-status.component.ts b/src/app/+item-page/edit-item-page/item-status/item-status.component.ts index e63154918b..1be13e3a7a 100644 --- a/src/app/+item-page/edit-item-page/item-status/item-status.component.ts +++ b/src/app/+item-page/edit-item-page/item-status/item-status.component.ts @@ -68,6 +68,7 @@ export class ItemStatusComponent implements OnInit { The value is supposed to be a href for the button */ this.operations = []; + this.operations.push(new ItemOperation('authorizations', this.getCurrentUrl(item) + '/authorizations')); this.operations.push(new ItemOperation('mappedCollections', this.getCurrentUrl(item) + '/mapper')); if (item.isWithdrawn) { this.operations.push(new ItemOperation('reinstate', this.getCurrentUrl(item) + '/reinstate')); diff --git a/src/app/core/resource-policy/resource-policy.service.ts b/src/app/core/resource-policy/resource-policy.service.ts index e79f04eb6f..b9dd131fbe 100644 --- a/src/app/core/resource-policy/resource-policy.service.ts +++ b/src/app/core/resource-policy/resource-policy.service.ts @@ -106,7 +106,7 @@ export class ResourcePolicyService { * @param resourceUUID Limit the returned policies to the specified DSO * @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved */ - searchByEPerson(UUID: string, resourceUUID?: string, ...linksToFollow: Array>) { + searchByEPerson(UUID: string, resourceUUID?: string, ...linksToFollow: Array>): Observable>> { const options = new FindListOptions(); options.searchParams = [new SearchParam('uuid', UUID)]; if (isNotEmpty(resourceUUID)) { @@ -122,7 +122,7 @@ export class ResourcePolicyService { * @param resourceUUID Limit the returned policies to the specified DSO * @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved */ - searchByGroup(UUID: string, resourceUUID?: string, ...linksToFollow: Array>) { + searchByGroup(UUID: string, resourceUUID?: string, ...linksToFollow: Array>): Observable>> { const options = new FindListOptions(); options.searchParams = [new SearchParam('uuid', UUID)]; if (isNotEmpty(resourceUUID)) { @@ -138,7 +138,7 @@ export class ResourcePolicyService { * @param action Limit the returned policies to the specified {@link ActionType} * @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved */ - searchByResource(UUID: string, action?: ActionType, ...linksToFollow: Array>) { + searchByResource(UUID: string, action?: ActionType, ...linksToFollow: Array>): Observable>> { const options = new FindListOptions(); options.searchParams = [new SearchParam('uuid', UUID)]; if (isNotEmpty(action)) {