ソースを参照

mol-plugin: only expand DownloadStructure for root actions

David Sehnal 5 年 前
コミット
cc8999cbc9
2 ファイル変更5 行追加3 行削除
  1. 4 2
      src/mol-plugin/ui/state/actions.tsx
  2. 1 1
      src/mol-plugin/ui/state/tree.tsx

+ 4 - 2
src/mol-plugin/ui/state/actions.tsx

@@ -11,7 +11,7 @@ import { State, StateAction } from '../../../mol-state';
 import { Icon } from '../controls/common';
 import { PluginContext } from '../../context';
 
-export class StateObjectActions extends PluginUIComponent<{ state: State, nodeRef: string, hideHeader?: boolean, initiallyCollapsed?: boolean }> {
+export class StateObjectActions extends PluginUIComponent<{ state: State, nodeRef: string, hideHeader?: boolean, initiallyCollapsed?: boolean, alwaysExpandFirst?: boolean }> {
     get current() {
         return this.plugin.state.behavior.currentObject.value;
     }
@@ -40,7 +40,9 @@ export class StateObjectActions extends PluginUIComponent<{ state: State, nodeRe
 
         return <div className='msp-state-actions'>
             {!this.props.hideHeader && <div className='msp-section-header'><Icon name='code' /> {`Actions (${display})`}</div> }
-            {actions.map((act, i) => <ApplyActionControl plugin={this.plugin} key={`${act.id}`} state={state} action={act} nodeRef={ref} initiallyCollapsed={this.props.initiallyCollapsed} />)}
+            {actions.map((act, i) => <ApplyActionControl
+                plugin={this.plugin} key={`${act.id}`} state={state} action={act} nodeRef={ref}
+                initiallyCollapsed={i === 0 ? !this.props.alwaysExpandFirst && this.props.initiallyCollapsed : this.props.initiallyCollapsed} />)}
         </div>;
     }
 }

+ 1 - 1
src/mol-plugin/ui/state/tree.tsx

@@ -35,7 +35,7 @@ export class StateTree extends PluginUIComponent<{ state: State }, { showActions
     render() {
         const ref = this.props.state.tree.root.ref;
         if (this.state.showActions) {
-            return <StateObjectActions state={this.props.state} nodeRef={ref} hideHeader={true} />
+            return <StateObjectActions state={this.props.state} nodeRef={ref} hideHeader={true} initiallyCollapsed={true} alwaysExpandFirst={true} />
         }
         return <StateTreeNode cell={this.props.state.cells.get(ref)!} depth={0} />;
     }