浏览代码

Merge pull request #731 from smiclea/fix-crash

Fix UI crash when selecting `null` value
Daniel Vincze 3 年之前
父节点
当前提交
7eaa9434cf

+ 7 - 4
src/components/modules/TransferModule/TransferItemModal/TransferItemModal.tsx

@@ -473,10 +473,11 @@ class TransferItemModal extends React.Component<Props, State> {
       type === "source"
         ? this.props.sourceEndpoint
         : this.props.destinationEndpoint;
-    const env =
+    const env = ObjectUtils.clone(
       type === "source"
         ? this.props.replica.source_environment
-        : this.props.replica.destination_environment;
+        : this.props.replica.destination_environment
+    );
     const stateEnv =
       type === "source" ? this.state.sourceData : this.state.destinationData;
 
@@ -560,10 +561,12 @@ class TransferItemModal extends React.Component<Props, State> {
   }
 
   validateOptions(type: "source" | "destination") {
-    const env =
+    const env = ObjectUtils.clone(
       type === "source"
         ? this.props.replica.source_environment
-        : this.props.replica.destination_environment;
+        : this.props.replica.destination_environment
+    );
+
     const data =
       type === "source" ? this.state.sourceData : this.state.destinationData;
     const schema =

+ 4 - 0
src/utils/ObjectUtils.ts

@@ -163,6 +163,10 @@ class ObjectUtils {
 
     return this.mergeDeep(target, ...sources);
   }
+
+  static clone(obj: any) {
+    return JSON.parse(JSON.stringify(obj));
+  }
 }
 
 export default ObjectUtils;