From 9faea5c1e7980dd99b39ec6225f1db6d379633f9 Mon Sep 17 00:00:00 2001 From: swapnil-verma-gl <92505353+swapnil-verma-gl@users.noreply.github.com> Date: Fri, 6 Dec 2024 14:15:03 +0530 Subject: [PATCH] [ACA-4556] Copy/Move button is now disabled on the My Libraries Page in Copy/Move dialog (#10402) * [ACA-4556] Copy/Move button is now disabled on the My Libraries Page in Copy/Move dialog * [ACA-4556] Fix linting issue * [ACA-4556] Added unit test * [AC-4556] Addressed code review findings --- ...tent-node-selector-panel.component.spec.ts | 13 +++++ .../content-node-selector-panel.component.ts | 53 +++++++------------ 2 files changed, 31 insertions(+), 35 deletions(-) diff --git a/lib/content-services/src/lib/content-node-selector/content-node-selector-panel/content-node-selector-panel.component.spec.ts b/lib/content-services/src/lib/content-node-selector/content-node-selector-panel/content-node-selector-panel.component.spec.ts index b5b81badd2..a533f9c7c2 100644 --- a/lib/content-services/src/lib/content-node-selector/content-node-selector-panel/content-node-selector-panel.component.spec.ts +++ b/lib/content-services/src/lib/content-node-selector/content-node-selector-panel/content-node-selector-panel.component.spec.ts @@ -437,6 +437,19 @@ describe('ContentNodeSelectorPanelComponent', () => { expect(fakeNodePage.list.pagination.hasMoreItems).toBe(false); }); + it('should not update chosen node if currently selected location is within the DISABLE_ACTION_FOLDER_LIST property', () => { + const fakeNode = new Node({ + id: 'fake-node', + path: { elements: [{ nodeType: 'st:site', name: 'fake-site' }] } + }); + component.chosenNode = [fakeNode]; + component.documentList.currentFolderId = '-mysites-'; + component.documentList.folderNode = fakeFolderNode; + component.onFolderLoaded(nodePage); + expect(component.chosenNode).not.toEqual([fakeFolderNode]); + expect(component.chosenNode).toEqual([fakeNode]); + }); + describe('in the case when isSelectionValid is a custom function for checking permissions,', () => { beforeEach(() => { component.isSelectionValid = returnHasPermission; diff --git a/lib/content-services/src/lib/content-node-selector/content-node-selector-panel/content-node-selector-panel.component.ts b/lib/content-services/src/lib/content-node-selector/content-node-selector-panel/content-node-selector-panel.component.ts index 1dbe2d7949..c515c77b32 100644 --- a/lib/content-services/src/lib/content-node-selector/content-node-selector-panel/content-node-selector-panel.component.ts +++ b/lib/content-services/src/lib/content-node-selector/content-node-selector-panel/content-node-selector-panel.component.ts @@ -15,17 +15,7 @@ * limitations under the License. */ -import { - Component, - DestroyRef, - EventEmitter, - inject, - Input, - OnInit, - Output, - ViewChild, - ViewEncapsulation -} from '@angular/core'; +import { Component, DestroyRef, EventEmitter, inject, Input, OnInit, Output, ViewChild, ViewEncapsulation } from '@angular/core'; import { CustomEmptyContentTemplateDirective, DataColumnComponent, @@ -40,24 +30,9 @@ import { UserPreferencesService, UserPreferenceValues } from '@alfresco/adf-core'; -import { - FileUploadCompleteEvent, - FileUploadDeleteEvent, - NodesApiService, - SitesService, - UploadService -} from '../../common'; +import { FileUploadCompleteEvent, FileUploadDeleteEvent, NodesApiService, SitesService, UploadService } from '../../common'; import { ReactiveFormsModule, UntypedFormControl } from '@angular/forms'; -import { - Node, - NodeEntry, - NodePaging, - Pagination, - RequestScope, - SearchRequest, - SiteEntry, - SitePaging -} from '@alfresco/js-api'; +import { Node, NodeEntry, NodePaging, Pagination, RequestScope, SearchRequest, SiteEntry, SitePaging } from '@alfresco/js-api'; import { DocumentListComponent } from '../../document-list/components/document-list.component'; import { RowFilter } from '../../document-list/data/row-filter.model'; import { ImageResolver } from '../../document-list/data/image-resolver.model'; @@ -124,6 +99,8 @@ export class ContentNodeSelectorPanelComponent implements OnInit { skipCount: 0 }); + readonly disableActionFolderList = ['-mysites-']; + private showSiteList = true; private showSearchField = true; private showCounter = false; @@ -358,11 +335,13 @@ export class ContentNodeSelectorPanelComponent implements OnInit { } ngOnInit() { - this.searchInput.valueChanges.pipe(debounceTime(this.debounceSearch), takeUntilDestroyed(this.destroyRef)).subscribe((searchValue: string) => { - this.searchTerm = searchValue; - this.queryBuilderService.userQuery = searchValue.length > 0 ? `${searchValue}*` : searchValue; - this.queryBuilderService.update(); - }); + this.searchInput.valueChanges + .pipe(debounceTime(this.debounceSearch), takeUntilDestroyed(this.destroyRef)) + .subscribe((searchValue: string) => { + this.searchTerm = searchValue; + this.queryBuilderService.userQuery = searchValue.length > 0 ? `${searchValue}*` : searchValue; + this.queryBuilderService.update(); + }); this.queryBuilderService.updated.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((searchRequest) => { if (searchRequest) { @@ -461,7 +440,7 @@ export class ContentNodeSelectorPanelComponent implements OnInit { private isExcludedSiteContent(row: ShareDataRow): boolean { const entry = row.node.entry; - if (this._excludeSiteContent?.length && entry && entry.properties?.['st:componentId']) { + if (this._excludeSiteContent?.length && entry?.properties?.['st:componentId']) { const excludedItem = this._excludeSiteContent.find((id: string) => entry.properties['st:componentId'] === id); return !!excludedItem; } @@ -655,11 +634,15 @@ export class ContentNodeSelectorPanelComponent implements OnInit { * @param entry node entry */ private attemptNodeSelection(entry: Node): void { - if (entry && this.isSelectionValid(entry)) { + if (entry && this.isSelectionValid(entry) && !this.isActionDisabledForFolder(this.documentList.currentFolderId)) { this.chosenNode = [entry]; } } + private isActionDisabledForFolder(folderId: string): boolean { + return this.disableActionFolderList.includes(folderId); + } + /** * Clears the chosen node */