[ACS-8476] ADW - on localhost attach file widget is opening login page instead of node selector (#9993)

This commit is contained in:
dominikiwanekhyland 2024-07-31 22:29:28 +02:00 committed by GitHub
parent b7ecfe6fc4
commit 8be3175cf2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 5 deletions

View File

@ -18,7 +18,16 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { AttachFileWidgetComponent } from './attach-file-widget.component';
import { FormFieldModel, FormModel, FormFieldTypes, FormService, FormFieldMetadata, DownloadService } from '@alfresco/adf-core';
import {
FormFieldModel,
FormModel,
FormFieldTypes,
FormService,
FormFieldMetadata,
DownloadService,
AppConfigService,
AppConfigValues
} from '@alfresco/adf-core';
import { ContentNodeDialogService, ContentModule } from '@alfresco/adf-content-services';
import { of } from 'rxjs';
import { Node } from '@alfresco/js-api';
@ -136,6 +145,7 @@ describe('AttachFileWidgetComponent', () => {
let fixture: ComponentFixture<AttachFileWidgetComponent>;
let element: HTMLInputElement;
let activitiContentService: ActivitiContentService;
let appConfigService: AppConfigService;
let contentNodeDialogService: ContentNodeDialogService;
let processContentService: ProcessContentService;
let downloadService: DownloadService;
@ -153,6 +163,7 @@ describe('AttachFileWidgetComponent', () => {
contentNodeDialogService = TestBed.inject(ContentNodeDialogService);
processContentService = TestBed.inject(ProcessContentService);
downloadService = TestBed.inject(DownloadService);
appConfigService = TestBed.inject(AppConfigService);
formService = TestBed.inject(FormService);
attachFileWidgetDialogService = TestBed.inject(AttachFileWidgetDialogService);
});
@ -608,4 +619,12 @@ describe('AttachFileWidgetComponent', () => {
expect(openLoginSpy).toHaveBeenCalledWith(fakeRepositoryListAnswer[2], undefined, 'alfresco-2000-external');
});
it('should open fileBrowserDialog if devMode flag is on', async () => {
spyOn(appConfigService, 'get').withArgs(AppConfigValues.ECMHOST).and.returnValue('ECMHOST');
spyOn(contentNodeDialogService, 'openFileBrowseDialogByDefaultLocation').and.returnValue(of([]));
widget.openSelectDialog({ repositoryUrl: 'repositoryUrl' });
await fixture.whenStable();
expect(contentNodeDialogService.openFileBrowseDialogByDefaultLocation).toHaveBeenCalled();
});
});

View File

@ -17,7 +17,7 @@
/* eslint-disable @angular-eslint/component-selector */
import { Component, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
import { Component, isDevMode, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
import { AppConfigService, AppConfigValues, DownloadService, ErrorWidgetComponent, FormService, ThumbnailService } from '@alfresco/adf-core';
import { ContentNodeDialogService, ContentService } from '@alfresco/adf-content-services';
import { AlfrescoEndpointRepresentation, Node, NodeChildAssociation, RelatedContentRepresentation } from '@alfresco/js-api';
@ -200,12 +200,14 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements
}
openSelectDialog(repository: AlfrescoEndpointRepresentation) {
if (this.isExternalHost(repository)) {
if (this.isExternalHost(repository) && !isDevMode()) {
this.uploadFileFromExternalCS(repository);
} else {
this.contentDialog.openFileBrowseDialogByDefaultLocation().subscribe((selections: Node[]) => {
if (selections.length) {
this.tempFilesList.push(...selections);
this.uploadFileFromCS(selections, `alfresco-${repository.id}-${repository.name}`);
}
});
}
}