Fix for pluginpanel crashing

This commit is contained in:
Alexei Stukov 2017-04-30 14:16:27 +03:00 committed by GitHub
parent eff75f27dc
commit 91dd2e6ee7
1 changed files with 5 additions and 2 deletions

View File

@ -3863,7 +3863,9 @@ class V2C_PluginCard extends BDV2.reactComponent {
constructor(props) { constructor(props) {
super(props); super(props);
let self = this; let self = this;
self.settingsPanel = self.props.plugin.getSettingsPanel(); if (typeof self.props.plugin.getSettingsPanel === "function") {
self.settingsPanel = self.props.plugin.getSettingsPanel();
}
self.onChange = self.onChange.bind(self); self.onChange = self.onChange.bind(self);
self.showSettings = self.showSettings.bind(self); self.showSettings = self.showSettings.bind(self);
self.setInitialState(); self.setInitialState();
@ -3943,7 +3945,7 @@ class V2C_PluginCard extends BDV2.reactComponent {
BDV2.react.createElement("input", { checked: this.state.checked, onChange: this.onChange, className: "ui-switch-checkbox", type: "checkbox" }), BDV2.react.createElement("input", { checked: this.state.checked, onChange: this.onChange, className: "ui-switch-checkbox", type: "checkbox" }),
BDV2.react.createElement("div", { className: "ui-switch" }) BDV2.react.createElement("div", { className: "ui-switch" })
), ),
BDV2.react.createElement( this.settingsPanel && BDV2.react.createElement(
"button", "button",
{ onClick: this.showSettings }, { onClick: this.showSettings },
"Settings" "Settings"
@ -3966,6 +3968,7 @@ class V2C_PluginCard extends BDV2.reactComponent {
} }
showSettings() { showSettings() {
if (!this.settingsPanel) return;
this.setState({ this.setState({
'settings': true 'settings': true
}); });