Browse Source

mol-plugin: fix transform update UI when error happens

David Sehnal 5 years ago
parent
commit
32c8664829
1 changed files with 11 additions and 1 deletions
  1. 11 1
      src/mol-plugin/ui/state/update-transform.tsx

+ 11 - 1
src/mol-plugin/ui/state/update-transform.tsx

@@ -32,7 +32,17 @@ class UpdateTransformControl extends TransformControlBase<UpdateTransformControl
     getInfo() { return this._getInfo(this.props.transform); }
     getTransformerId() { return this.props.transform.transformer.id; }
     getHeader() { return this.props.customHeader || this.props.transform.transformer.definition.display; }
-    canApply() { return !this.state.error && !this.state.busy && !this.state.isInitial; }
+    canApply() {
+        const { state } = this.props;
+        const cell = state.cells.get(this.props.transform.ref);
+        if (!cell) return false;
+        if (cell.status === 'error') {
+            const parent = state.cells.get(this.props.transform.parent)!;
+            if (!parent) return false;
+            return parent.status === 'ok';
+        }
+        return !this.state.error && !this.state.busy && !this.state.isInitial;
+    }
     applyText() { return this.canApply() ? 'Update' : 'Nothing to Update'; }
     isUpdate() { return true; }
     getSourceAndTarget() {