Skip to content

Commit

Permalink
[ACA-4556] Copy/Move button is now disabled on the My Libraries Page …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
swapnil-verma-gl authored Dec 6, 2024
1 parent e6c2152 commit 9faea5c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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';
Expand Down Expand Up @@ -124,6 +99,8 @@ export class ContentNodeSelectorPanelComponent implements OnInit {
skipCount: 0
});

readonly disableActionFolderList = ['-mysites-'];

private showSiteList = true;
private showSearchField = true;
private showCounter = false;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
*/
Expand Down

0 comments on commit 9faea5c

Please sign in to comment.