From 405888fc7b39b1d7c6cab42b7f44c29f36fab6dd Mon Sep 17 00:00:00 2001 From: John Schulz Date: Mon, 5 Apr 2021 15:50:57 -0400 Subject: [PATCH 1/7] Agent policy detail: Add lock icon w/tootip if hosted --- .../agent_policy/details_page/index.tsx | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/index.tsx index 350d6439c9d3d..9b04c46debac5 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/index.tsx @@ -12,6 +12,7 @@ import { FormattedMessage, FormattedDate } from '@kbn/i18n/react'; import { EuiFlexGroup, EuiFlexItem, + EuiIconTip, EuiText, EuiSpacer, EuiButtonEmpty, @@ -67,8 +68,25 @@ export const AgentPolicyDetailsPage: React.FunctionComponent = () => { const openEnrollmentFlyoutOpenByDefault = queryParams.get('openEnrollmentFlyout') === 'true'; const { isReady: isFleetReady } = useFleetStatus(); - const headerLeftContent = useMemo( - () => ( + const headerLeftContent = useMemo(() => { + const agentPolicyTitle = agentPolicy && agentPolicy.name && ( + <> + {agentPolicy.name}{' '} + {agentPolicy.is_managed && ( + + )} + + ); + return ( { {isLoading ? ( ) : ( - (agentPolicy && agentPolicy.name) || ( + agentPolicyTitle || ( { ) : null} - ), - [getHref, isLoading, agentPolicy, policyId] - ); + ); + }, [getHref, isLoading, agentPolicy, policyId]); const headerRightContent = useMemo( () => From 08d399a527c1163bdeffb459a0f904361688ce92 Mon Sep 17 00:00:00 2001 From: John Schulz Date: Tue, 6 Apr 2021 10:40:08 -0400 Subject: [PATCH 2/7] No 'delete integration' menu item for hosted policies --- .../package_policies_table.tsx | 84 ++++++++++--------- 1 file changed, 44 insertions(+), 40 deletions(-) diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/components/package_policies/package_policies_table.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/components/package_policies/package_policies_table.tsx index db88de0ba720b..92f0a76652da7 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/components/package_policies/package_policies_table.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/components/package_policies/package_policies_table.tsx @@ -167,42 +167,45 @@ export const PackagePoliciesTable: React.FunctionComponent = ({ }), actions: [ { - render: (packagePolicy: InMemoryPackagePolicy) => ( - {}} - // key="packagePolicyView" - // > - // - // , - - - , - // FIXME: implement Copy package policy action - // {}} key="packagePolicyCopy"> - // - // , + render: (packagePolicy: InMemoryPackagePolicy) => { + const menuItems = [ + // FIXME: implement View package policy action + // {}} + // key="packagePolicyView" + // > + // + // , + + + , + // FIXME: implement Copy package policy action + // {}} key="packagePolicyCopy"> + // + // , + ]; + + if (!agentPolicy.is_managed) { + menuItems.push( {(deletePackagePoliciesPrompt) => { return ( @@ -220,10 +223,11 @@ export const PackagePoliciesTable: React.FunctionComponent = ({ ); }} - , - ]} - /> - ), + + ); + } + return ; + }, }, ], }, From 18fca79d69ad83637e25c2292bdf5f0867b2b446 Mon Sep 17 00:00:00 2001 From: John Schulz Date: Tue, 6 Apr 2021 11:56:01 -0400 Subject: [PATCH 3/7] Lookup the policy directly versus searching for it --- .../fleet/sections/agents/agent_list_page/index.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 8e9c549fe5609..d01d290e129b8 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 @@ -341,9 +341,10 @@ export const AgentListPage: React.FunctionComponent<{}> = () => { const isAgentSelectable = (agent: Agent) => { if (!agent.active) return false; + if (!agent.policy_id) return true; - const agentPolicy = agentPolicies.find((p) => p.id === agent.policy_id); - const isManaged = agent.policy_id && agentPolicy?.is_managed === true; + const agentPolicy = agentPoliciesIndexedById[agent.policy_id]; + const isManaged = agentPolicy?.is_managed === true; return !isManaged; }; From bad2618a6959e24083aaf0884c34302afe1c1ccc Mon Sep 17 00:00:00 2001 From: John Schulz Date: Wed, 7 Apr 2021 12:41:54 -0400 Subject: [PATCH 4/7] Better (if not perfect) name & icon lockup --- .../agent_policy/details_page/index.tsx | 76 ++++++++++--------- 1 file changed, 40 insertions(+), 36 deletions(-) diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/index.tsx index 9b04c46debac5..3e6ca5944c380 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/index.tsx @@ -13,6 +13,7 @@ import { EuiFlexGroup, EuiFlexItem, EuiIconTip, + EuiTitle, EuiText, EuiSpacer, EuiButtonEmpty, @@ -68,25 +69,8 @@ export const AgentPolicyDetailsPage: React.FunctionComponent = () => { const openEnrollmentFlyoutOpenByDefault = queryParams.get('openEnrollmentFlyout') === 'true'; const { isReady: isFleetReady } = useFleetStatus(); - const headerLeftContent = useMemo(() => { - const agentPolicyTitle = agentPolicy && agentPolicy.name && ( - <> - {agentPolicy.name}{' '} - {agentPolicy.is_managed && ( - - )} - - ); - return ( + const headerLeftContent = useMemo( + () => ( { - -

- {isLoading ? ( - - ) : ( - agentPolicyTitle || ( - + ) : ( + + + +

+ {(agentPolicy && agentPolicy.name) || ( + + )} +

+
+
+ {agentPolicy?.is_managed && ( + + - ) + )} -

-
+
+ )} {agentPolicy && agentPolicy.description ? ( @@ -130,8 +133,9 @@ export const AgentPolicyDetailsPage: React.FunctionComponent = () => { ) : null} - ); - }, [getHref, isLoading, agentPolicy, policyId]); + ), + [getHref, isLoading, agentPolicy, policyId] + ); const headerRightContent = useMemo( () => From 66fd534af619bc5cee6fae30d1838a56749ee66b Mon Sep 17 00:00:00 2001 From: John Schulz Date: Wed, 7 Apr 2021 13:02:21 -0400 Subject: [PATCH 5/7] Hide 'Add integration' on detail page of hosted policies --- .../package_policies_table.tsx | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/components/package_policies/package_policies_table.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/components/package_policies/package_policies_table.tsx index 92f0a76652da7..9e23fc775a213 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/components/package_policies/package_policies_table.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/components/package_policies/package_policies_table.tsx @@ -248,19 +248,21 @@ export const PackagePoliciesTable: React.FunctionComponent = ({ }} {...rest} search={{ - toolsRight: [ - - - , - ], + toolsRight: agentPolicy.is_managed + ? [] + : [ + + + , + ], box: { incremental: true, schema: true, From a5cafedabb380654132af05b3e3921b6f1625380 Mon Sep 17 00:00:00 2001 From: John Schulz Date: Wed, 7 Apr 2021 13:26:20 -0400 Subject: [PATCH 6/7] Disable or hide restricted parts of settings tab for hosted policy --- .../sections/agent_policy/components/agent_policy_form.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_form.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_form.tsx index 238cba217da8e..a1ac30995f722 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_form.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_form.tsx @@ -144,6 +144,7 @@ export const AgentPolicyForm: React.FunctionComponent = ({ isInvalid={Boolean(touchedFields[name] && validation[name])} > updateAgentPolicy({ [name]: e.target.value })} @@ -283,7 +284,7 @@ export const AgentPolicyForm: React.FunctionComponent = ({ }} /> - {isEditing && 'id' in agentPolicy ? ( + {isEditing && 'id' in agentPolicy && agentPolicy.is_managed !== true ? ( From ba68056c36a033cd9e694095daff84c15768eb57 Mon Sep 17 00:00:00 2001 From: John Schulz Date: Thu, 8 Apr 2021 10:38:30 -0400 Subject: [PATCH 7/7] Hide actions button on agent details page for hosted agents --- .../agents/agent_details_page/index.tsx | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/index.tsx index adeb56f489ea3..56b99f645f97c 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/index.tsx @@ -194,17 +194,18 @@ export const AgentDetailsPage: React.FunctionComponent = () => { ), }, { - content: ( - - ), + content: + isAgentPolicyLoading || agentPolicyData?.item?.is_managed ? undefined : ( + + ), }, ].map((item, index) => (