From 3f1146bc491382e96a4304224d63d50722fb7573 Mon Sep 17 00:00:00 2001 From: Alisa Ismailati Date: Thu, 10 Aug 2023 15:32:29 +0200 Subject: [PATCH 1/5] [DSC-1184] fixed showing menu actions --- .../context-menu/item-version/item-version-menu.component.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/app/shared/context-menu/item-version/item-version-menu.component.ts b/src/app/shared/context-menu/item-version/item-version-menu.component.ts index 8d141f0cf83..f3563069f18 100644 --- a/src/app/shared/context-menu/item-version/item-version-menu.component.ts +++ b/src/app/shared/context-menu/item-version/item-version-menu.component.ts @@ -1,7 +1,6 @@ import { Component, Inject, OnInit } from '@angular/core'; import { BehaviorSubject, combineLatest } from 'rxjs'; -import { take } from 'rxjs/operators'; import { DSpaceObjectType } from '../../../core/shared/dspace-object-type.model'; import { DSpaceObject } from '../../../core/shared/dspace-object.model'; @@ -59,9 +58,7 @@ export class ItemVersionMenuComponent extends ContextMenuEntryComponent implemen const isAuthorized$ = this.authorizationService.isAuthorized(FeatureID.CanCreateVersion, this.contextMenuObject.self); const isDisabled$ = this.versioningModalService.isNewVersionButtonDisabled(this.contextMenuObject); - combineLatest([isAuthorized$, isDisabled$]).pipe( - take(1) - ).subscribe(([isAuthorized, isDisabled]) => { + combineLatest([isAuthorized$, isDisabled$]).subscribe(([isAuthorized, isDisabled]) => { this.canShow$.next(isAuthorized && !isDisabled); }); From 57e4056801166f0fac155928cc3cf80851b584df Mon Sep 17 00:00:00 2001 From: Alisa Ismailati Date: Thu, 10 Aug 2023 16:38:33 +0200 Subject: [PATCH 2/5] [DSC-1184] improvement --- .../item-version/item-version-menu.component.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/app/shared/context-menu/item-version/item-version-menu.component.ts b/src/app/shared/context-menu/item-version/item-version-menu.component.ts index f3563069f18..406c2e4cca5 100644 --- a/src/app/shared/context-menu/item-version/item-version-menu.component.ts +++ b/src/app/shared/context-menu/item-version/item-version-menu.component.ts @@ -1,6 +1,6 @@ import { Component, Inject, OnInit } from '@angular/core'; -import { BehaviorSubject, combineLatest } from 'rxjs'; +import { BehaviorSubject, combineLatest, distinctUntilChanged } from 'rxjs'; import { DSpaceObjectType } from '../../../core/shared/dspace-object-type.model'; import { DSpaceObject } from '../../../core/shared/dspace-object.model'; @@ -58,10 +58,12 @@ export class ItemVersionMenuComponent extends ContextMenuEntryComponent implemen const isAuthorized$ = this.authorizationService.isAuthorized(FeatureID.CanCreateVersion, this.contextMenuObject.self); const isDisabled$ = this.versioningModalService.isNewVersionButtonDisabled(this.contextMenuObject); - combineLatest([isAuthorized$, isDisabled$]).subscribe(([isAuthorized, isDisabled]) => { + combineLatest([isAuthorized$, isDisabled$]) + .pipe( + distinctUntilChanged(), + ).subscribe(([isAuthorized, isDisabled]) => { this.canShow$.next(isAuthorized && !isDisabled); }); - } /** From 6fe24e2a2bfc059482dacf1824688b61a72c4e3d Mon Sep 17 00:00:00 2001 From: Vincenzo Mecca Date: Tue, 24 Oct 2023 18:30:08 +0200 Subject: [PATCH 3/5] [DSC-1184] Forces to always fetch edit-modes --- .../shared/context-menu/edit-item/edit-item-menu.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/shared/context-menu/edit-item/edit-item-menu.component.ts b/src/app/shared/context-menu/edit-item/edit-item-menu.component.ts index 824fddc3db2..5383d16f971 100644 --- a/src/app/shared/context-menu/edit-item/edit-item-menu.component.ts +++ b/src/app/shared/context-menu/edit-item/edit-item-menu.component.ts @@ -101,7 +101,7 @@ export class EditItemMenuComponent extends ContextMenuEntryComponent implements } } getData(): void { - this.sub = this.editItemService.searchEditModesById(this.contextMenuObject.id).pipe( + this.sub = this.editItemService.searchEditModesById(this.contextMenuObject.id, false).pipe( getAllSucceededRemoteDataPayload(), getPaginatedListPayload(), startWith([]) From e799e7883f6365e0f2c316a082afd40b9f255e3a Mon Sep 17 00:00:00 2001 From: Vincenzo Mecca Date: Wed, 25 Oct 2023 13:04:25 +0200 Subject: [PATCH 4/5] [DSC-1184] Improvements to invalidate editmodes cache --- src/app/core/data/version-history-data.service.ts | 7 ++++++- .../edit-item/edit-item-menu.component.ts | 2 +- .../dso-versioning-modal.service.ts | 11 ++++++----- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/app/core/data/version-history-data.service.ts b/src/app/core/data/version-history-data.service.ts index 659feb9276d..f968b9e61da 100644 --- a/src/app/core/data/version-history-data.service.ts +++ b/src/app/core/data/version-history-data.service.ts @@ -16,7 +16,12 @@ import { VERSION_HISTORY } from '../shared/version-history.resource-type'; import { followLink, FollowLinkConfig } from '../../shared/utils/follow-link-config.model'; import { VersionDataService } from './version-data.service'; import { HttpOptions } from '../dspace-rest/dspace-rest.service'; -import { getAllSucceededRemoteData, getFirstCompletedRemoteData, getFirstSucceededRemoteDataPayload, getRemoteDataPayload } from '../shared/operators'; +import { + getAllSucceededRemoteData, + getFirstCompletedRemoteData, + getFirstSucceededRemoteDataPayload, + getRemoteDataPayload +} from '../shared/operators'; import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model'; import { hasValueOperator } from '../../shared/empty.util'; import { Item } from '../shared/item.model'; diff --git a/src/app/shared/context-menu/edit-item/edit-item-menu.component.ts b/src/app/shared/context-menu/edit-item/edit-item-menu.component.ts index 5383d16f971..824fddc3db2 100644 --- a/src/app/shared/context-menu/edit-item/edit-item-menu.component.ts +++ b/src/app/shared/context-menu/edit-item/edit-item-menu.component.ts @@ -101,7 +101,7 @@ export class EditItemMenuComponent extends ContextMenuEntryComponent implements } } getData(): void { - this.sub = this.editItemService.searchEditModesById(this.contextMenuObject.id, false).pipe( + this.sub = this.editItemService.searchEditModesById(this.contextMenuObject.id).pipe( getAllSucceededRemoteDataPayload(), getPaginatedListPayload(), startWith([]) diff --git a/src/app/shared/dso-page/dso-versioning-modal-service/dso-versioning-modal.service.ts b/src/app/shared/dso-page/dso-versioning-modal-service/dso-versioning-modal.service.ts index 46792294dd8..e66a6f5e146 100644 --- a/src/app/shared/dso-page/dso-versioning-modal-service/dso-versioning-modal.service.ts +++ b/src/app/shared/dso-page/dso-versioning-modal-service/dso-versioning-modal.service.ts @@ -16,6 +16,8 @@ import { ItemVersionsSharedService } from '../../../item-page/versions/item-vers import { ItemVersionsSummaryModalComponent } from '../../../item-page/versions/item-versions-summary-modal/item-versions-summary-modal.component'; +import { EditItemDataService } from '../../../core/submission/edititem-data.service'; +import { fromPromise } from 'rxjs/internal/observable/innerFrom'; /** * Service to take care of all the functionality related to the version creation modal @@ -34,6 +36,7 @@ export class DsoVersioningModalService { protected router: Router, protected workspaceItemDataService: WorkspaceitemDataService, protected itemService: ItemDataService, + protected editItemService: EditItemDataService, ) { } @@ -71,11 +74,9 @@ export class DsoVersioningModalService { getFirstSucceededRemoteDataPayload(), switchMap((newVersionItem: Item) => this.workspaceItemDataService.findByItem(newVersionItem.uuid, true, false)), getFirstSucceededRemoteDataPayload(), - ).subscribe((wsItem) => { - const wsiId = wsItem.id; - const route = 'workspaceitems/' + wsiId + '/edit'; - this.router.navigateByUrl(route); - }); + map((wsItem: WorkspaceItem) => `workspaceitems/${wsItem?.id}/edit`), + switchMap((route: string) => fromPromise(this.router.navigateByUrl(route))), + ).subscribe(() => this.editItemService.invalidateItemCache(item.uuid)); } /** From 6e055043d04c932cab0de2fd8b853757c2e0e414 Mon Sep 17 00:00:00 2001 From: Vincenzo Mecca Date: Wed, 25 Oct 2023 14:38:36 +0200 Subject: [PATCH 5/5] [DSC-1184] Fixes tests --- .../dso-versioning-modal.service.spec.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/app/shared/dso-page/dso-versioning-modal-service/dso-versioning-modal.service.spec.ts b/src/app/shared/dso-page/dso-versioning-modal-service/dso-versioning-modal.service.spec.ts index fc5c1dafc97..a8db842070e 100644 --- a/src/app/shared/dso-page/dso-versioning-modal-service/dso-versioning-modal.service.spec.ts +++ b/src/app/shared/dso-page/dso-versioning-modal-service/dso-versioning-modal.service.spec.ts @@ -18,6 +18,7 @@ describe('DsoVersioningModalService', () => { let router; let workspaceItemDataService; let itemService; + let editItemService; const mockItem: Item = Object.assign(new Item(), { bundles: createSuccessfulRemoteDataObject$(buildPaginatedList(new PageInfo(), [])), @@ -48,6 +49,7 @@ describe('DsoVersioningModalService', () => { router = jasmine.createSpyObj('router', ['navigateByUrl']); workspaceItemDataService = jasmine.createSpyObj('workspaceItemDataService', ['findByItem']); itemService = jasmine.createSpyObj('itemService', ['findByHref']); + editItemService = jasmine.createSpyObj('editItemService', ['invalidateItemCache']); service = new DsoVersioningModalService( modalService, @@ -56,7 +58,8 @@ describe('DsoVersioningModalService', () => { itemVersionShared, router, workspaceItemDataService, - itemService + itemService, + editItemService, ); })); describe('when onCreateNewVersion() is called', () => {