diff --git a/.travis.yml b/.travis.yml index 26265fa1a..830eefc6f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,7 +50,7 @@ env: - APP_CONFIG_OAUTH2_HOST=http://localhost:4200/auth/realms/alfresco - APP_CONFIG_OAUTH2_CLIENTID=alfresco - APP_CONFIG_PLUGIN_AOS=true - - APP_CONFIG_CONTENT_SERVICE=true + - APP_CONFIG_PLUGIN_CONTENT_SERVICE=true - APP_CONFIG_OAUTH2_IMPLICIT_FLOW=true - APP_CONFIG_OAUTH2_SILENT_LOGIN=true - APP_CONFIG_OAUTH2_REDIRECT_LOGOUT=/ diff --git a/Dockerfile b/Dockerfile index d12ae6456..f343a2eff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,7 +34,7 @@ ENV APP_CONFIG_OAUTH2_REDIRECT_SILENT_IFRAME_URI="{protocol}//{hostname}{:port}/ ENV APP_CONFIG_OAUTH2_REDIRECT_LOGIN="/" ENV APP_CONFIG_OAUTH2_REDIRECT_LOGOUT="/" ENV APP_CONFIG_PLUGIN_AOS=true -ENV APP_CONFIG_CONTENT_SERVICE=true +ENV APP_CONFIG_PLUGIN_CONTENT_SERVICE=true COPY docker/default.conf.template /etc/nginx/templates/ COPY docker/docker-entrypoint.d/* /docker-entrypoint.d/ diff --git a/README.md b/README.md index 3619e1464..af17d3833 100644 --- a/README.md +++ b/README.md @@ -30,4 +30,4 @@ APP_CONFIG_OAUTH2_REDIRECT_LOGOUT=/ # CONTENT - ALFRESCO OFFICE SERVICES PLUGIN RELATED APP_CONFIG_PLUGIN_AOS=true # ALFRESCO CONTENT SERVICE RELATED -APP_CONFIG_CONTENT_SERVICE=true +APP_CONFIG_PLUGIN_CONTENT_SERVICE=true diff --git a/app/src/app.config.json.tpl b/app/src/app.config.json.tpl index 707f7d95e..213ab45b7 100644 --- a/app/src/app.config.json.tpl +++ b/app/src/app.config.json.tpl @@ -6,9 +6,9 @@ "providers": "${APP_CONFIG_PROVIDER}", "authType": "${APP_CONFIG_AUTH_TYPE}", "loginRoute": "login", - "plugins":{ - "aosPlugin" : ${APP_CONFIG_PLUGIN_AOS}, - "contentService": ${APP_CONFIG_CONTENT_SERVICE} + "plugins": { + "aosPlugin": ${APP_CONFIG_PLUGIN_AOS}, + "contentService": ${APP_CONFIG_PLUGIN_CONTENT_SERVICE} }, "oauth2": { "host": "${APP_CONFIG_OAUTH2_HOST}", diff --git a/app/src/app/app.module.ts b/app/src/app/app.module.ts index 6eee1cbde..2f5c0b711 100644 --- a/app/src/app/app.module.ts +++ b/app/src/app/app.module.ts @@ -66,6 +66,7 @@ import { CreateFromTemplateDialogComponent } from './dialogs/node-template/creat import { environment } from '../environments/environment'; import { DetailsComponent } from './components/details/details.component'; import { ContentUrlService } from './services/content-url.service'; +import { HomeComponent } from './components/home/home.component'; import { registerLocaleData } from '@angular/common'; import localeFr from '@angular/common/locales/fr'; @@ -146,7 +147,8 @@ registerLocaleData(localeSv); FavoritesComponent, RecentFilesComponent, SharedFilesComponent, - CreateFromTemplateDialogComponent + CreateFromTemplateDialogComponent, + HomeComponent ], providers: [ { provide: AppConfigService, useClass: DebugAppConfigService }, diff --git a/app/src/app/app.routes.ts b/app/src/app/app.routes.ts index 3943c365b..d3ff65a29 100644 --- a/app/src/app/app.routes.ts +++ b/app/src/app/app.routes.ts @@ -37,6 +37,7 @@ 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 { DetailsComponent } from './components/details/details.component'; +import { HomeComponent } from './components/home/home.component'; export const APP_ROUTES: Routes = [ { @@ -77,8 +78,7 @@ export const APP_ROUTES: Routes = [ children: [ { path: '', - redirectTo: `/personal-files`, - pathMatch: 'full' + component: HomeComponent }, { path: 'personal-files', diff --git a/app/src/app/components/header/header.component.html b/app/src/app/components/header/header.component.html index 1fb0aef2b..6efa2e878 100644 --- a/app/src/app/components/header/header.component.html +++ b/app/src/app/components/header/header.component.html @@ -1,6 +1,6 @@ ; headerTextColor$: Observable; logo$: Observable; + landingPage: string; actions: Array = []; - constructor(store: Store, private appExtensions: AppExtensionService) { + constructor(store: Store, private appExtensions: AppExtensionService, private appConfigService: AppConfigService) { this.headerColor$ = store.select(getHeaderColor); this.headerTextColor$ = store.select(getHeaderTextColor); this.appName$ = store.select(getAppName); this.logo$ = store.select(getLogoPath); + this.landingPage = this.appConfigService.get('landingPage', '/personal-files'); store.select(getHeaderImagePath).subscribe((path) => { document.body.style.setProperty('--header-background-image', `url('${path}')`); diff --git a/app/src/app/components/home/home.component.spec.ts b/app/src/app/components/home/home.component.spec.ts new file mode 100644 index 000000000..a0efdf143 --- /dev/null +++ b/app/src/app/components/home/home.component.spec.ts @@ -0,0 +1,41 @@ +import { HomeComponent } from './home.component'; +import { AppConfigService, AppConfigServiceMock, setupTestBed } from '@alfresco/adf-core'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { Router } from '@angular/router'; +import { HttpClientModule } from '@angular/common/http'; +import { RouterTestingModule } from '@angular/router/testing'; + +describe('HomeComponent', () => { + let appConfig: AppConfigService; + let fixture: ComponentFixture; + let router: Router; + + setupTestBed({ + imports: [HttpClientModule, RouterTestingModule], + providers: [{ provide: AppConfigService, useClass: AppConfigServiceMock }] + }); + + beforeEach(() => { + fixture = TestBed.createComponent(HomeComponent); + router = TestBed.inject(Router); + appConfig = TestBed.inject(AppConfigService); + appConfig.config = Object.assign(appConfig.config, { + landingPage: '/my-mock-landing-page' + }); + }); + + it('should navigate to the landing page from the app config', () => { + const navigateSpy = spyOn(router, 'navigateByUrl'); + fixture.detectChanges(); + + expect(navigateSpy).toHaveBeenCalledWith('/my-mock-landing-page'); + }); + + it('should navigate to personal files by default when there is no landingPage defined', () => { + appConfig.config = {}; + const navigateSpy = spyOn(router, 'navigateByUrl'); + fixture.detectChanges(); + + expect(navigateSpy).toHaveBeenCalledWith('/personal-files'); + }); +}); diff --git a/app/src/app/components/home/home.component.ts b/app/src/app/components/home/home.component.ts new file mode 100644 index 000000000..0ea9a9902 --- /dev/null +++ b/app/src/app/components/home/home.component.ts @@ -0,0 +1,42 @@ +/*! + * @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, OnInit } from '@angular/core'; +import { Router } from '@angular/router'; +import { AppConfigService } from '@alfresco/adf-core'; + +@Component({ + template: '' +}) +export class HomeComponent implements OnInit { + readonly DEFAULT_LANDING_PAGE = '/personal-files'; + + constructor(private appConfig: AppConfigService, private router: Router) {} + + ngOnInit() { + const landingPage = this.appConfig.get('landingPage', this.DEFAULT_LANDING_PAGE); + this.router.navigateByUrl(landingPage); + } +} diff --git a/app/src/assets/app.extensions.json b/app/src/assets/app.extensions.json index 08dfa2329..7f4d905a0 100644 --- a/app/src/assets/app.extensions.json +++ b/app/src/assets/app.extensions.json @@ -233,7 +233,10 @@ "icon": "folder", "title": "APP.BROWSE.PERSONAL.SIDENAV_LINK.LABEL", "description": "APP.BROWSE.PERSONAL.SIDENAV_LINK.TOOLTIP", - "route": "personal-files" + "route": "personal-files", + "rules": { + "visible": "app.isContentServiceEnabled" + } }, { "id": "app.navbar.libraries.menu",