diff --git a/src/app/components/create-menu/create-menu.component.scss b/src/app/components/create-menu/create-menu.component.scss
index 6fe7324b3..c7f98cdbf 100644
--- a/src/app/components/create-menu/create-menu.component.scss
+++ b/src/app/components/create-menu/create-menu.component.scss
@@ -3,18 +3,6 @@
}
.app-create-menu {
- width: 100%;
-
- .mat-stroked-button:not(.app-create-menu-secondary-button) {
- background-color: var(--theme-accent-color);
- color: var(--theme-primary-color-default-contrast);
- margin-top: 0px;
-
- .mat-icon {
- color: var(--theme-primary-color-default-contrast);
- }
- }
-
.mat-stroked-button {
width: 100%;
height: 37.5px;
@@ -34,6 +22,16 @@
height: 20px;
text-align: left;
}
+
+ &:not(.app-create-menu-secondary-button) {
+ background-color: var(--theme-accent-color);
+ color: var(--theme-primary-color-default-contrast);
+ margin-top: 0px;
+
+ .mat-icon {
+ color: var(--theme-primary-color-default-contrast);
+ }
+ }
}
&__root-menu {
@@ -52,43 +50,48 @@
outline: none;
color: var(--theme-secondary-text-color);
cursor: pointer;
- &:hover {
- color: var(--theme-accent-color);
- }
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--icon {
- color: var(--theme-accent-color);
- }
+ &__sub-menu {
+ .mat-menu-item {
+ display: flex;
+ flex-direction: row;
+ align-items: center;
+ font-size: 14px;
+ color: var(--theme-secondary-text-color);
+ line-height: 48px;
+ box-shadow: none;
+ transform: none;
+ transition: unset;
+ font-weight: normal;
- &__sub-menu {
- .mat-menu-item {
- display: flex;
- flex-direction: row;
- align-items: center;
- font-size: 14px;
- 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);
+ &:hover {
+ color: var(--theme-primary-color);
+ }
}
- }
- .mat-menu-item[disabled],
- .mat-menu-item[disabled]:hover {
- color: var(--theme-text-disabled-color);
-
- .mat-icon {
+ .mat-menu-item[disabled],
+ .mat-menu-item[disabled]:hover {
color: var(--theme-text-disabled-color);
+
+ .mat-icon {
+ color: var(--theme-text-disabled-color);
+ }
}
}
}
-}
+}
\ No newline at end of file
diff --git a/src/app/components/main-action/main-action.component.html b/src/app/components/main-action/main-action.component.html
index 7cb9a4793..7dfce4bf0 100644
--- a/src/app/components/main-action/main-action.component.html
+++ b/src/app/components/main-action/main-action.component.html
@@ -1,15 +1,28 @@
-
+
+
+
+
+
diff --git a/src/app/components/main-action/main-action.component.scss b/src/app/components/main-action/main-action.component.scss
index 380e9fbef..5b8a07670 100644
--- a/src/app/components/main-action/main-action.component.scss
+++ b/src/app/components/main-action/main-action.component.scss
@@ -4,3 +4,7 @@
background-color: var(--theme-accent-color);
color: var(--theme-primary-color-default-contrast);
}
+
+.main-action-menu-icon {
+ color: var(--theme-accent-color);
+}
diff --git a/src/app/components/main-action/main-action.component.spec.ts b/src/app/components/main-action/main-action.component.spec.ts
index ecf2c9894..91d4537b4 100644
--- a/src/app/components/main-action/main-action.component.spec.ts
+++ b/src/app/components/main-action/main-action.component.spec.ts
@@ -36,6 +36,9 @@ 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;
@@ -52,47 +55,103 @@ describe('MainActionComponent', () => {
fixture = TestBed.createComponent(MainActionComponent);
mainActionComponent = fixture.componentInstance;
-
- fixture.detectChanges();
});
- it('should display button if main action is configured', () => {
- const button = fixture.debugElement.nativeElement.querySelector('.app-main-action-button');
- expect(button).toBeTruthy();
- expect(button.textContent.trim()).toBe(ACTION_TITLE);
+ 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();
+ });
});
- it('should not display button if main action is not configured', () => {
- spyOn(appExtensionService, 'getMainAction').and.returnValue(of(undefined));
- mainActionComponent.ngOnInit();
- fixture.detectChanges();
+ describe('component is displayed as icon', () => {
+ beforeEach(async () => {
+ mainActionComponent.expanded = false;
+ fixture.detectChanges();
+ });
- const button = fixture.debugElement.nativeElement.querySelector('.app-main-action-button');
- expect(button).toBeFalsy();
- });
+ it('should display icon if main action is configured', () => {
+ const buttonMainAction = fixture.debugElement.nativeElement.querySelector(buttonQuery);
+ const iconMainAction = fixture.debugElement.nativeElement.querySelector(iconQuery);
- it('should call extension action', () => {
- const runExtensionActionSpy = spyOn(appExtensionService, 'runActionById');
+ expect(buttonMainAction).toBeFalsy();
+ expect(iconMainAction).toBeTruthy();
+ });
- const button = fixture.debugElement.nativeElement.querySelector('button');
- button.click();
+ it('should not display icon if main action is not configured', () => {
+ spyOn(appExtensionService, 'getMainAction').and.returnValue(of(undefined));
+ mainActionComponent.ngOnInit();
+ fixture.detectChanges();
- expect(runExtensionActionSpy).toHaveBeenCalledWith(ACTION_CLICK);
- });
+ const mainAction = fixture.debugElement.nativeElement.querySelector(iconQuery);
+ expect(mainAction).toBeFalsy();
+ });
- it('should not call button if main action is disabled', () => {
- const disabledMainActionRef = getContentActionRef();
- disabledMainActionRef.disabled = true;
+ it('should call extension action', () => {
+ const runExtensionActionSpy = spyOn(appExtensionService, 'runActionById');
- spyOn(appExtensionService, 'getMainAction').and.returnValue(of(disabledMainActionRef));
- const runAction = spyOn(mainActionComponent, 'runAction');
+ const mainAction = fixture.debugElement.nativeElement.querySelector(iconQuery);
+ mainAction.click();
- mainActionComponent.ngOnInit();
- fixture.detectChanges();
+ expect(runExtensionActionSpy).toHaveBeenCalledWith(ACTION_CLICK);
+ });
- const button = fixture.debugElement.nativeElement.querySelector(`#${disabledMainActionRef.id}`);
- button.click();
+ it('should not call icon if main action is disabled', () => {
+ const disabledMainActionRef = getContentActionRef();
+ disabledMainActionRef.disabled = true;
- expect(runAction).not.toHaveBeenCalled();
+ 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/src/app/components/main-action/main-action.component.ts b/src/app/components/main-action/main-action.component.ts
index 08972f3f8..b5119bfce 100644
--- a/src/app/components/main-action/main-action.component.ts
+++ b/src/app/components/main-action/main-action.component.ts
@@ -25,7 +25,7 @@
import { AppExtensionService } from '@alfresco/aca-shared';
import { ContentActionRef, ContentActionType } from '@alfresco/adf-extensions';
-import { Component, OnDestroy, OnInit } from '@angular/core';
+import { Component, Input, OnDestroy, OnInit } from '@angular/core';
import { Observable, Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
@@ -35,6 +35,8 @@ import { takeUntil } from 'rxjs/operators';
styleUrls: ['./main-action.component.scss']
})
export class MainActionComponent implements OnInit, OnDestroy {
+ @Input() expanded: boolean;
+
mainAction$: Observable;
actionTypes = ContentActionType;
diff --git a/src/app/components/main-action/main-action.module.ts b/src/app/components/main-action/main-action.module.ts
index 335d228a9..f4aa3cab6 100644
--- a/src/app/components/main-action/main-action.module.ts
+++ b/src/app/components/main-action/main-action.module.ts
@@ -28,9 +28,10 @@ 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, TranslateModule.forChild()],
+ imports: [CommonModule, MatButtonModule, MatIconModule, TranslateModule.forChild()],
exports: [MainActionComponent],
declarations: [MainActionComponent]
})
diff --git a/src/app/components/sidenav/sidenav.component.html b/src/app/components/sidenav/sidenav.component.html
index 70f6cb594..2c91866da 100644
--- a/src/app/components/sidenav/sidenav.component.html
+++ b/src/app/components/sidenav/sidenav.component.html
@@ -1,8 +1,7 @@