mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
ACS-8404: Introduce App Settings service (#3939)
This commit is contained in:
@@ -23,28 +23,26 @@
|
||||
*/
|
||||
|
||||
import { HomeComponent } from './home.component';
|
||||
import { AppConfigService, AppConfigServiceMock } 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';
|
||||
import { AppSettingsService } from '@alfresco/aca-shared';
|
||||
|
||||
describe('HomeComponent', () => {
|
||||
let appConfig: AppConfigService;
|
||||
let appSettings: AppSettingsService;
|
||||
let fixture: ComponentFixture<HomeComponent>;
|
||||
let router: Router;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [HttpClientModule, RouterTestingModule, HomeComponent],
|
||||
providers: [{ provide: AppConfigService, useClass: AppConfigServiceMock }]
|
||||
imports: [HttpClientModule, RouterTestingModule, HomeComponent]
|
||||
});
|
||||
appSettings = TestBed.inject(AppSettingsService);
|
||||
spyOnProperty(appSettings, 'landingPage', 'get').and.returnValue('/my-mock-landing-page');
|
||||
|
||||
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', () => {
|
||||
@@ -53,12 +51,4 @@ describe('HomeComponent', () => {
|
||||
|
||||
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');
|
||||
});
|
||||
});
|
||||
|
@@ -22,9 +22,9 @@
|
||||
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { Component, inject, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { AppConfigService } from '@alfresco/adf-core';
|
||||
import { AppSettingsService } from '@alfresco/aca-shared';
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
@@ -32,12 +32,10 @@ import { AppConfigService } from '@alfresco/adf-core';
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class HomeComponent implements OnInit {
|
||||
readonly DEFAULT_LANDING_PAGE = '/personal-files';
|
||||
|
||||
constructor(private appConfig: AppConfigService, private router: Router) {}
|
||||
private appSettings = inject(AppSettingsService);
|
||||
private router = inject(Router);
|
||||
|
||||
ngOnInit() {
|
||||
const landingPage = this.appConfig.get('landingPage', this.DEFAULT_LANDING_PAGE);
|
||||
this.router.navigateByUrl(landingPage);
|
||||
this.router.navigateByUrl(this.appSettings.landingPage);
|
||||
}
|
||||
}
|
||||
|
@@ -26,9 +26,8 @@ import { Component, EventEmitter, inject, OnDestroy, OnInit, Output, ViewEncapsu
|
||||
import { Store } from '@ngrx/store';
|
||||
import { Subject } from 'rxjs';
|
||||
import { AppStore, getAppName, getLogoPath } from '@alfresco/aca-shared/store';
|
||||
import { AppConfigService } from '@alfresco/adf-core';
|
||||
import { ContentActionRef } from '@alfresco/adf-extensions';
|
||||
import { AppExtensionService, ToolbarComponent } from '@alfresco/aca-shared';
|
||||
import { AppExtensionService, AppSettingsService, ToolbarComponent } from '@alfresco/aca-shared';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
@@ -45,12 +44,12 @@ import { RouterModule } from '@angular/router';
|
||||
export class SidenavHeaderComponent implements OnInit, OnDestroy {
|
||||
private onDestroy$ = new Subject<boolean>();
|
||||
private store = inject<Store<AppStore>>(Store);
|
||||
private appConfigService = inject(AppConfigService);
|
||||
private appSettings = inject(AppSettingsService);
|
||||
private appExtensions = inject(AppExtensionService);
|
||||
|
||||
appName$ = this.store.select(getAppName);
|
||||
logo$ = this.store.select(getLogoPath);
|
||||
landingPage = this.appConfigService.get('landingPage', '/personal-files');
|
||||
landingPage = this.appSettings.landingPage;
|
||||
actions: Array<ContentActionRef> = [];
|
||||
|
||||
@Output()
|
||||
|
Reference in New Issue
Block a user