mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-06-30 18:15:11 +00:00
[ACS-8476] ADW - on localhost attach file widget is opening login page instead of node selector (#9993)
This commit is contained in:
parent
b7ecfe6fc4
commit
8be3175cf2
@ -18,7 +18,16 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { AttachFileWidgetComponent } from './attach-file-widget.component';
|
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 { ContentNodeDialogService, ContentModule } from '@alfresco/adf-content-services';
|
||||||
import { of } from 'rxjs';
|
import { of } from 'rxjs';
|
||||||
import { Node } from '@alfresco/js-api';
|
import { Node } from '@alfresco/js-api';
|
||||||
@ -136,6 +145,7 @@ describe('AttachFileWidgetComponent', () => {
|
|||||||
let fixture: ComponentFixture<AttachFileWidgetComponent>;
|
let fixture: ComponentFixture<AttachFileWidgetComponent>;
|
||||||
let element: HTMLInputElement;
|
let element: HTMLInputElement;
|
||||||
let activitiContentService: ActivitiContentService;
|
let activitiContentService: ActivitiContentService;
|
||||||
|
let appConfigService: AppConfigService;
|
||||||
let contentNodeDialogService: ContentNodeDialogService;
|
let contentNodeDialogService: ContentNodeDialogService;
|
||||||
let processContentService: ProcessContentService;
|
let processContentService: ProcessContentService;
|
||||||
let downloadService: DownloadService;
|
let downloadService: DownloadService;
|
||||||
@ -153,6 +163,7 @@ describe('AttachFileWidgetComponent', () => {
|
|||||||
contentNodeDialogService = TestBed.inject(ContentNodeDialogService);
|
contentNodeDialogService = TestBed.inject(ContentNodeDialogService);
|
||||||
processContentService = TestBed.inject(ProcessContentService);
|
processContentService = TestBed.inject(ProcessContentService);
|
||||||
downloadService = TestBed.inject(DownloadService);
|
downloadService = TestBed.inject(DownloadService);
|
||||||
|
appConfigService = TestBed.inject(AppConfigService);
|
||||||
formService = TestBed.inject(FormService);
|
formService = TestBed.inject(FormService);
|
||||||
attachFileWidgetDialogService = TestBed.inject(AttachFileWidgetDialogService);
|
attachFileWidgetDialogService = TestBed.inject(AttachFileWidgetDialogService);
|
||||||
});
|
});
|
||||||
@ -608,4 +619,12 @@ describe('AttachFileWidgetComponent', () => {
|
|||||||
|
|
||||||
expect(openLoginSpy).toHaveBeenCalledWith(fakeRepositoryListAnswer[2], undefined, 'alfresco-2000-external');
|
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();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
/* eslint-disable @angular-eslint/component-selector */
|
/* 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 { AppConfigService, AppConfigValues, DownloadService, ErrorWidgetComponent, FormService, ThumbnailService } from '@alfresco/adf-core';
|
||||||
import { ContentNodeDialogService, ContentService } from '@alfresco/adf-content-services';
|
import { ContentNodeDialogService, ContentService } from '@alfresco/adf-content-services';
|
||||||
import { AlfrescoEndpointRepresentation, Node, NodeChildAssociation, RelatedContentRepresentation } from '@alfresco/js-api';
|
import { AlfrescoEndpointRepresentation, Node, NodeChildAssociation, RelatedContentRepresentation } from '@alfresco/js-api';
|
||||||
@ -200,12 +200,14 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
openSelectDialog(repository: AlfrescoEndpointRepresentation) {
|
openSelectDialog(repository: AlfrescoEndpointRepresentation) {
|
||||||
if (this.isExternalHost(repository)) {
|
if (this.isExternalHost(repository) && !isDevMode()) {
|
||||||
this.uploadFileFromExternalCS(repository);
|
this.uploadFileFromExternalCS(repository);
|
||||||
} else {
|
} else {
|
||||||
this.contentDialog.openFileBrowseDialogByDefaultLocation().subscribe((selections: Node[]) => {
|
this.contentDialog.openFileBrowseDialogByDefaultLocation().subscribe((selections: Node[]) => {
|
||||||
|
if (selections.length) {
|
||||||
this.tempFilesList.push(...selections);
|
this.tempFilesList.push(...selections);
|
||||||
this.uploadFileFromCS(selections, `alfresco-${repository.id}-${repository.name}`);
|
this.uploadFileFromCS(selections, `alfresco-${repository.id}-${repository.name}`);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user