Skip to content

Commit

Permalink
[Ingest] Fix agent config key sorting (#63488)
Browse files Browse the repository at this point in the history
  • Loading branch information
nchaulet authored Apr 17, 2020
1 parent dacc95f commit e3eed0b
Showing 1 changed file with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@ import {
import { ShellEnrollmentInstructions } from '../../../../../components/enrollment_instructions';
import { Loading } from '../../../../../components';

const CONFIG_KEYS_ORDER = ['id', 'revision', 'outputs', 'datasources'];
const CONFIG_KEYS_ORDER = [
'id',
'revision',
'outputs',
'datasources',
'enabled',
'package',
'input',
];

export const ConfigYamlView = memo<{ config: AgentConfig }>(({ config }) => {
const core = useCore();
Expand All @@ -47,7 +55,17 @@ export const ConfigYamlView = memo<{ config: AgentConfig }>(({ config }) => {
<EuiCodeBlock language="yaml" isCopyable>
{dump(fullConfigRequest.data.item, {
sortKeys: (keyA: string, keyB: string) => {
return CONFIG_KEYS_ORDER.indexOf(keyA) - CONFIG_KEYS_ORDER.indexOf(keyB);
const indexA = CONFIG_KEYS_ORDER.indexOf(keyA);
const indexB = CONFIG_KEYS_ORDER.indexOf(keyB);
if (indexA >= 0 && indexB < 0) {
return -1;
}

if (indexA < 0 && indexB >= 0) {
return 1;
}

return indexA - indexB;
},
})}
</EuiCodeBlock>
Expand Down

0 comments on commit e3eed0b

Please sign in to comment.