Skip to content

Commit 7f48a65

Browse files
committed
fix json policy serialization
1 parent 7da30bd commit 7f48a65

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/policy_json_flyout.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,16 @@ import { SerializedPolicy } from '../../../../../common/types';
2727
import { useFormContext } from '../../../../shared_imports';
2828

2929
interface Props {
30+
legacyPolicy: SerializedPolicy;
3031
close: () => void;
3132
policyName: string;
3233
}
3334

34-
export const PolicyJsonFlyout: React.FunctionComponent<Props> = ({ policyName, close }) => {
35+
export const PolicyJsonFlyout: React.FunctionComponent<Props> = ({
36+
policyName,
37+
close,
38+
legacyPolicy,
39+
}) => {
3540
/**
3641
* policy === undefined: we are checking validity
3742
* policy === null: we have determined the policy is invalid
@@ -45,13 +50,20 @@ export const PolicyJsonFlyout: React.FunctionComponent<Props> = ({ policyName, c
4550
const subscription = form.subscribe(async (formUpdate) => {
4651
setPolicy(undefined);
4752
if (await formUpdate.validate()) {
48-
setPolicy(formUpdate.data.format());
53+
const p = formUpdate.data.format() as SerializedPolicy;
54+
setPolicy({
55+
...legacyPolicy,
56+
phases: {
57+
...legacyPolicy.phases,
58+
hot: p.phases.hot,
59+
},
60+
});
4961
} else {
5062
setPolicy(null);
5163
}
5264
});
53-
return subscription.unsubsribe;
54-
}, [form]);
65+
return subscription.unsubscribe;
66+
}, [form, legacyPolicy]);
5567

5668
let content: React.ReactNode;
5769
switch (policy) {

x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/edit_policy.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@ export const EditPolicy: React.FunctionComponent<Props> = ({
440440
{isShowingPolicyJsonFlyout ? (
441441
<PolicyJsonFlyout
442442
policyName={policy.name || ''}
443+
legacyPolicy={legacySerializePolicy(policy, existingPolicy?.policy)}
443444
close={() => setIsShowingPolicyJsonFlyout(false)}
444445
/>
445446
) : null}

0 commit comments

Comments
 (0)