mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACA-4503] Fix closing dialogs behind when closing the content selector dialog (#7138)
* [ACA-4503] Fix closing dialogs behind when closing the content selector dialog * [ACA-4503] Close the dialogs from the content node selector component
This commit is contained in:
committed by
GitHub
parent
05c3ed01d7
commit
d93980d1a3
@@ -142,12 +142,6 @@ describe('ContentNodeDialogService', () => {
|
|||||||
expect(spyOnDialogOpen).toHaveBeenCalled();
|
expect(spyOnDialogOpen).toHaveBeenCalled();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should be able to close the material dialog', () => {
|
|
||||||
spyOn(materialDialog, 'closeAll');
|
|
||||||
service.close();
|
|
||||||
expect(materialDialog.closeAll).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('for the copy/move dialog', () => {
|
describe('for the copy/move dialog', () => {
|
||||||
const siteNode: Node = <Node> {
|
const siteNode: Node = <Node> {
|
||||||
id: 'site-node-id',
|
id: 'site-node-id',
|
||||||
|
@@ -143,9 +143,6 @@ export class ContentNodeDialogService {
|
|||||||
if (this.contentService.hasAllowableOperations(contentEntry, permission)) {
|
if (this.contentService.hasAllowableOperations(contentEntry, permission)) {
|
||||||
|
|
||||||
const select = new Subject<Node[]>();
|
const select = new Subject<Node[]>();
|
||||||
select.subscribe({
|
|
||||||
complete: this.close.bind(this)
|
|
||||||
});
|
|
||||||
|
|
||||||
const data: ContentNodeSelectorComponentData = {
|
const data: ContentNodeSelectorComponentData = {
|
||||||
title: this.getTitleTranslation(action, contentEntry.name),
|
title: this.getTitleTranslation(action, contentEntry.name),
|
||||||
@@ -186,9 +183,6 @@ export class ContentNodeDialogService {
|
|||||||
*/
|
*/
|
||||||
openUploadFolderDialog(action: NodeAction, contentEntry: Node): Observable<Node[]> {
|
openUploadFolderDialog(action: NodeAction, contentEntry: Node): Observable<Node[]> {
|
||||||
const select = new Subject<Node[]>();
|
const select = new Subject<Node[]>();
|
||||||
select.subscribe({
|
|
||||||
complete: this.close.bind(this)
|
|
||||||
});
|
|
||||||
|
|
||||||
const data: ContentNodeSelectorComponentData = {
|
const data: ContentNodeSelectorComponentData = {
|
||||||
title: this.getTitleTranslation(action, this.translation.instant('DROPDOWN.MY_FILES_OPTION')),
|
title: this.getTitleTranslation(action, this.translation.instant('DROPDOWN.MY_FILES_OPTION')),
|
||||||
@@ -214,9 +208,6 @@ export class ContentNodeDialogService {
|
|||||||
*/
|
*/
|
||||||
openUploadFileDialog(action: NodeAction, contentEntry: Node, showFilesInResult = false): Observable<Node[]> {
|
openUploadFileDialog(action: NodeAction, contentEntry: Node, showFilesInResult = false): Observable<Node[]> {
|
||||||
const select = new Subject<Node[]>();
|
const select = new Subject<Node[]>();
|
||||||
select.subscribe({
|
|
||||||
complete: this.close.bind(this)
|
|
||||||
});
|
|
||||||
|
|
||||||
const data: ContentNodeSelectorComponentData = {
|
const data: ContentNodeSelectorComponentData = {
|
||||||
title: this.getTitleTranslation(action, this.translation.instant('DROPDOWN.MY_FILES_OPTION')),
|
title: this.getTitleTranslation(action, this.translation.instant('DROPDOWN.MY_FILES_OPTION')),
|
||||||
@@ -273,9 +264,4 @@ export class ContentNodeDialogService {
|
|||||||
return !!entry.guid || entry.nodeType === 'st:site' || entry.nodeType === 'st:sites';
|
return !!entry.guid || entry.nodeType === 'st:site' || entry.nodeType === 'st:sites';
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Closes the currently open dialog. */
|
|
||||||
close() {
|
|
||||||
this.dialog.closeAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -37,6 +37,7 @@ describe('ContentNodeSelectorComponent', () => {
|
|||||||
let fixture: ComponentFixture<ContentNodeSelectorComponent>;
|
let fixture: ComponentFixture<ContentNodeSelectorComponent>;
|
||||||
let data: any;
|
let data: any;
|
||||||
let uploadService: UploadService;
|
let uploadService: UploadService;
|
||||||
|
let dialog: MatDialogRef<ContentNodeSelectorComponent>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
data = {
|
data = {
|
||||||
@@ -73,6 +74,7 @@ describe('ContentNodeSelectorComponent', () => {
|
|||||||
|
|
||||||
const documentListService = TestBed.inject(DocumentListService);
|
const documentListService = TestBed.inject(DocumentListService);
|
||||||
const sitesService: SitesService = TestBed.inject(SitesService);
|
const sitesService: SitesService = TestBed.inject(SitesService);
|
||||||
|
dialog = TestBed.inject(MatDialogRef);
|
||||||
uploadService = TestBed.inject(UploadService);
|
uploadService = TestBed.inject(UploadService);
|
||||||
|
|
||||||
spyOn(documentListService, 'getFolder').and.callThrough();
|
spyOn(documentListService, 'getFolder').and.callThrough();
|
||||||
@@ -193,6 +195,23 @@ describe('ContentNodeSelectorComponent', () => {
|
|||||||
const closeButton = fixture.debugElement.query(By.css('[content-node-selector-actions-cancel]'));
|
const closeButton = fixture.debugElement.query(By.css('[content-node-selector-actions-cancel]'));
|
||||||
expect(closeButton).toBeNull();
|
expect(closeButton).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should close the dialog', () => {
|
||||||
|
let cancelButton;
|
||||||
|
data.select.subscribe(
|
||||||
|
() => {
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
cancelButton = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-actions-cancel"]'));
|
||||||
|
expect(cancelButton).not.toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
cancelButton = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-actions-cancel"]'));
|
||||||
|
cancelButton.triggerEventHandler('click', {});
|
||||||
|
expect(dialog.close).toHaveBeenCalled();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Action button for the chosen node', () => {
|
describe('Action button for the chosen node', () => {
|
||||||
@@ -227,6 +246,16 @@ describe('ContentNodeSelectorComponent', () => {
|
|||||||
|
|
||||||
expect(actionButtonWithoutNodeSelected.nativeElement.disabled).toBe(true);
|
expect(actionButtonWithoutNodeSelected.nativeElement.disabled).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should close the dialog when action button is clicked', async () => {
|
||||||
|
component.onSelect([new Node({ id: 'fake' })]);
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const actionButton = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-actions-choose"]'));
|
||||||
|
await actionButton.nativeElement.click();
|
||||||
|
|
||||||
|
expect(dialog.close).toHaveBeenCalled();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Title', () => {
|
describe('Title', () => {
|
||||||
|
@@ -77,6 +77,7 @@ export class ContentNodeSelectorComponent implements OnInit {
|
|||||||
|
|
||||||
close() {
|
close() {
|
||||||
this.data.select.complete();
|
this.data.select.complete();
|
||||||
|
this.dialog.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
onSelect(nodeList: Node[]) {
|
onSelect(nodeList: Node[]) {
|
||||||
@@ -94,7 +95,7 @@ export class ContentNodeSelectorComponent implements OnInit {
|
|||||||
|
|
||||||
onClick(): void {
|
onClick(): void {
|
||||||
this.data.select.next(this.chosenNode);
|
this.data.select.next(this.chosenNode);
|
||||||
this.data.select.complete();
|
this.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTitle(siteTitle: string) {
|
updateTitle(siteTitle: string) {
|
||||||
|
Reference in New Issue
Block a user