Fleet UI: Disable save host status without required dropdowns selected (#7759)

This commit is contained in:
RachelElysia 2022-09-15 12:03:28 -04:00 committed by GitHub
parent 486b67caca
commit 7a5663bebf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 2 deletions

View File

@ -0,0 +1 @@
* Users cannot save host status webhook without choosing required percent of hosts and days count in the app settings page

View File

@ -57,8 +57,18 @@ const HostStatusWebhook = ({
const validateForm = () => {
const errors: IAppConfigFormErrors = {};
if (enableHostStatusWebhook && !hostStatusWebhookDestinationURL) {
errors.destination_url = "Destination URL must be present";
if (enableHostStatusWebhook) {
if (!hostStatusWebhookDestinationURL) {
errors.destination_url = "Destination URL must be present";
}
if (!hostStatusWebhookDaysCount) {
errors.days_count = "Number of days must be present";
}
if (!hostStatusWebhookDaysCount) {
errors.host_percentage = "Percentage of hosts must be present";
}
}
setFormErrors(errors);
@ -180,6 +190,7 @@ const HostStatusWebhook = ({
name="hostStatusWebhookHostPercentage"
value={hostStatusWebhookHostPercentage}
parseTarget
onBlur={validateForm}
tooltip={
"\
<p>Select the minimum percentage of hosts that<br/>must fail to check into Fleet in order to trigger<br/>the webhook request.</p>\
@ -195,6 +206,7 @@ const HostStatusWebhook = ({
name="hostStatusWebhookDaysCount"
value={hostStatusWebhookDaysCount}
parseTarget
onBlur={validateForm}
tooltip={
"\
<p>Select the minimum number of days that the<br/>configured <b>Percentage of hosts</b> must fail to<br/>check into Fleet in order to trigger the<br/>webhook request.</p>\

View File

@ -28,6 +28,8 @@ export interface IAppConfigFormErrors {
user_name?: string | null;
password?: string | null;
destination_url?: string | null;
days_count?: string | null;
host_percentage?: string | null;
host_expiry_window?: string | null;
agent_options?: string | null;
transparency_url?: string | null;