mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-09-17 14:21:14 +00:00
deprecate unused main-action component
This commit is contained in:
committed by
Yasa-Nataliya
parent
76cd1eca89
commit
bb91029023
@@ -29,10 +29,9 @@ import { CoreModule } from '@alfresco/adf-core';
|
|||||||
import { AppToolbarModule } from '../toolbar/toolbar.module';
|
import { AppToolbarModule } from '../toolbar/toolbar.module';
|
||||||
import { AppSearchInputModule } from '../search/search-input.module';
|
import { AppSearchInputModule } from '../search/search-input.module';
|
||||||
import { HeaderActionsComponent } from './header-actions.component';
|
import { HeaderActionsComponent } from './header-actions.component';
|
||||||
import { MainActionModule } from '../main-action/main-action.module';
|
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [CommonModule, CoreModule.forChild(), AppToolbarModule, AppSearchInputModule, MainActionModule],
|
imports: [CommonModule, CoreModule.forChild(), AppToolbarModule, AppSearchInputModule],
|
||||||
declarations: [HeaderActionsComponent],
|
declarations: [HeaderActionsComponent],
|
||||||
exports: [HeaderActionsComponent]
|
exports: [HeaderActionsComponent]
|
||||||
})
|
})
|
||||||
|
@@ -1,30 +0,0 @@
|
|||||||
<ng-container *ngIf="(mainAction$ | async) as action">
|
|
||||||
<ng-container [ngSwitch]="action.type">
|
|
||||||
<ng-container *ngSwitchCase="actionTypes.button">
|
|
||||||
<button
|
|
||||||
*ngIf="expanded"
|
|
||||||
mat-stroked-button
|
|
||||||
[id]="action.id"
|
|
||||||
(click)="runAction(action.actions.click)"
|
|
||||||
[disabled]="action.disabled"
|
|
||||||
class="app-main-action-button"
|
|
||||||
data-automation-id="app-main-action-button"
|
|
||||||
>
|
|
||||||
{{action.title | translate}}
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<button
|
|
||||||
*ngIf="expanded === false"
|
|
||||||
mat-icon-button
|
|
||||||
[id]="action.id"
|
|
||||||
(click)="runAction(action.actions.click)"
|
|
||||||
[disabled]="action.disabled"
|
|
||||||
data-automation-id="app-main-action-icon"
|
|
||||||
title="{{ action.title| translate }}"
|
|
||||||
>
|
|
||||||
<mat-icon class="main-action-menu-icon">{{action.icon}}</mat-icon>
|
|
||||||
</button>
|
|
||||||
</ng-container>
|
|
||||||
</ng-container>
|
|
||||||
</ng-container>
|
|
||||||
|
|
@@ -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);
|
|
||||||
}
|
|
@@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
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<MainActionComponent>;
|
|
||||||
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();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
@@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
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<ContentActionRef>;
|
|
||||||
|
|
||||||
actionTypes = ContentActionType;
|
|
||||||
|
|
||||||
private onDestroy$ = new Subject<boolean>();
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
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 {}
|
|
@@ -25,11 +25,9 @@
|
|||||||
|
|
||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { AppCreateMenuModule } from '../create-menu/create-menu.module';
|
import { AppCreateMenuModule } from '../create-menu/create-menu.module';
|
||||||
import { CommonModule } from '@angular/common';
|
|
||||||
import { CoreModule } from '@alfresco/adf-core';
|
import { CoreModule } from '@alfresco/adf-core';
|
||||||
import { RouterModule } from '@angular/router';
|
import { RouterModule } from '@angular/router';
|
||||||
import { ExtensionsModule } from '@alfresco/adf-extensions';
|
import { ExtensionsModule } from '@alfresco/adf-extensions';
|
||||||
import { CoreExtensionsModule } from '../../extensions/core.extensions.module';
|
|
||||||
import { ExpansionPanelDirective } from './directives/expansion-panel.directive';
|
import { ExpansionPanelDirective } from './directives/expansion-panel.directive';
|
||||||
import { MenuPanelDirective } from './directives/menu-panel.directive';
|
import { MenuPanelDirective } from './directives/menu-panel.directive';
|
||||||
import { SidenavComponent } from './sidenav.component';
|
import { SidenavComponent } from './sidenav.component';
|
||||||
@@ -37,20 +35,11 @@ import { ActiveLinkDirective } from './directives/active-link.directive';
|
|||||||
import { ExpandMenuComponent } from './components/expand-menu.component';
|
import { ExpandMenuComponent } from './components/expand-menu.component';
|
||||||
import { ButtonMenuComponent } from './components/button-menu.component';
|
import { ButtonMenuComponent } from './components/button-menu.component';
|
||||||
import { ActionDirective } from './directives/action.directive';
|
import { ActionDirective } from './directives/action.directive';
|
||||||
import { MainActionModule } from '../main-action/main-action.module';
|
|
||||||
import { NavigationMenuComponent } from './navigation-menu/navigation-menu.component';
|
import { NavigationMenuComponent } from './navigation-menu/navigation-menu.component';
|
||||||
import { SidenavHeaderComponent } from './components/sidenav-header.component';
|
import { SidenavHeaderComponent } from './components/sidenav-header.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [CoreModule.forChild(), ExtensionsModule.forChild(), RouterModule, AppCreateMenuModule],
|
||||||
CommonModule,
|
|
||||||
CoreModule.forChild(),
|
|
||||||
CoreExtensionsModule.forChild(),
|
|
||||||
ExtensionsModule.forChild(),
|
|
||||||
RouterModule,
|
|
||||||
AppCreateMenuModule,
|
|
||||||
MainActionModule
|
|
||||||
],
|
|
||||||
declarations: [
|
declarations: [
|
||||||
MenuPanelDirective,
|
MenuPanelDirective,
|
||||||
ExpansionPanelDirective,
|
ExpansionPanelDirective,
|
||||||
|
Reference in New Issue
Block a user