From 961d3896e2b08e3788667ac3c8d4ed50ecd8ce4b Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Thu, 28 Nov 2019 18:53:24 +0000 Subject: [PATCH] [ACA-2834][ACA-2837][ACA-2835] regression fixes (#1270) * disable lazy loading for certain routes * backwards compatibility for old viewer routes * remove old lazy modules --- .../aca-shared/rules/src/navigation.rules.ts | 19 +++- src/app/app.module.ts | 9 +- src/app/app.routes.ts | 93 +++++++++++++++++-- .../components/favorites/favorites.module.ts | 66 ------------- .../recent-files/recent-files.module.ts | 65 ------------- .../shared-files/shared-files.module.ts | 66 ------------- 6 files changed, 111 insertions(+), 207 deletions(-) delete mode 100644 src/app/components/favorites/favorites.module.ts delete mode 100644 src/app/components/recent-files/recent-files.module.ts delete mode 100644 src/app/components/shared-files/shared-files.module.ts diff --git a/projects/aca-shared/rules/src/navigation.rules.ts b/projects/aca-shared/rules/src/navigation.rules.ts index 2cf05544f6..1a8c02a3ad 100644 --- a/projects/aca-shared/rules/src/navigation.rules.ts +++ b/projects/aca-shared/rules/src/navigation.rules.ts @@ -31,7 +31,12 @@ import { RuleContext } from '@alfresco/adf-extensions'; */ export function isPreview(context: RuleContext): boolean { const { url } = context.navigation; - return url && (url.includes('viewer:view') || url.includes('/view/')); + return ( + url && + (url.includes('/preview/') || + url.includes('viewer:view') || + url.includes('/view/')) + ); } /** @@ -165,7 +170,11 @@ export function isNotSearchResults(context: RuleContext): boolean { */ export function isSharedPreview(context: RuleContext): boolean { const { url } = context.navigation; - return url && url.startsWith('/shared') && url.includes('viewer:view'); + return ( + url && + (url.startsWith('/shared/preview/') || + (url.startsWith('/shared') && url.includes('viewer:view'))) + ); } /** @@ -174,7 +183,11 @@ export function isSharedPreview(context: RuleContext): boolean { */ export function isFavoritesPreview(context: RuleContext): boolean { const { url } = context.navigation; - return url && url.startsWith('/favorites') && url.includes('viewer:view'); + return ( + url && + (url.startsWith('/favorites/preview/') || + (url.startsWith('/favorites') && url.includes('viewer:view'))) + ); } /** diff --git a/src/app/app.module.ts b/src/app/app.module.ts index bdb487aff8..ec362240d6 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -73,6 +73,10 @@ import { AppSearchResultsModule } from './components/search/search-results.modul import { AppLoginModule } from './components/login/login.module'; import { AppHeaderModule } from './components/header/header.module'; import { AppNodeVersionModule } from './components/node-version/node-version.module'; +import { FavoritesComponent } from './components/favorites/favorites.component'; +import { RecentFilesComponent } from './components/recent-files/recent-files.component'; +import { SharedFilesComponent } from './components/shared-files/shared-files.component'; + import { environment } from '../environments/environment'; import { registerLocaleData } from '@angular/common'; @@ -151,7 +155,10 @@ registerLocaleData(localeSv); LibrariesComponent, FavoriteLibrariesComponent, NodeVersionUploadDialogComponent, - NodeVersionsDialogComponent + NodeVersionsDialogComponent, + FavoritesComponent, + RecentFilesComponent, + SharedFilesComponent ], providers: [ { provide: RouteReuseStrategy, useClass: AppRouteReuseStrategy }, diff --git a/src/app/app.routes.ts b/src/app/app.routes.ts index 1d27ecc25e..45f8d78186 100644 --- a/src/app/app.routes.ts +++ b/src/app/app.routes.ts @@ -36,6 +36,9 @@ import { GenericErrorComponent } from '@alfresco/aca-shared'; import { AuthGuardEcm, AuthGuard } from '@alfresco/adf-core'; +import { FavoritesComponent } from './components/favorites/favorites.component'; +import { RecentFilesComponent } from './components/recent-files/recent-files.component'; +import { SharedFilesComponent } from './components/shared-files/shared-files.component'; export const APP_ROUTES: Routes = [ { @@ -92,6 +95,14 @@ export const APP_ROUTES: Routes = [ defaultNodeId: '-my-' } }, + // deprecated, backwards compatibility with ACA 1.8 + { + path: 'preview/:nodeId', + loadChildren: './components/preview/preview.module#PreviewModule', + data: { + navigateSource: 'personal-files' + } + }, { path: 'view/:nodeId', outlet: 'viewer', @@ -119,6 +130,22 @@ export const APP_ROUTES: Routes = [ sortingPreferenceKey: 'personal-files' } }, + // deprecated, backwards compatibility with ACA 1.8 + { + path: 'preview/:nodeId', + loadChildren: './components/preview/preview.module#PreviewModule', + data: { + navigateSource: 'personal-files' + } + }, + // deprecated, backwards compatibility with ACA 1.8 + { + path: ':folderId/preview/:nodeId', + loadChildren: './components/preview/preview.module#PreviewModule', + data: { + navigateSource: 'personal-files' + } + }, { path: 'view/:nodeId', outlet: 'viewer', @@ -159,6 +186,14 @@ export const APP_ROUTES: Routes = [ sortingPreferenceKey: 'libraries-files' } }, + // deprecated, backwards compatibility with ACA 1.8 + { + path: 'preview/:nodeId', + loadChildren: './components/preview/preview.module#PreviewModule', + data: { + navigateSource: 'libraries' + } + }, { path: 'view/:nodeId', outlet: 'viewer', @@ -196,8 +231,21 @@ export const APP_ROUTES: Routes = [ children: [ { path: '', - loadChildren: - './components/favorites/favorites.module#AppFavoritesModule' + component: FavoritesComponent, + data: { + title: 'APP.BROWSE.FAVORITES.TITLE', + sortingPreferenceKey: 'favorites' + } + // loadChildren: + // './components/favorites/favorites.module#AppFavoritesModule' + }, + // deprecated, backwards compatibility with ACA 1.8 + { + path: 'preview/:nodeId', + loadChildren: './components/preview/preview.module#PreviewModule', + data: { + navigateSource: 'favorites' + } }, { path: 'view/:nodeId', @@ -223,8 +271,20 @@ export const APP_ROUTES: Routes = [ children: [ { path: '', - loadChildren: - './components/recent-files/recent-files.module#AppRecentFilesModule' + component: RecentFilesComponent, + data: { + title: 'APP.BROWSE.RECENT.TITLE' + } + // loadChildren: + // './components/recent-files/recent-files.module#AppRecentFilesModule' + }, + // deprecated, backwards compatibility with ACA 1.8 + { + path: 'preview/:nodeId', + loadChildren: './components/preview/preview.module#PreviewModule', + data: { + navigateSource: 'recent-files' + } }, { path: 'view/:nodeId', @@ -247,8 +307,21 @@ export const APP_ROUTES: Routes = [ children: [ { path: '', - loadChildren: - './components/shared-files/shared-files.module#AppSharedFilesModule' + data: { + title: 'APP.BROWSE.SHARED.TITLE', + sortingPreferenceKey: 'shared-files' + }, + component: SharedFilesComponent + // loadChildren: + // './components/shared-files/shared-files.module#AppSharedFilesModule' + }, + // deprecated, backwards compatibility with ACA 1.8 + { + path: 'preview/:nodeId', + loadChildren: './components/preview/preview.module#PreviewModule', + data: { + navigateSource: 'shared' + } }, { path: 'view/:nodeId', @@ -286,6 +359,14 @@ export const APP_ROUTES: Routes = [ title: 'APP.BROWSE.SEARCH.TITLE' } }, + // deprecated, backwards compatibility with ACA 1.8 + { + path: 'preview/:nodeId', + loadChildren: './components/preview/preview.module#PreviewModule', + data: { + navigateSource: 'search' + } + }, { path: 'view/:nodeId', outlet: 'viewer', diff --git a/src/app/components/favorites/favorites.module.ts b/src/app/components/favorites/favorites.module.ts deleted file mode 100644 index 006ef1f7e2..0000000000 --- a/src/app/components/favorites/favorites.module.ts +++ /dev/null @@ -1,66 +0,0 @@ -/*! - * @license - * Alfresco Example Content Application - * - * Copyright (C) 2005 - 2019 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 { FavoritesComponent } from './favorites.component'; -import { CommonModule } from '@angular/common'; -import { CoreModule } from '@alfresco/adf-core'; -import { RouterModule, Routes } from '@angular/router'; -import { ContentModule } from '@alfresco/adf-content-services'; -import { DirectivesModule } from '../../directives/directives.module'; -import { AppCommonModule } from '../common/common.module'; -import { AppToolbarModule } from '../toolbar/toolbar.module'; -import { ContextMenuModule } from '../context-menu/context-menu.module'; -import { AppInfoDrawerModule } from '../info-drawer/info.drawer.module'; -import { AppLayoutModule } from '../layout/layout.module'; - -const routes: Routes = [ - { - path: '', - component: FavoritesComponent, - data: { - title: 'APP.BROWSE.FAVORITES.TITLE', - sortingPreferenceKey: 'favorites' - } - } -]; - -@NgModule({ - imports: [ - CommonModule, - CoreModule.forChild(), - RouterModule.forChild(routes), - ContentModule.forChild(), - DirectivesModule, - AppCommonModule, - AppToolbarModule, - ContextMenuModule, - AppInfoDrawerModule, - AppLayoutModule - ], - declarations: [FavoritesComponent], - exports: [FavoritesComponent] -}) -export class AppFavoritesModule {} diff --git a/src/app/components/recent-files/recent-files.module.ts b/src/app/components/recent-files/recent-files.module.ts deleted file mode 100644 index 908dc49fbe..0000000000 --- a/src/app/components/recent-files/recent-files.module.ts +++ /dev/null @@ -1,65 +0,0 @@ -/*! - * @license - * Alfresco Example Content Application - * - * Copyright (C) 2005 - 2019 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 { RouterModule, Routes } from '@angular/router'; -import { ContentModule } from '@alfresco/adf-content-services'; -import { DirectivesModule } from '../../directives/directives.module'; -import { AppCommonModule } from '../common/common.module'; -import { AppToolbarModule } from '../toolbar/toolbar.module'; -import { ContextMenuModule } from '../context-menu/context-menu.module'; -import { RecentFilesComponent } from './recent-files.component'; -import { AppInfoDrawerModule } from '../info-drawer/info.drawer.module'; -import { AppLayoutModule } from '../layout/layout.module'; - -const routes: Routes = [ - { - path: '', - component: RecentFilesComponent, - data: { - title: 'APP.BROWSE.RECENT.TITLE' - } - } -]; - -@NgModule({ - imports: [ - CommonModule, - CoreModule.forChild(), - RouterModule.forChild(routes), - ContentModule.forChild(), - DirectivesModule, - AppCommonModule, - AppToolbarModule, - ContextMenuModule, - AppInfoDrawerModule, - AppLayoutModule - ], - declarations: [RecentFilesComponent], - exports: [RecentFilesComponent] -}) -export class AppRecentFilesModule {} diff --git a/src/app/components/shared-files/shared-files.module.ts b/src/app/components/shared-files/shared-files.module.ts deleted file mode 100644 index eb10d2fd8c..0000000000 --- a/src/app/components/shared-files/shared-files.module.ts +++ /dev/null @@ -1,66 +0,0 @@ -/*! - * @license - * Alfresco Example Content Application - * - * Copyright (C) 2005 - 2019 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 { SharedFilesComponent } from './shared-files.component'; -import { CommonModule } from '@angular/common'; -import { CoreModule } from '@alfresco/adf-core'; -import { RouterModule, Routes } from '@angular/router'; -import { ContentModule } from '@alfresco/adf-content-services'; -import { DirectivesModule } from '../../directives/directives.module'; -import { AppCommonModule } from '../common/common.module'; -import { AppToolbarModule } from '../toolbar/toolbar.module'; -import { ContextMenuModule } from '../context-menu/context-menu.module'; -import { AppInfoDrawerModule } from '../info-drawer/info.drawer.module'; -import { AppLayoutModule } from '../layout/layout.module'; - -const routes: Routes = [ - { - path: '', - component: SharedFilesComponent, - data: { - title: 'APP.BROWSE.SHARED.TITLE', - sortingPreferenceKey: 'shared-files' - } - } -]; - -@NgModule({ - imports: [ - CommonModule, - CoreModule.forChild(), - RouterModule.forChild(routes), - ContentModule.forChild(), - DirectivesModule, - AppCommonModule, - AppToolbarModule, - ContextMenuModule, - AppInfoDrawerModule, - AppLayoutModule - ], - declarations: [SharedFilesComponent], - exports: [SharedFilesComponent] -}) -export class AppSharedFilesModule {}