Skip to content
Snippets Groups Projects
Commit 2d3b8582 authored by David Sehnal's avatar David Sehnal
Browse files

mol-plugin: Allow to mount TransformUpdaterControl outside the main plugin

parent a5a34f39
No related branches found
No related tags found
No related merge requests found
...@@ -9,7 +9,8 @@ import { memoizeLatest } from '../../../mol-util/memoize'; ...@@ -9,7 +9,8 @@ import { memoizeLatest } from '../../../mol-util/memoize';
import { StateTransformParameters, TransformContolBase } from './common'; import { StateTransformParameters, TransformContolBase } from './common';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import * as React from 'react'; import * as React from 'react';
import { PluginUIComponent } from '../base'; import { PluginUIComponent, PluginReactContext } from '../base';
import { PluginContext } from '../../context';
export { UpdateTransformContol, TransformUpdaterControl }; export { UpdateTransformContol, TransformUpdaterControl };
...@@ -85,7 +86,7 @@ class UpdateTransformContol extends TransformContolBase<UpdateTransformContol.Pr ...@@ -85,7 +86,7 @@ class UpdateTransformContol extends TransformContolBase<UpdateTransformContol.Pr
} }
} }
class TransformUpdaterControl extends PluginUIComponent<{ nodeRef: string, initiallyCollapsed?: boolean, header?: StateTransformer.Definition['display'] }> { class TransformUpdaterControl extends PluginUIComponent<{ plugin?: PluginContext, nodeRef: string, initiallyCollapsed?: boolean, header?: StateTransformer.Definition['display'] }> {
componentDidMount() { componentDidMount() {
this.subscribe(this.plugin.events.state.object.updated, ({ ref, state }) => { this.subscribe(this.plugin.events.state.object.updated, ({ ref, state }) => {
if (this.props.nodeRef !== ref || this.plugin.state.dataState !== state) return; if (this.props.nodeRef !== ref || this.plugin.state.dataState !== state) return;
...@@ -102,6 +103,14 @@ class TransformUpdaterControl extends PluginUIComponent<{ nodeRef: string, initi ...@@ -102,6 +103,14 @@ class TransformUpdaterControl extends PluginUIComponent<{ nodeRef: string, initi
const transform = cell.transform; const transform = cell.transform;
if (this.props.plugin) {
return <PluginReactContext.Provider value={this.props.plugin}>
<div className='msp-plugin'>
<UpdateTransformContol state={state} transform={transform} initiallyCollapsed={this.props.initiallyCollapsed} customHeader={this.props.header} />
</div>
</PluginReactContext.Provider>;
}
return <UpdateTransformContol state={state} transform={transform} initiallyCollapsed={this.props.initiallyCollapsed} customHeader={this.props.header} />; return <UpdateTransformContol state={state} transform={transform} initiallyCollapsed={this.props.initiallyCollapsed} customHeader={this.props.header} />;
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment