Skip to content

Commit

Permalink
fix(ui): do not list platform not attached to an application (#3136)
Browse files Browse the repository at this point in the history
close #3132
Signed-off-by: Benjamin Coenen <[email protected]>
  • Loading branch information
bnjjj authored and fsamin committed Aug 3, 2018
1 parent b000583 commit f49791d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
29 changes: 27 additions & 2 deletions ui/src/app/shared/workflow/node/wizard/node.wizard.component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@

import {Observable, of as observableOf} from 'rxjs';

import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
import {Router} from '@angular/router';
import {TranslateService} from '@ngx-translate/core';
import {cloneDeep} from 'lodash';
import {Observable, of as observableOf} from 'rxjs';
import {finalize, first, map} from 'rxjs/operators';
import {Application} from '../../../../model/application.model';
import {Environment} from '../../../../model/environment.model';
Expand Down Expand Up @@ -95,6 +94,8 @@ export class WorkflowNodeAddWizardComponent implements OnInit {
loadingCreateEnvironment = false;
newEnvironment: Environment = new Environment();
_createNewEnvironment = false;
platforms: IdName[] = [];
loadingPlatforms = false;

constructor(private _router: Router,
private _translate: TranslateService,
Expand Down Expand Up @@ -207,10 +208,34 @@ export class WorkflowNodeAddWizardComponent implements OnInit {
return this.createApplication().pipe(
map(() => 'environment'));
}
this.getPlatforms();
this.pipelineSection = 'environment';
return observableOf('environment');
}

getPlatforms() {
this.loadingPlatforms = true;
let app = this.project.application_names.find((a) => a.id === this.node.context.application_id);
this._appStore.getDeploymentStrategies(this.project.key, app.name).pipe(
first(),
finalize(() => this.loadingPlatforms = false)
).subscribe(
(data) => {
this.platforms = [new IdName()];
let pfNames = Object.keys(data);
pfNames.forEach(s => {
let pf = this.project.platforms.find(p => p.name === s);
if (pf) {
let idName = new IdName();
idName.id = pf.id;
idName.name = pf.name;
this.platforms.push(idName);
}
})
}
);
}

createEnvironment(): Observable<Project> {
this.loadingCreateEnvironment = true;
return this._projectStore.addProjectEnvironment(this.project.key, this.newEnvironment)
Expand Down
7 changes: 4 additions & 3 deletions ui/src/app/shared/workflow/node/wizard/node.wizard.html
Original file line number Diff line number Diff line change
Expand Up @@ -228,16 +228,17 @@
<div class="ui row">
<div class="ui sixteen wide column">
<div class="fields">
<div class="six wide field">
<div class="ui active centered inline loader" *ngIf="loadingPlatforms"></div>
<div class="six wide field" *ngIf="!loadingPlatforms">
<label>{{'common_platform' | translate}}</label>
<sm-select
class="search"
placeholder="{{ 'common_platform' | translate }}"
[(model)]="node.context.project_platform_id"
[options]="{'fullTextSearch': true}"
id="WorkflowEnvironmentSelect">
id="WorkflowPlatformSelect">
<option> </option>
<option *ngFor="let platform of project.platforms" [value]="platform.id">{{ platform.name }}</option>
<option *ngFor="let platform of platforms" [value]="platform.id">{{ platform.name }}</option>
</sm-select>
</div>
</div>
Expand Down

0 comments on commit f49791d

Please sign in to comment.