Skip to content

Commit

Permalink
fix(ui): add in workflow modal the platform link to a pipeline #2991 (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
bnjjj authored and fsamin committed Jul 9, 2018
1 parent 3ec237b commit c763afd
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 13 deletions.
2 changes: 1 addition & 1 deletion contrib/grpcplugins/deployment/arsenal/Makefile
Expand Up @@ -62,4 +62,4 @@ publish:
echo "Updating plugin binary $(TARGET_NAME)-$$GOOS-$$GOARCH$$EXTENSION"; \
cdsctl admin plugins binary-add arsenal-deployment-plugin $(TARGET_DIR)/plugin-$$GOOS-$$GOARCH.yml $(TARGET_DIR)/$(TARGET_NAME)-$$GOOS-$$GOARCH$$EXTENSION; \
done; \
done
done
Expand Up @@ -55,11 +55,7 @@ export class WorkflowNodeFormComponent implements OnInit {
if (appName && appName !== ' ') {
this._appStore.getDeploymentStrategies(this.project.key, appName).pipe(
first(),
finalize(
() => {
this.initPlatformList();
}
)
finalize(() => this.initPlatformList())
).subscribe(
data => {
this.platforms = [];
Expand Down
26 changes: 22 additions & 4 deletions ui/src/app/shared/workflow/node/wizard/node.wizard.component.ts
Expand Up @@ -55,14 +55,14 @@ export class WorkflowNodeAddWizardComponent implements OnInit {
errorPipelineNamePattern = false;
loadingCreatePipeline = false;
newPipeline: Pipeline = new Pipeline();
set pipelineSection(data: 'pipeline'|'application'|'environment') {
set pipelineSection(data: 'pipeline'|'application'|'environment'|'platform') {
this._pipelineSection = data;
this.pipelineSectionChanged.emit(data);
}
get pipelineSection() {
return this._pipelineSection;
}
_pipelineSection: 'pipeline'|'application'|'environment' = 'pipeline';
_pipelineSection: 'pipeline'|'application'|'environment'|'platform' = 'pipeline';
_createNewPipeline = false;

// Application details
Expand Down Expand Up @@ -145,6 +145,9 @@ export class WorkflowNodeAddWizardComponent implements OnInit {
if (this.node.context.environment_id) {
this.node.context.environment_id = Number(this.node.context.environment_id);
}
if (this.node.context.project_platform_id) {
this.node.context.project_platform_id = Number(this.node.context.project_platform_id);
}

this.nodeCreated.emit(this.node);
}
Expand Down Expand Up @@ -218,16 +221,29 @@ export class WorkflowNodeAddWizardComponent implements OnInit {
map((proj) => {
this._toast.success('', this._translate.instant('environment_created'));
this.node.context.environment_id = proj.environments.find((env) => env.name === this.newEnvironment.name).id;
this.createNode();
if (!this.node.context.application_id) {
this.createNode();
} else {
this.pipelineSection = 'platform';
}
return proj;
}));
}

selectOrCreateEnvironment() {
if (this.createNewEnvironment && this.newEnvironment.name) {
return this.createEnvironment().pipe(
map(() => 'done'));
map(() => 'platform'));
}
if (!this.node.context.application_id) {
this.createNode();
return observableOf('done');
}
this.pipelineSection = 'platform';
return observableOf('platform');
}

selectOrCreatePlatform() {
this.createNode();
return observableOf('done');
}
Expand All @@ -240,6 +256,8 @@ export class WorkflowNodeAddWizardComponent implements OnInit {
return this.selectOrCreateApplication();
case 'environment':
return this.selectOrCreateEnvironment();
case 'platform':
return this.selectOrCreatePlatform();
}
}
}
41 changes: 41 additions & 0 deletions ui/src/app/shared/workflow/node/wizard/node.wizard.html
Expand Up @@ -31,6 +31,16 @@
<div class="description">{{'common_optional' | translate}}</div>
</div>
</div>
<div class="step pointing"
[class.disabled]="node == null || !node.pipeline_id || !node.context.application_id"
[class.active]="pipelineSection === 'platform'"
(click)="pipelineSection = 'platform'">
<i class="plug icon"></i>
<div class="content">
<div class="title">{{'common_platform' | translate}} <i class="green check icon" *ngIf="node.context.project_platform_id && node.context.project_platform_id > 0"></i></div>
<div class="description">{{'common_optional' | translate}}</div>
</div>
</div>
</div>
</div>
<div class="thirteen wide column">
Expand Down Expand Up @@ -207,6 +217,37 @@
<button class="ui button" type="button" (click)="goToProject()" *ngIf="!hideCancel">{{ 'btn_cancel' | translate }}</button>
<button class="ui right floated green button" type="button" *ngIf="!hideNext" (click)="goToNextSection().subscribe()"
[disabled]="!node.pipeline_id && !newPipeline.name" [class.loading]="loadingCreateEnvironment">
<span *ngIf="node.context.application_id">{{ 'btn_next' | translate }}</span>
<span *ngIf="!node.context.application_id">{{ 'btn_finish' | translate }}</span>
</button>
</div>
</div>
</div>
<!-- ############### PLATFORM SECTION ############## -->
<div *ngSwitchCase="'platform'">
<div class="ui row">
<div class="ui sixteen wide column">
<div class="fields">
<div class="six wide field">
<label>{{'common_platform' | translate}}</label>
<sm-select
class="search"
placeholder="{{ 'common_platform' | translate }}"
[(model)]="node.context.project_platform_id"
[options]="{'fullTextSearch': true}"
id="WorkflowEnvironmentSelect">
<option> </option>
<option *ngFor="let platform of project.platforms" [value]="platform.id">{{ platform.name }}</option>
</sm-select>
</div>
</div>
</div>
</div>
<div class="ui row">
<div class="ui sixteen wide column">
<button class="ui button" type="button" (click)="goToProject()" *ngIf="!hideCancel">{{ 'btn_cancel' | translate }}</button>
<button class="ui right floated green button" type="button" *ngIf="!hideNext" (click)="goToNextSection().subscribe()"
[disabled]="!node.pipeline_id && !newPipeline.name">
{{ 'btn_finish' | translate }}
</button>
</div>
Expand Down
Expand Up @@ -74,6 +74,12 @@ export class WorkflowTriggerComponent {
}

nextStep() {
this.nodeWizard.goToNextSection().subscribe((section) => this.currentSection = section);
this.nodeWizard.goToNextSection().subscribe((section) => {
if (section === 'done') {
this.saveTrigger();
} else {
this.currentSection = section;
}
});
}
}
3 changes: 1 addition & 2 deletions ui/src/app/shared/workflow/trigger/workflow.trigger.html
Expand Up @@ -17,7 +17,6 @@ <h3>{{ 'workflow_node_form_title' | translate }}</h3>
</div>
<div class="actions">
<button class="ui grey button" [disabled]="loading" (click)="hide()">{{ 'common_close' | translate }}</button>
<button class="ui green button" [disabled]="loading || trigger.workflow_dest_node == null" *ngIf="currentSection !== 'environment'" [class.loading]="loading" (click)="nextStep()">{{ 'btn_next' | translate }}</button>
<button class="ui green button" [disabled]="trigger.workflow_dest_node == null || !trigger.workflow_dest_node.pipeline_id" *ngIf="currentSection === 'environment'" [disabled]="loading" [class.loading]="loading" (click)="saveTrigger()">{{ 'btn_finish' | translate }}</button>
<button class="ui green button" [disabled]="loading || trigger.workflow_dest_node == null" [class.loading]="loading" (click)="nextStep()">{{ 'btn_next' | translate }}</button>
</div>
</ng-template>
1 change: 1 addition & 0 deletions ui/src/assets/i18n/en.json
Expand Up @@ -203,6 +203,7 @@
"common_pipeline": "Pipeline",
"common_pipelines": "Pipelines",
"common_platforms": "Platforms",
"common_platform": "Platform",
"common_project_title": "Project : ",
"common_requirements": "Requirements",
"common_status": "Status",
Expand Down
1 change: 1 addition & 0 deletions ui/src/assets/i18n/fr.json
Expand Up @@ -203,6 +203,7 @@
"common_pipeline": "Pipeline",
"common_pipelines": "Pipelines",
"common_platforms": "Plateformes",
"common_platform": "Plateforme",
"common_project_title": "Projet : ",
"common_requirements": "Pré-requis",
"common_status": "Status",
Expand Down

0 comments on commit c763afd

Please sign in to comment.