[AAE-8200] - Add a way to hide personal files and configure a landing… (#2494)

* [AAE-8200] - Add a way to hide personal files and configure a landing page

* Move global variable inside the function used

* Rename plugin content service variable

* Fix lint

* Fix comments
This commit is contained in:
arditdomi
2022-04-14 17:58:41 +01:00
committed by GitHub
parent 32bb39cf9c
commit 1bc4613f2a
11 changed files with 103 additions and 12 deletions

View File

@@ -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}",

View File

@@ -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 },

View File

@@ -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',

View File

@@ -1,6 +1,6 @@
<adf-layout-header
[logo]="logo$ | async"
[redirectUrl]="'/personal-files'"
[redirectUrl]="landingPage"
[tooltip]="appName$ | async"
[color]="headerColor$ | async"
[title]="appName$ | async"

View File

@@ -30,6 +30,7 @@ import { ContentActionRef } from '@alfresco/adf-extensions';
import { AppStore, getHeaderColor, getAppName, getLogoPath, getHeaderImagePath, getHeaderTextColor } from '@alfresco/aca-shared/store';
import { AppExtensionService } from '@alfresco/aca-shared';
import { takeUntil } from 'rxjs/operators';
import { AppConfigService } from '@alfresco/adf-core';
@Component({
selector: 'app-header',
@@ -49,14 +50,16 @@ export class AppHeaderComponent implements OnInit, OnDestroy {
headerColor$: Observable<any>;
headerTextColor$: Observable<string>;
logo$: Observable<string>;
landingPage: string;
actions: Array<ContentActionRef> = [];
constructor(store: Store<AppStore>, private appExtensions: AppExtensionService) {
constructor(store: Store<AppStore>, 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}')`);

View File

@@ -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<HomeComponent>;
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');
});
});

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
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);
}
}

View File

@@ -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",