mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[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
This commit is contained in:
@@ -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;
|
||||
|
@@ -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
|
||||
*/
|
||||
|
Reference in New Issue
Block a user