diff --git a/projects/aca-content/src/lib/components/header-actions/header-actions.module.ts b/projects/aca-content/src/lib/components/header-actions/header-actions.module.ts index 6073b30c2..a17eec67f 100644 --- a/projects/aca-content/src/lib/components/header-actions/header-actions.module.ts +++ b/projects/aca-content/src/lib/components/header-actions/header-actions.module.ts @@ -29,10 +29,9 @@ import { CoreModule } from '@alfresco/adf-core'; import { AppToolbarModule } from '../toolbar/toolbar.module'; import { AppSearchInputModule } from '../search/search-input.module'; import { HeaderActionsComponent } from './header-actions.component'; -import { MainActionModule } from '../main-action/main-action.module'; @NgModule({ - imports: [CommonModule, CoreModule.forChild(), AppToolbarModule, AppSearchInputModule, MainActionModule], + imports: [CommonModule, CoreModule.forChild(), AppToolbarModule, AppSearchInputModule], declarations: [HeaderActionsComponent], exports: [HeaderActionsComponent] }) diff --git a/projects/aca-content/src/lib/components/main-action/main-action.component.html b/projects/aca-content/src/lib/components/main-action/main-action.component.html deleted file mode 100644 index c8be49da3..000000000 --- a/projects/aca-content/src/lib/components/main-action/main-action.component.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - diff --git a/projects/aca-content/src/lib/components/main-action/main-action.component.scss b/projects/aca-content/src/lib/components/main-action/main-action.component.scss deleted file mode 100644 index a46a78fb1..000000000 --- a/projects/aca-content/src/lib/components/main-action/main-action.component.scss +++ /dev/null @@ -1,10 +0,0 @@ -.app-main-action-button { - width: 100%; - border-radius: 4px; - background-color: var(--theme-accent-color); - color: var(--theme-accent-color-default-contrast); -} - -.main-action-menu-icon { - color: var(--theme-accent-color); -} diff --git a/projects/aca-content/src/lib/components/main-action/main-action.component.spec.ts b/projects/aca-content/src/lib/components/main-action/main-action.component.spec.ts deleted file mode 100644 index 91d4537b4..000000000 --- a/projects/aca-content/src/lib/components/main-action/main-action.component.spec.ts +++ /dev/null @@ -1,157 +0,0 @@ -/*! - * @license - * Alfresco Example Content Application - * - * Copyright (C) 2005 - 2020 Alfresco Software Limited - * - * This file is part of the Alfresco Example Content Application. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * The Alfresco Example Content Application is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * The Alfresco Example Content Application is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ - -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { MainActionComponent } from './main-action.component'; -import { TranslationService, TranslationMock } from '@alfresco/adf-core'; -import { AppExtensionService } from '@alfresco/aca-shared'; -import { of } from 'rxjs'; -import { ACTION_CLICK, ACTION_TITLE, getContentActionRef } from '../../testing/content-action-ref'; -import { AppExtensionServiceMock } from '../../testing/app-extension-service-mock'; -import { CommonModule } from '@angular/common'; -import { MatButtonModule } from '@angular/material/button'; -import { TranslateModule } from '@ngx-translate/core'; - -describe('MainActionComponent', () => { - let mainActionComponent: MainActionComponent; - const buttonQuery = '[data-automation-id="app-main-action-button"]'; - const iconQuery = '[data-automation-id="app-main-action-icon"]'; - - let fixture: ComponentFixture; - let appExtensionService: AppExtensionServiceMock; - - beforeEach(async () => { - TestBed.configureTestingModule({ - imports: [CommonModule, MatButtonModule, TranslateModule.forRoot()], - providers: [ - { provide: TranslationService, useClass: TranslationMock }, - { provide: AppExtensionService, useClass: AppExtensionServiceMock } - ] - }).compileComponents(); - - appExtensionService = TestBed.inject(AppExtensionService); - - fixture = TestBed.createComponent(MainActionComponent); - mainActionComponent = fixture.componentInstance; - }); - - describe('component is in expanded mode', () => { - beforeEach(async () => { - mainActionComponent.expanded = true; - fixture.detectChanges(); - }); - - it('should display button if main action is configured', () => { - const buttonMainAction = fixture.debugElement.nativeElement.querySelector(buttonQuery); - const iconMainAction = fixture.debugElement.nativeElement.querySelector(iconQuery); - - expect(iconMainAction).toBeFalsy(); - expect(buttonMainAction.textContent.trim()).toBe(ACTION_TITLE); - }); - - it('should not display button if main action is not configured', () => { - spyOn(appExtensionService, 'getMainAction').and.returnValue(of(undefined)); - mainActionComponent.ngOnInit(); - fixture.detectChanges(); - - const button = fixture.debugElement.nativeElement.querySelector(buttonQuery); - expect(button).toBeFalsy(); - }); - - it('should call extension action', () => { - const runExtensionActionSpy = spyOn(appExtensionService, 'runActionById'); - - const button = fixture.debugElement.nativeElement.querySelector(buttonQuery); - button.click(); - - expect(runExtensionActionSpy).toHaveBeenCalledWith(ACTION_CLICK); - }); - - it('should not call button if main action is disabled', () => { - const disabledMainActionRef = getContentActionRef(); - disabledMainActionRef.disabled = true; - - spyOn(appExtensionService, 'getMainAction').and.returnValue(of(disabledMainActionRef)); - const runAction = spyOn(mainActionComponent, 'runAction'); - - mainActionComponent.ngOnInit(); - fixture.detectChanges(); - - const button = fixture.debugElement.nativeElement.querySelector(buttonQuery); - button.click(); - - expect(runAction).not.toHaveBeenCalled(); - }); - }); - - describe('component is displayed as icon', () => { - beforeEach(async () => { - mainActionComponent.expanded = false; - fixture.detectChanges(); - }); - - it('should display icon if main action is configured', () => { - const buttonMainAction = fixture.debugElement.nativeElement.querySelector(buttonQuery); - const iconMainAction = fixture.debugElement.nativeElement.querySelector(iconQuery); - - expect(buttonMainAction).toBeFalsy(); - expect(iconMainAction).toBeTruthy(); - }); - - it('should not display icon if main action is not configured', () => { - spyOn(appExtensionService, 'getMainAction').and.returnValue(of(undefined)); - mainActionComponent.ngOnInit(); - fixture.detectChanges(); - - const mainAction = fixture.debugElement.nativeElement.querySelector(iconQuery); - expect(mainAction).toBeFalsy(); - }); - - it('should call extension action', () => { - const runExtensionActionSpy = spyOn(appExtensionService, 'runActionById'); - - const mainAction = fixture.debugElement.nativeElement.querySelector(iconQuery); - mainAction.click(); - - expect(runExtensionActionSpy).toHaveBeenCalledWith(ACTION_CLICK); - }); - - it('should not call icon if main action is disabled', () => { - const disabledMainActionRef = getContentActionRef(); - disabledMainActionRef.disabled = true; - - spyOn(appExtensionService, 'getMainAction').and.returnValue(of(disabledMainActionRef)); - const runAction = spyOn(mainActionComponent, 'runAction'); - - mainActionComponent.ngOnInit(); - fixture.detectChanges(); - - const button = fixture.debugElement.nativeElement.querySelector(iconQuery); - button.click(); - - expect(runAction).not.toHaveBeenCalled(); - }); - }); -}); diff --git a/projects/aca-content/src/lib/components/main-action/main-action.component.ts b/projects/aca-content/src/lib/components/main-action/main-action.component.ts deleted file mode 100644 index b5119bfce..000000000 --- a/projects/aca-content/src/lib/components/main-action/main-action.component.ts +++ /dev/null @@ -1,59 +0,0 @@ -/*! - * @license - * Alfresco Example Content Application - * - * Copyright (C) 2005 - 2020 Alfresco Software Limited - * - * This file is part of the Alfresco Example Content Application. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * The Alfresco Example Content Application is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * The Alfresco Example Content Application is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ - -import { AppExtensionService } from '@alfresco/aca-shared'; -import { ContentActionRef, ContentActionType } from '@alfresco/adf-extensions'; -import { Component, Input, OnDestroy, OnInit } from '@angular/core'; -import { Observable, Subject } from 'rxjs'; -import { takeUntil } from 'rxjs/operators'; - -@Component({ - selector: 'app-main-action', - templateUrl: './main-action.component.html', - styleUrls: ['./main-action.component.scss'] -}) -export class MainActionComponent implements OnInit, OnDestroy { - @Input() expanded: boolean; - - mainAction$: Observable; - - actionTypes = ContentActionType; - - private onDestroy$ = new Subject(); - - constructor(private extensions: AppExtensionService) {} - - ngOnDestroy(): void { - this.onDestroy$.next(true); - } - - ngOnInit(): void { - this.mainAction$ = this.extensions.getMainAction().pipe(takeUntil(this.onDestroy$)); - } - - runAction(action: string): void { - this.extensions.runActionById(action); - } -} diff --git a/projects/aca-content/src/lib/components/main-action/main-action.module.ts b/projects/aca-content/src/lib/components/main-action/main-action.module.ts deleted file mode 100644 index f4aa3cab6..000000000 --- a/projects/aca-content/src/lib/components/main-action/main-action.module.ts +++ /dev/null @@ -1,38 +0,0 @@ -/*! - * @license - * Alfresco Example Content Application - * - * Copyright (C) 2005 - 2020 Alfresco Software Limited - * - * This file is part of the Alfresco Example Content Application. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * The Alfresco Example Content Application is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * The Alfresco Example Content Application is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ - -import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { MatButtonModule } from '@angular/material/button'; -import { TranslateModule } from '@ngx-translate/core'; -import { MainActionComponent } from './main-action.component'; -import { MatIconModule } from '@angular/material/icon'; - -@NgModule({ - imports: [CommonModule, MatButtonModule, MatIconModule, TranslateModule.forChild()], - exports: [MainActionComponent], - declarations: [MainActionComponent] -}) -export class MainActionModule {} diff --git a/projects/aca-content/src/lib/components/sidenav/sidenav.module.ts b/projects/aca-content/src/lib/components/sidenav/sidenav.module.ts index b2309abb4..9b54837ec 100644 --- a/projects/aca-content/src/lib/components/sidenav/sidenav.module.ts +++ b/projects/aca-content/src/lib/components/sidenav/sidenav.module.ts @@ -25,11 +25,9 @@ import { NgModule } from '@angular/core'; import { AppCreateMenuModule } from '../create-menu/create-menu.module'; -import { CommonModule } from '@angular/common'; import { CoreModule } from '@alfresco/adf-core'; import { RouterModule } from '@angular/router'; import { ExtensionsModule } from '@alfresco/adf-extensions'; -import { CoreExtensionsModule } from '../../extensions/core.extensions.module'; import { ExpansionPanelDirective } from './directives/expansion-panel.directive'; import { MenuPanelDirective } from './directives/menu-panel.directive'; import { SidenavComponent } from './sidenav.component'; @@ -37,20 +35,11 @@ import { ActiveLinkDirective } from './directives/active-link.directive'; import { ExpandMenuComponent } from './components/expand-menu.component'; import { ButtonMenuComponent } from './components/button-menu.component'; import { ActionDirective } from './directives/action.directive'; -import { MainActionModule } from '../main-action/main-action.module'; import { NavigationMenuComponent } from './navigation-menu/navigation-menu.component'; import { SidenavHeaderComponent } from './components/sidenav-header.component'; @NgModule({ - imports: [ - CommonModule, - CoreModule.forChild(), - CoreExtensionsModule.forChild(), - ExtensionsModule.forChild(), - RouterModule, - AppCreateMenuModule, - MainActionModule - ], + imports: [CoreModule.forChild(), ExtensionsModule.forChild(), RouterModule, AppCreateMenuModule], declarations: [ MenuPanelDirective, ExpansionPanelDirective,