diff --git a/demo-shell/src/app/app.module.ts b/demo-shell/src/app/app.module.ts index 2822b58c512..78495a2a6d5 100644 --- a/demo-shell/src/app/app.module.ts +++ b/demo-shell/src/app/app.module.ts @@ -67,6 +67,7 @@ import { ProcessCloudLayoutComponent } from './components/cloud/process-cloud-la import { CustomEditorComponent, CustomWidgetComponent } from './components/cloud/custom-form-components/custom-editor.component'; import { SearchFilterChipsComponent } from './components/search/search-filter-chips.component'; import { UserInfoComponent } from './components/app-layout/user-info/user-info.component'; +import { FolderDirectiveModule } from './folder-directive'; @NgModule({ imports: [ @@ -87,7 +88,8 @@ import { UserInfoComponent } from './components/app-layout/user-info/user-info.c ExtensionsModule.forRoot(), NgChartsModule, AppCloudSharedModule, - MonacoEditorModule.forRoot() + MonacoEditorModule.forRoot(), + FolderDirectiveModule ], declarations: [ AppComponent, diff --git a/demo-shell/src/app/components/files/files.component.html b/demo-shell/src/app/components/files/files.component.html index 47815e5df60..2ab363c0905 100644 --- a/demo-shell/src/app/components/files/files.component.html +++ b/demo-shell/src/app/components/files/files.component.html @@ -64,19 +64,6 @@ more_vert - - - - - - ... - -``` - -## Class members - -### Properties - -| Name | Type | Default value | Description | -| ---- | ---- | ------------- | ----------- | -| folder | `Node` | | Folder node to edit. | -| title | `string` | null | Title of folder edit dialog. | - -### Events - -| Name | Type | Description | -| ---- | ---- | ----------- | -| error | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`` | Emitted when an error occurs (eg, a folder with same name already exists). | -| success | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`` | Emitted when the folder has been edited successfully. | - -## Details - -Pass this directive a folder to edit its name and description using a [Folder Dialog component](../../../lib/content-services/dialogs/folder.dialog.ts). -If the data is valid then the dialog emits a `folderEdit` event when it closes. diff --git a/e2e/content-services/document-list/document-list-pagination.e2e.ts b/e2e/content-services/document-list/document-list-pagination.e2e.ts index bef68ea4758..1660313fe8f 100644 --- a/e2e/content-services/document-list/document-list-pagination.e2e.ts +++ b/e2e/content-services/document-list/document-list-pagination.e2e.ts @@ -269,10 +269,8 @@ describe('Document List - Pagination', () => { await expect(await paginationPage.getCurrentItemsPerPage()).toEqual('5'); await contentServicesPage.createAndOpenNewFolder(folderTwoModel.name); - await contentServicesPage.checkPaginationIsNotDisplayed(); await contentServicesPage.deleteSubFolderUnderRoot(newFolderModel.name, folderTwoModel.name); - }); it('[C260071] Should be able to change pagination when having 25 files', async () => { @@ -371,7 +369,6 @@ describe('Document List - Pagination', () => { await contentServicesPage.createNewFolder(folderTwoModel.name); const nodeIdSubFolderTwo = await contentServicesPage.getAttributeValueForElement(folderTwoModel.name, 'Node id'); await contentServicesPage.openFolder(folderTwoModel.name); - for (let i = 0; i < numberOfSubFolders; i++) { await uploadActions.createFolder('subfolder' + (i + 1), nodeIdSubFolderTwo); } diff --git a/lib/content-services/src/lib/content.module.ts b/lib/content-services/src/lib/content.module.ts index 4e9540f8120..6431bb6b9b5 100644 --- a/lib/content-services/src/lib/content.module.ts +++ b/lib/content-services/src/lib/content.module.ts @@ -33,7 +33,6 @@ import { ContentNodeSelectorModule } from './content-node-selector/content-node- import { ContentNodeShareModule } from './content-node-share/content-node-share.module'; import { ContentDirectiveModule } from './directives/content-directive.module'; import { DialogModule } from './dialogs/dialog.module'; -import { FolderDirectiveModule } from './folder-directive/folder-directive.module'; import { ContentMetadataModule } from './content-metadata/content-metadata.module'; import { PermissionManagerModule } from './permission-manager/permission-manager.module'; import { TreeViewModule } from './tree-view/tree-view.module'; @@ -70,7 +69,6 @@ import { ContentAuthLoaderService } from './auth-loader/content-auth-loader.serv ContentNodeSelectorModule, ContentNodeShareModule, ContentMetadataModule, - FolderDirectiveModule, ContentDirectiveModule, PermissionManagerModule, VersionManagerModule, @@ -98,7 +96,6 @@ import { ContentAuthLoaderService } from './auth-loader/content-auth-loader.serv ContentNodeShareModule, ContentMetadataModule, DialogModule, - FolderDirectiveModule, ContentDirectiveModule, PermissionManagerModule, VersionManagerModule, diff --git a/lib/content-services/src/lib/folder-directive/folder-edit.directive.spec.ts b/lib/content-services/src/lib/folder-directive/folder-edit.directive.spec.ts deleted file mode 100644 index 6b49f20e250..00000000000 --- a/lib/content-services/src/lib/folder-directive/folder-edit.directive.spec.ts +++ /dev/null @@ -1,110 +0,0 @@ -/*! - * @license - * Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { Component } from '@angular/core'; -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { MatDialog } from '@angular/material/dialog'; -import { By } from '@angular/platform-browser'; -import { Subject, of } from 'rxjs'; -import { FolderEditDirective } from './folder-edit.directive'; -import { Node } from '@alfresco/js-api'; -import { ContentTestingModule } from '../testing/content.testing.module'; -import { ContentService } from '../common/services/content.service'; - -@Component({ - template: '
' -}) -class TestComponent { - folder = {}; - public successParameter: Node = null; - - success(node: Node) { - this.successParameter = node; - } -} - -describe('FolderEditDirective', () => { - let fixture: ComponentFixture; - let element; - let dialog: MatDialog; - let contentService: ContentService; - let dialogRefMock; - - const event = { - type: 'click', - preventDefault: () => null - }; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ContentTestingModule], - declarations: [TestComponent] - }); - fixture = TestBed.createComponent(TestComponent); - element = fixture.debugElement.query(By.directive(FolderEditDirective)); - dialog = TestBed.inject(MatDialog); - contentService = TestBed.inject(ContentService); - - dialogRefMock = { - afterClosed: (val) => of(val), - componentInstance: { - error: new Subject(), - success: new Subject() - } - }; - - spyOn(dialog, 'open').and.returnValue(dialogRefMock); - }); - - it('should not emit folderEdit event when input value is undefined', async () => { - spyOn(dialogRefMock, 'afterClosed').and.returnValue(of(null)); - spyOn(contentService.folderEdit, 'next'); - - fixture.detectChanges(); - await fixture.whenStable(); - - element.nativeElement.click(); - expect(contentService.folderEdit.next).not.toHaveBeenCalled(); - }); - - it('should emit success event with node if the folder creation was successful', async () => { - fixture.detectChanges(); - const testNode: any = {}; - - element.triggerEventHandler('click', event); - dialogRefMock.componentInstance.success.next(testNode); - - fixture.detectChanges(); - await fixture.whenStable(); - expect(fixture.componentInstance.successParameter).toBe(testNode); - }); - - it('should open the dialog with the proper title', async () => { - fixture.detectChanges(); - element.triggerEventHandler('click', event); - - await fixture.whenStable(); - - expect(dialog.open).toHaveBeenCalledWith(jasmine.any(Function), { - data: { - folder: jasmine.any(Object), - editTitle: 'edit-title' - }, - width: jasmine.any(String) - }); - }); -}); diff --git a/lib/content-services/src/lib/folder-directive/folder-edit.directive.ts b/lib/content-services/src/lib/folder-directive/folder-edit.directive.ts deleted file mode 100644 index 5f19d8f0cf5..00000000000 --- a/lib/content-services/src/lib/folder-directive/folder-edit.directive.ts +++ /dev/null @@ -1,92 +0,0 @@ -/*! - * @license - * Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* eslint-disable @angular-eslint/no-input-rename */ - -import { Directive, ElementRef, HostListener, Input, Output, EventEmitter } from '@angular/core'; -import { MatDialog } from '@angular/material/dialog'; -import { Node } from '@alfresco/js-api'; -import { FolderDialogComponent } from '../dialogs/folder.dialog'; -import { ContentService } from '../common/services/content.service'; - -const DIALOG_WIDTH: number = 400; - -@Directive({ - selector: '[adf-edit-folder]' -}) -export class FolderEditDirective { - /** Folder node to edit. */ - @Input('adf-edit-folder') - folder: Node; - - /** Emitted when an error occurs (eg, a folder with same name already exists). */ - @Output() - error = new EventEmitter(); - - /** Title of folder edit dialog. */ - @Input() - title: string = null; - - /** Emitted when the folder has been edited successfully. */ - @Output() - success = new EventEmitter(); - - @HostListener('click', [ '$event' ]) - onClick(event) { - event.preventDefault(); - if (this.folder) { - this.openDialog(); - } - } - - constructor( - public dialogRef: MatDialog, - public elementRef: ElementRef, - public content: ContentService - ) {} - - private get dialogConfig() { - const { folder } = this; - - return { - data: { - folder, - editTitle: this.title - }, - width: `${DIALOG_WIDTH}px` - }; - } - - private openDialog(): void { - const { dialogRef, dialogConfig, content } = this; - const dialogInstance = dialogRef.open(FolderDialogComponent, dialogConfig); - - dialogInstance.componentInstance.error.subscribe((error) => { - this.error.emit(error); - }); - - dialogInstance.componentInstance.success.subscribe((node: Node) => { - this.success.emit(node); - }); - - dialogInstance.afterClosed().subscribe((node: Node) => { - if (node) { - content.folderEdit.next(node); - } - }); - } -} diff --git a/lib/content-services/src/lib/folder-directive/public-api.ts b/lib/content-services/src/lib/folder-directive/public-api.ts deleted file mode 100644 index f00ea95f1fa..00000000000 --- a/lib/content-services/src/lib/folder-directive/public-api.ts +++ /dev/null @@ -1,21 +0,0 @@ -/*! - * @license - * Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export * from './folder-create.directive'; -export * from './folder-edit.directive'; - -export * from './folder-directive.module'; diff --git a/lib/content-services/src/public-api.ts b/lib/content-services/src/public-api.ts index b9447dce146..4d9f241421e 100644 --- a/lib/content-services/src/public-api.ts +++ b/lib/content-services/src/public-api.ts @@ -26,7 +26,6 @@ export * from './lib/breadcrumb/index'; export * from './lib/version-manager/index'; export * from './lib/content-node-selector/index'; export * from './lib/dialogs/index'; -export * from './lib/folder-directive/index'; export * from './lib/content-metadata/index'; export * from './lib/permission-manager/index'; export * from './lib/content-node-share/index';