From aa97ba4509431a82922f2fa6930928093c876d6f Mon Sep 17 00:00:00 2001 From: Diego Medina Date: Thu, 1 Dec 2022 18:29:51 -0300 Subject: [PATCH] feat: root context provider extension point (#22188) --- .../src/ui-overrides/ExtensionsRegistry.ts | 1 + .../src/views/RootContextProviders.tsx | 56 ++++++++++++------- 2 files changed, 36 insertions(+), 21 deletions(-) diff --git a/superset-frontend/packages/superset-ui-core/src/ui-overrides/ExtensionsRegistry.ts b/superset-frontend/packages/superset-ui-core/src/ui-overrides/ExtensionsRegistry.ts index 2da3231ee57bb..d630525064b1c 100644 --- a/superset-frontend/packages/superset-ui-core/src/ui-overrides/ExtensionsRegistry.ts +++ b/superset-frontend/packages/superset-ui-core/src/ui-overrides/ExtensionsRegistry.ts @@ -65,6 +65,7 @@ export type Extensions = Partial<{ 'navbar.right-menu.item.icon': React.ComponentType; 'navbar.right': React.ComponentType; 'report-modal.dropdown.item.icon': React.ComponentType; + 'root.context.provider': React.ComponentType; 'welcome.message': React.ComponentType; 'welcome.banner': React.ComponentType; 'welcome.main.replacement': React.ComponentType; diff --git a/superset-frontend/src/views/RootContextProviders.tsx b/superset-frontend/src/views/RootContextProviders.tsx index f40f228bb8c13..99f620611b539 100644 --- a/superset-frontend/src/views/RootContextProviders.tsx +++ b/superset-frontend/src/views/RootContextProviders.tsx @@ -19,7 +19,7 @@ import React from 'react'; import { Route } from 'react-router-dom'; -import { ThemeProvider } from '@superset-ui/core'; +import { getExtensionsRegistry, ThemeProvider } from '@superset-ui/core'; import { Provider as ReduxProvider } from 'react-redux'; import { QueryParamProvider } from 'use-query-params'; import { DndProvider } from 'react-dnd'; @@ -33,23 +33,37 @@ import { DynamicPluginProvider } from '../components/DynamicPlugins'; const common = { ...bootstrapData.common }; -export const RootContextProviders: React.FC = ({ children }) => ( - - - - - - - - {children} - - - - - - - -); +const extensionsRegistry = getExtensionsRegistry(); + +export const RootContextProviders: React.FC = ({ children }) => { + const RootContextProviderExtension = extensionsRegistry.get( + 'root.context.provider', + ); + + return ( + + + + + + + + {RootContextProviderExtension ? ( + + {children} + + ) : ( + children + )} + + + + + + + + ); +};