forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fleet] add Agent config details yaml view (elastic#60943) (elastic#6…
- Loading branch information
Showing
8 changed files
with
103 additions
and
9 deletions.
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
File renamed without changes.
File renamed without changes.
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
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
78 changes: 78 additions & 0 deletions
78
.../applications/ingest_manager/sections/agent_config/details_page/components/yaml/index.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,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" /> | ||
<EuiText size="s"> | ||
<FormattedMessage | ||
id="xpack.ingestManager.yamlConfig.instructionDescription" | ||
defaultMessage="To enroll an agent with this configuration, copy and run the following command on your host." | ||
/> | ||
</EuiText> | ||
<EuiSpacer size="m" /> | ||
{apiKeyRequest.data && ( | ||
<ShellEnrollmentInstructions | ||
apiKey={apiKeyRequest.data.item} | ||
kibanaUrl={`${window.location.origin}${core.http.basePath.get()}`} | ||
/> | ||
)} | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
); | ||
}); |
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
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