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 db21b2a9db689..e361470662441 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 @@ -16,115 +16,9 @@ * specific language governing permissions and limitations * under the License. */ - -import React from 'react'; import { TypedRegistry } from '../models'; import { makeSingleton } from '../utils'; - -/** - * A function which returns text (or marked-up text) - * If what you want is a react component, don't use this. Use React.ComponentType instead. - */ -type ReturningDisplayable

= (props: P) => string | React.ReactElement; - -/** - * This type defines all available extensions of Superset's default UI. - * Namespace the keys here to follow the form of 'some_domain.functionality.item'. - * Take care to name your keys well, as the name describes what this extension point's role is in Superset. - * - * When defining a new option here, take care to keep any parameters to functions (or components) minimal. - * Any removal or alteration to a parameter will be considered a breaking change. - */ - -// from src/views/components/Menu, not imported since this is a separate package -interface MenuObjectChildProps { - label: string; - name?: string; - icon?: string; - index?: number; - url?: string; - isFrontendRoute?: boolean; - perm?: string | boolean; - view?: string; - disable?: boolean; -} - -export interface SwitchProps { - isEditMode: boolean; - dbFetched: any; - disableSSHTunnelingForEngine?: boolean; - useSSHTunneling: boolean; - setUseSSHTunneling: React.Dispatch>; - setDB: React.Dispatch; - isSSHTunneling: boolean; -} - -type ConfigDetailsProps = { - embeddedId: string; -}; -type RightMenuItemIconProps = { - menuChild: MenuObjectChildProps; -}; -type DatabaseDeleteRelatedExtensionProps = { - database: object; -}; -type DatasetDeleteRelatedExtensionProps = { - dataset: object; -}; - -/** - * Interface for extensions to database connections - */ -export interface DatabaseConnectionExtension { - /** - * Display title text for the extension show when creating a database connection - */ - title: string; - /** - * url or dataURI (recommended) of a logo to use in place of a title. title is fallback display if no logo is provided - */ - logo?: React.ComponentType; - /** - * Descriptive text displayed under the logo or title to provide user with more context about the configuration section - */ - description: React.ComponentType; - /** - * React component to render for display in the database connection configuration - */ - component: React.ComponentType; - /** - * Is the database extension enabled? - */ - enabled: () => boolean; - - /** - * Callbacks - */ - // TODO: we need to move the db types to superset-ui/core in order to import them correctly - onSave: (componentState: any, db: any) => any; - onEdit?: (componentState: any) => void; - onDelete?: (db: any) => void; -} - -export type Extensions = Partial<{ - 'alertsreports.header.icon': React.ComponentType; - 'embedded.documentation.configuration_details': React.ComponentType; - 'embedded.documentation.description': ReturningDisplayable; - 'embedded.documentation.url': string; - 'dashboard.nav.right': React.ComponentType; - '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; - 'ssh_tunnel.form.switch': React.ComponentType; - 'databaseconnection.extraOption': DatabaseConnectionExtension; - /* Custom components to show in the database and dataset delete modals */ - 'database.delete.related': React.ComponentType; - 'dataset.delete.related': React.ComponentType; -}>; +import { Extensions } from './types'; /** * A registry containing extensions which can alter Superset's UI at specific points defined by Superset. diff --git a/superset-frontend/packages/superset-ui-core/src/ui-overrides/index.tsx b/superset-frontend/packages/superset-ui-core/src/ui-overrides/index.tsx index 4796ae0fe322d..824c01b7a19f5 100644 --- a/superset-frontend/packages/superset-ui-core/src/ui-overrides/index.tsx +++ b/superset-frontend/packages/superset-ui-core/src/ui-overrides/index.tsx @@ -16,5 +16,5 @@ * specific language governing permissions and limitations * under the License. */ - export * from './ExtensionsRegistry'; +export * from './types'; diff --git a/superset-frontend/packages/superset-ui-core/src/ui-overrides/types.ts b/superset-frontend/packages/superset-ui-core/src/ui-overrides/types.ts new file mode 100644 index 0000000000000..df1cd3abae868 --- /dev/null +++ b/superset-frontend/packages/superset-ui-core/src/ui-overrides/types.ts @@ -0,0 +1,125 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import React from 'react'; + +/** + * A function which returns text (or marked-up text) + * If what you want is a react component, don't use this. Use React.ComponentType instead. + */ +type ReturningDisplayable

= (props: P) => string | React.ReactElement; + +/** + * This type defines all available extensions of Superset's default UI. + * Namespace the keys here to follow the form of 'some_domain.functionality.item'. + * Take care to name your keys well, as the name describes what this extension point's role is in Superset. + * + * When defining a new option here, take care to keep any parameters to functions (or components) minimal. + * Any removal or alteration to a parameter will be considered a breaking change. + */ +interface MenuObjectChildProps { + label: string; + name?: string; + icon?: string; + index?: number; + url?: string; + isFrontendRoute?: boolean; + perm?: string | boolean; + view?: string; + disable?: boolean; +} + +export interface SwitchProps { + isEditMode: boolean; + dbFetched: any; + disableSSHTunnelingForEngine?: boolean; + useSSHTunneling: boolean; + setUseSSHTunneling: React.Dispatch>; + setDB: React.Dispatch; + isSSHTunneling: boolean; +} + +type ConfigDetailsProps = { + embeddedId: string; +}; + +type RightMenuItemIconProps = { + menuChild: MenuObjectChildProps; +}; + +type DatabaseDeleteRelatedExtensionProps = { + database: object; +}; + +type DatasetDeleteRelatedExtensionProps = { + dataset: object; +}; + +/** + * Interface for extensions to database connections + */ +export interface DatabaseConnectionExtension { + /** + * Display title text for the extension show when creating a database connection + */ + title: string; + /** + * url or dataURI (recommended) of a logo to use in place of a title. title is fallback display if no logo is provided + */ + logo?: React.ComponentType; + /** + * Descriptive text displayed under the logo or title to provide user with more context about the configuration section + */ + description: React.ComponentType; + /** + * React component to render for display in the database connection configuration + */ + component: React.ComponentType; + /** + * Is the database extension enabled? + */ + enabled: () => boolean; + + /** + * Callbacks + */ + // TODO: we need to move the db types to superset-ui/core in order to import them correctly + onSave: (componentState: any, db: any) => any; + onEdit?: (componentState: any) => void; + onDelete?: (db: any) => void; +} + +export type Extensions = Partial<{ + 'alertsreports.header.icon': React.ComponentType; + 'embedded.documentation.configuration_details': React.ComponentType; + 'embedded.documentation.description': ReturningDisplayable; + 'embedded.documentation.url': string; + 'dashboard.nav.right': React.ComponentType; + '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; + 'ssh_tunnel.form.switch': React.ComponentType; + 'databaseconnection.extraOption': DatabaseConnectionExtension; + /* Custom components to show in the database and dataset delete modals */ + 'database.delete.related': React.ComponentType; + 'dataset.delete.related': React.ComponentType; +}>;