From 52d9c7cb0d68b3214e0e2273ebc5033f48e8a8fd Mon Sep 17 00:00:00 2001 From: John Schulz Date: Fri, 2 Apr 2021 19:04:20 -0400 Subject: [PATCH] Fix compile time & runtime error --- .../agent_policy/components/actions_menu.tsx | 85 +++++++++---------- .../sections/agents/agent_list_page/index.tsx | 6 +- 2 files changed, 47 insertions(+), 44 deletions(-) diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/actions_menu.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/actions_menu.tsx index dfda86f4b7a0c..bdf49f44f4397 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/actions_menu.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/actions_menu.tsx @@ -45,52 +45,51 @@ export const AgentPolicyActionMenu = memo<{ } }, [onCancelEnrollment, setIsEnrollmentFlyoutOpen]); - const viewPolicyItem = ( - setIsYamlFlyoutOpen(!isYamlFlyoutOpen)} - key="viewPolicy" - > - - - ); - - const menuItems = agentPolicy?.is_managed - ? [viewPolicyItem] - : [ - setIsEnrollmentFlyoutOpen(true)} - key="enrollAgents" - > - - , - viewPolicyItem, - { - copyAgentPolicyPrompt(agentPolicy, onCopySuccess); - }} - key="copyPolicy" - > - - , - ]; - return ( {(copyAgentPolicyPrompt) => { + const viewPolicyItem = ( + setIsYamlFlyoutOpen(!isYamlFlyoutOpen)} + key="viewPolicy" + > + + + ); + + const menuItems = agentPolicy?.is_managed + ? [viewPolicyItem] + : [ + setIsEnrollmentFlyoutOpen(true)} + key="enrollAgents" + > + + , + viewPolicyItem, + { + copyAgentPolicyPrompt(agentPolicy, onCopySuccess); + }} + key="copyPolicy" + > + + , + ]; return ( <> {isYamlFlyoutOpen ? ( diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/index.tsx index ae89e5a2f30af..8e9c549fe5609 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/index.tsx @@ -460,10 +460,14 @@ export const AgentListPage: React.FunctionComponent<{}> = () => { actions: [ { render: (agent: Agent) => { + const agentPolicy = + typeof agent.policy_id === 'string' + ? agentPoliciesIndexedById[agent.policy_id] + : undefined; return ( fetchData()} onReassignClick={() => setAgentToReassign(agent)} onUnenrollClick={() => setAgentToUnenroll(agent)}