[ACS-5845] remove Alfresco Compatibility usage (#8822)

* upgrade to latest js-api

* upgrade to latest js-api

* upgrade to latest js-api

* upgrade to latest js-api

* upgrade to latest js-api

* upgrade to latest js-api

* fix security concerns for execSync

* security fix

* fixes as per code reviews

* code fixes for attach file widget dialog

* code fixes

* code fixes

* disable ACS storage check

* add the jira to the commented out block

* remove useless logger call

* code fixes

* code fixes

* code fixes

* code and typing fixes

* fix lint

* disable the code

* try other fixes, add missing headers

* dump error to console

* replace test file with in-memory stream

* code fixes

* simplify checks

* disable upload

* remove useless test and ng-mocks dependency
This commit is contained in:
Denys Vuika
2023-08-22 00:02:39 +01:00
committed by GitHub
parent d0c35c28ee
commit 29ec2fcc96
23 changed files with 682 additions and 676 deletions

View File

@@ -16,43 +16,12 @@
*/
import { Injectable } from '@angular/core';
import {
AlfrescoApiCompatibility,
ContentApi,
Node, NodesApi
} from '@alfresco/js-api';
import { ReplaySubject, Subject } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class ExternalAlfrescoApiService {
/**
* Publish/subscribe to events related to node updates.
*/
nodeUpdated = new Subject<Node>();
alfrescoApiInitialized: ReplaySubject<boolean> = new ReplaySubject(1);
protected alfrescoApi: AlfrescoApiCompatibility;
_nodesApi: NodesApi;
getInstance(): AlfrescoApiCompatibility {
return this.alfrescoApi;
}
get contentApi(): ContentApi {
return this.getInstance().content;
}
get nodesApi(): NodesApi {
this._nodesApi = this._nodesApi ?? new NodesApi(this.getInstance());
return this._nodesApi;
}
import { AlfrescoApi } from '@alfresco/js-api';
import { AlfrescoApiService } from '@alfresco/adf-core';
@Injectable({ providedIn: 'root' })
export class ExternalAlfrescoApiService extends AlfrescoApiService {
init(ecmHost: string, contextRoot: string) {
const domainPrefix = this.createPrefixFromHost(ecmHost);
const config = {
@@ -62,15 +31,15 @@ export class ExternalAlfrescoApiService {
contextRoot,
domainPrefix
};
this.initAlfrescoApi(config);
this.setup(config);
this.alfrescoApiInitialized.next(true);
}
protected initAlfrescoApi(config) {
private setup(config) {
if (this.alfrescoApi) {
this.alfrescoApi.configureJsApi(config);
this.alfrescoApi.setConfig(config);
} else {
this.alfrescoApi = new AlfrescoApiCompatibility(config);
this.alfrescoApi = new AlfrescoApi(config);
}
}

View File

@@ -17,12 +17,7 @@
import { Component, Inject, ViewEncapsulation, ViewChild } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import {
AlfrescoApiService,
LoginDialogPanelComponent,
TranslationService,
AuthenticationService
} from '@alfresco/adf-core';
import { AlfrescoApiService, LoginDialogPanelComponent, TranslationService, AuthenticationService } from '@alfresco/adf-core';
import { AttachFileWidgetDialogComponentData } from './attach-file-widget-dialog-component.interface';
import { DocumentListService, SitesService, SearchService } from '@alfresco/adf-content-services';
import { ExternalAlfrescoApiService } from '../../services/external-alfresco-api.service';
@@ -38,10 +33,10 @@ import { Node } from '@alfresco/js-api';
DocumentListService,
SitesService,
SearchService,
{ provide: AlfrescoApiService, useClass: ExternalAlfrescoApiService } ]
{ provide: AlfrescoApiService, useClass: ExternalAlfrescoApiService }
]
})
export class AttachFileWidgetDialogComponent {
@ViewChild('adfLoginPanel')
loginPanel: LoginDialogPanelComponent;
@@ -50,12 +45,14 @@ export class AttachFileWidgetDialogComponent {
buttonActionName: string;
chosenNode: Node[];
constructor(private translation: TranslationService,
@Inject(MAT_DIALOG_DATA) public data: AttachFileWidgetDialogComponentData,
private externalApiService: AlfrescoApiService,
private authenticationService: AuthenticationService,
private matDialogRef: MatDialogRef<AttachFileWidgetDialogComponent>) {
(externalApiService as any).init(data.ecmHost, data.context);
constructor(
private translation: TranslationService,
@Inject(MAT_DIALOG_DATA) public data: AttachFileWidgetDialogComponentData,
private externalApiService: AlfrescoApiService,
private authenticationService: AuthenticationService,
private matDialogRef: MatDialogRef<AttachFileWidgetDialogComponent>
) {
(externalApiService as ExternalAlfrescoApiService).init(data.ecmHost, data.context);
this.action = data.actionName ? data.actionName.toUpperCase() : 'CHOOSE';
this.buttonActionName = `ATTACH-FILE.ACTIONS.${this.action}`;
this.updateTitle('DROPDOWN.MY_FILES_OPTION');
@@ -64,13 +61,13 @@ export class AttachFileWidgetDialogComponent {
updateExternalHost() {
this.authenticationService.onLogin.subscribe(() => this.registerAndClose());
if (this.externalApiService.getInstance().isLoggedIn()) {
if (this.isLoggedIn()) {
this.registerAndClose();
}
}
isLoggedIn() {
return this.externalApiService.getInstance().isLoggedIn();
isLoggedIn(): boolean {
return !!this.externalApiService.getInstance()?.isLoggedIn();
}
performLogin() {

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { UrlService, LogService, ContentLinkModel, FormService, DownloadService } from '@alfresco/adf-core';
import { UrlService, ContentLinkModel, FormService, DownloadService } from '@alfresco/adf-core';
import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges, ViewEncapsulation } from '@angular/core';
import { Observable } from 'rxjs';
import { ProcessContentService } from '../../services/process-content.service';
@@ -27,7 +27,6 @@ import { ProcessContentService } from '../../services/process-content.service';
encapsulation: ViewEncapsulation.None
})
export class ContentWidgetComponent implements OnChanges {
/** The content id to show. */
@Input()
id: string;
@@ -54,12 +53,12 @@ export class ContentWidgetComponent implements OnChanges {
content: ContentLinkModel;
constructor(protected formService: FormService,
private logService: LogService,
private downloadService: DownloadService,
private urlService: UrlService,
private processContentService: ProcessContentService) {
}
constructor(
protected formService: FormService,
private downloadService: DownloadService,
private urlService: UrlService,
private processContentService: ProcessContentService
) {}
ngOnChanges(changes: SimpleChanges) {
const contentId = changes['id'];
@@ -69,18 +68,16 @@ export class ContentWidgetComponent implements OnChanges {
}
loadContent(id: number) {
this.processContentService
.getFileContent(id)
.subscribe(
(response: ContentLinkModel) => {
this.content = new ContentLinkModel(response);
this.contentLoaded.emit(this.content);
this.loadThumbnailUrl(this.content);
},
(error) => {
this.error.emit(error);
}
);
this.processContentService.getFileContent(id).subscribe(
(response: ContentLinkModel) => {
this.content = new ContentLinkModel(response);
this.contentLoaded.emit(this.content);
this.loadThumbnailUrl(this.content);
},
(error) => {
this.error.emit(error);
}
);
}
loadThumbnailUrl(content: ContentLinkModel) {
@@ -101,7 +98,6 @@ export class ContentWidgetComponent implements OnChanges {
},
(error) => {
this.error.emit(error);
}
);
}
@@ -117,7 +113,6 @@ export class ContentWidgetComponent implements OnChanges {
(blob: Blob) => {
content.contentBlob = blob;
this.contentClick.emit(content);
this.logService.info('Content clicked' + content.id);
this.formService.formContentClicked.next(content);
},
(error) => {