mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
ACS-8404: Update application settings service (#3988)
This commit is contained in:
@@ -22,25 +22,21 @@
|
||||
* 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 { 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: `
|
||||
<ng-container *ngIf="isFileSelected; else empty">
|
||||
<adf-version-manager
|
||||
[showComments]="'adf-version-manager.allowComments' | adfAppConfig : true"
|
||||
[allowDownload]="'adf-version-manager.allowDownload' | adfAppConfig : true"
|
||||
[node]="node"
|
||||
>
|
||||
<adf-version-manager [showComments]="settings.uploadAllowComments" [allowDownload]="settings.uploadAllowDownload" [node]="node">
|
||||
</adf-version-manager>
|
||||
</ng-container>
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
@@ -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);
|
||||
});
|
||||
|
||||
|
@@ -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));
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user