diff --git a/e2e/suites/authentication/login.test.ts b/e2e/suites/authentication/login.test.ts index 7aafe277d..b70e69211 100755 --- a/e2e/suites/authentication/login.test.ts +++ b/e2e/suites/authentication/login.test.ts @@ -24,7 +24,7 @@ */ import { browser } from 'protractor'; -import { AdminActions, APP_ROUTES, LoginPage, BrowsingPage, Utils, navigate } from '@alfresco/aca-testing-shared'; +import { AdminActions, APP_ROUTES, LoginPage, Utils, navigate } from '@alfresco/aca-testing-shared'; describe('Login', () => { const loginPage = new LoginPage(); @@ -101,14 +101,6 @@ describe('Login', () => { expect(await browser.getCurrentUrl()).toContain(APP_ROUTES.PERSONAL_FILES); }); - it(`[C213108] displays user's name in header`, async () => { - const { userInfo } = new BrowsingPage(APP_ROUTES.PERSONAL_FILES).header; - const { username, firstName, lastName } = johnDoe; - - await loginPage.loginWith(username); - expect(await userInfo.fullName.getText()).toEqual(`${firstName} ${lastName}`); - }); - it(`[C213096] logs in with user having username containing "@"`, async () => { await loginPage.loginWith(testUser); expect(await browser.getCurrentUrl()).toContain(APP_ROUTES.PERSONAL_FILES); diff --git a/projects/aca-shared/src/lib/services/app.extension.service.spec.ts b/projects/aca-shared/src/lib/services/app.extension.service.spec.ts index 28b02238b..19650bbed 100644 --- a/projects/aca-shared/src/lib/services/app.extension.service.spec.ts +++ b/projects/aca-shared/src/lib/services/app.extension.service.spec.ts @@ -721,68 +721,6 @@ describe('AppExtensionService', () => { }); }); - describe('userActions', () => { - it('should load user actions from the config', () => { - applyConfig({ - $id: 'test', - $name: 'test', - $version: '1.0.0', - $license: 'MIT', - $vendor: 'Good company', - $runtime: '1.5.0', - features: { - userActions: [ - { - id: 'aca:toolbar/separator-1', - order: 1, - type: ContentActionType.separator, - title: 'action1' - }, - { - id: 'aca:toolbar/separator-2', - order: 2, - type: ContentActionType.separator, - title: 'action2' - } - ] - } - }); - - expect(service.userActions.length).toBe(2); - }); - - it('should sort user actions by order', () => { - applyConfig({ - $id: 'test', - $name: 'test', - $version: '1.0.0', - $license: 'MIT', - $vendor: 'Good company', - $runtime: '1.5.0', - features: { - userActions: [ - { - id: 'aca:toolbar/action-2', - order: 2, - type: ContentActionType.button, - title: 'action2' - }, - { - id: 'aca:toolbar/action-1', - order: 1, - type: ContentActionType.button, - title: 'action1' - } - ] - } - }); - - const actions = service.getUserActions(); - expect(actions[0].id).toBe('aca:toolbar/action-1'); - expect(actions[1].id).toBe('aca:toolbar/action-2'); - }); - }); - describe('getHeaderActions', () => { it('should load user actions from the config', () => { applyConfig({ diff --git a/projects/aca-shared/src/lib/services/app.extension.service.ts b/projects/aca-shared/src/lib/services/app.extension.service.ts index dc3435101..746b9ff9d 100644 --- a/projects/aca-shared/src/lib/services/app.extension.service.ts +++ b/projects/aca-shared/src/lib/services/app.extension.service.ts @@ -74,7 +74,6 @@ export class AppExtensionService implements RuleContext { sidebarActions: Array = []; contentMetadata: any; viewerRules: ViewerRules = {}; - userActions: Array = []; settingGroups: Array = []; documentListPresets: { @@ -150,7 +149,6 @@ export class AppExtensionService implements RuleContext { this.createActions = this.loader.getElements(config, 'features.create'); this.navbar = this.loadNavBar(config); this.sidebarTabs = this.loader.getElements(config, 'features.sidebar.tabs'); - this.userActions = this.loader.getContentActions(config, 'features.userActions'); this.contentMetadata = this.loadContentMetadata(config); this.documentListPresets = { @@ -416,10 +414,6 @@ export class AppExtensionService implements RuleContext { return this.getAllowedActions(this.contextMenuActions); } - getUserActions(): Array { - return this.userActions.filter((action) => this.filterVisible(action)).sort(sortByOrder); - } - getSettingsGroups(): Array { return this.settingGroups.filter((group) => this.filterVisible(group)); } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 7d779c930..71e3b07a9 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -54,7 +54,6 @@ import { AppSidenavModule } from './components/sidenav/sidenav.module'; import { AppPermissionsModule } from './components/permissions/permissions.module'; import { AppCommonModule } from './components/common/common.module'; import { AppLayoutModule } from './components/layout/layout.module'; -import { AppCurrentUserModule } from './components/current-user/current-user.module'; import { AppSearchInputModule } from './components/search/search-input.module'; import { DocumentListCustomComponentsModule } from './components/dl-custom-components/document-list-custom-components.module'; import { AppSearchResultsModule } from './components/search/search-results.module'; @@ -124,7 +123,6 @@ registerLocaleData(localeSv); AppLoginModule, AppCommonModule, AppLayoutModule, - AppCurrentUserModule, DirectivesModule, ContextMenuModule, AppInfoDrawerModule, diff --git a/src/app/components/current-user/current-user.component.html b/src/app/components/current-user/current-user.component.html deleted file mode 100644 index 87092e647..000000000 --- a/src/app/components/current-user/current-user.component.html +++ /dev/null @@ -1,22 +0,0 @@ -
-
{{ (profile$ | async)?.userName }}
- -
- - - - - - diff --git a/src/app/components/current-user/current-user.component.spec.ts b/src/app/components/current-user/current-user.component.spec.ts deleted file mode 100644 index cff80be8c..000000000 --- a/src/app/components/current-user/current-user.component.spec.ts +++ /dev/null @@ -1,97 +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 { CurrentUserComponent } from './current-user.component'; -import { TestBed, ComponentFixture } from '@angular/core/testing'; -import { AppTestingModule } from '../../testing/app-testing.module'; -import { NO_ERRORS_SCHEMA } from '@angular/core'; -import { Store } from '@ngrx/store'; -import { AppState, SetUserProfileAction } from '@alfresco/aca-shared/store'; -import { AppExtensionService } from '@alfresco/aca-shared'; - -describe('CurrentUserComponent', () => { - let fixture: ComponentFixture; - let component: CurrentUserComponent; - let appExtensionService; - let store: Store; - const person = { - entry: { - id: 'user-id', - firstName: 'Test', - lastName: 'User', - email: 'user@email.com', - enabled: true, - isAdmin: false, - userName: 'user-name' - } - }; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [AppTestingModule], - declarations: [CurrentUserComponent], - providers: [AppExtensionService], - schemas: [NO_ERRORS_SCHEMA] - }); - - fixture = TestBed.createComponent(CurrentUserComponent); - appExtensionService = TestBed.inject(AppExtensionService); - store = TestBed.inject(Store); - component = fixture.componentInstance; - }); - - it('should get profile data', (done) => { - const expectedProfile = { - firstName: 'Test', - lastName: 'User', - userName: 'Test User', - isAdmin: true, - id: 'user-id', - groups: [] - }; - - fixture.detectChanges(); - - store.dispatch(new SetUserProfileAction({ person: person.entry, groups: [] })); - - component.profile$.subscribe((profile: any) => { - expect(profile).toEqual(jasmine.objectContaining(expectedProfile)); - done(); - }); - }); - - it('should set menu actions', () => { - const actions: any[] = [ - { - id: 'action-id' - } - ]; - spyOn(appExtensionService, 'getUserActions').and.returnValue(actions); - - fixture.detectChanges(); - - expect(component.actions).toBe(actions); - }); -}); diff --git a/src/app/components/current-user/current-user.component.theme.scss b/src/app/components/current-user/current-user.component.theme.scss deleted file mode 100644 index a07979960..000000000 --- a/src/app/components/current-user/current-user.component.theme.scss +++ /dev/null @@ -1,44 +0,0 @@ -@mixin aca-current-user-theme($theme) { - $background: map-get($theme, background); - $am-avatar-size: 35px; - - .aca-current-user { - position: relative; - color: mat-color($background, card); - line-height: 20px; - - .am-avatar { - margin-left: 9px; - cursor: pointer; - display: inline-block; - width: $am-avatar-size; - height: $am-avatar-size; - line-height: $am-avatar-size; - font-size: 1em; - text-align: center; - color: inherit; - border-radius: 100%; - background-color: mat-color($background, card, 0.12); - } - - .current-user__full-name { - max-width: 100px; - text-align: right; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - display: inline-block; - height: 18px; - font-size: 14px; - line-height: 1.43; - letter-spacing: -0.3px; - cursor: default; - } - - @media screen and ($mat-small) { - .current-user__full-name { - display: none; - } - } - } -} diff --git a/src/app/components/current-user/current-user.component.ts b/src/app/components/current-user/current-user.component.ts deleted file mode 100644 index 4d480d600..000000000 --- a/src/app/components/current-user/current-user.component.ts +++ /dev/null @@ -1,53 +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 { Component, ViewEncapsulation, OnInit } from '@angular/core'; -import { Store } from '@ngrx/store'; -import { Observable } from 'rxjs'; -import { ProfileState, ContentActionRef } from '@alfresco/adf-extensions'; -import { AppStore, getUserProfile } from '@alfresco/aca-shared/store'; -import { AppExtensionService } from '@alfresco/aca-shared'; - -@Component({ - selector: 'aca-current-user', - templateUrl: './current-user.component.html', - encapsulation: ViewEncapsulation.None, - host: { class: 'aca-current-user' } -}) -export class CurrentUserComponent implements OnInit { - profile$: Observable; - actions: Array = []; - - constructor(private store: Store, private extensions: AppExtensionService) {} - - ngOnInit() { - this.profile$ = this.store.select(getUserProfile); - this.actions = this.extensions.getUserActions(); - } - - trackByActionId(_: number, action: ContentActionRef) { - return action.id; - } -} diff --git a/src/app/components/current-user/current-user.module.ts b/src/app/components/current-user/current-user.module.ts deleted file mode 100644 index a16783118..000000000 --- a/src/app/components/current-user/current-user.module.ts +++ /dev/null @@ -1,39 +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 { CoreModule } from '@alfresco/adf-core'; -import { ExtensionsModule } from '@alfresco/adf-extensions'; -import { CurrentUserComponent } from './current-user.component'; -import { UserMenuItemComponent } from './user-menu-item.component'; -import { RouterModule } from '@angular/router'; - -@NgModule({ - imports: [CommonModule, CoreModule.forChild(), RouterModule, ExtensionsModule], - declarations: [CurrentUserComponent, UserMenuItemComponent], - exports: [CurrentUserComponent, UserMenuItemComponent] -}) -export class AppCurrentUserModule {} diff --git a/src/app/components/current-user/user-menu-item.component.html b/src/app/components/current-user/user-menu-item.component.html deleted file mode 100644 index a6209b143..000000000 --- a/src/app/components/current-user/user-menu-item.component.html +++ /dev/null @@ -1,36 +0,0 @@ - diff --git a/src/app/components/current-user/user-menu-item.component.spec.ts b/src/app/components/current-user/user-menu-item.component.spec.ts deleted file mode 100644 index c050a23ae..000000000 --- a/src/app/components/current-user/user-menu-item.component.spec.ts +++ /dev/null @@ -1,118 +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 { TestBed, ComponentFixture } from '@angular/core/testing'; -import { AppTestingModule } from '../../testing/app-testing.module'; -import { UserMenuItemComponent } from './user-menu-item.component'; -import { TranslateModule, TranslateLoader, TranslateFakeLoader } from '@ngx-translate/core'; -import { NO_ERRORS_SCHEMA } from '@angular/core'; -import { ContentActionRef } from '@alfresco/adf-extensions'; -import { AppExtensionService } from '@alfresco/aca-shared'; - -describe('UserMenuItemComponent', () => { - let fixture: ComponentFixture; - let component: UserMenuItemComponent; - let appExtensionService; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ - AppTestingModule, - TranslateModule.forRoot({ - loader: { provide: TranslateLoader, useClass: TranslateFakeLoader } - }) - ], - declarations: [UserMenuItemComponent], - providers: [AppExtensionService], - schemas: [NO_ERRORS_SCHEMA] - }); - - fixture = TestBed.createComponent(UserMenuItemComponent); - appExtensionService = TestBed.inject(AppExtensionService); - component = fixture.componentInstance; - }); - - afterEach(() => { - fixture.destroy(); - }); - - it('should render button action', () => { - component.actionRef = { - id: 'action-button', - title: 'Test Button', - actions: { - click: 'TEST_EVENT' - } - } as ContentActionRef; - fixture.detectChanges(); - - const buttonElement = fixture.nativeElement.querySelector('#action-button'); - expect(buttonElement).not.toBe(null); - }); - - it('should render menu action', () => { - component.actionRef = { - type: 'menu', - id: 'action-menu', - title: 'Test Button', - actions: { - click: 'TEST_EVENT' - } - } as ContentActionRef; - fixture.detectChanges(); - - const menuElement = fixture.nativeElement.querySelector('#action-menu'); - expect(menuElement).not.toBe(null); - }); - - it('should render custom action', () => { - component.actionRef = { - type: 'custom', - id: 'action-custom', - component: 'custom-component' - } as ContentActionRef; - fixture.detectChanges(); - - const componentElement = fixture.nativeElement.querySelector('#custom-component'); - expect(componentElement).not.toBe(null); - }); - - it('should run defined action', () => { - spyOn(appExtensionService, 'runActionById'); - - component.actionRef = { - id: 'action-button', - title: 'Test Button', - actions: { - click: 'TEST_EVENT' - } - } as ContentActionRef; - fixture.detectChanges(); - - const buttonElement = fixture.nativeElement.querySelector('#action-button'); - buttonElement.dispatchEvent(new MouseEvent('click')); - expect(appExtensionService.runActionById).toHaveBeenCalledWith('TEST_EVENT'); - }); -}); diff --git a/src/app/components/current-user/user-menu-item.component.ts b/src/app/components/current-user/user-menu-item.component.ts deleted file mode 100644 index 8bc4d3754..000000000 --- a/src/app/components/current-user/user-menu-item.component.ts +++ /dev/null @@ -1,58 +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 { Component, Input, ViewEncapsulation } from '@angular/core'; -import { ContentActionRef } from '@alfresco/adf-extensions'; -import { AppExtensionService } from '@alfresco/aca-shared'; - -@Component({ - selector: 'app-user-menu-item', - templateUrl: 'user-menu-item.component.html', - encapsulation: ViewEncapsulation.None, - host: { class: 'app-user-menu-item' } -}) -export class UserMenuItemComponent { - @Input() - actionRef: ContentActionRef; - - constructor(private extensions: AppExtensionService) {} - - runAction() { - if (this.hasClickAction(this.actionRef)) { - this.extensions.runActionById(this.actionRef.actions.click); - } - } - - private hasClickAction(actionRef: ContentActionRef): boolean { - if (actionRef && actionRef.actions && actionRef.actions.click) { - return true; - } - return false; - } - - trackById(_: number, obj: { id: string }) { - return obj.id; - } -} diff --git a/src/app/components/header/header.module.ts b/src/app/components/header/header.module.ts index 65cb4b020..21381e4ff 100644 --- a/src/app/components/header/header.module.ts +++ b/src/app/components/header/header.module.ts @@ -27,12 +27,11 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { CoreModule } from '@alfresco/adf-core'; import { AppHeaderComponent } from './header.component'; -import { AppCurrentUserModule } from '../current-user/current-user.module'; import { AppSearchInputModule } from '../search/search-input.module'; import { AppToolbarModule } from '../toolbar/toolbar.module'; @NgModule({ - imports: [CommonModule, CoreModule.forChild(), AppCurrentUserModule, AppSearchInputModule, AppToolbarModule], + imports: [CommonModule, CoreModule.forChild(), AppSearchInputModule, AppToolbarModule], declarations: [AppHeaderComponent], exports: [AppHeaderComponent] }) diff --git a/src/app/extensions/core.extensions.module.ts b/src/app/extensions/core.extensions.module.ts index 3d3fe9c41..ae7e16baa 100644 --- a/src/app/extensions/core.extensions.module.ts +++ b/src/app/extensions/core.extensions.module.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { CoreModule, AuthGuardEcm } from '@alfresco/adf-core'; +import { CoreModule, AuthGuardEcm, UserInfoComponent } from '@alfresco/adf-core'; import { CommonModule } from '@angular/common'; import { APP_INITIALIZER, ModuleWithProviders, NgModule } from '@angular/core'; import { AppLayoutComponent } from '../components/layout/app-layout/app-layout.component'; @@ -52,7 +52,6 @@ import { ToggleSharedComponent } from '../components/common/toggle-shared/toggle import { ViewNodeComponent } from '../components/toolbar/view-node/view-node.component'; import { LanguagePickerComponent } from '../components/common/language-picker/language-picker.component'; import { LogoutComponent } from '../components/common/logout/logout.component'; -import { CurrentUserComponent } from '../components/current-user/current-user.component'; import { AppExtensionService, ExtensionsDataLoaderGuard } from '@alfresco/aca-shared'; import { PreviewComponent } from '../components/preview/preview.component'; @@ -109,7 +108,7 @@ export class CoreExtensionsModule { 'app.toolbar.viewNode': ViewNodeComponent, 'app.languagePicker': LanguagePickerComponent, 'app.logout': LogoutComponent, - 'app.user': CurrentUserComponent + 'app.user': UserInfoComponent }); extensions.setAuthGuards({ diff --git a/src/app/ui/custom-theme.scss b/src/app/ui/custom-theme.scss index c2aad486d..7dcc5406d 100644 --- a/src/app/ui/custom-theme.scss +++ b/src/app/ui/custom-theme.scss @@ -4,7 +4,6 @@ @import '../components/sidenav/sidenav.component.theme'; @import '../components/search/search-input/search-input.component.theme'; @import '../components/search/search-results-row/search-results-row.component.scss'; -@import '../components/current-user/current-user.component.theme'; @import '../components/permissions/permission-manager/permission-manager.component.theme'; @import '../components/context-menu/context-menu.component.theme'; @import '../components/dl-custom-components/name-column/name-column.component.scss'; @@ -41,7 +40,6 @@ $warn: map-get($custom-theme, warn); @include aca-node-versions-dialog-theme($theme); @include snackbar-theme($theme); @include sidenav-component-theme($theme); - @include aca-current-user-theme($theme); @include aca-context-menu-theme($theme); @include aca-custom-name-column-theme($theme); @include app-create-from-template-theme($theme);