[ACS-5839] migrate to latest JS-API types (#8859)

* [ci:force] migrate Minimal Node to Node

* [ci:force] remove js-api wrappers and use real types

* [ci:force] remove js-api wrappers and use real types

* [ci:force] fix linting errors

* [ci:force] fix linting errors

* [ci:force] security fixes

* [ci:force] sonarcloud bug fixes

* [ci:force] dead code elimination, sonar suggested fixes
This commit is contained in:
Denys Vuika
2023-08-29 20:56:40 +01:00
committed by GitHub
parent a5b05b3e5f
commit 3b4ce3b857
51 changed files with 1337 additions and 1984 deletions

View File

@@ -31,7 +31,7 @@ import {
import { Location } from '@angular/common';
import { MatDialog } from '@angular/material/dialog';
import { ActivatedRoute, Params, Router } from '@angular/router';
import { MinimalNodeEntity, NodePaging, Pagination, MinimalNodeEntryEntity, SiteEntry, SearchEntry } from '@alfresco/js-api';
import { NodeEntry, NodePaging, Pagination, Node, SiteEntry, SearchEntry } from '@alfresco/js-api';
import {
NotificationService,
DataRow,
@@ -71,12 +71,9 @@ const DEFAULT_FOLDER_TO_SHOW = '-my-';
templateUrl: './files.component.html',
styleUrls: ['./files.component.scss'],
encapsulation: ViewEncapsulation.None,
providers: [
{provide: FormRenderingService, useClass: ProcessFormRenderingService}
]
providers: [{ provide: FormRenderingService, useClass: ProcessFormRenderingService }]
})
export class FilesComponent implements OnInit, OnChanges, OnDestroy {
protected onDestroy$ = new Subject<boolean>();
errorMessage: string = null;
@@ -88,9 +85,9 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
includeFields = ['isFavorite', 'isLocked', 'aspectNames', 'definition'];
selectionModes = [
{value: 'none', viewValue: 'None'},
{value: 'single', viewValue: 'Single'},
{value: 'multiple', viewValue: 'Multiple'}
{ value: 'none', viewValue: 'None' },
{ value: 'single', viewValue: 'Single' },
{ value: 'multiple', viewValue: 'Multiple' }
];
// The identifier of a node. You can also use one of these well-known aliases: -my- | -shared- | -root-
@@ -199,13 +196,13 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
@Output()
deleteElementSuccess: EventEmitter<any> = new EventEmitter();
@ViewChild('documentList', {static: true})
@ViewChild('documentList', { static: true })
documentList: DocumentListComponent;
@ViewChild('standardPagination')
standardPagination: PaginationComponent;
@ViewChild(InfinitePaginationComponent, {static: true})
@ViewChild(InfinitePaginationComponent, { static: true })
infinitePaginationComponent: InfinitePaginationComponent;
permissionsStyle: PermissionStyleModel[] = [];
@@ -217,19 +214,20 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
displayEmptyMetadata = false;
hyperlinkNavigation = false;
constructor(private notificationService: NotificationService,
private uploadService: UploadService,
private contentService: ContentService,
private dialog: MatDialog,
private location: Location,
private router: Router,
private preference: UserPreferencesService,
private preview: PreviewService,
@Optional() private route: ActivatedRoute,
private contentMetadataService: ContentMetadataService,
private dialogAspectListService: DialogAspectListService,
private nodeService: NodesApiService) {
}
constructor(
private notificationService: NotificationService,
private uploadService: UploadService,
private contentService: ContentService,
private dialog: MatDialog,
private location: Location,
private router: Router,
private preference: UserPreferencesService,
private preview: PreviewService,
@Optional() private route: ActivatedRoute,
private contentMetadataService: ContentMetadataService,
private dialogAspectListService: DialogAspectListService,
private nodeService: NodesApiService
) {}
showFile(event) {
const entry = event.value.entry;
@@ -273,27 +271,17 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
this.onFileUploadEvent(value[0]);
});
this.uploadService.fileUploadDeleted
.pipe(takeUntil(this.onDestroy$))
.subscribe(value => this.onFileUploadEvent(value));
this.uploadService.fileUploadDeleted.pipe(takeUntil(this.onDestroy$)).subscribe((value) => this.onFileUploadEvent(value));
this.contentService.folderCreated
.pipe(takeUntil(this.onDestroy$))
.subscribe(value => this.onFolderCreated(value));
this.contentService.folderCreated.pipe(takeUntil(this.onDestroy$)).subscribe((value) => this.onFolderCreated(value));
this.contentService.folderCreate
.pipe(takeUntil(this.onDestroy$))
.subscribe(value => this.onFolderAction(value));
this.contentService.folderCreate.pipe(takeUntil(this.onDestroy$)).subscribe((value) => this.onFolderAction(value));
this.contentService.folderEdit
.pipe(takeUntil(this.onDestroy$))
.subscribe(value => this.onFolderAction(value));
this.contentService.folderEdit.pipe(takeUntil(this.onDestroy$)).subscribe((value) => this.onFolderAction(value));
this.contentMetadataService.error
.pipe(takeUntil(this.onDestroy$))
.subscribe((err: { message: string }) => {
this.notificationService.showError(err.message);
});
this.contentMetadataService.error.pipe(takeUntil(this.onDestroy$)).subscribe((err: { message: string }) => {
this.notificationService.showError(err.message);
});
}
onFileUploadEvent(event: FileUploadEvent) {
@@ -326,9 +314,9 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
} as Pagination;
}
getCurrentDocumentListNode(): MinimalNodeEntity[] {
getCurrentDocumentListNode(): NodeEntry[] {
if (this.documentList.folderNode) {
return [{entry: this.documentList.folderNode}];
return [{ entry: this.documentList.folderNode }];
} else {
return [];
}
@@ -416,7 +404,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
if (this.contentService.hasAllowableOperations(contentEntry, 'update')) {
this.dialog.open(VersionManagerDialogAdapterComponent, {
data: {contentEntry, showComments, allowDownload},
data: { contentEntry, showComments, allowDownload },
panelClass: 'adf-version-manager-dialog',
width: '630px'
});
@@ -427,7 +415,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
onAspectUpdate(event: any) {
this.dialogAspectListService.openAspectListDialog(event.value.entry.id).subscribe((aspectList) => {
this.nodeService.updateNode(event.value.entry.id, {aspectNames: [...aspectList]}).subscribe(() => {
this.nodeService.updateNode(event.value.entry.id, { aspectNames: [...aspectList] }).subscribe(() => {
this.openSnackMessageInfo('Node Aspects Updated');
});
});
@@ -476,7 +464,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
return null;
}
canEditFolder(selection: Array<MinimalNodeEntity>): boolean {
canEditFolder(selection: Array<NodeEntry>): boolean {
if (selection && selection.length === 1) {
const entry = selection[0].entry;
@@ -487,7 +475,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
return false;
}
canCreateContent(parentNode: MinimalNodeEntryEntity): boolean {
canCreateContent(parentNode: Node): boolean {
if (parentNode) {
return this.contentService.hasAllowableOperations(parentNode, 'create');
}
@@ -521,10 +509,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
toggleGalleryView(): void {
this.displayMode = this.displayMode === DisplayMode.List ? DisplayMode.Gallery : DisplayMode.List;
const url = this
.router
.createUrlTree(['/files', this.currentFolderId, 'display', this.displayMode])
.toString();
const url = this.router.createUrlTree(['/files', this.currentFolderId, 'display', this.displayMode]).toString();
this.location.go(url);
}
@@ -611,7 +596,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
objectFromMap[filter.key] = paramValue;
});
this.router.navigate([], {relativeTo: this.route, queryParams: objectFromMap});
this.router.navigate([], { relativeTo: this.route, queryParams: objectFromMap });
}
clearFilterNavigation() {

View File

@@ -17,20 +17,17 @@
import { Component, Inject, ViewEncapsulation } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { MinimalNodeEntryEntity } from '@alfresco/js-api';
import { Node } from '@alfresco/js-api';
@Component({
templateUrl: './metadata-dialog-adapter.component.html',
encapsulation: ViewEncapsulation.None
})
export class MetadataDialogAdapterComponent {
public contentEntry: MinimalNodeEntryEntity;
contentEntry: Node;
displayEmptyMetadata = false;
constructor(@Inject(MAT_DIALOG_DATA) data: any,
private containingDialog?: MatDialogRef<MetadataDialogAdapterComponent>) {
constructor(@Inject(MAT_DIALOG_DATA) data: any, private containingDialog?: MatDialogRef<MetadataDialogAdapterComponent>) {
this.contentEntry = data.contentEntry;
this.displayEmptyMetadata = data.displayEmptyMetadata;
}

View File

@@ -17,7 +17,7 @@
import { Component, Inject, ViewEncapsulation } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { MinimalNodeEntryEntity } from '@alfresco/js-api';
import { Node } from '@alfresco/js-api';
import { PreviewService } from '../../services/preview.service';
import { NotificationService } from '@alfresco/adf-core';
import { FileUploadErrorEvent } from '@alfresco/adf-content-services';
@@ -27,19 +27,19 @@ import { FileUploadErrorEvent } from '@alfresco/adf-content-services';
encapsulation: ViewEncapsulation.None
})
export class VersionManagerDialogAdapterComponent {
public contentEntry: MinimalNodeEntryEntity;
public newFileVersion: File;
contentEntry: Node;
newFileVersion: File;
showComments = true;
allowDownload = true;
readOnly = false;
showVersionComparison = false;
constructor(private previewService: PreviewService,
private notificationService: NotificationService,
@Inject(MAT_DIALOG_DATA) data: any,
private containingDialog?: MatDialogRef<VersionManagerDialogAdapterComponent>) {
constructor(
private previewService: PreviewService,
private notificationService: NotificationService,
@Inject(MAT_DIALOG_DATA) data: any,
private containingDialog?: MatDialogRef<VersionManagerDialogAdapterComponent>
) {
this.contentEntry = data.contentEntry;
this.newFileVersion = data.hasOwnProperty('newFileVersion') ? data.newFileVersion : this.newFileVersion;
this.showComments = data.hasOwnProperty('showComments') ? data.showComments : this.showComments;
@@ -47,8 +47,7 @@ export class VersionManagerDialogAdapterComponent {
}
uploadError(event: FileUploadErrorEvent) {
const errorMessage = event.error;
this.notificationService.showError(errorMessage);
this.notificationService.showError(event.error);
}
close() {

View File

@@ -17,7 +17,7 @@
import { Component } from '@angular/core';
import { Router } from '@angular/router';
import { MinimalNodeEntity } from '@alfresco/js-api';
import { NodeEntry } from '@alfresco/js-api';
import { PreviewService } from '../../services/preview.service';
@Component({
@@ -26,9 +26,7 @@ import { PreviewService } from '../../services/preview.service';
styleUrls: ['./search-bar.component.scss']
})
export class SearchBarComponent {
constructor(public router: Router, private preview: PreviewService) {
}
constructor(public router: Router, private preview: PreviewService) {}
/**
* Called when the user submits the search, e.g. hits enter or clicks submit
@@ -37,17 +35,19 @@ export class SearchBarComponent {
*/
onSearchSubmit(event: KeyboardEvent) {
const value = (event.target as HTMLInputElement).value;
this.router.navigate(['/search', {
q: value
}]);
this.router.navigate([
'/search',
{
q: value
}
]);
}
onItemClicked(event: MinimalNodeEntity) {
onItemClicked(event: NodeEntry) {
if (event.entry.isFile) {
this.preview.showResource(event.entry.id);
} else if (event.entry.isFolder) {
this.router.navigate(['/files', event.entry.id]);
}
}
}