Skip to content

Commit

Permalink
Hotfix/docker pull fix (#196)
Browse files Browse the repository at this point in the history
* Fix for docker pull command in versions modal

* Remove function in template

* Update docker pull command when tool changes

* Test docker pull command by injecting a real tool and real tag into the component

* Add an additional tool to database

* Simplify unit test

* Hotfix conflict fix

* Revert "Remove enduser"

This reverts commit 0aabdb9.

* Revert changes again

* Update database for hotfix branch
  • Loading branch information
garyluu authored Feb 14, 2018
1 parent ccb5e27 commit 34cb707
Show file tree
Hide file tree
Showing 9 changed files with 856 additions and 306 deletions.
4 changes: 2 additions & 2 deletions cypress/integration/ToolsSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ describe('Dockstore tool search page', function() {
});

describe('Select a tool', function() {
it('Should have three tools and no hidden row)', function() {
it('Should have 4 tools', function() {
cy
.get('tbody')
.children('tr')
.should('have.length', 3)
.should('have.length', 4)
});

it('Select dockstore-tool-imports', function() {
Expand Down
23 changes: 23 additions & 0 deletions cypress/integration/VersionModal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
describe('Public Version Modal', function() {
require('./helper.js')
beforeEach(function() {
cy.visit(String(global.baseUrl) + "/containers/quay.io/garyluu/dockstore-cgpmap/cgpmap-cramOut")
cy
.get('tab')
.should('have.length', 7)
});

it('Change tab to versions', function() {
cy
.get('.nav-link')
.contains('Versions')
.parent()
.click()

cy
.contains("View")
.click()
cy.get('form')
cy.get('#dockerPullCommand').should('be.visible').should('have.value','docker pull quay.io/garyluu/dockstore-cgpmap:3.0.0-rc8')
});
})
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ <h4 class="modal-title">{{TagEditorMode[mode]}} Version Tag</h4>
</label>
<div class="col-sm-9 col-md-9 col-lg-9" *ngIf="tool">
<div class="input-group">
<input type="text" class="form-control" value="{{ getFilteredDockerPullCmd(tool.tool_path, unsavedVersion.name) }}" aria-describedby="clipboard" #inputTarget>
<input type="text" id="dockerPullCommand" class="form-control" value="{{ dockerPullCommand }}" aria-describedby="clipboard" #inputTarget>
<span class="input-group-btn" id="clipboard">
<button class="btn btn-default btn-sm" type="button" [ngxClipboard]="inputTarget">
<span class="glyphicon glyphicon-copy"></span>
Expand Down
74 changes: 74 additions & 0 deletions src/app/container/version-modal/version-modal.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { FormsModule } from '@angular/forms';
import { ModalModule } from 'ngx-bootstrap/modal';
import { ClipboardModule } from 'ngx-clipboard';

import { ListContainersService } from '../../containers/list/list.service';
import { ContainerService } from '../../shared/container.service';
import { RefreshService } from '../../shared/refresh.service';
import { StateService } from '../../shared/state.service';
import { ContainersService } from '../../shared/swagger';
import { ParamfilesService } from '../paramfiles/paramfiles.service';
import { DateService } from './../../shared/date.service';
import { ContainertagsService } from './../../shared/swagger/api/containertags.service';
import { sampleTool1, sampleTag } from './../../test/mocked-objects';
import {
ContainersStubService,
ContainerStubService,
ContainertagsStubService,
DateStubService,
ParamFilesStubService,
RefreshStubService,
StateStubService,
} from './../../test/service-stubs';
import { VersionModalComponent } from './version-modal.component';
import { VersionModalService } from './version-modal.service';

describe('VersionModalComponent', () => {
let component: VersionModalComponent;
let fixture: ComponentFixture<VersionModalComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ VersionModalComponent ],
imports: [ModalModule.forRoot(), FormsModule, ClipboardModule],
providers: [
{provide: ParamfilesService, useClass: ParamFilesStubService},
VersionModalService,
{provide: ListContainersService, useClass: ListContainersService},
{provide: ContainerService, useClass: ContainerStubService},
{provide: ContainersService, useClass: ContainersStubService},
{provide: ContainertagsService, useClass: ContainertagsStubService},
{provide: StateService, useClass: StateStubService},
{provide: DateService, useClass: DateStubService},
{provide: RefreshService, useClass: RefreshStubService},
]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(VersionModalComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
it('should have the correct docker pull command', () => {
// Inject the real tool and real tag
const fakeTool = sampleTool1;
fakeTool.path = 'quay.io\/wtsicgp\/dockstore-cgpmap';
component.tool = fakeTool;
const fakeTag = sampleTag;
fakeTag.name = '3.0.0-rc8';
component.version = fakeTag;
// Manually trigger the update
component.updateDockerPullCommand();
// Let it detect changes
fixture.detectChanges();
// Check to see if the dockerPullCommand which is used in the template has the right docker pull command
expect(component.dockerPullCommand).toEqual('docker pull quay.io/wtsicgp/dockstore-cgpmap:3.0.0-rc8');
});
});
42 changes: 24 additions & 18 deletions src/app/container/version-modal/version-modal.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { RefreshService } from '../../shared/refresh.service';
/*
* Copyright 2017 OICR
*
Expand All @@ -15,24 +14,23 @@ import { RefreshService } from '../../shared/refresh.service';
* limitations under the License.
*/

import { ContainersService } from './../../shared/swagger/api/containers.service';
import { DockstoreTool } from './../../shared/swagger/model/dockstoreTool';
import { ToolDescriptor } from './../../shared/swagger/model/toolDescriptor';
import { ContainertagsService } from './../../shared/swagger/api/containertags.service';
import { DateService } from './../../shared/date.service';
import { ToolVersion } from './../../shared/swagger/model/toolVersion';
import { VersionModalService } from './version-modal.service';
import { Component, OnInit, ViewChild, AfterViewChecked } from '@angular/core';
import { NgForm, Validators } from '@angular/forms';
import { AfterViewChecked, Component, OnInit, ViewChild } from '@angular/core';
import { NgForm } from '@angular/forms';

import { ContainerService } from './../../shared/container.service';
import { DescriptorType } from '../../shared/enum/descriptorType.enum';
import { TagEditorMode } from '../../shared/enum/tagEditorMode.enum';
import { RefreshService } from '../../shared/refresh.service';
import { formErrors, validationMessages, validationPatterns } from '../../shared/validationMessages.model';
import { ListContainersService } from './../../containers/list/list.service';
import { ParamfilesService } from './../paramfiles/paramfiles.service';
import { ContainerService } from './../../shared/container.service';
import { DateService } from './../../shared/date.service';
import { StateService } from './../../shared/state.service';
import { TagEditorMode } from '../../shared/enum/tagEditorMode.enum';
import { validationMessages, validationPatterns, formErrors } from '../../shared/validationMessages.model';
import { View } from '../../shared/view';
import { ContainersService } from './../../shared/swagger/api/containers.service';
import { ContainertagsService } from './../../shared/swagger/api/containertags.service';
import { DockstoreTool } from './../../shared/swagger/model/dockstoreTool';
import { Tag } from './../../shared/swagger/model/tag';
import { ParamfilesService } from './../paramfiles/paramfiles.service';
import { VersionModalService } from './version-modal.service';

@Component({
selector: 'app-version-modal',
Expand All @@ -55,9 +53,10 @@ export class VersionModalComponent implements OnInit, AfterViewChecked {
public unsavedWDLTestParameterFilePaths: Array<string>;
public unsavedTestCWLFile = '';
public unsavedTestWDLFile = '';
public dockerPullCommand = '';

public formErrors = formErrors;
private version: ToolVersion;
public version: Tag;
public validationPatterns = validationPatterns;
tagEditorForm: NgForm;
@ViewChild('tagEditorForm') currentForm: NgForm;
Expand Down Expand Up @@ -222,14 +221,20 @@ export class VersionModalComponent implements OnInit, AfterViewChecked {
}
}

getFilteredDockerPullCmd(path: string, tagName: string = ''): string {
return this.listContainersService.getDockerPullCmd(path, tagName);
/**
* This updates the docker pull command in the template
*/
public updateDockerPullCommand(): void {
if (this.tool && this.version) {
this.dockerPullCommand = this.listContainersService.getDockerPullCmd(this.tool.path, this.version.name);
}
}

ngOnInit() {
this.versionModalService.version.subscribe(version => {
this.version = version;
this.unsavedVersion = Object.assign({}, this.version);
this.updateDockerPullCommand();
});
this.versionModalService.isModalShown.subscribe(isModalShown => {
if (!this.tool && this.isModalShown) {
Expand All @@ -248,6 +253,7 @@ export class VersionModalComponent implements OnInit, AfterViewChecked {
this.stateService.publicPage$.subscribe(publicPage => this.editMode = !publicPage);
this.containerService.tool$.subscribe(tool => {
this.tool = tool;
this.updateDockerPullCommand();
});
this.versionModalService.unsavedTestCWLFile.subscribe(
(file: string) => {
Expand Down
9 changes: 5 additions & 4 deletions src/app/container/version-modal/version-modal.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,20 @@
* limitations under the License.
*/

import { ToolVersion } from './../../shared/swagger/model/toolVersion';
import { Injectable } from '@angular/core';
import { Subject } from 'rxjs/Subject';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { Subject } from 'rxjs/Subject';

import { TagEditorMode } from '../../shared/enum/tagEditorMode.enum';
import { Tag } from '../../shared/swagger';

@Injectable()
export class VersionModalService {
mode: Subject<TagEditorMode> = new BehaviorSubject<TagEditorMode>(null);
unsavedTestCWLFile: Subject<string> = new BehaviorSubject<string>('');
unsavedTestWDLFile: Subject<string> = new BehaviorSubject<string>('');
isModalShown: Subject<boolean> = new BehaviorSubject<boolean>(false);
version: Subject<ToolVersion> = new BehaviorSubject<ToolVersion>(null);
version: Subject<Tag> = new BehaviorSubject<Tag>(null);
public setCurrentMode(mode: TagEditorMode): void {
this.mode.next(mode);
}
Expand All @@ -35,7 +36,7 @@ export class VersionModalService {
this.isModalShown.next(isModalShown);
}

public setVersion(version: ToolVersion) {
public setVersion(version: Tag) {
this.version.next(version);
}

Expand Down
10 changes: 9 additions & 1 deletion src/app/test/mocked-objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
* limitations under the License.
*/

import { Token } from './../shared/swagger/model/token';
import { DockstoreTool } from './../shared/swagger/model/dockstoreTool';
import { SourceFile } from './../shared/swagger/model/sourceFile';
import { Token } from './../shared/swagger/model/token';
import { Workflow } from './../shared/swagger/model/workflow';

export const updatedWorkflow: Workflow = {
'descriptorType': 'cwl',
'gitUrl': 'updatedGitUrl',
Expand Down Expand Up @@ -147,3 +149,9 @@ export const quayToken: Token = {
'refreshToken': null,
'userId': 2,
};

export const sampleTag = {
'reference': 'sampleReference',
'image_id': 'sampleImageId',
'name': 'sampleName'
};
Loading

0 comments on commit 34cb707

Please sign in to comment.