Allow zero (0) to unset unenroll_timeout field (#103790)
This commit is contained in:
parent
9f82e5ef74
commit
fd7dc18f35
|
@ -159,10 +159,6 @@ export const AgentPolicyForm: React.FunctionComponent<Props> = ({
|
|||
</EuiFormRow>
|
||||
);
|
||||
});
|
||||
const unenrollmentTimeoutText = i18n.translate(
|
||||
'xpack.fleet.agentPolicyForm.unenrollmentTimeoutLabel',
|
||||
{ defaultMessage: 'Unenrollment timeout' }
|
||||
);
|
||||
|
||||
const advancedOptionsContent = (
|
||||
<>
|
||||
|
@ -303,7 +299,14 @@ export const AgentPolicyForm: React.FunctionComponent<Props> = ({
|
|||
/>
|
||||
</EuiDescribedFormGroup>
|
||||
<EuiDescribedFormGroup
|
||||
title={<h4>{unenrollmentTimeoutText}</h4>}
|
||||
title={
|
||||
<h4>
|
||||
<FormattedMessage
|
||||
id="xpack.fleet.agentPolicyForm.unenrollmentTimeoutLabel"
|
||||
defaultMessage="Unenrollment timeout"
|
||||
/>
|
||||
</h4>
|
||||
}
|
||||
description={
|
||||
<FormattedMessage
|
||||
id="xpack.fleet.agentPolicyForm.unenrollmentTimeoutDescription"
|
||||
|
@ -315,12 +318,14 @@ export const AgentPolicyForm: React.FunctionComponent<Props> = ({
|
|||
<EuiFieldNumber
|
||||
fullWidth
|
||||
disabled={agentPolicy.is_managed === true}
|
||||
value={agentPolicy.unenroll_timeout}
|
||||
min={1}
|
||||
onChange={(e) => updateAgentPolicy({ unenroll_timeout: Number(e.target.value) })}
|
||||
value={agentPolicy.unenroll_timeout || ''}
|
||||
onChange={(e) => {
|
||||
updateAgentPolicy({
|
||||
unenroll_timeout: e.target.value ? Number(e.target.value) : 0,
|
||||
});
|
||||
}}
|
||||
isInvalid={Boolean(touchedFields.unenroll_timeout && validation.unenroll_timeout)}
|
||||
onBlur={() => setTouchedFields({ ...touchedFields, unenroll_timeout: true })}
|
||||
placeholder={unenrollmentTimeoutText}
|
||||
/>
|
||||
</EuiFormRow>
|
||||
</EuiDescribedFormGroup>
|
||||
|
|
|
@ -8,7 +8,14 @@
|
|||
import React, { memo, useState } from 'react';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import styled from 'styled-components';
|
||||
import { EuiBottomBar, EuiFlexGroup, EuiFlexItem, EuiButtonEmpty, EuiButton } from '@elastic/eui';
|
||||
import {
|
||||
EuiBottomBar,
|
||||
EuiFlexGroup,
|
||||
EuiFlexItem,
|
||||
EuiButtonEmpty,
|
||||
EuiButton,
|
||||
EuiSpacer,
|
||||
} from '@elastic/eui';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
|
||||
|
@ -145,58 +152,62 @@ export const SettingsView = memo<{ agentPolicy: AgentPolicy }>(
|
|||
/>
|
||||
|
||||
{hasChanges ? (
|
||||
<EuiBottomBar>
|
||||
<EuiFlexGroup justifyContent="spaceBetween" alignItems="center">
|
||||
<EuiFlexItem>
|
||||
<FormattedMessage
|
||||
id="xpack.fleet.editAgentPolicy.unsavedChangesText"
|
||||
defaultMessage="You have unsaved changes"
|
||||
/>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem>
|
||||
<EuiFlexGroup gutterSize="s" justifyContent="flexEnd">
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiButtonEmpty
|
||||
color="ghost"
|
||||
onClick={() => {
|
||||
setAgentPolicy({ ...originalAgentPolicy });
|
||||
setHasChanges(false);
|
||||
}}
|
||||
>
|
||||
<FormattedMessage
|
||||
id="xpack.fleet.editAgentPolicy.cancelButtonText"
|
||||
defaultMessage="Cancel"
|
||||
/>
|
||||
</EuiButtonEmpty>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiButton
|
||||
onClick={onSubmit}
|
||||
isLoading={isLoading}
|
||||
isDisabled={
|
||||
!hasWriteCapabilites || isLoading || Object.keys(validation).length > 0
|
||||
}
|
||||
iconType="save"
|
||||
color="primary"
|
||||
fill
|
||||
>
|
||||
{isLoading ? (
|
||||
<>
|
||||
<EuiSpacer size="xl" />
|
||||
<EuiSpacer size="xl" />
|
||||
<EuiBottomBar>
|
||||
<EuiFlexGroup justifyContent="spaceBetween" alignItems="center">
|
||||
<EuiFlexItem>
|
||||
<FormattedMessage
|
||||
id="xpack.fleet.editAgentPolicy.unsavedChangesText"
|
||||
defaultMessage="You have unsaved changes"
|
||||
/>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem>
|
||||
<EuiFlexGroup gutterSize="s" justifyContent="flexEnd">
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiButtonEmpty
|
||||
color="ghost"
|
||||
onClick={() => {
|
||||
setAgentPolicy({ ...originalAgentPolicy });
|
||||
setHasChanges(false);
|
||||
}}
|
||||
>
|
||||
<FormattedMessage
|
||||
id="xpack.fleet.editAgentPolicy.savingButtonText"
|
||||
defaultMessage="Saving…"
|
||||
id="xpack.fleet.editAgentPolicy.cancelButtonText"
|
||||
defaultMessage="Cancel"
|
||||
/>
|
||||
) : (
|
||||
<FormattedMessage
|
||||
id="xpack.fleet.editAgentPolicy.saveButtonText"
|
||||
defaultMessage="Save changes"
|
||||
/>
|
||||
)}
|
||||
</EuiButton>
|
||||
</EuiFlexItem>
|
||||
</EuiFlexGroup>
|
||||
</EuiFlexItem>
|
||||
</EuiFlexGroup>
|
||||
</EuiBottomBar>
|
||||
</EuiButtonEmpty>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiButton
|
||||
onClick={onSubmit}
|
||||
isLoading={isLoading}
|
||||
isDisabled={
|
||||
!hasWriteCapabilites || isLoading || Object.keys(validation).length > 0
|
||||
}
|
||||
iconType="save"
|
||||
color="primary"
|
||||
fill
|
||||
>
|
||||
{isLoading ? (
|
||||
<FormattedMessage
|
||||
id="xpack.fleet.editAgentPolicy.savingButtonText"
|
||||
defaultMessage="Saving…"
|
||||
/>
|
||||
) : (
|
||||
<FormattedMessage
|
||||
id="xpack.fleet.editAgentPolicy.saveButtonText"
|
||||
defaultMessage="Save changes"
|
||||
/>
|
||||
)}
|
||||
</EuiButton>
|
||||
</EuiFlexItem>
|
||||
</EuiFlexGroup>
|
||||
</EuiFlexItem>
|
||||
</EuiFlexGroup>
|
||||
</EuiBottomBar>
|
||||
</>
|
||||
) : null}
|
||||
</FormWrapper>
|
||||
);
|
||||
|
|
|
@ -642,9 +642,12 @@ class AgentPolicyService {
|
|||
data: (fullPolicy as unknown) as FleetServerPolicy['data'],
|
||||
policy_id: fullPolicy.id,
|
||||
default_fleet_server: policy.is_default_fleet_server === true,
|
||||
unenroll_timeout: policy.unenroll_timeout,
|
||||
};
|
||||
|
||||
if (policy.unenroll_timeout) {
|
||||
fleetServerPolicy.unenroll_timeout = policy.unenroll_timeout;
|
||||
}
|
||||
|
||||
await esClient.create({
|
||||
index: AGENT_POLICY_INDEX,
|
||||
body: fleetServerPolicy,
|
||||
|
|
|
@ -16,7 +16,7 @@ export const AgentPolicyBaseSchema = {
|
|||
namespace: NamespaceSchema,
|
||||
description: schema.maybe(schema.string()),
|
||||
is_managed: schema.maybe(schema.boolean()),
|
||||
unenroll_timeout: schema.maybe(schema.number({ min: 1 })),
|
||||
unenroll_timeout: schema.maybe(schema.number()),
|
||||
monitoring_enabled: schema.maybe(
|
||||
schema.arrayOf(
|
||||
schema.oneOf([schema.literal(dataTypes.Logs), schema.literal(dataTypes.Metrics)])
|
||||
|
|
Loading…
Reference in a new issue