Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ILM] Prettify JSON in "Show request" flyout #87612

Merged
merged 2 commits into from
Jan 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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