From 697487328898340e3a04384d86812e5db0dc3bd0 Mon Sep 17 00:00:00 2001 From: Maurizio Vitale Date: Tue, 9 Mar 2021 19:13:07 +0000 Subject: [PATCH] Revert "[ADF-5354] Content node selector is not working properly for read-only folders (#6777)" (#6801) This reverts commit e21b777a3ca28f8a9f0ce9c4741bb5a97d6e5fe0. --- ...tent-node-selector-panel.component.spec.ts | 15 ----------- .../content-node-selector-panel.component.ts | 8 +----- .../content-node-selector.component.spec.ts | 25 +++---------------- .../content-node-selector.component.ts | 2 +- 4 files changed, 5 insertions(+), 45 deletions(-) diff --git a/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.spec.ts b/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.spec.ts index 7e52439897..3c90d74ae9 100644 --- a/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.spec.ts +++ b/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.spec.ts @@ -328,21 +328,6 @@ describe('ContentNodeSelectorPanelComponent', () => { done(); }); }); - - it('should show the breadcrumb for the selected node event if selection is not valid', async () => { - const chosenNode = new Node({ path: { elements: [{ id: 'testId', name: 'testName' }] } }); - component.isSelectionValid = () => false; - searchQueryBuilderService.userQuery = 'mock-search-term'; - searchQueryBuilderService.update(); - triggerSearchResults(fakeResultSetPaging); - - component.onCurrentSelection([ { entry: chosenNode } ]); - fixture.detectChanges(); - const breadcrumb = fixture.debugElement.query(By.directive(DropdownBreadcrumbComponent)); - - expect(breadcrumb.componentInstance.route[0].name).toBe('testName'); - expect(breadcrumb.componentInstance.route[0].id).toBe('testId'); - }); }); describe('Site selection', () => { diff --git a/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.ts b/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.ts index 1ba9877c49..18e33ef8df 100644 --- a/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.ts +++ b/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.ts @@ -77,7 +77,6 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy { private showSiteList = true; private showSearchField = true; - private breadcrumbFolderNodeFallback: Node ; /** If true will restrict the search and breadcrumbs to the currentFolderId */ @Input() @@ -446,7 +445,7 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy { let folderNode: Node; if (this.showingSearchResults && this.chosenNode) { - folderNode = this.chosenNode[0] || this.breadcrumbFolderNodeFallback; + folderNode = this.chosenNode[0]; } else { folderNode = this.documentList.folderNode; } @@ -466,7 +465,6 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy { this.loadingSearchResults = true; this.addCorrespondingNodeIdsQuery(); this.resetChosenNode(); - this.breadcrumbFolderNodeFallback = null ; } /** @@ -608,12 +606,8 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy { * @param nodesEntries */ onCurrentSelection(nodesEntries: NodeEntry[]): void { - this.breadcrumbFolderNodeFallback = null; const validNodesEntity = nodesEntries.filter((node) => this.isSelectionValid(node.entry)); this.chosenNode = validNodesEntity.map((node) => node.entry); - if (!this.chosenNode.length) { - this.breadcrumbFolderNodeFallback = nodesEntries[0].entry; - } } setTitleIfCustomSite(site: SiteEntry) { diff --git a/lib/content-services/src/lib/content-node-selector/content-node-selector.component.spec.ts b/lib/content-services/src/lib/content-node-selector/content-node-selector.component.spec.ts index 8427986f5e..bf809d86eb 100644 --- a/lib/content-services/src/lib/content-node-selector/content-node-selector.component.spec.ts +++ b/lib/content-services/src/lib/content-node-selector/content-node-selector.component.spec.ts @@ -21,7 +21,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ContentNodeSelectorComponent } from './content-node-selector.component'; import { Node, NodeEntry } from '@alfresco/js-api'; import { By } from '@angular/platform-browser'; -import { SitesService, ContentService, AllowableOperationsEnum } from '@alfresco/adf-core'; +import { SitesService, ContentService } from '@alfresco/adf-core'; import { of } from 'rxjs'; import { ContentTestingModule } from '../testing/content.testing.module'; import { DocumentListService } from '../document-list/services/document-list.service'; @@ -79,6 +79,7 @@ describe('ContentNodeSelectorComponent', () => { fixture = TestBed.createComponent(ContentNodeSelectorComponent); component = fixture.componentInstance; const contentService = TestBed.inject(ContentService); + spyOn(contentService, 'hasAllowableOperations').and.returnValue(true); const fakeFolderNodeWithPermission = new NodeEntry({ entry: { @@ -95,6 +96,7 @@ describe('ContentNodeSelectorComponent', () => { spyOn(contentService, 'getNode').and.returnValue(of(fakeFolderNodeWithPermission)); component.data.showLocalUploadButton = true; + component.hasAllowableOperations = true; component.showingSearch = false; fixture.detectChanges(); }); @@ -224,27 +226,6 @@ describe('ContentNodeSelectorComponent', () => { }); }); - describe('Action button for current folder', () => { - it('should be disabled when current folder does not allow upload', () => { - const node = new Node({ id: 'fake'}); - component.onCurrentFolder(node); - fixture.detectChanges(); - - const actionButtonWithoutNodeSelected = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-actions-choose"]')); - expect(actionButtonWithoutNodeSelected.nativeElement.disabled).toBe(true); - }); - - it('should be enabled when current folder allows upload', () => { - const node = new Node({ id: 'fake', allowableOperations: [AllowableOperationsEnum.CREATE] }); - component.onCurrentFolder(node); - component.chosenNode = [node]; - fixture.detectChanges(); - - const actionButtonWithoutNodeSelected = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-actions-choose"]')); - expect(actionButtonWithoutNodeSelected.nativeElement.disabled).toBe(false); - }); - }); - describe('Title', () => { it('should be updated when a site is chosen', () => { diff --git a/lib/content-services/src/lib/content-node-selector/content-node-selector.component.ts b/lib/content-services/src/lib/content-node-selector/content-node-selector.component.ts index a952e4d8a8..affd22312b 100644 --- a/lib/content-services/src/lib/content-node-selector/content-node-selector.component.ts +++ b/lib/content-services/src/lib/content-node-selector/content-node-selector.component.ts @@ -109,7 +109,7 @@ export class ContentNodeSelectorComponent implements OnInit { } isChooseButtonDisabled(): boolean { - return this.uploadService.isUploading() || !this.hasNodeSelected() || this.hasNoPermissionToUpload(); + return this.uploadService.isUploading() || !this.hasNodeSelected(); } hasNodeSelected(): boolean {