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 validateForm = () => {
const errors: IAppConfigFormErrors = {}; const errors: IAppConfigFormErrors = {};
if (enableHostStatusWebhook && !hostStatusWebhookDestinationURL) { if (enableHostStatusWebhook) {
errors.destination_url = "Destination URL must be present"; 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); setFormErrors(errors);
@ -180,6 +190,7 @@ const HostStatusWebhook = ({
name="hostStatusWebhookHostPercentage" name="hostStatusWebhookHostPercentage"
value={hostStatusWebhookHostPercentage} value={hostStatusWebhookHostPercentage}
parseTarget parseTarget
onBlur={validateForm}
tooltip={ 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>\ <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" name="hostStatusWebhookDaysCount"
value={hostStatusWebhookDaysCount} value={hostStatusWebhookDaysCount}
parseTarget parseTarget
onBlur={validateForm}
tooltip={ 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>\ <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; user_name?: string | null;
password?: string | null; password?: string | null;
destination_url?: string | null; destination_url?: string | null;
days_count?: string | null;
host_percentage?: string | null;
host_expiry_window?: string | null; host_expiry_window?: string | null;
agent_options?: string | null; agent_options?: string | null;
transparency_url?: string | null; transparency_url?: string | null;