Skip to content

Commit

Permalink
Disable Launch w/FireCloud if WDL has file imports (#332)
Browse files Browse the repository at this point in the history
* Disable Launch w/FireCloud if WDL has file imports

dockstore/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.
  • Loading branch information
coverbeck authored Jul 6, 2018
1 parent 250e81c commit 8e6a951
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 12 deletions.
14 changes: 14 additions & 0 deletions src/app/workflow/workflow.component.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
7 changes: 4 additions & 3 deletions src/app/workflow/workflow.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -210,19 +210,20 @@ <h3>Source Repositories</h3>
</div>
</div>
</div>
<div class="panel panel-default" *ngIf="workflow && (dnastackURL || fireCloudURL)">
<div class="panel panel-default" *ngIf="isWdl(workflow)">
<div class="panel-heading">
<h3>Launch with</h3>
</div>
<div class="panel-body">
<div class="container-source-repos">
<div class="container-launch-with">
<div class="button-wrap">
<p *ngIf="dnastackURL && (wdlHasFileImports || wdlHasHttpImports)" class="import-warning" >Warning: this version of the WDL has imports, which are not supported by DNAstack. Make sure to select a version without imports in DNAstack.</p>
<div *ngIf="dnastackURL" class="button">
<p><a href="{{dnastackURL}}"><img src="../../assets/images/thirdparty/dnastack.png"> DNAstack &raquo;</a></p>
</div>
<div *ngIf="fireCloudURL" class="button">
<p><a href="{{fireCloudURL}}"><img src="../../assets/images/thirdparty/FireCloud-white-icon.svg"> FireCloud &raquo;</a></p>
<div *ngIf="enableLaunchWithFireCloud" class="button" [title]="wdlHasFileImports ? 'FireCloud does not support file-path imports in WDL. It only supports http(s) imports.' : ''">
<p><a [class.disabled]="wdlHasFileImports" (click)="gotoFirecloud()"><img src="../../assets/images/thirdparty/FireCloud-white-icon.svg"> FireCloud &raquo;</a></p>
</div>
</div>
</div>
Expand Down
50 changes: 41 additions & 9 deletions src/app/workflow/workflow.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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;
Expand Down Expand Up @@ -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<SourceFile>) => {
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;
}
});
}
Expand All @@ -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);
}
}

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 8e6a951

Please sign in to comment.