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);
|
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,', () => {
|
describe('in the case when isSelectionValid is a custom function for checking permissions,', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
component.isSelectionValid = returnHasPermission;
|
component.isSelectionValid = returnHasPermission;
|
||||||
|
@@ -15,17 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import { Component, DestroyRef, EventEmitter, inject, Input, OnInit, Output, ViewChild, ViewEncapsulation } from '@angular/core';
|
||||||
Component,
|
|
||||||
DestroyRef,
|
|
||||||
EventEmitter,
|
|
||||||
inject,
|
|
||||||
Input,
|
|
||||||
OnInit,
|
|
||||||
Output,
|
|
||||||
ViewChild,
|
|
||||||
ViewEncapsulation
|
|
||||||
} from '@angular/core';
|
|
||||||
import {
|
import {
|
||||||
CustomEmptyContentTemplateDirective,
|
CustomEmptyContentTemplateDirective,
|
||||||
DataColumnComponent,
|
DataColumnComponent,
|
||||||
@@ -40,24 +30,9 @@ import {
|
|||||||
UserPreferencesService,
|
UserPreferencesService,
|
||||||
UserPreferenceValues
|
UserPreferenceValues
|
||||||
} from '@alfresco/adf-core';
|
} from '@alfresco/adf-core';
|
||||||
import {
|
import { FileUploadCompleteEvent, FileUploadDeleteEvent, NodesApiService, SitesService, UploadService } from '../../common';
|
||||||
FileUploadCompleteEvent,
|
|
||||||
FileUploadDeleteEvent,
|
|
||||||
NodesApiService,
|
|
||||||
SitesService,
|
|
||||||
UploadService
|
|
||||||
} from '../../common';
|
|
||||||
import { ReactiveFormsModule, UntypedFormControl } from '@angular/forms';
|
import { ReactiveFormsModule, UntypedFormControl } from '@angular/forms';
|
||||||
import {
|
import { Node, NodeEntry, NodePaging, Pagination, RequestScope, SearchRequest, SiteEntry, SitePaging } from '@alfresco/js-api';
|
||||||
Node,
|
|
||||||
NodeEntry,
|
|
||||||
NodePaging,
|
|
||||||
Pagination,
|
|
||||||
RequestScope,
|
|
||||||
SearchRequest,
|
|
||||||
SiteEntry,
|
|
||||||
SitePaging
|
|
||||||
} from '@alfresco/js-api';
|
|
||||||
import { DocumentListComponent } from '../../document-list/components/document-list.component';
|
import { DocumentListComponent } from '../../document-list/components/document-list.component';
|
||||||
import { RowFilter } from '../../document-list/data/row-filter.model';
|
import { RowFilter } from '../../document-list/data/row-filter.model';
|
||||||
import { ImageResolver } from '../../document-list/data/image-resolver.model';
|
import { ImageResolver } from '../../document-list/data/image-resolver.model';
|
||||||
@@ -124,6 +99,8 @@ export class ContentNodeSelectorPanelComponent implements OnInit {
|
|||||||
skipCount: 0
|
skipCount: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
|
readonly disableActionFolderList = ['-mysites-'];
|
||||||
|
|
||||||
private showSiteList = true;
|
private showSiteList = true;
|
||||||
private showSearchField = true;
|
private showSearchField = true;
|
||||||
private showCounter = false;
|
private showCounter = false;
|
||||||
@@ -358,11 +335,13 @@ export class ContentNodeSelectorPanelComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.searchInput.valueChanges.pipe(debounceTime(this.debounceSearch), takeUntilDestroyed(this.destroyRef)).subscribe((searchValue: string) => {
|
this.searchInput.valueChanges
|
||||||
this.searchTerm = searchValue;
|
.pipe(debounceTime(this.debounceSearch), takeUntilDestroyed(this.destroyRef))
|
||||||
this.queryBuilderService.userQuery = searchValue.length > 0 ? `${searchValue}*` : searchValue;
|
.subscribe((searchValue: string) => {
|
||||||
this.queryBuilderService.update();
|
this.searchTerm = searchValue;
|
||||||
});
|
this.queryBuilderService.userQuery = searchValue.length > 0 ? `${searchValue}*` : searchValue;
|
||||||
|
this.queryBuilderService.update();
|
||||||
|
});
|
||||||
|
|
||||||
this.queryBuilderService.updated.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((searchRequest) => {
|
this.queryBuilderService.updated.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((searchRequest) => {
|
||||||
if (searchRequest) {
|
if (searchRequest) {
|
||||||
@@ -461,7 +440,7 @@ export class ContentNodeSelectorPanelComponent implements OnInit {
|
|||||||
|
|
||||||
private isExcludedSiteContent(row: ShareDataRow): boolean {
|
private isExcludedSiteContent(row: ShareDataRow): boolean {
|
||||||
const entry = row.node.entry;
|
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);
|
const excludedItem = this._excludeSiteContent.find((id: string) => entry.properties['st:componentId'] === id);
|
||||||
return !!excludedItem;
|
return !!excludedItem;
|
||||||
}
|
}
|
||||||
@@ -655,11 +634,15 @@ export class ContentNodeSelectorPanelComponent implements OnInit {
|
|||||||
* @param entry node entry
|
* @param entry node entry
|
||||||
*/
|
*/
|
||||||
private attemptNodeSelection(entry: Node): void {
|
private attemptNodeSelection(entry: Node): void {
|
||||||
if (entry && this.isSelectionValid(entry)) {
|
if (entry && this.isSelectionValid(entry) && !this.isActionDisabledForFolder(this.documentList.currentFolderId)) {
|
||||||
this.chosenNode = [entry];
|
this.chosenNode = [entry];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private isActionDisabledForFolder(folderId: string): boolean {
|
||||||
|
return this.disableActionFolderList.includes(folderId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears the chosen node
|
* Clears the chosen node
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user