Skip to content

Commit

Permalink
fixed dialog for preparing step
Browse files Browse the repository at this point in the history
  • Loading branch information
godfryd committed Nov 19, 2023
1 parent 453b058 commit 9425950
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 31 deletions.
15 changes: 10 additions & 5 deletions server/kraken/server/schemaval.py
Original file line number Diff line number Diff line change
Expand Up @@ -862,27 +862,32 @@ def get_schema():
fields = {
"tool": {
"description": tool.description,
"const": name_ver
"const": name_ver,
"base": True
},
"attempts": {
"description": "A number of times the step is retried if if it returns error.",
"default": 1,
"type": "integer"
"type": "integer",
"base": True
},
"sleep_time_after_attempt": {
"description": "A sleep time between subsequent execution attempts.",
"default": 0,
"type": "integer"
"type": "integer",
"base": True
},
"name": {
"description": "A name of the step, displayed in web UI.",
"default": "",
"type": "string"
"type": "string",
"base": True
},
"when": {
"description": "A condition when a step may be executed. Any Jinja2 expression can be used, e.g.: `'job.steps[step.index - 1].result.duration > 3'`. The following predefined values are available: `'prev_ok'`, `'always'`, `'never'`, `'was_any_error'`, `'was_no_error'`, `'is_ci'`, `'is_dev'`.",
"default": "was_no_error",
"type": "string"
"type": "string",
"base": True
},
}

Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/branch-mgmt/branch-mgmt.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
<table class="step-help-table">
<ng-container *ngFor="let f of stepFields">
<tr *ngIf="f.name !== 'tool'">
<td class="step-help-name">{{ f.name }}</td>
<td class="step-help-name" [ngClass]="{'text-400': f.base}">{{ f.name }}</td>
<td class="step-help-type">{{ f.type }}</td>
<td class="step-help-value">
<input type="text" [(ngModel)]="f.value" pInputText (keyup)="generateStep2()" class="p-inputtext-sm" *ngIf="f.type === 'string'" />
Expand Down
53 changes: 28 additions & 25 deletions ui/src/app/branch-mgmt/branch-mgmt.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,7 @@ export class BranchMgmtComponent implements OnInit, OnDestroy {
descr: fv['description'],
default: fv['default'],
value: fv['default'] !== undefined ? fv['default'] : '',
base: fv['base'],
}
if (fv['type'] === 'array') {
if (fv['items']['type'] === 'object') {
Expand All @@ -747,32 +748,34 @@ export class BranchMgmtComponent implements OnInit, OnDestroy {
const json = {}
for (const fv of this.stepFields) {
const fn = fv.name
if (fv['type'] === 'string') {
if (fv['default'] !== undefined && fv['default'] === fv.value) {
// nothing
} else if (fv['enum']) {
json[fn] = fv['enum'][0]
} else {
json[fn] = fv.value
}
} else if (fv['type'] === 'integer') {
if (fv['default'] !== undefined && fv['default'] === fv.value) {
// nothing
} else if (fv['minimum']) {
json[fn] = fv['minimum']
} else {
json[fn] = fv.value
}
} else if (fv['type'] === 'boolean') {
if (fv['default'] !== undefined && fv['default'] === fv.value) {
// nothing
} else {
json[fn] = false
if (fv['type']) {
if (fv['type'] === 'string') {
if (fv['default'] !== undefined && fv['default'] === fv.value) {
// nothing
} else if (fv['enum']) {
json[fn] = fv['enum'][0]
} else {
json[fn] = fv.value
}
} else if (fv['type'] === 'integer') {
if (fv['default'] !== undefined && fv['default'] === fv.value) {
// nothing
} else if (fv['minimum']) {
json[fn] = fv['minimum']
} else {
json[fn] = fv.value
}
} else if (fv['type'] === 'boolean') {
if (fv['default'] !== undefined && fv['default'] === fv.value) {
// nothing
} else {
json[fn] = false
}
} else if (fv['type'].startsWith('array')) {
json[fn] = []
} else if (fv['type'] === 'object') {
json[fn] = {}
}
} else if (fv['type'].startsWith('array')) {
json[fn] = []
} else if (fv['type'] === 'object') {
json[fn] = {}
}

if (fn === 'tool') {
Expand Down

0 comments on commit 9425950

Please sign in to comment.