Skip to content

Commit 660d2e1

Browse files
authored
Adds support for file touch and remove tasks in the st2 linux pack (#488)
* added requiresVm to conditional test to show VM Credentials div * adds checkbox for action parameters * parameters are set to default values if defined * resets placeholder value to display name since we now have the option to set a default
1 parent aa7ab21 commit 660d2e1

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

src/app/components/tasks/task-edit/task-edit.component.html

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,10 @@ <h2>Action</h2>
5454
class="param-full-width"
5555
*ngIf="
5656
(param.inputType === 'text' || param.inputType === 'textArea') &&
57-
param.key.toLowerCase() !== 'username'
57+
!(param.key.toLowerCase() === 'username' && param.requiresVm)
5858
"
5959
>
60+
<mat-label>{{ param.display }}</mat-label>
6061
<input
6162
*ngIf="param.inputType === 'text'"
6263
matInput
@@ -98,6 +99,16 @@ <h2>Action</h2>
9899
</mat-option>
99100
</mat-select>
100101
</mat-form-field>
102+
<mat-checkbox
103+
class="param-full-width"
104+
*ngIf="param.inputType === 'checkbox'"
105+
name="{{ param.key }}"
106+
[matTooltip]="param.hint"
107+
[(ngModel)]="param.value"
108+
(change)="onCommandChange()"
109+
>
110+
{{ param.display }}
111+
</mat-checkbox>
101112
<span class="param-full-width" *ngIf="param.inputType === 'file'">
102113
<input
103114
#file

src/app/components/tasks/task-edit/task-edit.component.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export class TaskEditComponent implements OnInit, OnDestroy {
122122
onCommandChange() {
123123
const actionParameters: Record<string, string> = {};
124124
this.selectedCommand.parameters.forEach((param) => {
125-
actionParameters[param.key] = param.value;
125+
actionParameters[param.key] = param.value.toString();
126126
if (param.key.toLowerCase() === 'username') {
127127
this.username.next(param.value);
128128
} else if (param.key.toLowerCase() === 'password') {
@@ -152,6 +152,8 @@ export class TaskEditComponent implements OnInit, OnDestroy {
152152
) {
153153
cmd.parameters.forEach((p) => {
154154
p.value = this.data.task.actionParameters[p.key];
155+
//p.value = p.value || !p.default ? p.value : p.default;
156+
p.value = p.value.toLowerCase() === 'false' ? '' : p.value;
155157
if (p.key.toLowerCase() === 'username') {
156158
this.username.next(p.value);
157159
} else if (p.key.toLowerCase() === 'password') {
@@ -161,7 +163,8 @@ export class TaskEditComponent implements OnInit, OnDestroy {
161163
this.selectedCommand = cmd;
162164
} else {
163165
cmd.parameters.forEach((p) => {
164-
p.value = '';
166+
p.value = p.default ? p.default : '';
167+
p.value = p.value.toLowerCase() === 'false' ? '' : p.value;
165168
});
166169
}
167170
});

src/app/models/command.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export interface CommandParameters {
1414
hint: string;
1515
value: string;
1616
choices: CommandParameterChoice[];
17+
default: string;
1718
}
1819

1920
export interface Command {

0 commit comments

Comments
 (0)