This is an automated email from the ASF dual-hosted git repository.

suddjian pushed a commit to branch dynamic-plugin-import
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git

commit 0b3d809e0878f518f68b338491dd3d504683dff0
Author: David Aaron Suddjian <[email protected]>
AuthorDate: Fri Jul 10 01:31:14 2020 -0700

    hack at getting dynamic plugins working with dashboards
---
 superset-frontend/src/components/DynamicPlugins/PluginContext.ts | 2 +-
 superset-frontend/src/dashboard/App.jsx                          | 5 ++++-
 superset-frontend/src/dashboard/components/Dashboard.jsx         | 6 ++++++
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/superset-frontend/src/components/DynamicPlugins/PluginContext.ts 
b/superset-frontend/src/components/DynamicPlugins/PluginContext.ts
index aa66010..9e7597a 100644
--- a/superset-frontend/src/components/DynamicPlugins/PluginContext.ts
+++ b/superset-frontend/src/components/DynamicPlugins/PluginContext.ts
@@ -15,7 +15,7 @@ export type PluginContextType = {
 };
 
 export const dummyPluginContext: PluginContextType = {
-  loading: false,
+  loading: true,
   plugins: {},
   fetchAll: () => {},
 };
diff --git a/superset-frontend/src/dashboard/App.jsx 
b/superset-frontend/src/dashboard/App.jsx
index 2deb9f6..7b84635 100644
--- a/superset-frontend/src/dashboard/App.jsx
+++ b/superset-frontend/src/dashboard/App.jsx
@@ -21,6 +21,7 @@ import React from 'react';
 import { Provider } from 'react-redux';
 import { supersetTheme, ThemeProvider } from '@superset-ui/style';
 
+import DynamicPluginProvider from 
'src/components/DynamicPlugins/DynamicPluginProvider';
 import setupApp from '../setup/setupApp';
 import setupPlugins from '../setup/setupPlugins';
 import DashboardContainer from './containers/Dashboard';
@@ -31,7 +32,9 @@ setupPlugins();
 const App = ({ store }) => (
   <Provider store={store}>
     <ThemeProvider theme={supersetTheme}>
-      <DashboardContainer />
+      <DynamicPluginProvider>
+        <DashboardContainer />
+      </DynamicPluginProvider>
     </ThemeProvider>
   </Provider>
 );
diff --git a/superset-frontend/src/dashboard/components/Dashboard.jsx 
b/superset-frontend/src/dashboard/components/Dashboard.jsx
index 33eb420..d7e9048 100644
--- a/superset-frontend/src/dashboard/components/Dashboard.jsx
+++ b/superset-frontend/src/dashboard/components/Dashboard.jsx
@@ -40,6 +40,7 @@ import { areObjectsEqual } from '../../reduxUtils';
 import '../stylesheets/index.less';
 import getLocationHash from '../util/getLocationHash';
 import isDashboardEmpty from '../util/isDashboardEmpty';
+import { PluginContext } from 'src/components/DynamicPlugins/PluginContext';
 
 const propTypes = {
   actions: PropTypes.shape({
@@ -185,6 +186,8 @@ class Dashboard extends React.PureComponent {
     return Object.values(this.props.charts);
   }
 
+  static contextType = PluginContext;
+
   applyFilters() {
     const appliedFilters = this.appliedFilters;
     const { activeFilters } = this.props;
@@ -242,6 +245,9 @@ class Dashboard extends React.PureComponent {
   }
 
   render() {
+    if (this.context.loading) {
+      return 'loading...';
+    }
     return (
       <>
         <OmniContainer logEvent={this.props.actions.logEvent} />

Reply via email to