Skip to content

Commit

Permalink
Fix compile time & runtime error
Browse files Browse the repository at this point in the history
  • Loading branch information
John Schulz committed Apr 2, 2021
1 parent f0c267f commit 52d9c7c
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,52 +45,51 @@ export const AgentPolicyActionMenu = memo<{
}
}, [onCancelEnrollment, setIsEnrollmentFlyoutOpen]);

const viewPolicyItem = (
<EuiContextMenuItem
icon="inspect"
onClick={() => setIsYamlFlyoutOpen(!isYamlFlyoutOpen)}
key="viewPolicy"
>
<FormattedMessage
id="xpack.fleet.agentPolicyActionMenu.viewPolicyText"
defaultMessage="View policy"
/>
</EuiContextMenuItem>
);

const menuItems = agentPolicy?.is_managed
? [viewPolicyItem]
: [
<EuiContextMenuItem
disabled={!hasWriteCapabilities}
icon="plusInCircle"
onClick={() => setIsEnrollmentFlyoutOpen(true)}
key="enrollAgents"
>
<FormattedMessage
id="xpack.fleet.agentPolicyActionMenu.enrollAgentActionText"
defaultMessage="Add agent"
/>
</EuiContextMenuItem>,
viewPolicyItem,
<EuiContextMenuItem
disabled={!hasWriteCapabilities}
icon="copy"
onClick={() => {
copyAgentPolicyPrompt(agentPolicy, onCopySuccess);
}}
key="copyPolicy"
>
<FormattedMessage
id="xpack.fleet.agentPolicyActionMenu.copyPolicyActionText"
defaultMessage="Copy policy"
/>
</EuiContextMenuItem>,
];

return (
<AgentPolicyCopyProvider>
{(copyAgentPolicyPrompt) => {
const viewPolicyItem = (
<EuiContextMenuItem
icon="inspect"
onClick={() => setIsYamlFlyoutOpen(!isYamlFlyoutOpen)}
key="viewPolicy"
>
<FormattedMessage
id="xpack.fleet.agentPolicyActionMenu.viewPolicyText"
defaultMessage="View policy"
/>
</EuiContextMenuItem>
);

const menuItems = agentPolicy?.is_managed
? [viewPolicyItem]
: [
<EuiContextMenuItem
disabled={!hasWriteCapabilities}
icon="plusInCircle"
onClick={() => setIsEnrollmentFlyoutOpen(true)}
key="enrollAgents"
>
<FormattedMessage
id="xpack.fleet.agentPolicyActionMenu.enrollAgentActionText"
defaultMessage="Add agent"
/>
</EuiContextMenuItem>,
viewPolicyItem,
<EuiContextMenuItem
disabled={!hasWriteCapabilities}
icon="copy"
onClick={() => {
copyAgentPolicyPrompt(agentPolicy, onCopySuccess);
}}
key="copyPolicy"
>
<FormattedMessage
id="xpack.fleet.agentPolicyActionMenu.copyPolicyActionText"
defaultMessage="Copy policy"
/>
</EuiContextMenuItem>,
];
return (
<>
{isYamlFlyoutOpen ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<RowActions
agent={agent}
agentPolicy={agent.policy_id && agentPoliciesIndexedById[agent.policy_id]}
agentPolicy={agentPolicy}
refresh={() => fetchData()}
onReassignClick={() => setAgentToReassign(agent)}
onUnenrollClick={() => setAgentToUnenroll(agent)}
Expand Down

0 comments on commit 52d9c7c

Please sign in to comment.