ACS-8404: Update application settings service (#3988)

This commit is contained in:
Denys Vuika 2024-08-22 11:50:00 -04:00 committed by GitHub
parent 360970da85
commit 11f51af54c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 86 additions and 40 deletions

View File

@ -38,7 +38,6 @@
"logo": "assets/images/app-logo.svg", "logo": "assets/images/app-logo.svg",
"copyright": "APP.COPYRIGHT" "copyright": "APP.COPYRIGHT"
}, },
"viewer.maxRetries": 1,
"pagination": { "pagination": {
"size": 25, "size": 25,
"supportedPageSizes": [25, 50, 100] "supportedPageSizes": [25, 50, 100]
@ -54,10 +53,6 @@
"defaultDateTimeFormat": "MMM d, y, h:mm", "defaultDateTimeFormat": "MMM d, y, h:mm",
"defaultLocale": "en" "defaultLocale": "en"
}, },
"adf-version-manager": {
"allowComments": true,
"allowDownload": true
},
"sideNav": { "sideNav": {
"preserveState": true, "preserveState": true,
"expandedSidenav": true "expandedSidenav": true
@ -330,7 +325,6 @@
"downloadPromptDelay": 50, "downloadPromptDelay": 50,
"downloadPromptReminderDelay": 30, "downloadPromptReminderDelay": 30,
"enableFileAutoDownload": true, "enableFileAutoDownload": true,
"fileAutoDownloadSizeThresholdInMB": 15, "fileAutoDownloadSizeThresholdInMB": 15
"closeButtonPosition": "right"
} }
} }

View File

@ -1,5 +1,5 @@
<adf-login <adf-login
[copyrightText]="'application.copyright' | adfAppConfig | translate" [copyrightText]="settings.appCopyright | translate"
successRoute="/personal-files" successRoute="/personal-files"
logoImageUrl="./assets/images/alfresco-logo.svg" logoImageUrl="./assets/images/alfresco-logo.svg"
backgroundImageUrl="./assets/images/Wallpaper-BG-generic.svg" backgroundImageUrl="./assets/images/Wallpaper-BG-generic.svg"

View File

@ -22,14 +22,17 @@
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>. * from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/ */
import { AppConfigPipe, LoginComponent } from '@alfresco/adf-core'; import { LoginComponent } from '@alfresco/adf-core';
import { Component, ViewEncapsulation } from '@angular/core'; import { Component, inject, ViewEncapsulation } from '@angular/core';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { AppSettingsService } from '@alfresco/aca-shared';
@Component({ @Component({
standalone: true, standalone: true,
imports: [LoginComponent, TranslateModule, AppConfigPipe], imports: [LoginComponent, TranslateModule],
templateUrl: './app-login.component.html', templateUrl: './app-login.component.html',
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None
}) })
export class AppLoginComponent {} export class AppLoginComponent {
settings = inject(AppSettingsService);
}

View File

@ -59,7 +59,7 @@ module.exports = () => {
global: { global: {
statements: 75, statements: 75,
branches: 65, branches: 65,
functions: 70, functions: 69,
lines: 74 lines: 74
} }
} }

View File

@ -22,25 +22,21 @@
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>. * from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/ */
import { Component, Input, OnChanges, OnInit, ViewEncapsulation } from '@angular/core'; import { Component, inject, Input, OnChanges, OnInit, ViewEncapsulation } from '@angular/core';
import { Node } from '@alfresco/js-api'; import { Node } from '@alfresco/js-api';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { VersionManagerModule } from '@alfresco/adf-content-services'; import { VersionManagerModule } from '@alfresco/adf-content-services';
import { MatIconModule } from '@angular/material/icon'; import { MatIconModule } from '@angular/material/icon';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { AppConfigPipe } from '@alfresco/adf-core'; import { AppSettingsService } from '@alfresco/aca-shared';
@Component({ @Component({
standalone: true, standalone: true,
imports: [CommonModule, VersionManagerModule, MatIconModule, TranslateModule, AppConfigPipe], imports: [CommonModule, VersionManagerModule, MatIconModule, TranslateModule],
selector: 'app-versions-tab', selector: 'app-versions-tab',
template: ` template: `
<ng-container *ngIf="isFileSelected; else empty"> <ng-container *ngIf="isFileSelected; else empty">
<adf-version-manager <adf-version-manager [showComments]="settings.uploadAllowComments" [allowDownload]="settings.uploadAllowDownload" [node]="node">
[showComments]="'adf-version-manager.allowComments' | adfAppConfig : true"
[allowDownload]="'adf-version-manager.allowDownload' | adfAppConfig : true"
[node]="node"
>
</adf-version-manager> </adf-version-manager>
</ng-container> </ng-container>
@ -54,6 +50,8 @@ import { AppConfigPipe } from '@alfresco/adf-core';
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None
}) })
export class VersionsTabComponent implements OnInit, OnChanges { export class VersionsTabComponent implements OnInit, OnChanges {
settings = inject(AppSettingsService);
@Input() @Input()
node: Node; node: Node;

View File

@ -1505,7 +1505,10 @@ describe('ContentManagementService', () => {
it('should open dialog with NewVersionUploaderService', () => { it('should open dialog with NewVersionUploaderService', () => {
contentManagementService.versionUpdateDialog(fakeNode, fakeFile); contentManagementService.versionUpdateDialog(fakeNode, fakeFile);
const expectedParams = [{ node: fakeNode, file: fakeFile, currentVersion: { id: '1.0' }, title: 'VERSION.DIALOG.TITLE' }, { width: '600px' }]; const expectedParams = [
{ node: fakeNode, file: fakeFile, currentVersion: { id: '1.0' }, title: 'VERSION.DIALOG.TITLE', showComments: true, allowDownload: true },
{ width: '600px' }
];
expect(spyOnOpenUploadNewVersionDialog).toHaveBeenCalledOnceWith(...expectedParams); expect(spyOnOpenUploadNewVersionDialog).toHaveBeenCalledOnceWith(...expectedParams);
}); });

View File

@ -47,7 +47,6 @@ import {
DocumentListService, DocumentListService,
FolderDialogComponent, FolderDialogComponent,
LibraryDialogComponent, LibraryDialogComponent,
NewVersionUploaderData,
NewVersionUploaderDataAction, NewVersionUploaderDataAction,
NewVersionUploaderDialogData, NewVersionUploaderDialogData,
NewVersionUploaderService, NewVersionUploaderService,
@ -152,17 +151,20 @@ export class ContentManagementService {
} }
} }
versionUpdateDialog(node, file) { versionUpdateDialog(node: Node, file: File) {
this.contentApi.getNodeVersions(node.id).subscribe(({ list }) => { this.contentApi.getNodeVersions(node.id).subscribe(({ list }) => {
const newVersionUploaderDialogData: NewVersionUploaderDialogData = { const newVersionUploaderDialogData = {
node, node,
file, file,
currentVersion: list.entries[0].entry, currentVersion: list.entries[0].entry,
title: 'VERSION.DIALOG.TITLE' title: 'VERSION.DIALOG.TITLE',
}; showComments: this.appSettingsService.uploadAllowComments,
allowDownload: this.appSettingsService.uploadAllowDownload
} as NewVersionUploaderDialogData;
const dialogConfig: MatDialogConfig = { width: '600px' }; const dialogConfig: MatDialogConfig = { width: '600px' };
this.newVersionUploaderService.openUploadNewVersionDialog(newVersionUploaderDialogData, dialogConfig).subscribe( this.newVersionUploaderService.openUploadNewVersionDialog(newVersionUploaderDialogData, dialogConfig).subscribe(
(data: NewVersionUploaderData) => { (data) => {
if (data.action === NewVersionUploaderDataAction.upload) { if (data.action === NewVersionUploaderDataAction.upload) {
if (data.newVersion.value.entry.properties['cm:lockType'] === 'WRITE_LOCK') { if (data.newVersion.value.entry.properties['cm:lockType'] === 'WRITE_LOCK') {
this.store.dispatch(new UnlockWriteAction(data.newVersion.value)); this.store.dispatch(new UnlockWriteAction(data.newVersion.value));
@ -573,7 +575,7 @@ export class ContentManagementService {
this.newVersionUploaderService this.newVersionUploaderService
.openUploadNewVersionDialog(newVersionUploaderDialogData, { width: '630px', role: 'dialog' }, focusedElementOnCloseSelector) .openUploadNewVersionDialog(newVersionUploaderDialogData, { width: '630px', role: 'dialog' }, focusedElementOnCloseSelector)
.subscribe({ .subscribe({
next: (newVersionUploaderData: NewVersionUploaderData) => { next: (newVersionUploaderData) => {
switch (newVersionUploaderData.action) { switch (newVersionUploaderData.action) {
case NewVersionUploaderDataAction.refresh: case NewVersionUploaderDataAction.refresh:
this.store.dispatch(new RefreshPreviewAction(newVersionUploaderData.node)); this.store.dispatch(new RefreshPreviewAction(newVersionUploaderData.node));

View File

@ -235,13 +235,13 @@ describe('UploadEffects', () => {
detail: { detail: {
files: [ files: [
{ {
file: new FileModel({ file: {
name: 'Fake New file', name: 'Fake New file',
type: 'image/png', type: 'image/png',
lastModified: 1589273450599, lastModified: 1589273450599,
size: 1351, size: 1351,
slice: null slice: null
} as File), } as File,
entry: new FileModel({ entry: new FileModel({
name: 'Fake New file', name: 'Fake New file',
type: 'image/png', type: 'image/png',
@ -274,7 +274,7 @@ describe('UploadEffects', () => {
id: '1bf8a8f7-18ac-4eef-919d-61d952eaa179', id: '1bf8a8f7-18ac-4eef-919d-61d952eaa179',
allowableOperations: ['delete', 'update', 'updatePermissions'], allowableOperations: ['delete', 'update', 'updatePermissions'],
isFavorite: false isFavorite: false
} } as any
} }
} }
} }

View File

@ -3,7 +3,7 @@
[ngClass]="{ [ngClass]="{
'aca-right_side--hide': !showRightSide 'aca-right_side--hide': !showRightSide
}" }"
[maxRetries]="'viewer.maxRetries' | adfAppConfig" [maxRetries]="settings.viewerMaxRetries"
[nodeId]="nodeId" [nodeId]="nodeId"
[versionId]="versionId" [versionId]="versionId"
[allowNavigate]="navigateMultiple" [allowNavigate]="navigateMultiple"
@ -14,7 +14,7 @@
[allowFullScreen]="false" [allowFullScreen]="false"
[overlayMode]="true" [overlayMode]="true"
[hideInfoButton]="true" [hideInfoButton]="true"
[closeButtonPosition]="'viewer.closeButtonPosition' | adfAppConfig: 'right'" [closeButtonPosition]="settings.viewerCloseButtonPosition"
(showViewerChange)="onViewerVisibilityChanged()" (showViewerChange)="onViewerVisibilityChanged()"
[canNavigateBefore]="!!previousNodeId" [canNavigateBefore]="!!previousNodeId"
[canNavigateNext]="!!nextNodeId" [canNavigateNext]="!!nextNodeId"

View File

@ -39,7 +39,6 @@ import {
} from '@alfresco/aca-shared'; } from '@alfresco/aca-shared';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { Node } from '@alfresco/js-api'; import { Node } from '@alfresco/js-api';
import { AcaViewerModule } from '../../viewer.module';
const apiError = `{ const apiError = `{
"error": { "error": {
@ -68,7 +67,7 @@ describe('AcaViewerComponent', () => {
beforeEach(() => { beforeEach(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [LibTestingModule, AcaViewerModule], imports: [LibTestingModule, AcaViewerComponent],
providers: [ providers: [
{ provide: DocumentBasePageService, useValue: DocumentBasePageServiceMock }, { provide: DocumentBasePageService, useValue: DocumentBasePageServiceMock },
{ provide: DiscoveryApiService, useValue: discoveryApiServiceMockValue }, { provide: DiscoveryApiService, useValue: discoveryApiServiceMockValue },

View File

@ -25,6 +25,7 @@
import { import {
AppExtensionService, AppExtensionService,
AppHookService, AppHookService,
AppSettingsService,
ContentApiService, ContentApiService,
InfoDrawerComponent, InfoDrawerComponent,
ToolbarComponent, ToolbarComponent,
@ -45,18 +46,27 @@ import { ContentActionRef, SelectionState } from '@alfresco/adf-extensions';
import { Node, VersionEntry, VersionsApi } from '@alfresco/js-api'; import { Node, VersionEntry, VersionsApi } from '@alfresco/js-api';
import { Component, HostListener, inject, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core'; import { Component, HostListener, inject, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
import { ActivatedRoute, PRIMARY_OUTLET, Router } from '@angular/router'; import { ActivatedRoute, PRIMARY_OUTLET, Router } from '@angular/router';
import { AlfrescoApiService, AppConfigPipe, ViewerModule } from '@alfresco/adf-core'; import { AlfrescoApiService, ViewerOpenWithComponent, ViewerSidebarComponent, ViewerToolbarActionsComponent } from '@alfresco/adf-core';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { from, Observable, Subject } from 'rxjs'; import { from, Observable, Subject } from 'rxjs';
import { debounceTime, takeUntil } from 'rxjs/operators'; import { debounceTime, takeUntil } from 'rxjs/operators';
import { Actions, ofType } from '@ngrx/effects'; import { Actions, ofType } from '@ngrx/effects';
import { AlfrescoViewerModule, DocumentListService, NodesApiService, UploadService } from '@alfresco/adf-content-services'; import { AlfrescoViewerComponent, DocumentListService, NodesApiService, UploadService } from '@alfresco/adf-content-services';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { ViewerService } from '../../services/viewer.service'; import { ViewerService } from '../../services/viewer.service';
@Component({ @Component({
standalone: true, standalone: true,
imports: [CommonModule, ViewerModule, AlfrescoViewerModule, InfoDrawerComponent, ToolbarMenuItemComponent, ToolbarComponent, AppConfigPipe], imports: [
CommonModule,
InfoDrawerComponent,
ToolbarMenuItemComponent,
ToolbarComponent,
AlfrescoViewerComponent,
ViewerToolbarActionsComponent,
ViewerOpenWithComponent,
ViewerSidebarComponent
],
selector: 'aca-viewer', selector: 'aca-viewer',
templateUrl: './viewer.component.html', templateUrl: './viewer.component.html',
styleUrls: ['./viewer.component.scss'], styleUrls: ['./viewer.component.scss'],
@ -64,6 +74,8 @@ import { ViewerService } from '../../services/viewer.service';
host: { class: 'app-viewer' } host: { class: 'app-viewer' }
}) })
export class AcaViewerComponent implements OnInit, OnDestroy { export class AcaViewerComponent implements OnInit, OnDestroy {
settings = inject(AppSettingsService);
private documentListService = inject(DocumentListService); private documentListService = inject(DocumentListService);
private _versionsApi: VersionsApi; private _versionsApi: VersionsApi;

View File

@ -23,13 +23,20 @@
*/ */
import { inject, Injectable } from '@angular/core'; import { inject, Injectable } from '@angular/core';
import { AppConfigService } from '@alfresco/adf-core'; import { AppConfigService, CloseButtonPosition } from '@alfresco/adf-core';
import { AlfrescoMimeType, DefaultMimeTypes } from '../constants/mime-types'; import { AlfrescoMimeType, DefaultMimeTypes } from '../constants/mime-types';
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class AppSettingsService { export class AppSettingsService {
private appConfig = inject(AppConfigService); private appConfig = inject(AppConfigService);
/**
* Get the application copyright text from the app settings.
*/
get appCopyright(): string {
return this.appConfig.get<string>('application.copyright', '');
}
/** /**
* Get the AOS (Alfresco Office Services) host URL from the app settings. * Get the AOS (Alfresco Office Services) host URL from the app settings.
*/ */
@ -98,6 +105,34 @@ export class AppSettingsService {
return result; return result;
} }
/**
* Get the viewer close button position from the app settings.
*/
get viewerCloseButtonPosition(): CloseButtonPosition {
return this.appConfig.get('viewer.closeButtonPosition', CloseButtonPosition.Right);
}
/**
* Get the viewer max retries from the app settings.
*/
get viewerMaxRetries(): number {
return this.appConfig.get<number>('viewer.maxRetries', 1);
}
/**
* Enabled state of the comment feature for upload dialog
*/
get uploadAllowComments(): boolean {
return this.appConfig.get<boolean>('adf-version-manager.allowComments', true);
}
/**
* Enabled state of the download feature for upload dialog
*/
get uploadAllowDownload(): boolean {
return this.appConfig.get<boolean>('adf-version-manager.allowDownload', true);
}
/** /**
* Gets the enablement of the file auto tryDownload feature from the app settings. * Gets the enablement of the file auto tryDownload feature from the app settings.
*/ */