-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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] add Agent config details yaml view #60943
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* 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 } from 'react'; | ||
import { dump } from 'js-yaml'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
import { | ||
EuiTitle, | ||
EuiSpacer, | ||
EuiText, | ||
EuiCodeBlock, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
} from '@elastic/eui'; | ||
import { AgentConfig } from '../../../../../../../../common/types/models'; | ||
import { | ||
useGetOneAgentConfigFull, | ||
useGetEnrollmentAPIKeys, | ||
useGetOneEnrollmentAPIKey, | ||
useCore, | ||
} from '../../../../../hooks'; | ||
import { ShellEnrollmentInstructions } from '../../../../../components/enrollment_instructions'; | ||
import { Loading } from '../../../../../components'; | ||
|
||
const CONFIG_KEYS_ORDER = ['id', 'revision', 'outputs', 'datasources']; | ||
|
||
export const ConfigYamlView = memo<{ config: AgentConfig }>(({ config }) => { | ||
const core = useCore(); | ||
|
||
const fullConfigRequest = useGetOneAgentConfigFull(config.id); | ||
const apiKeysRequest = useGetEnrollmentAPIKeys(); | ||
const apiKeyRequest = useGetOneEnrollmentAPIKey(apiKeysRequest.data?.list?.[0].id as string); | ||
|
||
if (fullConfigRequest.isLoading && !fullConfigRequest.data) { | ||
return <Loading />; | ||
} | ||
|
||
return ( | ||
<EuiFlexGroup> | ||
<EuiFlexItem grow={7}> | ||
<EuiCodeBlock language="yaml" isCopyable> | ||
{dump(fullConfigRequest.data.item, { | ||
sortKeys: (keyA: string, keyB: string) => { | ||
return CONFIG_KEYS_ORDER.indexOf(keyA) - CONFIG_KEYS_ORDER.indexOf(keyB); | ||
}, | ||
})} | ||
</EuiCodeBlock> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={3}> | ||
<EuiTitle size="s"> | ||
<h3> | ||
<FormattedMessage | ||
id="xpack.ingestManager.yamlConfig.instructionTittle " | ||
defaultMessage="Enroll with fleet" | ||
/> | ||
</h3> | ||
</EuiTitle> | ||
<EuiSpacer size={'m'} /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. keep as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍it's annoying that prettier do not catch things like that |
||
<EuiText size="s"> | ||
<FormattedMessage | ||
id="xpack.ingestManager.yamlConfig.instructionDescription " | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. trailing space |
||
defaultMessage="To enroll an agent with this configuration, copy and run the following command on your host." | ||
/> | ||
</EuiText> | ||
<EuiSpacer size={'m'} /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. keep as |
||
{apiKeyRequest.data && ( | ||
<ShellEnrollmentInstructions | ||
apiKey={apiKeyRequest.data.item} | ||
kibanaUrl={`${window.location.origin}${core.http.basePath.get()}`} | ||
/> | ||
)} | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
); | ||
}); |
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.
trailing space and typo -
instructionTitle