From fa0d10c419e2a3b6072e51fe27c7ca679807ea80 Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Mon, 3 Sep 2018 19:28:15 +0100 Subject: [PATCH] extra app modules (#596) * toolbar module * lazy load Settings * fix build * remove duplicate build for e2e * Revert "remove duplicate build for e2e" This reverts commit 94b872239b91ba5c6e25217673768d665ad67de0. --- src/app/app.module.ts | 19 ++----- src/app/app.routes.ts | 3 +- src/app/components/preview/preview.module.ts | 4 +- .../components/settings/settings.module.ts | 47 ++++++++++++++++ .../toolbar-action.component.html | 0 .../toolbar-action.component.ts | 2 +- .../toolbar-button.component.html | 28 ++++++++++ .../toolbar-button.component.ts | 33 +---------- src/app/components/toolbar/toolbar.module.ts | 56 +++++++++++++++++++ src/app/extensions/core.extensions.module.ts | 10 ---- 10 files changed, 143 insertions(+), 59 deletions(-) create mode 100644 src/app/components/settings/settings.module.ts rename src/app/{extensions/components/toolbar => components/toolbar/toolbar-action}/toolbar-action.component.html (100%) rename src/app/{extensions/components/toolbar => components/toolbar/toolbar-action}/toolbar-action.component.ts (96%) create mode 100644 src/app/components/toolbar/toolbar-button/toolbar-button.component.html rename src/app/{extensions/components/toolbar => components/toolbar/toolbar-button}/toolbar-button.component.ts (62%) create mode 100644 src/app/components/toolbar/toolbar.module.ts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 7dda8ed0f..9aa1fc6c1 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -56,7 +56,6 @@ import { ContentManagementService } from './services/content-management.service' import { NodeActionsService } from './services/node-actions.service'; import { NodePermissionService } from './services/node-permission.service'; import { SearchResultsComponent } from './components/search/search-results/search-results.component'; -import { SettingsComponent } from './components/settings/settings.component'; import { ProfileResolver } from './services/profile.resolver'; import { ExperimentalGuard } from './services/experimental-guard.service'; @@ -71,11 +70,9 @@ import { PermissionsManagerComponent } from './components/permission-manager/per import { AppRouteReuseStrategy } from './app.routes.strategy'; import { AppInfoDrawerModule } from './components/info-drawer/info.drawer.module'; import { DirectivesModule } from './directives/directives.module'; -import { ToggleInfoDrawerComponent } from './components/toolbar/toggle-info-drawer/toggle-info-drawer.component'; -import { DocumentDisplayModeComponent } from './components/toolbar/document-display-mode/document-display-mode.component'; -import { ToggleFavoriteComponent } from './components/toolbar/toggle-favorite/toggle-favorite.component'; import { ContextMenuModule } from './components/context-menu/context-menu.module'; import { ExtensionsModule } from '@alfresco/adf-extensions'; +import { AppToolbarModule } from './components/toolbar/toolbar.module'; @NgModule({ imports: [ @@ -97,7 +94,8 @@ import { ExtensionsModule } from '@alfresco/adf-extensions'; DirectivesModule, ContextMenuModule.forRoot(), - AppInfoDrawerModule + AppInfoDrawerModule, + AppToolbarModule ], declarations: [ AppComponent, @@ -122,11 +120,7 @@ import { ExtensionsModule } from '@alfresco/adf-extensions'; NodePermissionsDialogComponent, PermissionsManagerComponent, SearchResultsComponent, - SettingsComponent, - SharedLinkViewComponent, - ToggleInfoDrawerComponent, - DocumentDisplayModeComponent, - ToggleFavoriteComponent + SharedLinkViewComponent ], providers: [ { provide: RouteReuseStrategy, useClass: AppRouteReuseStrategy }, @@ -149,10 +143,7 @@ import { ExtensionsModule } from '@alfresco/adf-extensions'; entryComponents: [ LibraryDialogComponent, NodeVersionsDialogComponent, - NodePermissionsDialogComponent, - ToggleInfoDrawerComponent, - DocumentDisplayModeComponent, - ToggleFavoriteComponent + NodePermissionsDialogComponent ], bootstrap: [AppComponent] }) diff --git a/src/app/app.routes.ts b/src/app/app.routes.ts index 64ab1553c..f6dea60bd 100644 --- a/src/app/app.routes.ts +++ b/src/app/app.routes.ts @@ -39,7 +39,6 @@ import { TrashcanComponent } from './components/trashcan/trashcan.component'; import { LoginComponent } from './components/login/login.component'; import { GenericErrorComponent } from './components/generic-error/generic-error.component'; import { SearchResultsComponent } from './components/search/search-results/search-results.component'; -import { SettingsComponent } from './components/settings/settings.component'; import { ProfileResolver } from './services/profile.resolver'; @@ -53,7 +52,7 @@ export const APP_ROUTES: Routes = [ }, { path: 'settings', - component: SettingsComponent, + loadChildren: 'src/app/components/settings/settings.module#AppSettingsModule', data: { title: 'Settings' } diff --git a/src/app/components/preview/preview.module.ts b/src/app/components/preview/preview.module.ts index 1e91bcad8..9e3adcf2c 100644 --- a/src/app/components/preview/preview.module.ts +++ b/src/app/components/preview/preview.module.ts @@ -34,6 +34,7 @@ import { AppInfoDrawerModule } from '../info-drawer/info.drawer.module'; import { PreviewComponent } from './preview.component'; import { ViewUtilService } from './view-util.service'; import { PreviewExtensionComponent } from './preview-extension.component'; +import { AppToolbarModule } from '../toolbar/toolbar.module'; const routes: Routes = [ { @@ -50,7 +51,8 @@ const routes: Routes = [ ContentDirectiveModule, DirectivesModule, AppInfoDrawerModule, - CoreExtensionsModule.forChild() + CoreExtensionsModule.forChild(), + AppToolbarModule ], declarations: [ PreviewComponent, diff --git a/src/app/components/settings/settings.module.ts b/src/app/components/settings/settings.module.ts new file mode 100644 index 000000000..884bb297b --- /dev/null +++ b/src/app/components/settings/settings.module.ts @@ -0,0 +1,47 @@ +/*! + * @license + * Alfresco Example Content Application + * + * Copyright (C) 2005 - 2018 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 { SettingsComponent } from './settings.component'; +import { Routes, RouterModule } from '@angular/router'; +import { CommonModule } from '@angular/common'; +import { CoreModule } from '@alfresco/adf-core'; + +const routes: Routes = [ + { + path: '', + component: SettingsComponent + } +]; + +@NgModule({ + imports: [ + CommonModule, + CoreModule.forChild(), + RouterModule.forChild(routes) + ], + declarations: [SettingsComponent] +}) +export class AppSettingsModule {} diff --git a/src/app/extensions/components/toolbar/toolbar-action.component.html b/src/app/components/toolbar/toolbar-action/toolbar-action.component.html similarity index 100% rename from src/app/extensions/components/toolbar/toolbar-action.component.html rename to src/app/components/toolbar/toolbar-action/toolbar-action.component.html diff --git a/src/app/extensions/components/toolbar/toolbar-action.component.ts b/src/app/components/toolbar/toolbar-action/toolbar-action.component.ts similarity index 96% rename from src/app/extensions/components/toolbar/toolbar-action.component.ts rename to src/app/components/toolbar/toolbar-action/toolbar-action.component.ts index 78eeceb8c..acaece0d0 100644 --- a/src/app/extensions/components/toolbar/toolbar-action.component.ts +++ b/src/app/components/toolbar/toolbar-action/toolbar-action.component.ts @@ -31,8 +31,8 @@ import { } from '@angular/core'; import { AppStore } from '../../../store/states'; import { Store } from '@ngrx/store'; -import { AppExtensionService } from '../../extension.service'; import { ContentActionRef } from '@alfresco/adf-extensions'; +import { AppExtensionService } from '../../../extensions/extension.service'; @Component({ selector: 'aca-toolbar-action', diff --git a/src/app/components/toolbar/toolbar-button/toolbar-button.component.html b/src/app/components/toolbar/toolbar-button/toolbar-button.component.html new file mode 100644 index 000000000..a8b484f68 --- /dev/null +++ b/src/app/components/toolbar/toolbar-button/toolbar-button.component.html @@ -0,0 +1,28 @@ + + + + + + + + diff --git a/src/app/extensions/components/toolbar/toolbar-button.component.ts b/src/app/components/toolbar/toolbar-button/toolbar-button.component.ts similarity index 62% rename from src/app/extensions/components/toolbar/toolbar-button.component.ts rename to src/app/components/toolbar/toolbar-button/toolbar-button.component.ts index e05a3d50f..345413ef4 100644 --- a/src/app/extensions/components/toolbar/toolbar-button.component.ts +++ b/src/app/components/toolbar/toolbar-button/toolbar-button.component.ts @@ -25,11 +25,11 @@ import { Component, Input } from '@angular/core'; import { ContentActionRef } from '@alfresco/adf-extensions'; -import { AppExtensionService } from '../../extension.service'; import { Store } from '@ngrx/store'; import { AppStore } from '../../../store/states'; import { appSelection } from '../../../store/selectors/app.selectors'; import { take } from 'rxjs/operators'; +import { AppExtensionService } from '../../../extensions/extension.service'; export enum ToolbarButtonType { ICON_BUTTON = 'icon-button', @@ -38,36 +38,7 @@ export enum ToolbarButtonType { @Component({ selector: 'app-toolbar-button', - template: ` - - - - - - - - - ` + templateUrl: 'toolbar-button.component.html' }) export class ToolbarButtonComponent { @Input() type: ToolbarButtonType = ToolbarButtonType.ICON_BUTTON; diff --git a/src/app/components/toolbar/toolbar.module.ts b/src/app/components/toolbar/toolbar.module.ts new file mode 100644 index 000000000..c499242c3 --- /dev/null +++ b/src/app/components/toolbar/toolbar.module.ts @@ -0,0 +1,56 @@ +/*! + * @license + * Alfresco Example Content Application + * + * Copyright (C) 2005 - 2018 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 { DocumentDisplayModeComponent } from './document-display-mode/document-display-mode.component'; +import { ToggleFavoriteComponent } from './toggle-favorite/toggle-favorite.component'; +import { ToggleInfoDrawerComponent } from './toggle-info-drawer/toggle-info-drawer.component'; +import { CommonModule } from '@angular/common'; +import { CoreModule } from '@alfresco/adf-core'; +import { ToolbarButtonComponent } from './toolbar-button/toolbar-button.component'; +import { ToolbarActionComponent } from './toolbar-action/toolbar-action.component'; +import { ExtensionsModule } from '@alfresco/adf-extensions'; + +export function components() { + return [ + DocumentDisplayModeComponent, + ToggleFavoriteComponent, + ToggleInfoDrawerComponent, + ToolbarButtonComponent, + ToolbarActionComponent + ]; +} + +@NgModule({ + imports: [ + CommonModule, + CoreModule.forChild(), + ExtensionsModule.forChild() + ], + declarations: components(), + exports: components(), + entryComponents: components() +}) +export class AppToolbarModule {} diff --git a/src/app/extensions/core.extensions.module.ts b/src/app/extensions/core.extensions.module.ts index f1ee331de..da2648e87 100644 --- a/src/app/extensions/core.extensions.module.ts +++ b/src/app/extensions/core.extensions.module.ts @@ -28,13 +28,11 @@ import { CommonModule } from '@angular/common'; import { APP_INITIALIZER, ModuleWithProviders, NgModule } from '@angular/core'; import { LayoutComponent } from '../components/layout/layout.component'; import { TrashcanComponent } from '../components/trashcan/trashcan.component'; -import { ToolbarActionComponent } from './components/toolbar/toolbar-action.component'; import * as app from './evaluators/app.evaluators'; import * as nav from './evaluators/navigation.evaluators'; import { AppExtensionService } from './extension.service'; import { ToggleInfoDrawerComponent } from '../components/toolbar/toggle-info-drawer/toggle-info-drawer.component'; import { ToggleFavoriteComponent } from '../components/toolbar/toggle-favorite/toggle-favorite.component'; -import { ToolbarButtonComponent } from './components/toolbar/toolbar-button.component'; import { MetadataTabComponent } from '../components/info-drawer/metadata-tab/metadata-tab.component'; import { CommentsTabComponent } from '../components/info-drawer/comments-tab/comments-tab.component'; import { VersionsTabComponent } from '../components/info-drawer/versions-tab/versions-tab.component'; @@ -49,14 +47,6 @@ export function setupExtensions(service: AppExtensionService): Function { CommonModule, CoreModule.forChild(), ExtensionsModule.forChild() - ], - declarations: [ - ToolbarActionComponent, - ToolbarButtonComponent - ], - exports: [ - ToolbarActionComponent, - ToolbarButtonComponent ] }) export class CoreExtensionsModule {