From d2eedfe890a54d7f42968f0896d21e086bfd0bd1 Mon Sep 17 00:00:00 2001 From: Richard LT Date: Thu, 21 Dec 2023 14:23:05 +0100 Subject: [PATCH] fix(ui): template apply form (#6750) Signed-off-by: richardlt --- ...workflow-template.apply-modal.component.ts | 9 +- .../workflow-template.bulk-modal.component.ts | 20 +-- .../workflow-template.bulk-modal.html | 114 +++++++++--------- .../workflow-template.param-form.component.ts | 13 +- .../workflow-template.param-form.html | 40 +++--- 5 files changed, 93 insertions(+), 103 deletions(-) diff --git a/ui/src/app/shared/workflow-template/apply-modal/workflow-template.apply-modal.component.ts b/ui/src/app/shared/workflow-template/apply-modal/workflow-template.apply-modal.component.ts index fcf6030463..4ac0858e11 100644 --- a/ui/src/app/shared/workflow-template/apply-modal/workflow-template.apply-modal.component.ts +++ b/ui/src/app/shared/workflow-template/apply-modal/workflow-template.apply-modal.component.ts @@ -17,8 +17,7 @@ import { calculateWorkflowTemplateDiff } from 'app/shared/diff/diff'; import { Item } from 'app/shared/diff/list/diff.list.component'; import { forkJoin } from 'rxjs'; import { finalize } from 'rxjs/operators'; -import {NZ_MODAL_DATA, NzModalRef} from 'ng-zorro-antd/modal'; -import { ToastService } from 'app/shared/toast/ToastService'; +import { NZ_MODAL_DATA, NzModalRef } from 'ng-zorro-antd/modal'; interface IModalData { workflowTemplateIn: WorkflowTemplate; @@ -61,8 +60,7 @@ export class WorkflowTemplateApplyModalComponent implements OnInit, OnChanges { private _projectService: ProjectService, private _workflowService: WorkflowService, private _templateService: WorkflowTemplateService, - private _cd: ChangeDetectorRef, - private _toast: ToastService + private _cd: ChangeDetectorRef ) { } ngOnChanges() { @@ -118,12 +116,11 @@ export class WorkflowTemplateApplyModalComponent implements OnInit, OnChanges { } onApply() { - this._workflowService.getWorkflow(this.workflowTemplateInstance.project.key, + this._workflowService.getWorkflow(this.workflowTemplateInstance.request.project_key, this.workflowTemplateInstance.workflow_name).subscribe(w => { this.workflowTemplateInstance = Object.assign({}, w.template_instance); this._cd.markForCheck(); }); - } loadAudits() { diff --git a/ui/src/app/shared/workflow-template/bulk-modal/workflow-template.bulk-modal.component.ts b/ui/src/app/shared/workflow-template/bulk-modal/workflow-template.bulk-modal.component.ts index 0da116c60d..d97bf6d3ba 100644 --- a/ui/src/app/shared/workflow-template/bulk-modal/workflow-template.bulk-modal.component.ts +++ b/ui/src/app/shared/workflow-template/bulk-modal/workflow-template.bulk-modal.component.ts @@ -24,7 +24,7 @@ import { AutoUnsubscribe } from 'app/shared/decorator/autoUnsubscribe'; import { Column, ColumnType, Select } from 'app/shared/table/data-table.component'; import { interval, Observable, Subscription } from 'rxjs'; import { finalize } from 'rxjs/operators'; -import {NZ_MODAL_DATA, NzModalRef} from 'ng-zorro-antd/modal'; +import { NZ_MODAL_DATA, NzModalRef } from 'ng-zorro-antd/modal'; interface IModalData { workflowTemplate: WorkflowTemplate; @@ -50,7 +50,6 @@ export class WorkflowTemplateBulkModalComponent implements OnInit, OnDestroy { currentStep = 0; selectedInstanceKeys: Array = new Array(); selectedInstances: Array; - accordionOpenedIndex = 0; parameters: { [s: number]: ParamData }; response: WorkflowTemplateBulk; pollingStatusSub: Subscription; @@ -94,16 +93,16 @@ export class WorkflowTemplateBulkModalComponent implements OnInit, OnDestroy { name: 'Status', class: 'rightAlign', selector: (i: WorkflowTemplateBulkOperation) => ({ - class: OperationStatusUtil.color(i.status), - value: OperationStatusUtil.translate(i.status) - }) + class: OperationStatusUtil.color(i.status), + value: OperationStatusUtil.translate(i.status) + }) } ]; this.parameters = {}; } - ngOnDestroy(): void {} // Should be set to use @AutoUnsubscribe with AOT + ngOnDestroy(): void { } // Should be set to use @AutoUnsubscribe with AOT ngOnInit(): void { this.workflowTemplate = this.nzModalData.workflowTemplate; @@ -192,15 +191,6 @@ export class WorkflowTemplateBulkModalComponent implements OnInit, OnDestroy { this.moveToStep(2); } - accordionOpen(e: any, index: number) { - if (this.accordionOpenedIndex === index) { - this.accordionOpenedIndex = -1; // close all accordion items - } else { - this.accordionOpenedIndex = index; - } - this._cd.markForCheck(); - } - changeParam(instanceID: number, params: ParamData) { this.parameters[instanceID] = params; this.validateParam(); diff --git a/ui/src/app/shared/workflow-template/bulk-modal/workflow-template.bulk-modal.html b/ui/src/app/shared/workflow-template/bulk-modal/workflow-template.bulk-modal.html index b66aa37f26..aad825b4f5 100644 --- a/ui/src/app/shared/workflow-template/bulk-modal/workflow-template.bulk-modal.html +++ b/ui/src/app/shared/workflow-template/bulk-modal/workflow-template.bulk-modal.html @@ -1,59 +1,59 @@ -
- - - - - - - - - - - - - - - - -
- - - -
-
- - - - +
+ + + + + + + + + + + + + + + + +
+ + + +
+
+ + + + - - -
- - - - - -
-
- - - - - - - - - - - -
+
+
+
+ + + + + +
+
+ + + + + + + + + + + +
\ No newline at end of file diff --git a/ui/src/app/shared/workflow-template/param-form/workflow-template.param-form.component.ts b/ui/src/app/shared/workflow-template/param-form/workflow-template.param-form.component.ts index 27da8e5349..a36d2901a0 100644 --- a/ui/src/app/shared/workflow-template/param-form/workflow-template.param-form.component.ts +++ b/ui/src/app/shared/workflow-template/param-form/workflow-template.param-form.component.ts @@ -85,7 +85,7 @@ export class WorkflowTemplateParamFormComponent implements OnInit, OnDestroy { ngOnInit(): void { this.initProject(); - this.changeParam(); + this.emitParam(); } initProject() { @@ -124,7 +124,7 @@ export class WorkflowTemplateParamFormComponent implements OnInit, OnDestroy { let existingRepo = repoNames.find(n => n === selectedRepo); if (existingRepo) { this.parameterValues[parameterKey + '-repository'] = existingRepo; - this.changeParam(); + this.emitParam(); } } } @@ -175,7 +175,7 @@ export class WorkflowTemplateParamFormComponent implements OnInit, OnDestroy { } if (this.workflowTemplate) { - this.changeParam(); + this.emitParam(); } } @@ -194,7 +194,12 @@ export class WorkflowTemplateParamFormComponent implements OnInit, OnDestroy { this._cd.markForCheck() } - changeParam() { + changeParam(key: string, value: any): void { + this.parameterValues[key] = value; + this.emitParam(); + } + + emitParam(): void { let parameters = new ParamData(); this.workflowTemplate.parameters.forEach(parameter => { diff --git a/ui/src/app/shared/workflow-template/param-form/workflow-template.param-form.html b/ui/src/app/shared/workflow-template/param-form/workflow-template.param-form.html index 895a1fe151..89f63ea712 100644 --- a/ui/src/app/shared/workflow-template/param-form/workflow-template.param-form.html +++ b/ui/src/app/shared/workflow-template/param-form/workflow-template.param-form.html @@ -10,48 +10,46 @@

Parameters

- + [ngModel]="parameterValues[parameter.key]" (change)="changeParam(parameter.key, $event)"> + + [ngModel]="parameterValues[parameter.key]" [config]="codeMirrorConfig" + (change)="changeParam(parameter.key, $event)" #codemirror> + nzPlaceHolder="{{'workflow_wizard_select_repo_man' | translate}}" + [ngModel]="parameterValues[parameter.key]" (ngModelChange)="fetchRepos(parameter.key, $event)"> + nzPlaceHolder="{{'workflow_template_param_select_key' | translate}}" + (ngModelChange)="changeParam(parameter.key, $event)" (ngModel]="parameterValues[parameter.key]"> + nzPlaceHolder="{{'workflow_template_param_select_key' | translate}}" + (ngModelChange)="changeParam(parameter.key, $event)" [ngModel]="parameterValues[parameter.key]" #select> - + [ngModel]="parameterValues[parameter.key + '-repository']" (nzFocus)="focusRepo(parameter.key)" + (nzOnSearch)="filterRepo($event)" + (ngModelChange)="changeParam(parameter.key + '-repository', $event)"> + -
- + \ No newline at end of file