From 8e6a951208fc1c78d7d6762e65127adb797c7784 Mon Sep 17 00:00:00 2001 From: Charles Overbeck Date: Fri, 6 Jul 2018 13:47:57 -0700 Subject: [PATCH] Disable Launch w/FireCloud if WDL has file imports (#332) * Disable Launch w/FireCloud if WDL has file imports ga4gh/dockstore#330 For FireCloud, disable instead of hide the Launch button if there are file-path imports, so user knows what is going on, with a tooltip explaining why the button is disabled. For DNAstack, because the user can select any version of the workflow in their UI, display a warning, but don't disable the button, if the workflow has any imports. --- src/app/workflow/workflow.component.css | 14 +++++++ src/app/workflow/workflow.component.html | 7 ++-- src/app/workflow/workflow.component.ts | 50 +++++++++++++++++++----- 3 files changed, 59 insertions(+), 12 deletions(-) diff --git a/src/app/workflow/workflow.component.css b/src/app/workflow/workflow.component.css index 2e6cf08e36..bddbab6a19 100644 --- a/src/app/workflow/workflow.component.css +++ b/src/app/workflow/workflow.component.css @@ -34,3 +34,17 @@ pre { .button-wrap > .button:not(:last-child) { margin-bottom: 10px; } +a.disabled { + color: gray; + cursor: not-allowed; +} +a.disabled > img { + filter: brightness(90%); +} +p.import-warning { + font-size: 11px; + font-style: italic; + text-align: left; + line-height: 1em; + margin-bottom: 4px; +} diff --git a/src/app/workflow/workflow.component.html b/src/app/workflow/workflow.component.html index 6a8176216e..73cbba1e44 100644 --- a/src/app/workflow/workflow.component.html +++ b/src/app/workflow/workflow.component.html @@ -210,7 +210,7 @@

Source Repositories

-
+

Launch with

@@ -218,11 +218,12 @@

Launch with

+

Warning: this version of the WDL has imports, which are not supported by DNAstack. Make sure to select a version without imports in DNAstack.

-
diff --git a/src/app/workflow/workflow.component.ts b/src/app/workflow/workflow.component.ts index a7bb653e6b..4c5b2371da 100644 --- a/src/app/workflow/workflow.component.ts +++ b/src/app/workflow/workflow.component.ts @@ -38,6 +38,8 @@ import { Workflow } from './../shared/swagger/model/workflow'; import { UrlResolverService } from './../shared/url-resolver.service'; import { SourceFile } from '../shared/swagger/model/sourceFile'; +const importHttpRegEx: RegExp = new RegExp(/^\s*import\s+"https?/, 'm'); + @Component({ selector: 'app-workflow', templateUrl: './workflow.component.html', @@ -47,6 +49,9 @@ export class WorkflowComponent extends Entry { workflowEditData: any; dnastackURL: string; fireCloudURL: string; + public wdlHasHttpImports: boolean; + public wdlHasFileImports: boolean; + public enableLaunchWithFireCloud = Dockstore.FEATURES.enableLaunchWithFireCloud; public workflow; public missingWarning: boolean; public title: string; @@ -110,18 +115,45 @@ export class WorkflowComponent extends Entry { } } - private isWdl(workflowRef: ExtendedWorkflow) { - return workflowRef.full_workflow_path && workflowRef.descriptorType === 'wdl'; + public isWdl(workflowRef: ExtendedWorkflow) { + return workflowRef && workflowRef.full_workflow_path && workflowRef.descriptorType === 'wdl'; + } + + public gotoFirecloud() { + if (this.fireCloudURL) { + window.open(this.fireCloudURL); + } } - private setupFireCloudUrl(workflowRef: ExtendedWorkflow) { - if (Dockstore.FEATURES.enableLaunchWithFireCloud) { - this.fireCloudURL = null; + /** + * Checks WDL for import statements, setting wdlHasFileImports and wdlHasHttpImports properties + * accordingly. If the WDL has file imports, doesn't bother to check if there are http imports, to save + * an Ajax call. + * + * Also sets the fireCloudURL property if the WDL has no file imports. + * + * This can be done more cleanly, but since code has been moved and substantially changed in develop branch, + * leaving like this for hot fix. + * + * @param {ExtendedWorkflow} workflowRef + */ + private checkWdlForImportsAndSetFirecloudUrl(workflowRef: ExtendedWorkflow) { + this.fireCloudURL = null; + this.wdlHasFileImports = false; + this.wdlHasHttpImports = false; + if (this.isWdl(workflowRef)) { const version: WorkflowVersion = this.selectedVersion; - if (version && this.isWdl(workflowRef)) { + if (version) { this.workflowsService.secondaryWdl(workflowRef.id, version.name).subscribe((sourceFiles: Array) => { if (!sourceFiles || sourceFiles.length === 0) { - this.fireCloudURL = `${Dockstore.FIRECLOUD_IMPORT_URL}/${workflowRef.full_workflow_path}:${version.name}`; + this.workflowsService.wdl(workflowRef.id, version.name).subscribe((sourceFile) => { + this.wdlHasHttpImports = importHttpRegEx.test(sourceFile.content); + }); + if (this.enableLaunchWithFireCloud) { + this.fireCloudURL = `${Dockstore.FIRECLOUD_IMPORT_URL}/${workflowRef.full_workflow_path}:${version.name}`; + } + } else { + this.wdlHasFileImports = true; } }); } @@ -142,7 +174,7 @@ export class WorkflowComponent extends Entry { this.title = this.workflow.full_workflow_path; this.initTool(); this.sortedVersions = this.getSortedVersions(this.workflow.workflowVersions, this.defaultVersion); - this.setupFireCloudUrl(this.workflow); + this.checkWdlForImportsAndSetFirecloudUrl(this.workflow); } } @@ -297,7 +329,7 @@ export class WorkflowComponent extends Entry { if (this.workflow != null) { this.updateUrl(this.workflow.full_workflow_path, 'my-workflows', 'workflows'); } - this.setupFireCloudUrl(this.workflow); + this.checkWdlForImportsAndSetFirecloudUrl(this.workflow); } setEntryTab(tabName: string): void {