From 510e8cc39341ed17eb8dfe00b1b72a86c2734b96 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Thu, 7 Jan 2021 10:40:50 +0100 Subject: [PATCH] prettify json --- .../edit_policy/components/policy_json_flyout.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/policy_json_flyout.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/policy_json_flyout.tsx index a8b1680ebde07..ef69f6a545656 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/policy_json_flyout.tsx +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/policy_json_flyout.tsx @@ -32,6 +32,19 @@ interface Props { policyName: string; } +/** + * Ensure that the JSON we get from the from has phases in the correct order. + */ +const prettifyFormJson = (policy: SerializedPolicy): SerializedPolicy => ({ + ...policy, + phases: { + hot: policy.phases.hot, + warm: policy.phases.warm, + cold: policy.phases.cold, + delete: policy.phases.delete, + }, +}); + export const PolicyJsonFlyout: React.FunctionComponent = ({ policyName, close }) => { /** * policy === undefined: we are checking validity @@ -46,7 +59,7 @@ export const PolicyJsonFlyout: React.FunctionComponent = ({ policyName, c const updatePolicy = useCallback(async () => { setPolicy(undefined); if (await validateForm()) { - setPolicy(getFormData() as SerializedPolicy); + setPolicy(prettifyFormJson(getFormData())); } else { setPolicy(null); }