mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
fix policy preselect (#133711)
This commit is contained in:
parent
747b898efb
commit
6014b1ef74
1 changed files with 13 additions and 1 deletions
|
@ -14,7 +14,7 @@ import {
|
|||
} from '../../applications/fleet/sections/agents/components';
|
||||
import { AgentPolicyCreateInlineForm } from '../../applications/fleet/sections/agent_policy/components';
|
||||
import type { AgentPolicy } from '../../types';
|
||||
import { incrementPolicyName } from '../../services';
|
||||
import { incrementPolicyName, policyHasFleetServer } from '../../services';
|
||||
|
||||
import { AgentPolicySelection } from '.';
|
||||
|
||||
|
@ -48,6 +48,18 @@ export const SelectCreateAgentPolicy: React.FC<Props> = ({
|
|||
);
|
||||
}, [agentPolicies, excludeFleetServer]);
|
||||
|
||||
useEffect(() => {
|
||||
// Select default value if policy has no fleet server
|
||||
if (
|
||||
regularAgentPolicies.length === 1 &&
|
||||
!selectedPolicyId &&
|
||||
excludeFleetServer !== false &&
|
||||
!policyHasFleetServer(regularAgentPolicies[0])
|
||||
) {
|
||||
setSelectedPolicyId(regularAgentPolicies[0].id);
|
||||
}
|
||||
}, [regularAgentPolicies, selectedPolicyId, setSelectedPolicyId, excludeFleetServer]);
|
||||
|
||||
const onAgentPolicyChange = useCallback(
|
||||
async (key?: string, policy?: AgentPolicy) => {
|
||||
if (policy) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue