8000 fix(ui): do not list platform not attached to an application (#3136) · ovh/cds@f49791d · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit f49791d

Browse files
bnjjjfsamin
authored andcommitted
fix(ui): do not list platform not attached to an application (#3136)
close #3132 Signed-off-by: Benjamin Coenen <benjamin.coenen@corp.ovh.com>
1 parent b000583 commit f49791d

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

ui/src/app/shared/workflow/node/wizard/node.wizard.component.ts

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11

2-
import {Observable, of as observableOf} from 'rxjs';
3-
42
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
53
import {Router} from '@angular/router';
64
import {TranslateService} from '@ngx-translate/core';
75
import {cloneDeep} from 'lodash';
6+
import {Observable, of as observableOf} from 'rxjs';
87
import {finalize, first, map} from 'rxjs/operators';
98
import {Application} from '../../../../model/application.model';
109
import {Environment} from '../../../../model/environment.model';
@@ -95,6 +94,8 @@ export class WorkflowNodeAddWizardComponent implements OnInit {
9594
loadingCreateEnvironment = false;
9695
newEnvironment: Environment = new Environment();
9796
_createNewEnvironment = false;
97+
platforms: IdName[] = [];
98+
loadingPlatforms = false;
9899

99100
constructor(private _router: Router,
100101
private _translate: TranslateService,
@@ -207,10 +208,34 @@ export class WorkflowNodeAddWizardComponent implements OnInit {
207208
return this.createApplication().pipe(
208209
map(() => 'environment'));
209210
}
211+
this.getPlatforms();
210212
this.pipelineSection = 'environment';
211213
return observableOf('environment');
212214
}
213215

216+
getPlatforms() {
217+
this.loadingPlatforms = true;
218+
let app = this.project.application_names.find((a) => a.id === this.node.context.application_id);
219+
this._appStore.getDeploymentStrategies(this.project.key, app.name).pipe(
220+
first(),
221+
finalize(() => this.loadingPlatforms = false)
222+
).subscribe(
223+
(data) => {
224+
this.platforms = [new IdName()];
225+
let pfNames = Object.keys(data);
226+
pfNames.forEach(s => {
227+
let pf = this.project.platforms.find(p => p.name === s);
228+
if (pf) {
229+
let idName = new IdName();
230+
idName.id = pf.id;
231+
idName.name = pf.name;
232+
this.platforms.push(idName);
233+
}
234+
})
235+
}
236+
);
237+
}
238+
214239
createEnvironment(): Observable<Project> {
215240
this.loadingCreateEnvironment = true;
216241
return this._projectStore.addProjectEnvironment(this.project.key, this.newEnvironment)

ui/src/app/shared/workflow/node/wizard/node.wizard.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,16 +228,17 @@
228228
<div class="ui row">
229229
<div class="ui sixteen wide column">
230230
<div class="fields">
231-
<div class="six wide field">
231+
<div class="ui active centered inline loader" *ngIf="loadingPlatforms"></div>
232+
<div class="six wide field" *ngIf="!loadingPlatforms">
232233
<label>{{'common_platform' | translate}}</label>
233234
<sm-select
234235
class="search"
235236
placeholder="{{ 'common_platform' | translate }}"
236237
[(model)]="node.context.project_platform_id"
237238
[options]="{'fullTextSearch': true}"
238-
id="WorkflowEnvironmentSelect">
239+
id="WorkflowPlatformSelect">
239240
<option> </option>
240-
<option *ngFor="let platform of project.platforms" [value]="platform.id">{{ platform.name }}</option>
241+
<option *ngFor="let platform of platforms" [value]="platform.id">{{ platform.name }}</option>
241242
</sm-select>
242243
</div>
243244
</div>

0 commit comments

Comments
 (0)
0