Skip to content
Snippets Groups Projects
Commit 7dd808a7 authored by Alexander Rose's avatar Alexander Rose
Browse files

add custom import controls

parent 945e55f8
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,8 @@ Note that since we don't clearly distinguish between a public and private interf ...@@ -7,7 +7,8 @@ Note that since we don't clearly distinguish between a public and private interf
## [Unreleased] ## [Unreleased]
- Fix handling of mmcif with empty ``label_*`` fields - Fix handling of mmcif with empty ``label_*`` fields
- Add LoadTrajectory action - Add ``LoadTrajectory`` action
- Add ``CustomImportControls`` to left panel
- Add Zenodo import extension (load structures, trajectories, volumes, and zip files) - Add Zenodo import extension (load structures, trajectories, volumes, and zip files)
- Fix loading of some compressed files within sessions - Fix loading of some compressed files within sessions
......
...@@ -15,7 +15,7 @@ export const ZenodoImport = PluginBehavior.create<{ }>({ ...@@ -15,7 +15,7 @@ export const ZenodoImport = PluginBehavior.create<{ }>({
}, },
ctor: class extends PluginBehavior.Handler<{ }> { ctor: class extends PluginBehavior.Handler<{ }> {
register(): void { register(): void {
this.ctx.customStructureControls.set('zenodo-import', ZenodoImportUI as any); this.ctx.customImportControls.set('zenodo-import', ZenodoImportUI as any);
} }
update() { update() {
...@@ -23,7 +23,7 @@ export const ZenodoImport = PluginBehavior.create<{ }>({ ...@@ -23,7 +23,7 @@ export const ZenodoImport = PluginBehavior.create<{ }>({
} }
unregister() { unregister() {
this.ctx.customStructureControls.delete('zenodo-import'); this.ctx.customImportControls.delete('zenodo-import');
} }
}, },
params: () => ({ }) params: () => ({ })
......
/** /**
* Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info. * Copyright (c) 2019-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
* *
* @author David Sehnal <david.sehnal@gmail.com> * @author David Sehnal <david.sehnal@gmail.com>
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/ */
import * as React from 'react'; import * as React from 'react';
...@@ -19,6 +20,20 @@ import { StateTree } from './state/tree'; ...@@ -19,6 +20,20 @@ import { StateTree } from './state/tree';
import { HelpContent } from './viewport/help'; import { HelpContent } from './viewport/help';
import { HomeOutlinedSvg, AccountTreeOutlinedSvg, TuneSvg, HelpOutlineSvg, SaveOutlinedSvg, DeleteOutlinedSvg } from './controls/icons'; import { HomeOutlinedSvg, AccountTreeOutlinedSvg, TuneSvg, HelpOutlineSvg, SaveOutlinedSvg, DeleteOutlinedSvg } from './controls/icons';
export class CustomImportControls extends PluginUIComponent<{ initiallyCollapsed?: boolean }> {
componentDidMount() {
this.subscribe(this.plugin.state.behaviors.events.changed, () => this.forceUpdate());
}
render() {
const controls: JSX.Element[] = [];
this.plugin.customImportControls.forEach((Controls, key) => {
controls.push(<Controls initiallyCollapsed={this.props.initiallyCollapsed} key={key} />);
});
return controls.length > 0 ? <>{controls}</> : null;
}
}
export class LeftPanelControls extends PluginUIComponent<{}, { tab: LeftPanelTabName }> { export class LeftPanelControls extends PluginUIComponent<{}, { tab: LeftPanelTabName }> {
state = { tab: this.plugin.behaviors.layout.leftPanelTabName.value }; state = { tab: this.plugin.behaviors.layout.leftPanelTabName.value };
...@@ -54,6 +69,7 @@ export class LeftPanelControls extends PluginUIComponent<{}, { tab: LeftPanelTab ...@@ -54,6 +69,7 @@ export class LeftPanelControls extends PluginUIComponent<{}, { tab: LeftPanelTab
'root': <> 'root': <>
<SectionHeader icon={HomeOutlinedSvg} title='Home' /> <SectionHeader icon={HomeOutlinedSvg} title='Home' />
<StateObjectActions state={this.plugin.state.data} nodeRef={StateTransform.RootRef} hideHeader={true} initiallyCollapsed={true} alwaysExpandFirst={true} /> <StateObjectActions state={this.plugin.state.data} nodeRef={StateTransform.RootRef} hideHeader={true} initiallyCollapsed={true} alwaysExpandFirst={true} />
<CustomImportControls />
{this.plugin.spec.components?.remoteState !== 'none' && <RemoteStateSnapshots listOnly /> } {this.plugin.spec.components?.remoteState !== 'none' && <RemoteStateSnapshots listOnly /> }
</>, </>,
'data': <> 'data': <>
......
/** /**
* Copyright (c) 2018-2021 mol* contributors, licensed under MIT, See LICENSE file for more info. * Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
* *
* @author David Sehnal <david.sehnal@gmail.com> * @author David Sehnal <david.sehnal@gmail.com>
* @author Alexander Rose <alexander.rose@weirdbyte.de> * @author Alexander Rose <alexander.rose@weirdbyte.de>
...@@ -176,6 +176,7 @@ export class PluginContext { ...@@ -176,6 +176,7 @@ export class PluginContext {
readonly customStructureProperties = new CustomProperty.Registry<Structure>(); readonly customStructureProperties = new CustomProperty.Registry<Structure>();
readonly customStructureControls = new Map<string, { new(): any /* constructible react components with <action.customControl /> */ }>(); readonly customStructureControls = new Map<string, { new(): any /* constructible react components with <action.customControl /> */ }>();
readonly customImportControls = new Map<string, { new(): any /* constructible react components with <action.customControl /> */ }>();
readonly genericRepresentationControls = new Map<string, (selection: StructureHierarchyManager['selection']) => [StructureHierarchyRef[], string]>(); readonly genericRepresentationControls = new Map<string, (selection: StructureHierarchyManager['selection']) => [StructureHierarchyRef[], string]>();
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment