From 226e55b18888a90e4129f12d7230f1f82f6b76c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Thu, 13 Dec 2018 11:35:07 +0100 Subject: [PATCH] fixed ordering changing panel types, fixes issues with loading panel options --- .../dashboard/dashgrid/DashboardPanel.tsx | 39 ++++++++++--------- .../dashboard/dashgrid/VisualizationTab.tsx | 2 +- .../plugins/panel/table/column_options.html | 5 ++- public/sass/_variables.dark.scss | 2 +- public/sass/components/_form_select_box.scss | 2 +- 5 files changed, 28 insertions(+), 22 deletions(-) diff --git a/public/app/features/dashboard/dashgrid/DashboardPanel.tsx b/public/app/features/dashboard/dashgrid/DashboardPanel.tsx index 130a4f99bb0..4ae12fc24b4 100644 --- a/public/app/features/dashboard/dashgrid/DashboardPanel.tsx +++ b/public/app/features/dashboard/dashgrid/DashboardPanel.tsx @@ -43,8 +43,8 @@ export class DashboardPanel extends PureComponent { this.specialPanels['add-panel'] = this.renderAddPanel.bind(this); } - isSpecial() { - return this.specialPanels[this.props.panel.type]; + isSpecial(pluginId: string) { + return this.specialPanels[pluginId]; } renderRow() { @@ -56,38 +56,41 @@ export class DashboardPanel extends PureComponent { } onPluginTypeChanged = (plugin: PanelPlugin) => { - this.props.panel.changeType(plugin.id, this.state.angularPanel !== null); - this.loadPlugin(); + this.loadPlugin(plugin.id); }; - loadPlugin() { - if (this.isSpecial()) { + async loadPlugin(pluginId: string) { + if (this.isSpecial(pluginId)) { return; } const { panel } = this.props; // handle plugin loading & changing of plugin type - if (!this.state.plugin || this.state.plugin.id !== panel.type) { - const plugin = config.panels[panel.type] || getPanelPluginNotFound(panel.type); + if (!this.state.plugin || this.state.plugin.id !== pluginId) { + const plugin = config.panels[pluginId] || getPanelPluginNotFound(pluginId); + + // remember if this is from an angular panel + const fromAngularPanel = this.state.angularPanel != null; + + // unmount angular panel + this.cleanUpAngularPanel(); if (plugin.exports) { - this.cleanUpAngularPanel(); this.setState({ plugin: plugin }); } else { - importPluginModule(plugin.module).then(pluginExports => { - this.cleanUpAngularPanel(); - // cache plugin exports (saves a promise async cycle next time) - plugin.exports = pluginExports; - // update panel state - this.setState({ plugin: plugin }); - }); + plugin.exports = await importPluginModule(plugin.module); + this.setState({ plugin: plugin }); + } + + if (panel.type !== pluginId) { + this.props.panel.changeType(pluginId, fromAngularPanel); } } } componentDidMount() { - this.loadPlugin(); + this.loadPlugin(this.props.panel.type); } componentDidUpdate() { @@ -140,7 +143,7 @@ export class DashboardPanel extends PureComponent { const { panel, dashboard, isFullscreen, isEditing } = this.props; const { plugin, angularPanel } = this.state; - if (this.isSpecial()) { + if (this.isSpecial(panel.type)) { return this.specialPanels[panel.type](); } diff --git a/public/app/features/dashboard/dashgrid/VisualizationTab.tsx b/public/app/features/dashboard/dashgrid/VisualizationTab.tsx index f598ae5f7a0..cad204ce712 100644 --- a/public/app/features/dashboard/dashgrid/VisualizationTab.tsx +++ b/public/app/features/dashboard/dashgrid/VisualizationTab.tsx @@ -106,7 +106,7 @@ export class VisualizationTab extends PureComponent { template += `
` + - (i > 0 ? `
{{ctrl.editorTabs[${i}].title}}
` : '') + + (i > -1 ? `
{{ctrl.editorTabs[${i}].title}}
` : '') + `
diff --git a/public/app/plugins/panel/table/column_options.html b/public/app/plugins/panel/table/column_options.html index ffb6ea8e67f..d0dbd0c1e98 100644 --- a/public/app/plugins/panel/table/column_options.html +++ b/public/app/plugins/panel/table/column_options.html @@ -1,5 +1,4 @@
-

{{style.pattern || 'New rule'}}

Options
@@ -182,9 +181,13 @@ Remove Rule
+ +
+
+ diff --git a/public/sass/_variables.dark.scss b/public/sass/_variables.dark.scss index 4e756be7f59..e2c350ff220 100644 --- a/public/sass/_variables.dark.scss +++ b/public/sass/_variables.dark.scss @@ -95,7 +95,7 @@ $headings-color: darken($white, 11%); $abbr-border-color: $gray-3 !default; $text-muted: $text-color-weak; -$hr-border-color: rgba(0, 0, 0, 0.1) !default; +$hr-border-color: $dark-4; // Panel // ------------------------- diff --git a/public/sass/components/_form_select_box.scss b/public/sass/components/_form_select_box.scss index 54488ad3fff..aecc21d8176 100644 --- a/public/sass/components/_form_select_box.scss +++ b/public/sass/components/_form_select_box.scss @@ -56,7 +56,7 @@ $select-input-bg-disabled: $input-bg-disabled; background: $input-bg; box-shadow: $menu-dropdown-shadow; position: absolute; - z-index: 2; + z-index: $zindex-dropdown; min-width: 100%; }