Skip to content

Commit

Permalink
[ACS-5839] migrate to latest JS-API types (#8859)
Browse files Browse the repository at this point in the history
* [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
  • Loading branch information
DenysVuika committed Aug 29, 2023
1 parent a5b05b3 commit 3b4ce3b
Show file tree
Hide file tree
Showing 51 changed files with 1,344 additions and 1,991 deletions.
87 changes: 36 additions & 51 deletions demo-shell/src/app/components/files/files.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand All @@ -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-
Expand Down Expand Up @@ -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[] = [];
Expand All @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 [];
}
Expand Down Expand Up @@ -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'
});
Expand All @@ -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');
});
});
Expand Down Expand Up @@ -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;

Expand All @@ -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');
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -27,28 +27,27 @@ 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;
this.allowDownload = data.hasOwnProperty('allowDownload') ? data.allowDownload : this.allowDownload;
}

uploadError(event: FileUploadErrorEvent) {
const errorMessage = event.error;
this.notificationService.showError(errorMessage);
this.notificationService.showError(event.error);
}

close() {
Expand Down
18 changes: 9 additions & 9 deletions demo-shell/src/app/components/search/search-bar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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
Expand All @@ -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]);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ will trigger the same action.) You can also add your own handler by implementing
`execute` event.

Note that you can use _both_ a built-in handler and your own `execute`
function in the same action. The `execute` function is passed a [`NodeMinimalEntry`](../../../lib/content-services/src/lib/document-list/models/document-library.model.ts) as its
function in the same action. The `execute` function is passed a **NodeEntry** as its
parameter. For
example, with `handler="delete"` you could use `execute` to show a message with the name,
type, and other details of the item just deleted:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ Extends from [`BaseCardViewUpdate`](../../../lib/core/src/lib/card-view/interfac
```ts
export interface BaseCardViewContentUpdate {
itemUpdated$: Subject<UpdateNotification>;
updatedAspect$: Subject<MinimalNode>;
updatedAspect$: Subject<Node>;

update(property: CardViewBaseItemModel, newValue: any);
updateElement(notification: CardViewBaseItemModel);
updateNodeAspect(node: MinimalNode);
updateNodeAspect(node: Node);
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ constructor(private contentDialogService: ContentNodeDialogService){}
yourFunctionOnCopyOrMove(){
this.contentDialogService
.openCopyMoveDialog(actionName, targetNode, neededPermissionForAction)
.subscribe((selections: MinimalNode[]) => {
.subscribe((selections: Node[]) => {
// place your action here on operation success!
});
}
Expand Down

0 comments on commit 3b4ce3b

Please sign in to comment.