diff --git a/app/src/app.config.json b/app/src/app.config.json index 62c09f205e..44182f1478 100644 --- a/app/src/app.config.json +++ b/app/src/app.config.json @@ -38,7 +38,6 @@ "logo": "assets/images/app-logo.svg", "copyright": "APP.COPYRIGHT" }, - "viewer.maxRetries": 1, "pagination": { "size": 25, "supportedPageSizes": [25, 50, 100] @@ -54,10 +53,6 @@ "defaultDateTimeFormat": "MMM d, y, h:mm", "defaultLocale": "en" }, - "adf-version-manager": { - "allowComments": true, - "allowDownload": true - }, "sideNav": { "preserveState": true, "expandedSidenav": true @@ -330,7 +325,6 @@ "downloadPromptDelay": 50, "downloadPromptReminderDelay": 30, "enableFileAutoDownload": true, - "fileAutoDownloadSizeThresholdInMB": 15, - "closeButtonPosition": "right" + "fileAutoDownloadSizeThresholdInMB": 15 } } diff --git a/app/src/app/components/login/app-login.component.html b/app/src/app/components/login/app-login.component.html index c846eb5992..36ec3d13d1 100644 --- a/app/src/app/components/login/app-login.component.html +++ b/app/src/app/components/login/app-login.component.html @@ -1,5 +1,5 @@ . */ -import { AppConfigPipe, LoginComponent } from '@alfresco/adf-core'; -import { Component, ViewEncapsulation } from '@angular/core'; +import { LoginComponent } from '@alfresco/adf-core'; +import { Component, inject, ViewEncapsulation } from '@angular/core'; import { TranslateModule } from '@ngx-translate/core'; +import { AppSettingsService } from '@alfresco/aca-shared'; @Component({ standalone: true, - imports: [LoginComponent, TranslateModule, AppConfigPipe], + imports: [LoginComponent, TranslateModule], templateUrl: './app-login.component.html', encapsulation: ViewEncapsulation.None }) -export class AppLoginComponent {} +export class AppLoginComponent { + settings = inject(AppSettingsService); +} diff --git a/karma.conf.js b/karma.conf.js index 3c66cb3d86..5097744ddb 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -59,7 +59,7 @@ module.exports = () => { global: { statements: 75, branches: 65, - functions: 70, + functions: 69, lines: 74 } } diff --git a/projects/aca-content/src/lib/components/info-drawer/versions-tab/versions-tab.component.ts b/projects/aca-content/src/lib/components/info-drawer/versions-tab/versions-tab.component.ts index 9040cc4119..2c31b99b55 100644 --- a/projects/aca-content/src/lib/components/info-drawer/versions-tab/versions-tab.component.ts +++ b/projects/aca-content/src/lib/components/info-drawer/versions-tab/versions-tab.component.ts @@ -22,25 +22,21 @@ * from Hyland Software. If not, see . */ -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 { CommonModule } from '@angular/common'; import { VersionManagerModule } from '@alfresco/adf-content-services'; import { MatIconModule } from '@angular/material/icon'; import { TranslateModule } from '@ngx-translate/core'; -import { AppConfigPipe } from '@alfresco/adf-core'; +import { AppSettingsService } from '@alfresco/aca-shared'; @Component({ standalone: true, - imports: [CommonModule, VersionManagerModule, MatIconModule, TranslateModule, AppConfigPipe], + imports: [CommonModule, VersionManagerModule, MatIconModule, TranslateModule], selector: 'app-versions-tab', template: ` - + @@ -54,6 +50,8 @@ import { AppConfigPipe } from '@alfresco/adf-core'; encapsulation: ViewEncapsulation.None }) export class VersionsTabComponent implements OnInit, OnChanges { + settings = inject(AppSettingsService); + @Input() node: Node; diff --git a/projects/aca-content/src/lib/services/content-management.service.spec.ts b/projects/aca-content/src/lib/services/content-management.service.spec.ts index 71e19cd4e9..912820b05f 100644 --- a/projects/aca-content/src/lib/services/content-management.service.spec.ts +++ b/projects/aca-content/src/lib/services/content-management.service.spec.ts @@ -1505,7 +1505,10 @@ describe('ContentManagementService', () => { it('should open dialog with NewVersionUploaderService', () => { 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); }); diff --git a/projects/aca-content/src/lib/services/content-management.service.ts b/projects/aca-content/src/lib/services/content-management.service.ts index ec866a0c6c..880ffb68c3 100644 --- a/projects/aca-content/src/lib/services/content-management.service.ts +++ b/projects/aca-content/src/lib/services/content-management.service.ts @@ -47,7 +47,6 @@ import { DocumentListService, FolderDialogComponent, LibraryDialogComponent, - NewVersionUploaderData, NewVersionUploaderDataAction, NewVersionUploaderDialogData, NewVersionUploaderService, @@ -152,17 +151,20 @@ export class ContentManagementService { } } - versionUpdateDialog(node, file) { + versionUpdateDialog(node: Node, file: File) { this.contentApi.getNodeVersions(node.id).subscribe(({ list }) => { - const newVersionUploaderDialogData: NewVersionUploaderDialogData = { + const newVersionUploaderDialogData = { node, file, 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' }; + this.newVersionUploaderService.openUploadNewVersionDialog(newVersionUploaderDialogData, dialogConfig).subscribe( - (data: NewVersionUploaderData) => { + (data) => { if (data.action === NewVersionUploaderDataAction.upload) { if (data.newVersion.value.entry.properties['cm:lockType'] === 'WRITE_LOCK') { this.store.dispatch(new UnlockWriteAction(data.newVersion.value)); @@ -573,7 +575,7 @@ export class ContentManagementService { this.newVersionUploaderService .openUploadNewVersionDialog(newVersionUploaderDialogData, { width: '630px', role: 'dialog' }, focusedElementOnCloseSelector) .subscribe({ - next: (newVersionUploaderData: NewVersionUploaderData) => { + next: (newVersionUploaderData) => { switch (newVersionUploaderData.action) { case NewVersionUploaderDataAction.refresh: this.store.dispatch(new RefreshPreviewAction(newVersionUploaderData.node)); diff --git a/projects/aca-content/src/lib/store/effects/upload.effects.spec.ts b/projects/aca-content/src/lib/store/effects/upload.effects.spec.ts index d3ac408325..a2d7940f68 100644 --- a/projects/aca-content/src/lib/store/effects/upload.effects.spec.ts +++ b/projects/aca-content/src/lib/store/effects/upload.effects.spec.ts @@ -235,13 +235,13 @@ describe('UploadEffects', () => { detail: { files: [ { - file: new FileModel({ + file: { name: 'Fake New file', type: 'image/png', lastModified: 1589273450599, size: 1351, slice: null - } as File), + } as File, entry: new FileModel({ name: 'Fake New file', type: 'image/png', @@ -274,7 +274,7 @@ describe('UploadEffects', () => { id: '1bf8a8f7-18ac-4eef-919d-61d952eaa179', allowableOperations: ['delete', 'update', 'updatePermissions'], isFavorite: false - } + } as any } } } diff --git a/projects/aca-content/viewer/src/lib/components/viewer/viewer.component.html b/projects/aca-content/viewer/src/lib/components/viewer/viewer.component.html index da74769ac2..989bdd243e 100644 --- a/projects/aca-content/viewer/src/lib/components/viewer/viewer.component.html +++ b/projects/aca-content/viewer/src/lib/components/viewer/viewer.component.html @@ -3,7 +3,7 @@ [ngClass]="{ 'aca-right_side--hide': !showRightSide }" - [maxRetries]="'viewer.maxRetries' | adfAppConfig" + [maxRetries]="settings.viewerMaxRetries" [nodeId]="nodeId" [versionId]="versionId" [allowNavigate]="navigateMultiple" @@ -14,7 +14,7 @@ [allowFullScreen]="false" [overlayMode]="true" [hideInfoButton]="true" - [closeButtonPosition]="'viewer.closeButtonPosition' | adfAppConfig: 'right'" + [closeButtonPosition]="settings.viewerCloseButtonPosition" (showViewerChange)="onViewerVisibilityChanged()" [canNavigateBefore]="!!previousNodeId" [canNavigateNext]="!!nextNodeId" diff --git a/projects/aca-content/viewer/src/lib/components/viewer/viewer.component.spec.ts b/projects/aca-content/viewer/src/lib/components/viewer/viewer.component.spec.ts index dd982a4c6f..e3bef5a629 100644 --- a/projects/aca-content/viewer/src/lib/components/viewer/viewer.component.spec.ts +++ b/projects/aca-content/viewer/src/lib/components/viewer/viewer.component.spec.ts @@ -39,7 +39,6 @@ import { } from '@alfresco/aca-shared'; import { Store } from '@ngrx/store'; import { Node } from '@alfresco/js-api'; -import { AcaViewerModule } from '../../viewer.module'; const apiError = `{ "error": { @@ -68,7 +67,7 @@ describe('AcaViewerComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [LibTestingModule, AcaViewerModule], + imports: [LibTestingModule, AcaViewerComponent], providers: [ { provide: DocumentBasePageService, useValue: DocumentBasePageServiceMock }, { provide: DiscoveryApiService, useValue: discoveryApiServiceMockValue }, diff --git a/projects/aca-content/viewer/src/lib/components/viewer/viewer.component.ts b/projects/aca-content/viewer/src/lib/components/viewer/viewer.component.ts index 7a245d94ae..af6e18c635 100644 --- a/projects/aca-content/viewer/src/lib/components/viewer/viewer.component.ts +++ b/projects/aca-content/viewer/src/lib/components/viewer/viewer.component.ts @@ -25,6 +25,7 @@ import { AppExtensionService, AppHookService, + AppSettingsService, ContentApiService, InfoDrawerComponent, ToolbarComponent, @@ -45,18 +46,27 @@ import { ContentActionRef, SelectionState } from '@alfresco/adf-extensions'; import { Node, VersionEntry, VersionsApi } from '@alfresco/js-api'; import { Component, HostListener, inject, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core'; 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 { from, Observable, Subject } from 'rxjs'; import { debounceTime, takeUntil } from 'rxjs/operators'; 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 { ViewerService } from '../../services/viewer.service'; @Component({ standalone: true, - imports: [CommonModule, ViewerModule, AlfrescoViewerModule, InfoDrawerComponent, ToolbarMenuItemComponent, ToolbarComponent, AppConfigPipe], + imports: [ + CommonModule, + InfoDrawerComponent, + ToolbarMenuItemComponent, + ToolbarComponent, + AlfrescoViewerComponent, + ViewerToolbarActionsComponent, + ViewerOpenWithComponent, + ViewerSidebarComponent + ], selector: 'aca-viewer', templateUrl: './viewer.component.html', styleUrls: ['./viewer.component.scss'], @@ -64,6 +74,8 @@ import { ViewerService } from '../../services/viewer.service'; host: { class: 'app-viewer' } }) export class AcaViewerComponent implements OnInit, OnDestroy { + settings = inject(AppSettingsService); + private documentListService = inject(DocumentListService); private _versionsApi: VersionsApi; diff --git a/projects/aca-shared/src/lib/services/app-settings.service.ts b/projects/aca-shared/src/lib/services/app-settings.service.ts index 5145a3b24e..053f4638b3 100644 --- a/projects/aca-shared/src/lib/services/app-settings.service.ts +++ b/projects/aca-shared/src/lib/services/app-settings.service.ts @@ -23,13 +23,20 @@ */ 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'; @Injectable({ providedIn: 'root' }) export class AppSettingsService { private appConfig = inject(AppConfigService); + /** + * Get the application copyright text from the app settings. + */ + get appCopyright(): string { + return this.appConfig.get('application.copyright', ''); + } + /** * Get the AOS (Alfresco Office Services) host URL from the app settings. */ @@ -98,6 +105,34 @@ export class AppSettingsService { 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('viewer.maxRetries', 1); + } + + /** + * Enabled state of the comment feature for upload dialog + */ + get uploadAllowComments(): boolean { + return this.appConfig.get('adf-version-manager.allowComments', true); + } + + /** + * Enabled state of the download feature for upload dialog + */ + get uploadAllowDownload(): boolean { + return this.appConfig.get('adf-version-manager.allowDownload', true); + } + /** * Gets the enablement of the file auto tryDownload feature from the app settings. */