Skip to content

Commit

Permalink
ACS-8404: consolidate application settings (#3952)
Browse files Browse the repository at this point in the history
  • Loading branch information
DenysVuika authored Jul 18, 2024
1 parent 74384f0 commit 2ff54af
Show file tree
Hide file tree
Showing 19 changed files with 132 additions and 182 deletions.
2 changes: 0 additions & 2 deletions app/src/app.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
"copyright": "APP.COPYRIGHT"
},
"viewer.maxRetries": 1,
"customCssPath": "",
"webFontPath": "",
"pagination": {
"size": 25,
"supportedPageSizes": [25, 50, 100]
Expand Down
13 changes: 1 addition & 12 deletions app/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,8 @@ import localeSv from '@angular/common/locales/sv';
import { TranslateModule } from '@ngx-translate/core';
import { RouterModule } from '@angular/router';
import { AppComponent } from './app.components';
import {
ContentUrlService,
INITIAL_APP_STATE,
CONTENT_LAYOUT_ROUTES,
ContentServiceExtensionModule,
CoreExtensionsModule
} from '@alfresco/aca-content';
import { ContentUrlService, CONTENT_LAYOUT_ROUTES, ContentServiceExtensionModule, CoreExtensionsModule } from '@alfresco/aca-content';
import { ContentVersionService } from '@alfresco/adf-content-services';
import { STORE_INITIAL_APP_DATA } from '@alfresco/aca-shared/store';
import { ShellModule, SHELL_APP_SERVICE, SHELL_AUTH_TOKEN } from '@alfresco/adf-core/shell';
import { StoreDevtoolsModule } from '@ngrx/store-devtools';
import { APP_ROUTES } from './app.routes';
Expand Down Expand Up @@ -112,10 +105,6 @@ registerLocaleData(localeSv);
provide: SHELL_AUTH_TOKEN,
useClass: AuthGuard
},
{
provide: STORE_INITIAL_APP_DATA,
useValue: INITIAL_APP_STATE
},
{
provide: TRANSLATION_PROVIDER,
multi: true,
Expand Down
2 changes: 1 addition & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ module.exports = () => {
global: {
statements: 75,
branches: 67,
functions: 72,
functions: 71,
lines: 74
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,7 @@ import { BehaviorSubject, of, Subject } from 'rxjs';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { DefaultProjectorFn, MemoizedSelector, Store } from '@ngrx/store';
import { ContentApiService } from '@alfresco/aca-shared';
import {
AppStore,
isInfoDrawerOpened,
NavigateToFolder,
NavigateToPreviousPage,
SetSelectedNodesAction,
STORE_INITIAL_APP_DATA
} from '@alfresco/aca-shared/store';
import { AppStore, isInfoDrawerOpened, NavigateToFolder, NavigateToPreviousPage, SetSelectedNodesAction } from '@alfresco/aca-shared/store';
import { NodeEntry, PathElement } from '@alfresco/js-api';
import { RouterTestingModule } from '@angular/router/testing';
import { AuthenticationService, PageTitleService } from '@alfresco/adf-core';
Expand Down Expand Up @@ -86,10 +79,6 @@ describe('DetailsComponent', () => {
provide: PageTitleService,
useValue: {}
},
{
provide: STORE_INITIAL_APP_DATA,
useValue: {}
},
{
provide: AuthenticationService,
useValue: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import {
NavigateToFolder,
SetInfoDrawerPreviewStateAction,
SetInfoDrawerStateAction,
showFacetFilter,
ShowInfoDrawerPreviewAction,
SnackbarErrorAction
} from '@alfresco/aca-shared/store';
Expand Down Expand Up @@ -95,7 +94,6 @@ import { DocumentListPresetRef, DynamicColumnComponent } from '@alfresco/adf-ext
styleUrls: ['./search-results.component.scss']
})
export class SearchResultsComponent extends PageComponent implements OnInit {
showFacetFilter$ = this.store.select(showFacetFilter);
infoDrawerPreview$ = this.store.select(infoDrawerPreview);

searchedWord: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
(click)="toggleNavBar.emit()"
(keypress)="toggleNavBar.emit()">
<img
src="{{ logo$ | async }}"
src="{{ logoUrl }}"
title="{{'APP.TOOLTIPS.COLLAPSE_NAVIGATION' | translate}}"
alt="{{ 'CORE.HEADER.LOGO_ARIA' | translate }}" />
</div>
Expand All @@ -15,7 +15,7 @@
class="aca-sidenav-header-title-text"
data-automation-id="app-sidenav-header-title-text"
[routerLink]="landingPage">
{{ appName$ | async | translate }}
{{ appName | translate }}
</div>

<aca-toolbar [items]="actions"></aca-toolbar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
*/

import { Component, EventEmitter, inject, OnDestroy, OnInit, Output, ViewEncapsulation } from '@angular/core';
import { Store } from '@ngrx/store';
import { Subject } from 'rxjs';
import { AppStore, getAppName, getLogoPath } from '@alfresco/aca-shared/store';
import { ContentActionRef } from '@alfresco/adf-extensions';
import { AppExtensionService, AppSettingsService, ToolbarComponent } from '@alfresco/aca-shared';
import { takeUntil } from 'rxjs/operators';
Expand All @@ -43,12 +41,11 @@ import { RouterModule } from '@angular/router';
})
export class SidenavHeaderComponent implements OnInit, OnDestroy {
private onDestroy$ = new Subject<boolean>();
private store = inject<Store<AppStore>>(Store);
private appSettings = inject(AppSettingsService);
private appExtensions = inject(AppExtensionService);

appName$ = this.store.select(getAppName);
logo$ = this.store.select(getLogoPath);
appName = this.appSettings.appName;
logoUrl = this.appSettings.appLogoUrl;
landingPage = this.appSettings.landingPage;
actions: Array<ContentActionRef> = [];

Expand Down
45 changes: 21 additions & 24 deletions projects/aca-content/src/lib/services/content-management.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/

import { AppHookService, ContentApiService, NodePermissionService } from '@alfresco/aca-shared';
import { AppHookService, AppSettingsService, ContentApiService, NodePermissionService } from '@alfresco/aca-shared';
import {
AppStore,
DeletedNodeInfo,
DeleteStatus,
getAppSelection,
getSharedUrl,
NavigateRouteAction,
NavigateToParentFolder,
NodeInfo,
Expand Down Expand Up @@ -91,7 +90,8 @@ export class ContentManagementService {
private nodeAspectService: NodeAspectService,
private appHookService: AppHookService,
private newVersionUploaderService: NewVersionUploaderService,
private router: Router
private router: Router,
private appSettingsService: AppSettingsService
) {}

addFavorite(nodes: Array<NodeEntry>) {
Expand Down Expand Up @@ -189,27 +189,24 @@ export class ContentManagementService {
}
}

openShareLinkDialog(node, focusedElementOnCloseSelector?: string) {
this.store
.select(getSharedUrl)
.pipe(take(1))
.subscribe((baseShareUrl) => {
this.dialogRef
.open(ShareDialogComponent, {
restoreFocus: true,
width: '600px',
panelClass: 'adf-share-link-dialog',
data: {
node,
baseShareUrl
}
})
.afterClosed()
.subscribe(() => {
this.store.dispatch(new SetSelectedNodesAction([node]));
this.appHookService.linksUnshared.next();
this.focusAfterClose(focusedElementOnCloseSelector);
});
openShareLinkDialog(node: any, focusedElementOnCloseSelector?: string) {
const baseShareUrl = this.appSettingsService.baseShareUrl;

this.dialogRef
.open(ShareDialogComponent, {
restoreFocus: true,
width: '600px',
panelClass: 'adf-share-link-dialog',
data: {
node,
baseShareUrl
}
})
.afterClosed()
.subscribe(() => {
this.store.dispatch(new SetSelectedNodesAction([node]));
this.appHookService.linksUnshared.next();
this.focusAfterClose(focusedElementOnCloseSelector);
});
}

Expand Down
41 changes: 1 addition & 40 deletions projects/aca-content/src/lib/store/initial-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,43 +22,4 @@
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/

import { AppState, AppStore } from '@alfresco/aca-shared/store';

export const INITIAL_APP_STATE: AppState = {
appName: 'Alfresco Content Application',
logoPath: 'assets/images/alfresco-logo-white.svg',
customCssPath: '',
webFontPath: '',
sharedUrl: '',
user: {
isAdmin: null,
id: null,
firstName: '',
lastName: ''
},
selection: {
nodes: [],
libraries: [],
isEmpty: true,
count: 0
},
navigation: {
currentFolder: null
},
currentNodeVersion: null,
infoDrawerOpened: false,
infoDrawerPreview: false,
infoDrawerMetadataAspect: '',
showFacetFilter: true,
fileUploadingDialog: true,
showLoader: false,
repository: {
status: {
isQuickShareEnabled: true
}
} as any
};

export const INITIAL_STATE: AppStore = {
app: INITIAL_APP_STATE
};
export { INITIAL_STATE, INITIAL_APP_STATE } from '@alfresco/aca-shared/store';
8 changes: 2 additions & 6 deletions projects/aca-content/src/lib/store/reducers/app.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import {
SetUserProfileAction,
SetCurrentFolderAction,
SetCurrentUrlAction,
SetInitialStateAction,
SetSelectedNodesAction,
SetRepositoryInfoAction,
SetInfoDrawerStateAction,
Expand All @@ -38,17 +37,14 @@ import {
SetFileUploadingDialogAction,
SetInfoDrawerPreviewStateAction,
AppActionTypes,
ShowLoaderAction
ShowLoaderAction,
INITIAL_APP_STATE
} from '@alfresco/aca-shared/store';
import { INITIAL_APP_STATE } from '../initial-state';

export function appReducer(state: AppState = INITIAL_APP_STATE, action: Action): AppState {
let newState: AppState;

switch (action.type) {
case AppActionTypes.SetInitialState:
newState = { ...(action as SetInitialStateAction).payload };
break;
case NodeActionTypes.SetSelection:
newState = updateSelectedNodes(state, action as SetSelectedNodesAction);
break;
Expand Down
5 changes: 0 additions & 5 deletions projects/aca-content/src/lib/testing/app-testing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import { INITIAL_STATE } from '../store/initial-state';
import { BehaviorSubject, Observable, Subject, of } from 'rxjs';
import { ContentManagementService } from '../services/content-management.service';
import { DocumentBasePageService } from '@alfresco/aca-shared';
import { STORE_INITIAL_APP_DATA } from '@alfresco/aca-shared/store';

@NgModule({
imports: [
Expand Down Expand Up @@ -100,10 +99,6 @@ import { STORE_INITIAL_APP_DATA } from '@alfresco/aca-shared/store';
{
provide: PageTitleService,
useValue: {}
},
{
provide: STORE_INITIAL_APP_DATA,
useValue: {}
}
]
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import {
getCurrentFolder,
getAppSelection,
isInfoDrawerOpened,
getSharedUrl,
ViewNodeAction,
ViewNodeExtras,
SetSelectedNodesAction
Expand All @@ -60,7 +59,6 @@ export abstract class PageComponent implements OnInit, OnDestroy, OnChanges {
infoDrawerOpened$: Observable<boolean>;
node: Node;
selection: SelectionState;
sharedPreviewUrl$: Observable<string>;
actions: Array<ContentActionRef> = [];
viewerToolbarActions: Array<ContentActionRef> = [];
canUpdateNode = false;
Expand Down Expand Up @@ -89,7 +87,6 @@ export abstract class PageComponent implements OnInit, OnDestroy, OnChanges {
this.createActions = actions;
});

this.sharedPreviewUrl$ = this.store.select(getSharedUrl);
this.infoDrawerOpened$ = this.store.select(isInfoDrawerOpened);

this.store
Expand Down
46 changes: 46 additions & 0 deletions projects/aca-shared/src/lib/services/app-settings.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,50 @@ export class AppSettingsService {
get mimeTypes(): AlfrescoMimeType[] {
return this.appConfig.get<AlfrescoMimeType[]>('mimeTypes', DefaultMimeTypes);
}

/**
* Get the application name from the app settings.
*/
get appName(): string {
return this.appConfig.get<string>('application.name', 'Alfresco Content Application');
}

/**
* Get the application version from the app settings.
*/
get appVersion(): string {
return this.appConfig.get<string>('application.version', '1.0.0');
}

/**
* Get the application logo URL from the app settings.
*/
get appLogoUrl(): string {
return this.appConfig.get<string>('application.logo', 'assets/images/app-logo.svg');
}

/**
* Get the custom CSS stylesheet path from the app settings.
*/
get customCssPath(): string {
return this.appConfig.get<string>('customCssPath', '');
}

/**
* Get the custom web font path from the app settings.
*/
get webFontPath(): string {
return this.appConfig.get<string>('webFontPath', '');
}

/**
* Get the base share URL from the app settings.
*/
get baseShareUrl(): string {
let result = this.appConfig.get<string>('baseShareUrl', '');
if (!result.endsWith('/')) {
result += '/';
}
return result;
}
}
Loading

0 comments on commit 2ff54af

Please sign in to comment.