diff --git a/src/app/workflow-spec-list/workflow-spec-list.component.spec.ts b/src/app/workflow-spec-list/workflow-spec-list.component.spec.ts index bf7402a..36b8caa 100644 --- a/src/app/workflow-spec-list/workflow-spec-list.component.spec.ts +++ b/src/app/workflow-spec-list/workflow-spec-list.component.spec.ts @@ -495,10 +495,7 @@ describe('WorkflowSpecListComponent', () => { it('should not delete a library if it is being used', () => { const badWorkflowSpec = cloneDeep(mockWorkflowSpec0); - badWorkflowSpec.parents=[ - { id: 1234, - display_name: 'test parent', - }] + mockWorkflowSpec1.libraries = ['all_things'] badWorkflowSpec.library=true; const mockConfirmDeleteData: DeleteWorkflowSpecDialogData = { confirm: false, @@ -508,12 +505,10 @@ describe('WorkflowSpecListComponent', () => { const _deleteWorkflowSpecSpy = spyOn((component as any), '_deleteWorkflowSpec').and.stub(); const openDialogSpy = spyOn(component.dialog, 'open') .and.returnValue({afterClosed: () => of(mockConfirmDeleteData)} as any); - const snackBarSpy = spyOn((component as any).snackBar, 'open').and.stub(); mockConfirmDeleteData.confirm = true; component.confirmDeleteWorkflowSpec(badWorkflowSpec); expect(openDialogSpy).toHaveBeenCalled(); expect(_deleteWorkflowSpecSpy).not.toHaveBeenCalled(); - expect(snackBarSpy).toHaveBeenCalled(); }); diff --git a/src/app/workflow-spec-list/workflow-spec-list.component.ts b/src/app/workflow-spec-list/workflow-spec-list.component.ts index 1f97f51..9fbad47 100644 --- a/src/app/workflow-spec-list/workflow-spec-list.component.ts +++ b/src/app/workflow-spec-list/workflow-spec-list.component.ts @@ -191,10 +191,15 @@ export class WorkflowSpecListComponent implements OnInit { canDeleteWorkflowSpec(wfs){ - // TODO: move this to the backend - // Find if library is still being referenced somewhere. If so, return a message about where + // TODO: put the popup back in for this + let references = [] if (wfs.library){ - // return false; + this.workflowSpecs.forEach(spec => { + if (spec.libraries.indexOf(wfs.id) >= 0 ) { + references.push(wfs.id); + } + }); + return false; // and later return and deal with references } return true; } @@ -210,10 +215,12 @@ export class WorkflowSpecListComponent implements OnInit { dialogRef.afterClosed().subscribe((data: DeleteWorkflowSpecDialogData) => { if (data && data.confirm && data.workflowSpec && this.canDeleteWorkflowSpec(data.workflowSpec)) { - this._deleteWorkflowSpec(data.workflowSpec); +7 this._deleteWorkflowSpec(data.workflowSpec); if (typeof this.masterStatusSpec !== 'undefined') { this.selectSpec(this.masterStatusSpec); } + } else { + // TODO: the library is being referenced elsewhere still } }); }