Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add requiredSlots disable logic for multi-instance tasks #2860

Merged
merged 3 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions desktop/i18n/resources.resjson
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"add-certificate-form.password.required": "Password is required if the certificate format is '.pfx'",
"add-certificate-form.title": "Create certificate",
"add-task-form.action": "Add",
"add-task-form.info.disable-required-slots": "Required slots must be 1 for multi-instance tasks",
"add-task-form.subtitle": "Add a task to the selected job",
"add-task-form.title": "Add task",
"auth-service.activate-tenant": "Activate tenant to authorize",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
public fileUri = "create.task.batch.json";
public virtualMachineConfiguration: VirtualMachineConfiguration = null;
public userAccounts: any[] = [];
public displayDisableRequiredSlotsMsg = false;

Check warning on line 33 in desktop/src/app/components/task/action/add/add-task-form.component.ts

View check run for this annotation

Codecov / codecov/patch

desktop/src/app/components/task/action/add/add-task-form.component.ts#L33

Added line #L33 was not covered by tests

constructor(
i18n: I18nService,
Expand Down Expand Up @@ -87,6 +88,7 @@
});
}
});
this._subscribeMultiInstanceSettings();

Check warning on line 91 in desktop/src/app/components/task/action/add/add-task-form.component.ts

View check run for this annotation

Codecov / codecov/patch

desktop/src/app/components/task/action/add/add-task-form.component.ts#L91

Added line #L91 was not covered by tests
}

public dtoToForm(task: TaskCreateDto) {
Expand Down Expand Up @@ -126,4 +128,20 @@
},
};
}

private _subscribeMultiInstanceSettings() {
const multiInstanceSettings = this.form.controls.multiInstanceSettings;
const requiredSlots = this.form.controls.requiredSlots;
multiInstanceSettings.valueChanges.subscribe((value) => {

Check warning on line 135 in desktop/src/app/components/task/action/add/add-task-form.component.ts

View check run for this annotation

Codecov / codecov/patch

desktop/src/app/components/task/action/add/add-task-form.component.ts#L132-L135

Added lines #L132 - L135 were not covered by tests
if (value) {
// set requiredSlot to 1 & disable the control & display msg
requiredSlots.setValue(1);
requiredSlots.disable();
this.displayDisableRequiredSlotsMsg = true;

Check warning on line 140 in desktop/src/app/components/task/action/add/add-task-form.component.ts

View check run for this annotation

Codecov / codecov/patch

desktop/src/app/components/task/action/add/add-task-form.component.ts#L138-L140

Added lines #L138 - L140 were not covered by tests
} else {
requiredSlots.enable();
this.displayDisableRequiredSlotsMsg = false;

Check warning on line 143 in desktop/src/app/components/task/action/add/add-task-form.component.ts

View check run for this annotation

Codecov / codecov/patch

desktop/src/app/components/task/action/add/add-task-form.component.ts#L142-L143

Added lines #L142 - L143 were not covered by tests
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
<bl-form-field>
<input blInput formControlName="requiredSlots" placeholder="Required slots">
</bl-form-field>
<div *ngIf="displayDisableRequiredSlotsMsg" class="info-text">
{{'add-task-form.info.disable-required-slots' | i18n}}
</div>
<bl-error controlName="requiredSlots" code="required">Required slots is a required field</bl-error>
<bl-error controlName="requiredSlots" code="min">Required slots value must be greater than or equal to 1</bl-error>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ add-task-form:
title: Add task
subtitle: Add a task to the selected job
action: Add
info:
disable-required-slots: Required slots must be 1 for multi-instance tasks
5 changes: 5 additions & 0 deletions desktop/src/app/models/forms/create-task-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
data.applicationPackageReferences = formData.appPackages;
}

// Remove required slots if multi-instance is enabled, backend will set it to 1.
if (formData.multiInstanceSettings) {
delete data.requiredSlots;

Check warning on line 54 in desktop/src/app/models/forms/create-task-model.ts

View check run for this annotation

Codecov / codecov/patch

desktop/src/app/models/forms/create-task-model.ts#L54

Added line #L54 was not covered by tests
}

return new TaskCreateDto(data);
}

Expand Down
4 changes: 4 additions & 0 deletions desktop/src/app/styles/base/forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,7 @@ mat-tab-group.form-tabs {
height: 32px;
}
}

.info-text {
color: $secondary-text;
}