Skip to content

Commit fcdb048

Browse files
authored
[Ingest] Fix agent config key sorting (#63488) (#63813)
1 parent e390a7d commit fcdb048

File tree

1 file changed

+20
-2
lines changed
  • x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/yaml

1 file changed

+20
-2
lines changed

x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/yaml/index.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,15 @@ import {
2525
import { ShellEnrollmentInstructions } from '../../../../../components/enrollment_instructions';
2626
import { Loading } from '../../../../../components';
2727

28-
const CONFIG_KEYS_ORDER = ['id', 'revision', 'outputs', 'datasources'];
28+
const CONFIG_KEYS_ORDER = [
29+
'id',
30+
'revision',
31+
'outputs',
32+
'datasources',
33+
'enabled',
34+
'package',
35+
'input',
36+
];
2937

3038
export const ConfigYamlView = memo<{ config: AgentConfig }>(({ config }) => {
3139
const core = useCore();
@@ -47,7 +55,17 @@ export const ConfigYamlView = memo<{ config: AgentConfig }>(({ config }) => {
4755
<EuiCodeBlock language="yaml" isCopyable>
4856
{dump(fullConfigRequest.data.item, {
4957
sortKeys: (keyA: string, keyB: string) => {
50-
return CONFIG_KEYS_ORDER.indexOf(keyA) - CONFIG_KEYS_ORDER.indexOf(keyB);
58+
const indexA = CONFIG_KEYS_ORDER.indexOf(keyA);
59+
const indexB = CONFIG_KEYS_ORDER.indexOf(keyB);
60+
if (indexA >= 0 && indexB < 0) {
61+
return -1;
62+
}
63+
64+
if (indexA < 0 && indexB >= 0) {
65+
return 1;
66+
}
67+
68+
return indexA - indexB;
5169
},
5270
})}
5371
</EuiCodeBlock>

0 commit comments

Comments
 (0)