Skip to content

Commit

Permalink
prettify json (#87612)
Browse files Browse the repository at this point in the history
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
jloleysens and kibanamachine authored Jan 11, 2021
1 parent 55fe83d commit 8a21b64
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Props> = ({ policyName, close }) => {
/**
* policy === undefined: we are checking validity
Expand All @@ -46,7 +59,7 @@ export const PolicyJsonFlyout: React.FunctionComponent<Props> = ({ policyName, c
const updatePolicy = useCallback(async () => {
setPolicy(undefined);
if (await validateForm()) {
setPolicy(getFormData() as SerializedPolicy);
setPolicy(prettifyFormJson(getFormData()));
} else {
setPolicy(null);
}
Expand Down

0 comments on commit 8a21b64

Please sign in to comment.