mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
[ACS-5304] remove unused create menu component (#3233)
* remove unused create menu component * remove unused i18n keys * raise coverage * fix missing a11y import, fix css var bug
This commit is contained in:
@@ -82,8 +82,6 @@
|
||||
"TITLE": "Details"
|
||||
},
|
||||
"NEW_MENU": {
|
||||
"LABEL": "New",
|
||||
"TOOLTIP": "Add new files and folders, or create a new File Library",
|
||||
"MENU_ITEMS": {
|
||||
"CREATE_FOLDER": "Create Folder",
|
||||
"UPLOAD_FILE": "Upload File",
|
||||
|
@@ -50,7 +50,6 @@ import { DirectivesModule } from './directives/directives.module';
|
||||
import { ContextMenuModule } from './components/context-menu/context-menu.module';
|
||||
import { ExtensionService, ExtensionsModule } from '@alfresco/adf-extensions';
|
||||
import { AppToolbarModule } from './components/toolbar/toolbar.module';
|
||||
import { AppCreateMenuModule } from './components/create-menu/create-menu.module';
|
||||
import { AppSidenavModule } from './components/sidenav/sidenav.module';
|
||||
import { AppCommonModule } from './components/common/common.module';
|
||||
import { AppSearchInputModule } from './components/search/search-input.module';
|
||||
@@ -115,7 +114,6 @@ import { UserMenuComponent } from './components/sidenav/user-menu/user-menu.comp
|
||||
AppInfoDrawerModule,
|
||||
AppToolbarModule,
|
||||
AppSidenavModule,
|
||||
AppCreateMenuModule,
|
||||
DocumentListCustomComponentsModule,
|
||||
AppSearchInputModule,
|
||||
AppSearchResultsModule,
|
||||
|
@@ -1,36 +0,0 @@
|
||||
<ng-container *ngIf="expanded">
|
||||
<button
|
||||
mat-stroked-button
|
||||
data-automation-id="create-button"
|
||||
[matMenuTriggerFor]="rootMenu"
|
||||
title="{{ 'APP.NEW_MENU.TOOLTIP' | translate }}"
|
||||
[class]="{
|
||||
'app-create-menu-secondary-button': isMainActionPresent
|
||||
}"
|
||||
>
|
||||
<span class="app-create-menu__text">{{ 'APP.NEW_MENU.LABEL' | translate }}</span>
|
||||
<mat-icon title="{{ 'APP.NEW_MENU.TOOLTIP' | translate }}">arrow_drop_down</mat-icon>
|
||||
</button>
|
||||
</ng-container>
|
||||
|
||||
<ng-container *ngIf="!expanded">
|
||||
<button
|
||||
mat-icon-button
|
||||
[class]="{
|
||||
'app-create-menu-secondary-button': isMainActionPresent,
|
||||
'app-create-menu--collapsed': true
|
||||
}"
|
||||
data-automation-id="create-button"
|
||||
[matMenuTriggerFor]="rootMenu"
|
||||
#createMenu="matMenuTrigger"
|
||||
title="{{ 'APP.NEW_MENU.TOOLTIP' | translate }}"
|
||||
>
|
||||
<mat-icon class="app-create-menu--icon" title="{{ 'APP.NEW_MENU.TOOLTIP' | translate }}">queue</mat-icon>
|
||||
</button>
|
||||
</ng-container>
|
||||
|
||||
<mat-menu #rootMenu="matMenu" role="menu" class="app-create-menu__root-menu app-create-menu__sub-menu" [overlapTrigger]="false" yPosition="below">
|
||||
<div *ngFor="let action of createActions; trackBy: trackByActionId">
|
||||
<app-toolbar-menu-item [actionRef]="action"></app-toolbar-menu-item>
|
||||
</div>
|
||||
</mat-menu>
|
@@ -1,97 +0,0 @@
|
||||
.app-create-menu {
|
||||
.mat-stroked-button {
|
||||
width: 100%;
|
||||
height: 37.5px;
|
||||
border-radius: 4px;
|
||||
font-size: var(--new-button-font-size);
|
||||
font-weight: normal;
|
||||
text-transform: uppercase;
|
||||
margin-top: 10px;
|
||||
|
||||
.mat-icon {
|
||||
width: 24px;
|
||||
height: 25px;
|
||||
}
|
||||
|
||||
&__text {
|
||||
width: 100%;
|
||||
height: 20px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
&:not(.app-create-menu-secondary-button) {
|
||||
background-color: var(--theme-accent-color);
|
||||
color: var(--theme-accent-color-default-contrast);
|
||||
margin-top: 0;
|
||||
|
||||
.mat-icon {
|
||||
color: var(--theme-accent-color-default-contrast);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&__root-menu {
|
||||
max-width: 290px !important;
|
||||
width: 290px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
& > .mat-menu-content {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.app-create-menu--icon {
|
||||
&__sub-menu {
|
||||
.mat-menu-item {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
font-size: var(--theme-button-font-size);
|
||||
color: var(--theme-secondary-text-color);
|
||||
line-height: 48px;
|
||||
box-shadow: none;
|
||||
transform: none;
|
||||
transition: unset;
|
||||
font-weight: normal;
|
||||
|
||||
&:hover {
|
||||
color: var(--theme-primary-color);
|
||||
}
|
||||
}
|
||||
|
||||
.mat-menu-item[disabled],
|
||||
.mat-menu-item[disabled]:hover {
|
||||
color: var(--theme-text-disabled-color);
|
||||
|
||||
.mat-icon {
|
||||
color: var(--theme-text-disabled-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&--collapsed {
|
||||
outline: none;
|
||||
color: var(--theme-secondary-text-color);
|
||||
cursor: pointer;
|
||||
margin: 0;
|
||||
border: none;
|
||||
background: none;
|
||||
|
||||
&:not(.app-create-menu-secondary-button) {
|
||||
.app-create-menu--icon {
|
||||
color: var(--theme-accent-color);
|
||||
}
|
||||
|
||||
&:hover {
|
||||
color: var(--theme-accent-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.app-create-menu:focus {
|
||||
outline: none;
|
||||
}
|
@@ -1,155 +0,0 @@
|
||||
/*!
|
||||
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* 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
|
||||
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { CreateMenuComponent } from './create-menu.component';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { AppCreateMenuModule } from './create-menu.module';
|
||||
import { OverlayContainer, OverlayModule } from '@angular/cdk/overlay';
|
||||
import { AppExtensionService } from '@alfresco/aca-shared';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { AppTestingModule } from '../../testing/app-testing.module';
|
||||
import { MatMenuModule } from '@angular/material/menu';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { of } from 'rxjs';
|
||||
import { ContentActionRef, ContentActionType } from '@alfresco/adf-extensions';
|
||||
|
||||
describe('CreateMenuComponent', () => {
|
||||
let fixture: ComponentFixture<CreateMenuComponent>;
|
||||
let extensionService: AppExtensionService;
|
||||
let getCreateActionsSpy: jasmine.Spy;
|
||||
|
||||
const getContentActionRef = (): ContentActionRef => ({
|
||||
id: 'id',
|
||||
type: ContentActionType.button,
|
||||
title: 'ACTION_TITLE',
|
||||
disabled: false,
|
||||
actions: {
|
||||
click: 'ACTION_CLICK'
|
||||
}
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [AppTestingModule, AppCreateMenuModule, OverlayModule, MatMenuModule, MatButtonModule]
|
||||
});
|
||||
|
||||
extensionService = TestBed.inject(AppExtensionService);
|
||||
getCreateActionsSpy = spyOn(extensionService, 'getCreateActions');
|
||||
getCreateActionsSpy.and.returnValue(
|
||||
of([
|
||||
{
|
||||
id: 'action1',
|
||||
type: ContentActionType.button,
|
||||
title: 'action one'
|
||||
}
|
||||
])
|
||||
);
|
||||
|
||||
spyOn(extensionService, 'getMainAction').and.returnValue(of(getContentActionRef()));
|
||||
|
||||
fixture = TestBed.createComponent(CreateMenuComponent);
|
||||
});
|
||||
|
||||
async function clickMenu() {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const button: HTMLButtonElement = fixture.debugElement.query(By.css('[data-automation-id="create-button"]')).nativeElement;
|
||||
button.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
}
|
||||
|
||||
it('should render collapsed button', async () => {
|
||||
fixture.componentInstance.expanded = false;
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const button: HTMLButtonElement = fixture.debugElement.query(By.css('[data-automation-id="create-button"]')).nativeElement;
|
||||
const isCollapsed = button.classList.contains('app-create-menu--collapsed');
|
||||
|
||||
expect(isCollapsed).toBe(true);
|
||||
});
|
||||
|
||||
it('should render expanded button', async () => {
|
||||
fixture.componentInstance.expanded = true;
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const button: HTMLButtonElement = fixture.debugElement.query(By.css('[data-automation-id="create-button"]')).nativeElement;
|
||||
const isCollapsed = button.classList.contains('app-create-menu--collapsed');
|
||||
|
||||
expect(isCollapsed).toBe(false);
|
||||
});
|
||||
|
||||
it('should render custom actions', async () => {
|
||||
await clickMenu();
|
||||
|
||||
const menuItems = fixture.debugElement.queryAll(By.css('.app-toolbar-menu-item'));
|
||||
expect(menuItems.length).toBe(1);
|
||||
|
||||
const label: HTMLSpanElement = (menuItems[0].nativeElement as HTMLButtonElement).querySelector('[data-automation-id="menu-item-title"]');
|
||||
expect(label.innerText).toBe('action one');
|
||||
});
|
||||
|
||||
it('should render sub-menus', async () => {
|
||||
getCreateActionsSpy.and.returnValue(
|
||||
of([
|
||||
{
|
||||
id: 'level1',
|
||||
type: ContentActionType.menu,
|
||||
title: 'level one',
|
||||
children: [
|
||||
{
|
||||
id: 'level2',
|
||||
type: ContentActionType.button,
|
||||
title: 'level two'
|
||||
}
|
||||
]
|
||||
}
|
||||
])
|
||||
);
|
||||
|
||||
await clickMenu();
|
||||
|
||||
const level1 = fixture.debugElement.query(By.css('#level1')).nativeElement as HTMLButtonElement;
|
||||
level1.click();
|
||||
|
||||
const overlayContainer = TestBed.inject(OverlayContainer);
|
||||
const level2 = overlayContainer.getContainerElement().querySelector('#level2');
|
||||
|
||||
expect(level2).not.toBeNull();
|
||||
});
|
||||
|
||||
it('should recognise if main button is present', async () => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const button: HTMLButtonElement = fixture.debugElement.query(By.css('[data-automation-id="create-button"]')).nativeElement;
|
||||
const isSecondaryButton = button.classList.contains('app-create-menu-secondary-button');
|
||||
|
||||
expect(isSecondaryButton).toBeTrue();
|
||||
});
|
||||
});
|
@@ -1,75 +0,0 @@
|
||||
/*!
|
||||
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* 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
|
||||
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Component, Input, OnInit, OnDestroy, ViewEncapsulation } from '@angular/core';
|
||||
import { ContentActionRef } from '@alfresco/adf-extensions';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { Subject } from 'rxjs';
|
||||
import { AppExtensionService } from '@alfresco/aca-shared';
|
||||
|
||||
@Component({
|
||||
selector: 'app-create-menu',
|
||||
templateUrl: './create-menu.component.html',
|
||||
styleUrls: ['./create-menu.component.scss'],
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
host: { class: 'app-create-menu' }
|
||||
})
|
||||
export class CreateMenuComponent implements OnInit, OnDestroy {
|
||||
createActions: Array<ContentActionRef> = [];
|
||||
onDestroy$: Subject<boolean> = new Subject<boolean>();
|
||||
isMainActionPresent: boolean;
|
||||
|
||||
@Input()
|
||||
showLabel: boolean;
|
||||
|
||||
@Input()
|
||||
expanded: boolean;
|
||||
|
||||
constructor(private extensions: AppExtensionService) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.extensions
|
||||
.getCreateActions()
|
||||
.pipe(takeUntil(this.onDestroy$))
|
||||
.subscribe((createActions) => {
|
||||
this.createActions = createActions;
|
||||
});
|
||||
|
||||
this.extensions
|
||||
.getMainAction()
|
||||
.pipe(takeUntil(this.onDestroy$))
|
||||
.subscribe((mainAction) => {
|
||||
this.isMainActionPresent = !!mainAction;
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.onDestroy$.next(true);
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
|
||||
trackByActionId(_: number, obj: ContentActionRef): string {
|
||||
return obj.id;
|
||||
}
|
||||
}
|
@@ -1,36 +0,0 @@
|
||||
/*!
|
||||
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* 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
|
||||
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CreateMenuComponent } from './create-menu.component';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { CoreModule } from '@alfresco/adf-core';
|
||||
import { AppToolbarModule } from '../toolbar/toolbar.module';
|
||||
|
||||
@NgModule({
|
||||
imports: [CommonModule, CoreModule.forChild(), AppToolbarModule],
|
||||
declarations: [CreateMenuComponent],
|
||||
exports: [CreateMenuComponent]
|
||||
})
|
||||
export class AppCreateMenuModule {}
|
@@ -0,0 +1,57 @@
|
||||
/*!
|
||||
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* 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
|
||||
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { TagsColumnComponent } from './tags-column.component';
|
||||
import { ChangeDetectorRef } from '@angular/core';
|
||||
|
||||
describe('TagsColumnComponent', () => {
|
||||
let fixture: ComponentFixture<TagsColumnComponent>;
|
||||
let component: TagsColumnComponent;
|
||||
let changeDetector: ChangeDetectorRef;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [TagsColumnComponent],
|
||||
providers: [{ provide: ChangeDetectorRef, useValue: { detectChanges() {} } }]
|
||||
});
|
||||
|
||||
changeDetector = TestBed.inject(ChangeDetectorRef);
|
||||
fixture = TestBed.createComponent(TagsColumnComponent);
|
||||
component = fixture.componentInstance;
|
||||
component.context = { row: { id: '0' } };
|
||||
});
|
||||
|
||||
it('should return nodeId from the row', () => {
|
||||
const row: any = { id: 'test1' };
|
||||
expect(component.getNodeId(row)).toBe('test1');
|
||||
});
|
||||
|
||||
it('should force change detection on tags loading', () => {
|
||||
spyOn(changeDetector, 'detectChanges');
|
||||
component = new TagsColumnComponent(changeDetector);
|
||||
component.onTagsLoaded();
|
||||
expect(changeDetector.detectChanges).toHaveBeenCalled();
|
||||
});
|
||||
});
|
@@ -23,7 +23,6 @@
|
||||
*/
|
||||
|
||||
import { NgModule } from '@angular/core';
|
||||
import { AppCreateMenuModule } from '../create-menu/create-menu.module';
|
||||
import { CoreModule } from '@alfresco/adf-core';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { ExtensionsModule } from '@alfresco/adf-extensions';
|
||||
@@ -39,7 +38,7 @@ import { SharedToolbarModule } from '@alfresco/aca-shared';
|
||||
import { UserMenuComponent } from './user-menu/user-menu.component';
|
||||
|
||||
@NgModule({
|
||||
imports: [CoreModule.forChild(), ExtensionsModule.forChild(), RouterModule, AppCreateMenuModule, SharedToolbarModule],
|
||||
imports: [CoreModule.forChild(), ExtensionsModule.forChild(), RouterModule, SharedToolbarModule],
|
||||
declarations: [
|
||||
MenuPanelDirective,
|
||||
ExpansionPanelDirective,
|
||||
|
@@ -86,7 +86,7 @@ app-view-profile {
|
||||
border: 2px solid var(--theme-blue-button-color) !important;
|
||||
border-radius: 6px;
|
||||
outline: none !important;
|
||||
box-shadow: 0 0 2px (--theme-blue-button-color);
|
||||
box-shadow: 0 0 2px var(--theme-blue-button-color);
|
||||
}
|
||||
|
||||
.app-general-edit {
|
||||
|
@@ -30,9 +30,10 @@ import { ExtensionsModule } from '@alfresco/adf-extensions';
|
||||
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
||||
import { SharedToolbarModule } from '../tool-bar/shared-toolbar.module';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { A11yModule } from '@angular/cdk/a11y';
|
||||
|
||||
@NgModule({
|
||||
imports: [CommonModule, InfoDrawerModule, MatProgressBarModule, ExtensionsModule, ToolbarModule, SharedToolbarModule, TranslateModule],
|
||||
imports: [CommonModule, InfoDrawerModule, MatProgressBarModule, ExtensionsModule, ToolbarModule, SharedToolbarModule, TranslateModule, A11yModule],
|
||||
declarations: [InfoDrawerComponent],
|
||||
exports: [InfoDrawerComponent]
|
||||
})
|
||||
|
Reference in New Issue
Block a user