mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
78243: edit-item-page mocks, item-status operation refactoring
This commit is contained in:
@@ -3,8 +3,8 @@ import { fadeIn, fadeInOut } from '../../../shared/animations/fade';
|
||||
import { Item } from '../../../core/shared/item.model';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { ItemOperation } from '../item-operation/itemOperation.model';
|
||||
import { distinctUntilChanged, first, map } from 'rxjs/operators';
|
||||
import { BehaviorSubject, combineLatest as observableCombineLatest, Observable, of } from 'rxjs';
|
||||
import { distinctUntilChanged, first, map, mergeMap, toArray } from 'rxjs/operators';
|
||||
import { BehaviorSubject, Observable, from as observableFrom } from 'rxjs';
|
||||
import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { getItemEditRoute, getItemPageRoute } from '../../item-page-routing-paths';
|
||||
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
|
||||
@@ -95,16 +95,19 @@ export class ItemStatusComponent implements OnInit {
|
||||
|
||||
this.operations$.next(operations);
|
||||
|
||||
observableCombineLatest(operations.map((operation) => {
|
||||
if (hasValue(operation.featureID)) {
|
||||
return this.authorizationService.isAuthorized(operation.featureID, item.self).pipe(
|
||||
distinctUntilChanged(),
|
||||
map((authorized) => new ItemOperation(operation.operationKey, operation.operationUrl, operation.featureID, !authorized, authorized))
|
||||
);
|
||||
} else {
|
||||
return of(operation);
|
||||
}
|
||||
})).subscribe((ops) => this.operations$.next(ops));
|
||||
observableFrom(operations).pipe(
|
||||
mergeMap((operation) => {
|
||||
if (hasValue(operation.featureID)) {
|
||||
return this.authorizationService.isAuthorized(operation.featureID, item.self).pipe(
|
||||
distinctUntilChanged(),
|
||||
map((authorized) => new ItemOperation(operation.operationKey, operation.operationUrl, operation.featureID, !authorized, authorized))
|
||||
);
|
||||
} else {
|
||||
return [operation];
|
||||
}
|
||||
}),
|
||||
toArray()
|
||||
).subscribe((ops) => this.operations$.next(ops));
|
||||
});
|
||||
this.itemPageRoute$ = this.itemRD$.pipe(
|
||||
getAllSucceededRemoteDataPayload(),
|
||||
|
@@ -216,7 +216,7 @@ export const returnForbiddenUrlTreeOrLoginOnAllFalse = (router: Router, authServ
|
||||
(source: Observable<boolean[]>): Observable<boolean | UrlTree> =>
|
||||
observableCombineLatest(source, authService.isAuthenticated()).pipe(
|
||||
map(([authorizedList, authenticated]: [boolean[], boolean]) => {
|
||||
if (authorizedList.indexOf(true) > -1) {
|
||||
if (authorizedList.some((b: boolean) => b === true)) {
|
||||
return true;
|
||||
} else {
|
||||
if (authenticated) {
|
||||
|
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"_links": {
|
||||
"self": {
|
||||
"href": "https://api7.dspace.org/server/api/authz/authorizations/search/object?uri=https://api7.dspace.org/server/api/core/items/96715576-3748-4761-ad45-001646632963&feature=canDelete"
|
||||
}
|
||||
},
|
||||
"page": {
|
||||
"size": 20,
|
||||
"totalElements": 0,
|
||||
"totalPages": 1,
|
||||
"number": 0
|
||||
}
|
||||
}
|
@@ -2,33 +2,33 @@
|
||||
"_embedded": {
|
||||
"authorizations": [
|
||||
{
|
||||
"id": "cd824a61-95be-4e16-bccd-51fea26707d0_canMove_core.item_96715576-3748-4761-ad45-001646632963",
|
||||
"id": "cd824a61-95be-4e16-bccd-51fea26707d0_canManageMappings_core.item_e98b0f27-5c19-49a0-960d-eb6ad5287067",
|
||||
"type": "authorization",
|
||||
"_links": {
|
||||
"eperson": {
|
||||
"href": "https://api7.dspace.org/server/api/authz/authorizations/cd824a61-95be-4e16-bccd-51fea26707d0_canMove_core.item_96715576-3748-4761-ad45-001646632963/eperson"
|
||||
"href": "https://api7.dspace.org/server/api/authz/authorizations/cd824a61-95be-4e16-bccd-51fea26707d0_canManageMappings_core.item_e98b0f27-5c19-49a0-960d-eb6ad5287067/eperson"
|
||||
},
|
||||
"feature": {
|
||||
"href": "https://api7.dspace.org/server/api/authz/authorizations/cd824a61-95be-4e16-bccd-51fea26707d0_canMove_core.item_96715576-3748-4761-ad45-001646632963/feature"
|
||||
"href": "https://api7.dspace.org/server/api/authz/authorizations/cd824a61-95be-4e16-bccd-51fea26707d0_canManageMappings_core.item_e98b0f27-5c19-49a0-960d-eb6ad5287067/feature"
|
||||
},
|
||||
"object": {
|
||||
"href": "https://api7.dspace.org/server/api/authz/authorizations/cd824a61-95be-4e16-bccd-51fea26707d0_canMove_core.item_96715576-3748-4761-ad45-001646632963/object"
|
||||
"href": "https://api7.dspace.org/server/api/authz/authorizations/cd824a61-95be-4e16-bccd-51fea26707d0_canManageMappings_core.item_e98b0f27-5c19-49a0-960d-eb6ad5287067/object"
|
||||
},
|
||||
"self": {
|
||||
"href": "https://api7.dspace.org/server/api/authz/authorizations/cd824a61-95be-4e16-bccd-51fea26707d0_canMove_core.item_96715576-3748-4761-ad45-001646632963"
|
||||
"href": "https://api7.dspace.org/server/api/authz/authorizations/cd824a61-95be-4e16-bccd-51fea26707d0_canManageMappings_core.item_e98b0f27-5c19-49a0-960d-eb6ad5287067"
|
||||
}
|
||||
},
|
||||
"_embedded": {
|
||||
"feature": {
|
||||
"id": "canMove",
|
||||
"description": "It can be used to verify if the user is allowed to move items",
|
||||
"id": "canManageMappings",
|
||||
"description": "It can be used to verify if the mappings of the specified objects can be managed",
|
||||
"type": "feature",
|
||||
"resourcetypes": [
|
||||
"core.item"
|
||||
],
|
||||
"_links": {
|
||||
"self": {
|
||||
"href": "https://api7.dspace.org/server/api/authz/features/canMove"
|
||||
"href": "https://api7.dspace.org/server/api/authz/features/canManageMappings"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,7 @@
|
||||
},
|
||||
"_links": {
|
||||
"self": {
|
||||
"href": "https://api7.dspace.org/server/api/authz/authorizations/search/object?uri=https://api7.dspace.org/server/api/core/items/96715576-3748-4761-ad45-001646632963&feature=canMove"
|
||||
"href": "https://api7.dspace.org/server/api/authz/authorizations/search/object?uri=https://api7.dspace.org/server/api/core/items/e98b0f27-5c19-49a0-960d-eb6ad5287067&feature=canManageMappings"
|
||||
}
|
||||
},
|
||||
"page": {
|
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"_embedded": {
|
||||
"authorizations": [
|
||||
{
|
||||
"id": "cd824a61-95be-4e16-bccd-51fea26707d0_canManageRelationships_core.item_047556d1-3d01-4c53-bc68-0cee7ad7ed4e",
|
||||
"type": "authorization",
|
||||
"_links": {
|
||||
"eperson": {
|
||||
"href": "https://api7.dspace.org/server/api/authz/authorizations/cd824a61-95be-4e16-bccd-51fea26707d0_canManageRelationships_core.item_047556d1-3d01-4c53-bc68-0cee7ad7ed4e/eperson"
|
||||
},
|
||||
"feature": {
|
||||
"href": "https://api7.dspace.org/server/api/authz/authorizations/cd824a61-95be-4e16-bccd-51fea26707d0_canManageRelationships_core.item_047556d1-3d01-4c53-bc68-0cee7ad7ed4e/feature"
|
||||
},
|
||||
"object": {
|
||||
"href": "https://api7.dspace.org/server/api/authz/authorizations/cd824a61-95be-4e16-bccd-51fea26707d0_canManageRelationships_core.item_047556d1-3d01-4c53-bc68-0cee7ad7ed4e/object"
|
||||
},
|
||||
"self": {
|
||||
"href": "https://api7.dspace.org/server/api/authz/authorizations/cd824a61-95be-4e16-bccd-51fea26707d0_canManageRelationships_core.item_047556d1-3d01-4c53-bc68-0cee7ad7ed4e"
|
||||
}
|
||||
},
|
||||
"_embedded": {
|
||||
"feature": {
|
||||
"id": "canManageRelationships",
|
||||
"description": "It can be used to verify if the relationships of the specified objects can be managed",
|
||||
"type": "feature",
|
||||
"resourcetypes": [
|
||||
"core.item"
|
||||
],
|
||||
"_links": {
|
||||
"self": {
|
||||
"href": "https://api7.dspace.org/server/api/authz/features/canManageRelationships"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"_links": {
|
||||
"self": {
|
||||
"href": "https://api7.dspace.org/server/api/authz/authorizations/search/object?uri=https://api7.dspace.org/server/api/core/items/047556d1-3d01-4c53-bc68-0cee7ad7ed4e&feature=canManageRelationships"
|
||||
}
|
||||
},
|
||||
"page": {
|
||||
"size": 20,
|
||||
"totalElements": 1,
|
||||
"totalPages": 1,
|
||||
"number": 0
|
||||
}
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"_embedded": {
|
||||
"authorizations": [
|
||||
{
|
||||
"id": "cd824a61-95be-4e16-bccd-51fea26707d0_canManageVersions_core.item_e98b0f27-5c19-49a0-960d-eb6ad5287067",
|
||||
"type": "authorization",
|
||||
"_links": {
|
||||
"eperson": {
|
||||
"href": "https://api7.dspace.org/server/api/authz/authorizations/cd824a61-95be-4e16-bccd-51fea26707d0_canManageVersions_core.item_e98b0f27-5c19-49a0-960d-eb6ad5287067/eperson"
|
||||
},
|
||||
"feature": {
|
||||
"href": "https://api7.dspace.org/server/api/authz/authorizations/cd824a61-95be-4e16-bccd-51fea26707d0_canManageVersions_core.item_e98b0f27-5c19-49a0-960d-eb6ad5287067/feature"
|
||||
},
|
||||
"object": {
|
||||
"href": "https://api7.dspace.org/server/api/authz/authorizations/cd824a61-95be-4e16-bccd-51fea26707d0_canManageVersions_core.item_e98b0f27-5c19-49a0-960d-eb6ad5287067/object"
|
||||
},
|
||||
"self": {
|
||||
"href": "https://api7.dspace.org/server/api/authz/authorizations/cd824a61-95be-4e16-bccd-51fea26707d0_canManageVersions_core.item_e98b0f27-5c19-49a0-960d-eb6ad5287067"
|
||||
}
|
||||
},
|
||||
"_embedded": {
|
||||
"feature": {
|
||||
"id": "canManageVersions",
|
||||
"description": "It can be used to verify if the versions of the specified objects can be managed",
|
||||
"type": "feature",
|
||||
"resourcetypes": [
|
||||
"core.item"
|
||||
],
|
||||
"_links": {
|
||||
"self": {
|
||||
"href": "https://api7.dspace.org/server/api/authz/features/canManageVersions"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"_links": {
|
||||
"self": {
|
||||
"href": "https://api7.dspace.org/server/api/authz/authorizations/search/object?uri=https://api7.dspace.org/server/api/core/items/e98b0f27-5c19-49a0-960d-eb6ad5287067&feature=canManageVersions"
|
||||
}
|
||||
},
|
||||
"page": {
|
||||
"size": 20,
|
||||
"totalElements": 1,
|
||||
"totalPages": 1,
|
||||
"number": 0
|
||||
}
|
||||
}
|
@@ -3,8 +3,9 @@ import { InjectionToken } from '@angular/core';
|
||||
// import mockPublicationResponse from './mock-publication-response.json';
|
||||
// import mockUntypedItemResponse from './mock-untyped-item-response.json';
|
||||
import mockFeatureItemCanManageBitstreamsResponse from './mock-feature-item-can-manage-bitstreams-response.json';
|
||||
import mockFeatureItemCanMoveResponse from './mock-feature-item-can-move-response.json';
|
||||
import mockFeatureItemCanDeleteNoneResponse from './mock-feature-item-can-delete-none-response.json';
|
||||
import mockFeatureItemCanManageRelationshipsResponse from './mock-feature-item-can-manage-relationships-response.json';
|
||||
import mockFeatureItemCanManageVersionsResponse from './mock-feature-item-can-manage-versions-response.json';
|
||||
import mockFeatureItemCanManageMappingsResponse from './mock-feature-item-can-manage-mappings-response.json';
|
||||
|
||||
export class ResponseMapMock extends Map<string, any> {}
|
||||
|
||||
@@ -20,6 +21,7 @@ export const mockResponseMap: ResponseMapMock = new Map([
|
||||
// [ '/api/pid/find', mockPublicationResponse ],
|
||||
// [ '/api/pid/find', mockUntypedItemResponse ],
|
||||
[ 'https://api7.dspace.org/server/api/authz/authorizations/search/object?uri=https://api7.dspace.org/server/api/core/items/96715576-3748-4761-ad45-001646632963&feature=canManageBitstreams&embed=feature', mockFeatureItemCanManageBitstreamsResponse ],
|
||||
[ 'https://api7.dspace.org/server/api/authz/authorizations/search/object?uri=https://api7.dspace.org/server/api/core/items/96715576-3748-4761-ad45-001646632963&feature=canMove&embed=feature', mockFeatureItemCanMoveResponse ],
|
||||
[ 'https://api7.dspace.org/server/api/authz/authorizations/search/object?uri=https://api7.dspace.org/server/api/core/items/96715576-3748-4761-ad45-001646632963&feature=canDelete&embed=feature', mockFeatureItemCanDeleteNoneResponse ],
|
||||
[ 'https://api7.dspace.org/server/api/authz/authorizations/search/object?uri=https://api7.dspace.org/server/api/core/items/047556d1-3d01-4c53-bc68-0cee7ad7ed4e&feature=canManageRelationships&embed=feature', mockFeatureItemCanManageRelationshipsResponse ],
|
||||
[ 'https://api7.dspace.org/server/api/authz/authorizations/search/object?uri=https://api7.dspace.org/server/api/core/items/e98b0f27-5c19-49a0-960d-eb6ad5287067&feature=canManageVersions&embed=feature', mockFeatureItemCanManageVersionsResponse ],
|
||||
[ 'https://api7.dspace.org/server/api/authz/authorizations/search/object?uri=https://api7.dspace.org/server/api/core/items/e98b0f27-5c19-49a0-960d-eb6ad5287067&feature=canManageMappings&embed=feature', mockFeatureItemCanManageMappingsResponse ],
|
||||
]);
|
||||
|
@@ -1761,7 +1761,7 @@
|
||||
|
||||
"item.edit.tabs.status.buttons.reinstate.label": "Reinstate item into the repository",
|
||||
|
||||
"item.edit.tabs.status.buttons.unauthorized": "You don't have permission to perform this action",
|
||||
"item.edit.tabs.status.buttons.unauthorized": "You're not authorized to perform this action",
|
||||
|
||||
"item.edit.tabs.status.buttons.withdraw.button": "Withdraw...",
|
||||
|
||||
|
Reference in New Issue
Block a user