Skip to content

Commit

Permalink
Items 5c2 and 4a from the spec ticket
Browse files Browse the repository at this point in the history
  • Loading branch information
John Schulz committed Apr 2, 2021
1 parent cd05cd0 commit f0c267f
Showing 1 changed file with 44 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,49 @@ 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) => {
Expand Down Expand Up @@ -80,42 +123,7 @@ export const AgentPolicyActionMenu = memo<{
}
: undefined
}
items={[
<EuiContextMenuItem
disabled={!hasWriteCapabilities}
icon="plusInCircle"
onClick={() => setIsEnrollmentFlyoutOpen(true)}
key="enrollAgents"
>
<FormattedMessage
id="xpack.fleet.agentPolicyActionMenu.enrollAgentActionText"
defaultMessage="Add agent"
/>
</EuiContextMenuItem>,
<EuiContextMenuItem
icon="inspect"
onClick={() => setIsYamlFlyoutOpen(!isYamlFlyoutOpen)}
key="viewPolicy"
>
<FormattedMessage
id="xpack.fleet.agentPolicyActionMenu.viewPolicyText"
defaultMessage="View policy"
/>
</EuiContextMenuItem>,
<EuiContextMenuItem
disabled={!hasWriteCapabilities}
icon="copy"
onClick={() => {
copyAgentPolicyPrompt(agentPolicy, onCopySuccess);
}}
key="copyPolicy"
>
<FormattedMessage
id="xpack.fleet.agentPolicyActionMenu.copyPolicyActionText"
defaultMessage="Copy policy"
/>
</EuiContextMenuItem>,
]}
items={menuItems}
/>
</>
);
Expand Down

0 comments on commit f0c267f

Please sign in to comment.