mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Fleet] Hide many actions for hosted agent policies (#96160)
## Summary Fixes items 2a, 4a, 5c2, and 6 from https://github.com/elastic/kibana/issues/91906 ### 2a - On the agents table, remove all actions except for "View agent" [code commit](a93dd8cc7b
) <img width="1090" alt="Screen Shot 2021-04-02 at 2 00 34 PM" src="https://user-images.githubusercontent.com/57655/113446102-1b40bd00-93c5-11eb-804b-2afec37a176b.png"> <img width="1100" alt="Screen Shot 2021-04-02 at 2 00 41 PM" src="https://user-images.githubusercontent.com/57655/113446103-1b40bd00-93c5-11eb-8aba-daa1aa539955.png"> ### 4a & 5c2 On the agent policy list page, remove the "add agent" & "copy policy" actions which appears in the [...] actions menu [code commit](f0c267f717
) <img width="1067" alt="Screen Shot 2021-04-02 at 2 36 57 PM" src="https://user-images.githubusercontent.com/57655/113446281-7b376380-93c5-11eb-9f82-03e957e6656c.png"> <img width="1104" alt="Screen Shot 2021-04-02 at 2 37 02 PM" src="https://user-images.githubusercontent.com/57655/113446282-7bcffa00-93c5-11eb-942c-1a98ebbab385.png"> ### 6 - Do not show the the "revoke token" trash icon [code commit](cd05cd0f97
) <img width="1088" alt="Screen Shot 2021-04-02 at 2 15 54 PM" src="https://user-images.githubusercontent.com/57655/113446176-4a572e80-93c5-11eb-9740-9723c1cb9f50.png"> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
2745a6e957
commit
2adc060044
3 changed files with 112 additions and 91 deletions
|
@ -48,6 +48,48 @@ export const AgentPolicyActionMenu = memo<{
|
|||
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 ? (
|
||||
|
@ -80,42 +122,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}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
|
|
@ -55,74 +55,81 @@ const REFRESH_INTERVAL_MS = 30000;
|
|||
|
||||
const RowActions = React.memo<{
|
||||
agent: Agent;
|
||||
agentPolicy?: AgentPolicy;
|
||||
refresh: () => void;
|
||||
onReassignClick: () => void;
|
||||
onUnenrollClick: () => void;
|
||||
onUpgradeClick: () => void;
|
||||
}>(({ agent, refresh, onReassignClick, onUnenrollClick, onUpgradeClick }) => {
|
||||
}>(({ agent, agentPolicy, refresh, onReassignClick, onUnenrollClick, onUpgradeClick }) => {
|
||||
const { getHref } = useLink();
|
||||
const hasWriteCapabilites = useCapabilities().write;
|
||||
|
||||
const isUnenrolling = agent.status === 'unenrolling';
|
||||
const kibanaVersion = useKibanaVersion();
|
||||
const [isMenuOpen, setIsMenuOpen] = useState(false);
|
||||
const menuItems = [
|
||||
<EuiContextMenuItem
|
||||
icon="inspect"
|
||||
href={getHref('fleet_agent_details', { agentId: agent.id })}
|
||||
key="viewAgent"
|
||||
>
|
||||
<FormattedMessage id="xpack.fleet.agentList.viewActionText" defaultMessage="View agent" />
|
||||
</EuiContextMenuItem>,
|
||||
];
|
||||
|
||||
if (agentPolicy?.is_managed === false) {
|
||||
menuItems.push(
|
||||
<EuiContextMenuItem
|
||||
icon="pencil"
|
||||
onClick={() => {
|
||||
onReassignClick();
|
||||
}}
|
||||
disabled={!agent.active}
|
||||
key="reassignPolicy"
|
||||
>
|
||||
<FormattedMessage
|
||||
id="xpack.fleet.agentList.reassignActionText"
|
||||
defaultMessage="Assign to new policy"
|
||||
/>
|
||||
</EuiContextMenuItem>,
|
||||
<EuiContextMenuItem
|
||||
disabled={!hasWriteCapabilites || !agent.active}
|
||||
icon="trash"
|
||||
onClick={() => {
|
||||
onUnenrollClick();
|
||||
}}
|
||||
>
|
||||
{isUnenrolling ? (
|
||||
<FormattedMessage
|
||||
id="xpack.fleet.agentList.forceUnenrollOneButton"
|
||||
defaultMessage="Force unenroll"
|
||||
/>
|
||||
) : (
|
||||
<FormattedMessage
|
||||
id="xpack.fleet.agentList.unenrollOneButton"
|
||||
defaultMessage="Unenroll agent"
|
||||
/>
|
||||
)}
|
||||
</EuiContextMenuItem>,
|
||||
<EuiContextMenuItem
|
||||
icon="refresh"
|
||||
disabled={!isAgentUpgradeable(agent, kibanaVersion)}
|
||||
onClick={() => {
|
||||
onUpgradeClick();
|
||||
}}
|
||||
>
|
||||
<FormattedMessage
|
||||
id="xpack.fleet.agentList.upgradeOneButton"
|
||||
defaultMessage="Upgrade agent"
|
||||
/>
|
||||
</EuiContextMenuItem>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<ContextMenuActions
|
||||
isOpen={isMenuOpen}
|
||||
onChange={(isOpen) => setIsMenuOpen(isOpen)}
|
||||
items={[
|
||||
<EuiContextMenuItem
|
||||
icon="inspect"
|
||||
href={getHref('fleet_agent_details', { agentId: agent.id })}
|
||||
key="viewAgent"
|
||||
>
|
||||
<FormattedMessage id="xpack.fleet.agentList.viewActionText" defaultMessage="View agent" />
|
||||
</EuiContextMenuItem>,
|
||||
<EuiContextMenuItem
|
||||
icon="pencil"
|
||||
onClick={() => {
|
||||
onReassignClick();
|
||||
}}
|
||||
disabled={!agent.active}
|
||||
key="reassignPolicy"
|
||||
>
|
||||
<FormattedMessage
|
||||
id="xpack.fleet.agentList.reassignActionText"
|
||||
defaultMessage="Assign to new policy"
|
||||
/>
|
||||
</EuiContextMenuItem>,
|
||||
<EuiContextMenuItem
|
||||
disabled={!hasWriteCapabilites || !agent.active}
|
||||
icon="trash"
|
||||
onClick={() => {
|
||||
onUnenrollClick();
|
||||
}}
|
||||
>
|
||||
{isUnenrolling ? (
|
||||
<FormattedMessage
|
||||
id="xpack.fleet.agentList.forceUnenrollOneButton"
|
||||
defaultMessage="Force unenroll"
|
||||
/>
|
||||
) : (
|
||||
<FormattedMessage
|
||||
id="xpack.fleet.agentList.unenrollOneButton"
|
||||
defaultMessage="Unenroll agent"
|
||||
/>
|
||||
)}
|
||||
</EuiContextMenuItem>,
|
||||
<EuiContextMenuItem
|
||||
icon="refresh"
|
||||
disabled={!isAgentUpgradeable(agent, kibanaVersion)}
|
||||
onClick={() => {
|
||||
onUpgradeClick();
|
||||
}}
|
||||
>
|
||||
<FormattedMessage
|
||||
id="xpack.fleet.agentList.upgradeOneButton"
|
||||
defaultMessage="Upgrade agent"
|
||||
/>
|
||||
</EuiContextMenuItem>,
|
||||
]}
|
||||
items={menuItems}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
@ -453,9 +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={agentPolicy}
|
||||
refresh={() => fetchData()}
|
||||
onReassignClick={() => setAgentToReassign(agent)}
|
||||
onUnenrollClick={() => setAgentToUnenroll(agent)}
|
||||
|
|
|
@ -242,8 +242,10 @@ export const EnrollmentTokenListPage: React.FunctionComponent<{}> = () => {
|
|||
}),
|
||||
width: '70px',
|
||||
render: (_: any, apiKey: EnrollmentAPIKey) => {
|
||||
const agentPolicy = agentPolicies.find((c) => c.id === apiKey.policy_id);
|
||||
const canUnenroll = apiKey.active && !agentPolicy?.is_managed;
|
||||
return (
|
||||
apiKey.active && (
|
||||
canUnenroll && (
|
||||
<DeleteButton
|
||||
apiKey={apiKey}
|
||||
refresh={() => enrollmentAPIKeysRequest.resendRequest()}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue