-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Fleet] Update agent details page #84434
Merged
nchaulet
merged 6 commits into
elastic:master
from
nchaulet:feature-fleet-update-design-agent-details-page
Dec 1, 2020
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4bdf9fa
[Fleet] Update agent details page to prepare for a per integrations s…
nchaulet 0271964
Fix after review
nchaulet 1ec8e98
Merge branch 'master' of github.com:elastic/kibana into feature-fleet…
nchaulet 3932205
Fix useless import
nchaulet fed695b
Better route definition for fleet_agent_details
nchaulet 25524bc
Do not override EUIAccordion internal classes
nchaulet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
147 changes: 0 additions & 147 deletions
147
...public/applications/fleet/sections/agents/agent_details_page/components/agent_details.tsx
This file was deleted.
Oops, something went wrong.
153 changes: 153 additions & 0 deletions
153
...ections/agents/agent_details_page/components/agent_details/agent_details_integrations.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
import React, { memo, useMemo } from 'react'; | ||
import { | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiLink, | ||
EuiAccordion, | ||
EuiTitle, | ||
EuiPanel, | ||
EuiButtonIcon, | ||
EuiBasicTable, | ||
} from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
import styled from 'styled-components'; | ||
import { Agent, AgentPolicy, PackagePolicy, PackagePolicyInput } from '../../../../../types'; | ||
import { useLink } from '../../../../../hooks'; | ||
import { PackageIcon } from '../../../../../components'; | ||
import { displayInputType, getLogsQueryByInputType } from './input_type_utils'; | ||
|
||
const StyledCollapsablePanel = styled(EuiPanel).attrs((props) => ({ | ||
paddingSize: 'none', | ||
}))` | ||
.euiAccordion__triggerWrapper { | ||
border-bottom: 1px solid ${(props) => props.theme.eui.euiColorLightShade}; | ||
padding: ${(props) => props.theme.eui.paddingSizes.m} | ||
${(props) => props.theme.eui.paddingSizes.m}; | ||
} | ||
.euiAccordion__childWrapper { | ||
overflow: visible; | ||
} | ||
`; | ||
|
||
const CollapsablePanel: React.FC<{ title: React.ReactNode }> = ({ title, children }) => { | ||
return ( | ||
<StyledCollapsablePanel paddingSize="none"> | ||
<EuiAccordion id="accordion-1" arrowDisplay="right" buttonContent={title}> | ||
{children} | ||
</EuiAccordion> | ||
</StyledCollapsablePanel> | ||
); | ||
}; | ||
|
||
export const AgentDetailsIntegration: React.FunctionComponent<{ | ||
agent: Agent; | ||
agentPolicy: AgentPolicy; | ||
packagePolicy: PackagePolicy; | ||
}> = memo(({ agent, agentPolicy, packagePolicy }) => { | ||
const { getHref } = useLink(); | ||
|
||
const inputs = useMemo(() => { | ||
return packagePolicy.inputs.filter((input) => input.enabled); | ||
}, [packagePolicy.inputs]); | ||
|
||
const columns = [ | ||
{ | ||
field: 'type', | ||
width: '100%', | ||
name: i18n.translate('xpack.fleet.agentDetailsIntegrations.inputTypeLabel', { | ||
defaultMessage: 'Input', | ||
}), | ||
render: (inputType: string) => { | ||
return displayInputType(inputType); | ||
}, | ||
}, | ||
{ | ||
name: i18n.translate('xpack.fleet.agentDetailsIntegrations.actionsLabel', { | ||
defaultMessage: 'Actions', | ||
}), | ||
field: 'type', | ||
width: 'auto', | ||
render: (inputType: string) => { | ||
return ( | ||
<EuiButtonIcon | ||
href={`${getHref('fleet_agent_details', { | ||
agentId: agent.id, | ||
tabId: 'logs', | ||
})}?${getLogsQueryByInputType(inputType)}`} | ||
nchaulet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
iconType="editorAlignLeft" | ||
title={i18n.translate('xpack.fleet.agentDetailsIntegrations.viewLogsButton', { | ||
defaultMessage: 'View logs', | ||
})} | ||
/> | ||
); | ||
}, | ||
}, | ||
]; | ||
|
||
return ( | ||
<CollapsablePanel | ||
title={ | ||
<EuiTitle size="xs"> | ||
<h3> | ||
<EuiFlexGroup gutterSize="s"> | ||
<EuiFlexItem grow={false}> | ||
{packagePolicy.package ? ( | ||
<PackageIcon | ||
packageName={packagePolicy.package.name} | ||
version={packagePolicy.package.version} | ||
size="l" | ||
tryApi={true} | ||
/> | ||
) : ( | ||
<PackageIcon size="l" packageName="default" version="0" /> | ||
)} | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiLink | ||
href={getHref('edit_integration', { | ||
policyId: agentPolicy.id, | ||
packagePolicyId: packagePolicy.id, | ||
})} | ||
> | ||
{packagePolicy.name} | ||
</EuiLink> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</h3> | ||
</EuiTitle> | ||
} | ||
> | ||
<EuiBasicTable<PackagePolicyInput> tableLayout="auto" items={inputs} columns={columns} /> | ||
</CollapsablePanel> | ||
); | ||
}); | ||
|
||
export const AgentDetailsIntegrationsSection: React.FunctionComponent<{ | ||
agent: Agent; | ||
agentPolicy?: AgentPolicy; | ||
}> = memo(({ agent, agentPolicy }) => { | ||
if (!agentPolicy || !agentPolicy.package_policies) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<EuiFlexGroup direction="column"> | ||
{(agentPolicy.package_policies as PackagePolicy[]).map((packagePolicy) => { | ||
nchaulet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return ( | ||
<EuiFlexItem grow={false} key={packagePolicy.id}> | ||
<AgentDetailsIntegration | ||
agent={agent} | ||
agentPolicy={agentPolicy} | ||
packagePolicy={packagePolicy} | ||
/> | ||
</EuiFlexItem> | ||
); | ||
})} | ||
</EuiFlexGroup> | ||
); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we do this without targeting EUI internal classes? If the solution isn't obvious, mind opening a ticket/discussion with the EUI team for a suggestion or fix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think it's possible to do it without custom css here, I know @hbharding implemented it the same way for the overview panel,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@elastic/eui-design Do you think there is anything built in that I can use to build this component? I currently use an EuiAccordion in a EuiPanel with some custom css
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @nchaulet , It looks like what you're actually building is a table within the contents of the accordion body. I would explicitly use the EuiBasicTable component so that all the right associations are made between cells. Then you'll just need to remove the padding from the accordion but pass a custom padding and class to the button portion of the accordion. Here's an example CodeSandox https://codesandbox.io/s/thirsty-river-hmfd2?file=/index.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot I just updated to use a buttonClass in EuiAccordion works perfectly :)