Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ACA-4556] Copy/Move button is now disabled on the My Libraries Page in Copy/Move dialog #10402

Merged
merged 4 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading