Skip to content

Commit 0ba7d9c

Browse files
authored
[Fleet] Update agent details page (#84434)
1 parent 4a7071e commit 0ba7d9c

File tree

14 files changed

+530
-257
lines changed

14 files changed

+530
-257
lines changed

x-pack/plugins/fleet/public/applications/fleet/constants/page_paths.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ export const pagePathGetters: {
7878
`/policies/${policyId}/edit-integration/${packagePolicyId}`,
7979
fleet: () => '/fleet',
8080
fleet_agent_list: ({ kuery }) => `/fleet/agents${kuery ? `?kuery=${kuery}` : ''}`,
81-
fleet_agent_details: ({ agentId, tabId }) =>
82-
`/fleet/agents/${agentId}${tabId ? `/${tabId}` : ''}`,
81+
fleet_agent_details: ({ agentId, tabId, logQuery }) =>
82+
`/fleet/agents/${agentId}${tabId ? `/${tabId}` : ''}${logQuery ? `?_q=${logQuery}` : ''}`,
8383
fleet_enrollment_tokens: () => '/fleet/enrollment-tokens',
8484
data_streams: () => '/data-streams',
8585
};

x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/actions_menu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export const AgentDetailsActionMenu: React.FunctionComponent<{
7373
)}
7474
<ContextMenuActions
7575
button={{
76-
props: { iconType: 'arrowDown', iconSide: 'right' },
76+
props: { iconType: 'arrowDown', iconSide: 'right', color: 'primary', fill: true },
7777
children: (
7878
<FormattedMessage
7979
id="xpack.fleet.agentDetails.actionsButton"

x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_details.tsx

Lines changed: 0 additions & 147 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
import React, { memo, useMemo } from 'react';
7+
import {
8+
EuiFlexGroup,
9+
EuiFlexItem,
10+
EuiLink,
11+
EuiAccordion,
12+
EuiTitle,
13+
EuiPanel,
14+
EuiButtonIcon,
15+
EuiBasicTable,
16+
} from '@elastic/eui';
17+
import { i18n } from '@kbn/i18n';
18+
import styled from 'styled-components';
19+
import { Agent, AgentPolicy, PackagePolicy, PackagePolicyInput } from '../../../../../types';
20+
import { useLink } from '../../../../../hooks';
21+
import { PackageIcon } from '../../../../../components';
22+
import { displayInputType, getLogsQueryByInputType } from './input_type_utils';
23+
24+
const StyledEuiAccordion = styled(EuiAccordion)`
25+
.ingest-integration-title-button {
26+
padding: ${(props) => props.theme.eui.paddingSizes.m}
27+
${(props) => props.theme.eui.paddingSizes.m};
28+
border-bottom: 1px solid ${(props) => props.theme.eui.euiColorLightShade};
29+
}
30+
`;
31+
32+
const CollapsablePanel: React.FC<{ id: string; title: React.ReactNode }> = ({
33+
id,
34+
title,
35+
children,
36+
}) => {
37+
return (
38+
<EuiPanel paddingSize="none">
39+
<StyledEuiAccordion
40+
id={id}
41+
arrowDisplay="right"
42+
buttonClassName={'ingest-integration-title-button'}
43+
buttonContent={title}
44+
>
45+
{children}
46+
</StyledEuiAccordion>
47+
</EuiPanel>
48+
);
49+
};
50+
51+
export const AgentDetailsIntegration: React.FunctionComponent<{
52+
agent: Agent;
53+
agentPolicy: AgentPolicy;
54+
packagePolicy: PackagePolicy;
55+
}> = memo(({ agent, agentPolicy, packagePolicy }) => {
56+
const { getHref } = useLink();
57+
58+
const inputs = useMemo(() => {
59+
return packagePolicy.inputs.filter((input) => input.enabled);
60+
}, [packagePolicy.inputs]);
61+
62+
const columns = [
63+
{
64+
field: 'type',
65+
width: '100%',
66+
name: i18n.translate('xpack.fleet.agentDetailsIntegrations.inputTypeLabel', {
67+
defaultMessage: 'Input',
68+
}),
69+
render: (inputType: string) => {
70+
return displayInputType(inputType);
71+
},
72+
},
73+
{
74+
name: i18n.translate('xpack.fleet.agentDetailsIntegrations.actionsLabel', {
75+
defaultMessage: 'Actions',
76+
}),
77+
field: 'type',
78+
width: 'auto',
79+
render: (inputType: string) => {
80+
return (
81+
<EuiButtonIcon
82+
href={getHref('fleet_agent_details', {
83+
agentId: agent.id,
84+
tabId: 'logs',
85+
logQuery: getLogsQueryByInputType(inputType),
86+
})}
87+
iconType="editorAlignLeft"
88+
title={i18n.translate('xpack.fleet.agentDetailsIntegrations.viewLogsButton', {
89+
defaultMessage: 'View logs',
90+
})}
91+
/>
92+
);
93+
},
94+
},
95+
];
96+
97+
return (
98+
<CollapsablePanel
99+
id={packagePolicy.id}
100+
title={
101+
<EuiTitle size="xs">
102+
<h3>
103+
<EuiFlexGroup gutterSize="s">
104+
<EuiFlexItem grow={false}>
105+
{packagePolicy.package ? (
106+
<PackageIcon
107+
packageName={packagePolicy.package.name}
108+
version={packagePolicy.package.version}
109+
size="l"
110+
tryApi={true}
111+
/>
112+
) : (
113+
<PackageIcon size="l" packageName="default" version="0" />
114+
)}
115+
</EuiFlexItem>
116+
<EuiFlexItem grow={false}>
117+
<EuiLink
118+
href={getHref('edit_integration', {
119+
policyId: agentPolicy.id,
120+
packagePolicyId: packagePolicy.id,
121+
})}
122+
>
123+
{packagePolicy.name}
124+
</EuiLink>
125+
</EuiFlexItem>
126+
</EuiFlexGroup>
127+
</h3>
128+
</EuiTitle>
129+
}
130+
>
131+
<EuiBasicTable<PackagePolicyInput> tableLayout="auto" items={inputs} columns={columns} />
132+
</CollapsablePanel>
133+
);
134+
});
135+
136+
export const AgentDetailsIntegrationsSection: React.FunctionComponent<{
137+
agent: Agent;
138+
agentPolicy?: AgentPolicy;
139+
}> = memo(({ agent, agentPolicy }) => {
140+
if (!agentPolicy || !agentPolicy.package_policies) {
141+
return null;
142+
}
143+
144+
return (
145+
<EuiFlexGroup direction="column">
146+
{(agentPolicy.package_policies as PackagePolicy[]).map((packagePolicy) => {
147+
return (
148+
<EuiFlexItem grow={false} key={packagePolicy.id}>
149+
<AgentDetailsIntegration
150+
agent={agent}
151+
agentPolicy={agentPolicy}
152+
packagePolicy={packagePolicy}
153+
/>
154+
</EuiFlexItem>
155+
);
156+
})}
157+
</EuiFlexGroup>
158+
);
159+
});

0 commit comments

Comments
 (0)