Skip to content

Commit

Permalink
Fix TransferItemModal failing to preserve original object field value…
Browse files Browse the repository at this point in the history
…s on Migration Recreation.

Signed-off-by: Nashwan Azhari <[email protected]>
  • Loading branch information
aznashwan committed Apr 25, 2024
1 parent 2662a48 commit fd3e118
Showing 1 changed file with 9 additions and 5 deletions.
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

0 comments on commit fd3e118

Please sign in to comment.