mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-12 17:04:46 +00:00
[ACS-8961] Remove expandedSidenav from local storage upon logout (#4242)
* [ACS-8961] Remove expandedSidenav from local storage on logout * [ACS-8961] fix sonarcloud issue
This commit is contained in:
parent
66f701367b
commit
d6f859dd74
@ -30,7 +30,8 @@ import {
|
||||
TranslationMock,
|
||||
TranslationService,
|
||||
UserPreferencesService,
|
||||
NotificationService
|
||||
NotificationService,
|
||||
StorageService
|
||||
} from '@alfresco/adf-core';
|
||||
import { BehaviorSubject, Observable, of, Subject } from 'rxjs';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
@ -64,6 +65,7 @@ describe('AppService', () => {
|
||||
let sharedLinksApiService: SharedLinksApiService;
|
||||
let contentApi: ContentApiService;
|
||||
let preferencesService: UserPreferencesService;
|
||||
let storageService: StorageService;
|
||||
let appSettingsService: AppSettingsService;
|
||||
let userProfileService: UserProfileService;
|
||||
let notificationService: NotificationService;
|
||||
@ -113,7 +115,13 @@ describe('AppService', () => {
|
||||
}
|
||||
},
|
||||
{ provide: TranslationService, useClass: TranslationMock },
|
||||
{ provide: UserPreferencesService, useValue: { setStoragePrefix: () => null } }
|
||||
{
|
||||
provide: UserPreferencesService,
|
||||
useValue: {
|
||||
setStoragePrefix: () => null,
|
||||
getPropertyKey: (property: string) => `prefix__${property}`
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
@ -127,6 +135,7 @@ describe('AppService', () => {
|
||||
spyOn(contentApi, 'getRepositoryInformation').and.returnValue(of({} as any));
|
||||
service = TestBed.inject(AppService);
|
||||
preferencesService = TestBed.inject(UserPreferencesService);
|
||||
storageService = TestBed.inject(StorageService);
|
||||
userProfileService = TestBed.inject(UserProfileService);
|
||||
loadUserProfileSpy = spyOn(userProfileService, 'loadUserProfile').and.returnValue(Promise.resolve({} as any));
|
||||
notificationService = TestBed.inject(NotificationService);
|
||||
@ -156,6 +165,14 @@ describe('AppService', () => {
|
||||
await expect(resetToDefaults).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should remove expandedSidenav item from local storage upon logout', async () => {
|
||||
const key = preferencesService.getPropertyKey('expandedSidenav');
|
||||
spyOn(storageService, 'removeItem');
|
||||
auth.onLogout.next(true);
|
||||
|
||||
expect(storageService.removeItem).toHaveBeenCalledWith(key);
|
||||
});
|
||||
|
||||
it('should raise notification on share link error', () => {
|
||||
const showError = spyOn(notificationService, 'showError').and.stub();
|
||||
spyOn(store, 'select').and.returnValue(of(''));
|
||||
|
@ -23,8 +23,15 @@
|
||||
*/
|
||||
|
||||
import { inject, Injectable } from '@angular/core';
|
||||
import { AppConfigService, AuthenticationService, NotificationService, PageTitleService, UserPreferencesService } from '@alfresco/adf-core';
|
||||
import { BehaviorSubject, Observable, Subject } from 'rxjs';
|
||||
import {
|
||||
AuthenticationService,
|
||||
AppConfigService,
|
||||
PageTitleService,
|
||||
UserPreferencesService,
|
||||
NotificationService,
|
||||
StorageService
|
||||
} from '@alfresco/adf-core';
|
||||
import { Observable, BehaviorSubject, Subject } from 'rxjs';
|
||||
import {
|
||||
AlfrescoApiService,
|
||||
FileUploadErrorEvent,
|
||||
@ -92,7 +99,8 @@ export class AppService implements ShellAppService {
|
||||
searchQueryBuilderService: SearchQueryBuilderService,
|
||||
private acaMobileAppSwitcherService: AcaMobileAppSwitcherService,
|
||||
private appSettingsService: AppSettingsService,
|
||||
private userProfileService: UserProfileService
|
||||
private readonly userProfileService: UserProfileService,
|
||||
private readonly storage: StorageService
|
||||
) {
|
||||
this.ready = new BehaviorSubject(this.authenticationService.isLoggedIn() || this.withCredentials);
|
||||
this.ready$ = this.ready.asObservable();
|
||||
@ -103,6 +111,7 @@ export class AppService implements ShellAppService {
|
||||
});
|
||||
|
||||
this.authenticationService.onLogout.subscribe(() => {
|
||||
this.storage.removeItem(this.preferencesService.getPropertyKey('expandedSidenav'));
|
||||
searchQueryBuilderService.resetToDefaults();
|
||||
acaMobileAppSwitcherService.clearSessionExpireTime();
|
||||
acaMobileAppSwitcherService.closeDialog();
|
||||
|
Loading…
x
Reference in New Issue
Block a user