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

Fix TransferItemModal failing to preserve original object field values on Migration Recreation. #807

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 @@ -632,11 +632,11 @@ class TransferItemModal extends React.Component<Props, State> {
? { ...this.state.sourceData }
: { ...this.state.destinationData };

const replicaData: any =
type === "source"
? this.props.replica.source_environment
: this.props.replica.destination_environment;
if (field.type === "array") {
const replicaData: any =
type === "source"
? this.props.replica.source_environment
: this.props.replica.destination_environment;
const currentValues: string[] = data[field.name] || [];
const oldValues: string[] = replicaData[field.name] || [];
let values: string[] = currentValues;
Expand All @@ -654,7 +654,11 @@ class TransferItemModal extends React.Component<Props, State> {
}
data[field.groupName][field.name] = value;
} else if (parentFieldName) {
data[parentFieldName] = data[parentFieldName] || {};
// NOTE(aznashwan): in order to prevent accidentally un-setting any
// existing fields from Object options from the previous Migration/Replica,
// we always re-merge all the values on an object field update.
data[parentFieldName] =
data[parentFieldName] || replicaData[parentFieldName] || {};
data[parentFieldName][field.name] = value;
} else {
data[field.name] = value;
Expand Down
Loading