From 0a181838cadaada56365652a5c6b00c314c304da Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Mon, 11 Jan 2021 16:28:09 +0100 Subject: [PATCH] prettify json (#87612) (#87823) Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- .../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); }