+ ),
+}));
jest.mock(
'react-virtualized-auto-sizer',
() =>
diff --git a/superset-frontend/src/SqlLab/components/TablePreview/index.tsx b/superset-frontend/src/SqlLab/components/TablePreview/index.tsx
index fc616ca818e..eae105f3ca8 100644
--- a/superset-frontend/src/SqlLab/components/TablePreview/index.tsx
+++ b/superset-frontend/src/SqlLab/components/TablePreview/index.tsx
@@ -32,11 +32,16 @@ import {
import AutoSizer from 'react-virtualized-auto-sizer';
import { Icons } from 'src/components/Icons';
import type { SqlLabRootState } from 'src/SqlLab/types';
-import { Breadcrumb } from 'src/components/Breadcrumb';
-import Button from 'src/components/Button';
+import {
+ Alert,
+ Breadcrumb,
+ Button,
+ Card,
+ CopyToClipboard,
+ Dropdown,
+ FilterableTable,
+} from 'src/components';
import Skeleton from 'src/components/Skeleton';
-import { Dropdown } from 'src/components/Dropdown';
-import FilterableTable from 'src/components/FilterableTable';
import Tabs from 'src/components/Tabs';
import {
tableApiUtil,
@@ -45,10 +50,7 @@ import {
useTableMetadataQuery,
} from 'src/hooks/apiResources';
import { runTablePreviewQuery } from 'src/SqlLab/actions/sqlLab';
-import Alert from 'src/components/Alert';
import { Menu } from 'src/components/Menu';
-import Card from 'src/components/Card';
-import CopyToClipboard from 'src/components/CopyToClipboard';
import ResultSet from '../ResultSet';
import ShowSQL from '../ShowSQL';
diff --git a/superset-frontend/src/SqlLab/components/TemplateParamsEditor/index.tsx b/superset-frontend/src/SqlLab/components/TemplateParamsEditor/index.tsx
index 87d1f07a201..8079c8e417d 100644
--- a/superset-frontend/src/SqlLab/components/TemplateParamsEditor/index.tsx
+++ b/superset-frontend/src/SqlLab/components/TemplateParamsEditor/index.tsx
@@ -21,11 +21,9 @@ import { t, styled } from '@superset-ui/core';
import { InfoTooltipWithTrigger } from '@superset-ui/chart-controls';
import { debounce } from 'lodash';
-import Badge from 'src/components/Badge';
+import { Badge, ConfigEditor, Tooltip } from 'src/components';
import ModalTrigger from 'src/components/ModalTrigger';
-import { ConfigEditor } from 'src/components/AsyncAceEditor';
import { FAST_DEBOUNCE } from 'src/constants';
-import { Tooltip } from 'src/components/Tooltip';
import useQueryEditor from 'src/SqlLab/hooks/useQueryEditor';
const StyledConfigEditor = styled(ConfigEditor)`
diff --git a/superset-frontend/src/SqlLab/constants.ts b/superset-frontend/src/SqlLab/constants.ts
index 0b6118f1127..07d9dbaae88 100644
--- a/superset-frontend/src/SqlLab/constants.ts
+++ b/superset-frontend/src/SqlLab/constants.ts
@@ -17,9 +17,9 @@
* under the License.
*/
import { t } from '@superset-ui/core';
-import type { Type } from 'src/components/Label';
+import type { LabelType } from 'src/components';
-export const STATE_TYPE_MAP: Record = {
+export const STATE_TYPE_MAP: Record = {
offline: 'error',
failed: 'error',
pending: 'info',
diff --git a/superset-frontend/src/SqlLab/types.ts b/superset-frontend/src/SqlLab/types.ts
index 3cff1d7eb28..6438db4e562 100644
--- a/superset-frontend/src/SqlLab/types.ts
+++ b/superset-frontend/src/SqlLab/types.ts
@@ -22,8 +22,7 @@ import {
UserWithPermissionsAndRoles,
} from 'src/types/bootstrapTypes';
import { ToastType } from 'src/components/MessageToasts/types';
-import { DropdownButtonProps } from 'src/components/DropdownButton';
-import { ButtonProps } from 'src/components/Button';
+import type { ButtonProps, DropdownButtonProps } from 'src/components';
import type { TableMetaData } from 'src/hooks/apiResources';
export type QueryButtonProps = DropdownButtonProps | ButtonProps;
diff --git a/superset-frontend/src/components/Alert/Alert.stories.tsx b/superset-frontend/src/components/Alert/Alert.stories.tsx
index a57b12ab228..97241e10580 100644
--- a/superset-frontend/src/components/Alert/Alert.stories.tsx
+++ b/superset-frontend/src/components/Alert/Alert.stories.tsx
@@ -16,7 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
-import Alert, { AlertProps } from './index';
+import { Alert } from '.';
+import type { AlertProps } from './types';
type AlertType = Required>;
type AlertTypeValue = AlertType['type'];
diff --git a/superset-frontend/src/components/Alert/index.tsx b/superset-frontend/src/components/Alert/index.tsx
index bcea9467e7f..c3eb4dd343b 100644
--- a/superset-frontend/src/components/Alert/index.tsx
+++ b/superset-frontend/src/components/Alert/index.tsx
@@ -16,15 +16,10 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { PropsWithChildren } from 'react';
import { Alert as AntdAlert } from 'antd-v5';
-import { AlertProps as AntdAlertProps } from 'antd-v5/es/alert';
+import type { AlertProps } from './types';
-export type AlertProps = PropsWithChildren<
- Omit & { roomBelow?: boolean }
->;
-
-export default function Alert(props: AlertProps) {
+export const Alert = (props: AlertProps) => {
const {
type = 'info',
description,
@@ -46,4 +41,6 @@ export default function Alert(props: AlertProps) {
{...rest}
/>
);
-}
+};
+
+export type { AlertProps };
diff --git a/superset-frontend/src/components/Checkbox/Checkbox.tsx b/superset-frontend/src/components/Alert/types.ts
similarity index 72%
rename from superset-frontend/src/components/Checkbox/Checkbox.tsx
rename to superset-frontend/src/components/Alert/types.ts
index 7d3e49ded15..dcae40eb874 100644
--- a/superset-frontend/src/components/Checkbox/Checkbox.tsx
+++ b/superset-frontend/src/components/Alert/types.ts
@@ -16,12 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { Checkbox as AntCheckbox } from 'antd-v5';
-import type {
- CheckboxProps as AntCheckboxProps,
- CheckboxChangeEvent as AntCheckboxChangeEvent,
-} from 'antd-v5/es/checkbox';
+import type { PropsWithChildren } from 'react';
+import type { AlertProps as AntdAlertProps } from 'antd-v5/es/alert';
-export type CheckboxProps = AntCheckboxProps;
-export type CheckboxChangeEvent = AntCheckboxChangeEvent;
-export default AntCheckbox;
+export type AlertProps = PropsWithChildren<
+ Omit & { roomBelow?: boolean }
+>;
diff --git a/superset-frontend/src/components/AlteredSliceTag/AlteredSliceTag.stories.tsx b/superset-frontend/src/components/AlteredSliceTag/AlteredSliceTag.stories.tsx
index 3a27a0b7510..71a64885096 100644
--- a/superset-frontend/src/components/AlteredSliceTag/AlteredSliceTag.stories.tsx
+++ b/superset-frontend/src/components/AlteredSliceTag/AlteredSliceTag.stories.tsx
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-import AlteredSliceTag from '.';
+import { AlteredSliceTag } from '.';
import { defaultProps } from './AlteredSliceTagMocks';
export default {
diff --git a/superset-frontend/src/components/AlteredSliceTag/AlteredSliceTag.test.jsx b/superset-frontend/src/components/AlteredSliceTag/AlteredSliceTag.test.jsx
index bd35db103b3..267b50291ca 100644
--- a/superset-frontend/src/components/AlteredSliceTag/AlteredSliceTag.test.jsx
+++ b/superset-frontend/src/components/AlteredSliceTag/AlteredSliceTag.test.jsx
@@ -17,11 +17,12 @@
* under the License.
*/
import { render, screen, userEvent } from 'spec/helpers/testing-library';
-import AlteredSliceTag, {
+import {
+ AlteredSliceTag,
alterForComparison,
formatValueHandler,
isEqualish,
-} from 'src/components/AlteredSliceTag';
+} from '.';
import { defaultProps } from './AlteredSliceTagMocks';
const controlsMap = {
diff --git a/superset-frontend/src/components/AlteredSliceTag/AlteredSliceTagMocks.ts b/superset-frontend/src/components/AlteredSliceTag/AlteredSliceTagMocks.ts
index 6428b503b85..c307eace575 100644
--- a/superset-frontend/src/components/AlteredSliceTag/AlteredSliceTagMocks.ts
+++ b/superset-frontend/src/components/AlteredSliceTag/AlteredSliceTagMocks.ts
@@ -18,7 +18,7 @@
*/
import { QueryFormData } from '@superset-ui/core';
import { ControlPanelConfig } from '@superset-ui/chart-controls';
-import { DiffType, RowType } from './index';
+import type { DiffType, RowType } from './types';
export const defaultProps: Record> = {
origFormData: {
diff --git a/superset-frontend/src/components/AlteredSliceTag/index.tsx b/superset-frontend/src/components/AlteredSliceTag/index.tsx
index fafaddc5c07..be63b84eddb 100644
--- a/superset-frontend/src/components/AlteredSliceTag/index.tsx
+++ b/superset-frontend/src/components/AlteredSliceTag/index.tsx
@@ -19,56 +19,23 @@
import { useCallback, useEffect, useMemo, useState, FC } from 'react';
import { isEqual, isEmpty } from 'lodash';
-import { QueryFormData, t } from '@superset-ui/core';
+import { t } from '@superset-ui/core';
import { sanitizeFormData } from 'src/explore/exploreUtils/formData';
import getControlsForVizType from 'src/utils/getControlsForVizType';
-import Label from 'src/components/Label';
-import { Icons } from 'src/components/Icons';
import { safeStringify } from 'src/utils/safeStringify';
-import { Tooltip } from 'src/components/Tooltip';
+import { Icons } from 'src/components/Icons';
+import { Label } from '../Label';
+import { Tooltip } from '../Tooltip';
import ModalTrigger from '../ModalTrigger';
import TableView from '../TableView';
-
-interface AlteredSliceTagProps {
- origFormData: QueryFormData;
- currentFormData: QueryFormData;
-}
-
-export interface ControlMap {
- [key: string]: {
- label?: string;
- type?: string;
- };
-}
-
-type FilterItemType = {
- comparator?: string | string[];
- subject: string;
- operator: string;
- label?: string;
-};
-
-export type DiffItemType<
- T = FilterItemType | number | string | Record,
-> =
- | T[]
- | boolean
- | number
- | string
- | Record
- | null
- | undefined;
-
-export type DiffType = {
- before: DiffItemType;
- after: DiffItemType;
-};
-
-export type RowType = {
- before: string | number;
- after: string | number;
- control: string;
-};
+import type {
+ AlteredSliceTagProps,
+ ControlMap,
+ DiffItemType,
+ DiffType,
+ FilterItemType,
+ RowType,
+} from './types';
export const alterForComparison = (
value?: string | null | [],
@@ -151,7 +118,7 @@ export const getRowsFromDiffs = (
export const isEqualish = (val1: string, val2: string): boolean =>
isEqual(alterForComparison(val1), alterForComparison(val2));
-const AlteredSliceTag: FC = props => {
+export const AlteredSliceTag: FC = props => {
const [rows, setRows] = useState([]);
const [hasDiffs, setHasDiffs] = useState(false);
@@ -248,4 +215,4 @@ const AlteredSliceTag: FC = props => {
);
};
-export default AlteredSliceTag;
+export type { AlteredSliceTagProps };
diff --git a/superset-frontend/src/components/FormRow/FormRow.stories.tsx b/superset-frontend/src/components/AlteredSliceTag/types.ts
similarity index 51%
rename from superset-frontend/src/components/FormRow/FormRow.stories.tsx
rename to superset-frontend/src/components/AlteredSliceTag/types.ts
index babe6aee119..e1f61086088 100644
--- a/superset-frontend/src/components/FormRow/FormRow.stories.tsx
+++ b/superset-frontend/src/components/AlteredSliceTag/types.ts
@@ -16,39 +16,45 @@
* specific language governing permissions and limitations
* under the License.
*/
-import TextControl from 'src/explore/components/controls/TextControl';
-import CheckboxControl from 'src/explore/components/controls/CheckboxControl';
-import FormRow from '.';
+import type { QueryFormData } from '@superset-ui/core';
-export default {
- title: 'Components/FormRow',
+export interface AlteredSliceTagProps {
+ origFormData: QueryFormData;
+ currentFormData: QueryFormData;
+}
+
+export interface ControlMap {
+ [key: string]: {
+ label?: string;
+ type?: string;
+ };
+}
+
+export type FilterItemType = {
+ comparator?: string | string[];
+ subject: string;
+ operator: string;
+ label?: string;
};
-export const InteractiveFormRow = ({ isCheckbox, ...rest }: any) => {
- const control = isCheckbox ? (
-
- ) : (
-
- );
- return (
-
-
-
- );
+export type DiffItemType<
+ T = FilterItemType | number | string | Record,
+> =
+ | T[]
+ | boolean
+ | number
+ | string
+ | Record
+ | null
+ | undefined;
+
+export type DiffType = {
+ before: DiffItemType;
+ after: DiffItemType;
};
-InteractiveFormRow.args = {
- label: 'Label',
- tooltip: 'Tooltip',
- control: ,
- isCheckbox: false,
-};
-
-InteractiveFormRow.argTypes = {
- control: {
- defaultValue: ,
- table: {
- disable: true,
- },
- },
+export type RowType = {
+ before: string | number;
+ after: string | number;
+ control: string;
};
diff --git a/superset-frontend/src/components/AsyncAceEditor/AsyncAceEditor.stories.tsx b/superset-frontend/src/components/AsyncAceEditor/AsyncAceEditor.stories.tsx
index dbeac65054d..5f6b7679f11 100644
--- a/superset-frontend/src/components/AsyncAceEditor/AsyncAceEditor.stories.tsx
+++ b/superset-frontend/src/components/AsyncAceEditor/AsyncAceEditor.stories.tsx
@@ -24,9 +24,10 @@ import {
CssEditor,
JsonEditor,
ConfigEditor,
- AsyncAceEditorOptions,
} from '.';
+import type { AsyncAceEditorOptions } from './types';
+
type EditorType =
| 'sql'
| 'full-sql'
diff --git a/superset-frontend/src/components/AsyncAceEditor/AsyncAceEditor.test.tsx b/superset-frontend/src/components/AsyncAceEditor/AsyncAceEditor.test.tsx
index 6e377f889fd..b0170a36e7c 100644
--- a/superset-frontend/src/components/AsyncAceEditor/AsyncAceEditor.test.tsx
+++ b/superset-frontend/src/components/AsyncAceEditor/AsyncAceEditor.test.tsx
@@ -17,7 +17,8 @@
* under the License.
*/
import { render, screen, waitFor } from 'spec/helpers/testing-library';
-import AsyncAceEditor, {
+import {
+ AsyncAceEditor,
SQLEditor,
FullSQLEditor,
MarkdownEditor,
@@ -25,9 +26,9 @@ import AsyncAceEditor, {
CssEditor,
JsonEditor,
ConfigEditor,
- AceModule,
- AsyncAceEditorOptions,
-} from 'src/components/AsyncAceEditor';
+} from '.';
+
+import type { AceModule, AsyncAceEditorOptions } from './types';
const selector = '[id="ace-editor"]';
diff --git a/superset-frontend/src/components/AsyncAceEditor/Tooltip.tsx b/superset-frontend/src/components/AsyncAceEditor/Tooltip.tsx
index 13d48390fbb..e6f9d0dc8db 100644
--- a/superset-frontend/src/components/AsyncAceEditor/Tooltip.tsx
+++ b/superset-frontend/src/components/AsyncAceEditor/Tooltip.tsx
@@ -17,7 +17,7 @@
* under the License.
*/
import { renderToStaticMarkup } from 'react-dom/server';
-import { Tag } from 'src/components/Tag';
+import { Tag } from '../Tag';
type Props = {
title: string;
diff --git a/superset-frontend/src/components/AsyncAceEditor/index.tsx b/superset-frontend/src/components/AsyncAceEditor/index.tsx
index e40aa0d0077..6a86b1f94a4 100644
--- a/superset-frontend/src/components/AsyncAceEditor/index.tsx
+++ b/superset-frontend/src/components/AsyncAceEditor/index.tsx
@@ -16,58 +16,49 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { forwardRef, useEffect, ComponentType } from 'react';
+/**
+ * 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 { forwardRef, useEffect } from 'react';
-import type {
- Editor as OrigEditor,
- IEditSession,
- Position,
- TextMode as OrigTextMode,
-} from 'brace';
+import type { IEditSession, Position } from 'brace';
import type AceEditor from 'react-ace';
-import type { IAceEditorProps } from 'react-ace';
-import AsyncEsmComponent, {
- PlaceholderProps,
-} from 'src/components/AsyncEsmComponent';
import useEffectEvent from 'src/hooks/useEffectEvent';
import { useTheme, css } from '@superset-ui/core';
import { Global } from '@emotion/react';
+import { AsyncEsmComponent } from '../AsyncEsmComponent';
+import type {
+ AceCompleterKeyword,
+ AceModule,
+ AsyncAceEditorOptions,
+ AsyncAceEditorProps,
+ TextMode,
+ Editor,
+} from './types';
export { getTooltipHTML } from './Tooltip';
-export interface AceCompleterKeywordData {
- name: string;
- value: string;
- score: number;
- meta: string;
- docText?: string;
- docHTML?: string;
-}
-
-export type TextMode = OrigTextMode & { $id: string };
-
-export interface AceCompleter {
- insertMatch: (
- data?: Editor | { value: string } | string,
- options?: AceCompleterKeywordData,
- ) => void;
-}
-
-export type Editor = OrigEditor & {
- completer: AceCompleter;
- completers: AceCompleter[];
-};
-
-export interface AceCompleterKeyword extends AceCompleterKeywordData {
- completer?: AceCompleter;
-}
-
/**
* Async loaders to import brace modules. Must manually create call `import(...)`
* promises because webpack can only analyze async imports statically.
*/
-const aceModuleLoaders = {
+export const aceModuleLoaders = {
'mode/sql': () => import('brace/mode/sql'),
'mode/markdown': () => import('brace/mode/markdown'),
'mode/css': () => import('brace/mode/css'),
@@ -81,28 +72,10 @@ const aceModuleLoaders = {
'ext/searchbox': () => import('brace/ext/searchbox'),
};
-export type AceModule = keyof typeof aceModuleLoaders;
-
-export type AsyncAceEditorProps = IAceEditorProps & {
- keywords?: AceCompleterKeyword[];
-};
-
-export type AceEditorMode = 'sql';
-export type AceEditorTheme = 'textmate' | 'github';
-export type AsyncAceEditorOptions = {
- defaultMode?: AceEditorMode;
- defaultTheme?: AceEditorTheme;
- defaultTabSize?: number;
- fontFamily?: string;
- placeholder?: ComponentType<
- PlaceholderProps & Partial
- > | null;
-};
-
/**
* Get an async AceEditor with automatical loading of specified ace modules.
*/
-export default function AsyncAceEditor(
+export function AsyncAceEditor(
aceModules: AceModule[],
{
defaultMode,
@@ -408,3 +381,5 @@ export const ConfigEditor = AsyncAceEditor([
'mode/yaml',
'theme/github',
]);
+
+export type { AsyncAceEditorProps, Editor };
diff --git a/superset-frontend/src/components/AsyncAceEditor/types.ts b/superset-frontend/src/components/AsyncAceEditor/types.ts
new file mode 100644
index 00000000000..17a4210b2ba
--- /dev/null
+++ b/superset-frontend/src/components/AsyncAceEditor/types.ts
@@ -0,0 +1,68 @@
+/**
+ * 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 type { Editor as OrigEditor, TextMode as OrigTextMode } from 'brace';
+import type { ComponentType } from 'react';
+import type { IAceEditorProps } from 'react-ace';
+import type { PlaceholderProps } from '../AsyncEsmComponent/types';
+import { aceModuleLoaders } from '.';
+
+export interface AceCompleterKeywordData {
+ name: string;
+ value: string;
+ score: number;
+ meta: string;
+ docText?: string;
+ docHTML?: string;
+}
+
+export type TextMode = OrigTextMode & { $id: string };
+
+export interface AceCompleter {
+ insertMatch: (
+ data?: Editor | { value: string } | string,
+ options?: AceCompleterKeywordData,
+ ) => void;
+}
+
+export type Editor = OrigEditor & {
+ completer: AceCompleter;
+ completers: AceCompleter[];
+};
+
+export interface AceCompleterKeyword extends AceCompleterKeywordData {
+ completer?: AceCompleter;
+}
+
+export type AceModule = keyof typeof aceModuleLoaders;
+
+export type AsyncAceEditorProps = IAceEditorProps & {
+ keywords?: AceCompleterKeyword[];
+};
+
+export type AceEditorMode = 'sql';
+export type AceEditorTheme = 'textmate' | 'github';
+export type AsyncAceEditorOptions = {
+ defaultMode?: AceEditorMode;
+ defaultTheme?: AceEditorTheme;
+ defaultTabSize?: number;
+ fontFamily?: string;
+ placeholder?: ComponentType<
+ PlaceholderProps & Partial
+ > | null;
+};
diff --git a/superset-frontend/src/components/AsyncEsmComponent/AsyncEsmComponent.stories.tsx b/superset-frontend/src/components/AsyncEsmComponent/AsyncEsmComponent.stories.tsx
index de0df2d408e..0c786141e06 100644
--- a/superset-frontend/src/components/AsyncEsmComponent/AsyncEsmComponent.stories.tsx
+++ b/superset-frontend/src/components/AsyncEsmComponent/AsyncEsmComponent.stories.tsx
@@ -16,7 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
-import AsyncEsmComponent, { PlaceholderProps } from '.';
+import { AsyncEsmComponent } from '.';
+import type { PlaceholderProps } from './types';
export default {
title: 'Components/AsyncEsmComponent',
diff --git a/superset-frontend/src/components/AsyncEsmComponent/AsyncEsmComponent.test.tsx b/superset-frontend/src/components/AsyncEsmComponent/AsyncEsmComponent.test.tsx
index 9e23acf5d64..8c16c800ecc 100644
--- a/superset-frontend/src/components/AsyncEsmComponent/AsyncEsmComponent.test.tsx
+++ b/superset-frontend/src/components/AsyncEsmComponent/AsyncEsmComponent.test.tsx
@@ -17,7 +17,7 @@
* under the License.
*/
import { render, screen } from 'spec/helpers/testing-library';
-import AsyncEsmComponent from 'src/components/AsyncEsmComponent';
+import { AsyncEsmComponent } from '.';
const Placeholder = () => Loading...;
diff --git a/superset-frontend/src/components/AsyncEsmComponent/index.tsx b/superset-frontend/src/components/AsyncEsmComponent/index.tsx
index 220c513f4de..dd643a8e1a6 100644
--- a/superset-frontend/src/components/AsyncEsmComponent/index.tsx
+++ b/superset-frontend/src/components/AsyncEsmComponent/index.tsx
@@ -17,7 +17,6 @@
* under the License.
*/
import {
- CSSProperties,
useEffect,
useState,
RefObject,
@@ -28,16 +27,8 @@ import {
RefAttributes,
} from 'react';
-import Loading from '../Loading';
-
-export type PlaceholderProps = {
- showLoadingForImport?: boolean;
- width?: string | number;
- height?: string | number;
- placeholderStyle?: CSSProperties;
-} & {
- [key: string]: any;
-};
+import { Loading } from '../Loading';
+import type { PlaceholderProps } from './types';
function DefaultPlaceholder({
width,
@@ -62,7 +53,7 @@ function DefaultPlaceholder({
* Asynchronously import an ES module as a React component, render a placeholder
* first (if provided) and re-render once import is complete.
*/
-export default function AsyncEsmComponent<
+export function AsyncEsmComponent<
P = PlaceholderProps,
M = ComponentType
| { default: ComponentType
},
>(
@@ -139,3 +130,5 @@ export default function AsyncEsmComponent<
preload: typeof waitForPromise;
};
}
+
+export type { PlaceholderProps };
diff --git a/superset-frontend/src/components/AsyncEsmComponent/types.ts b/superset-frontend/src/components/AsyncEsmComponent/types.ts
new file mode 100644
index 00000000000..d00bdaa7c5e
--- /dev/null
+++ b/superset-frontend/src/components/AsyncEsmComponent/types.ts
@@ -0,0 +1,28 @@
+/**
+ * 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 type { CSSProperties } from 'react';
+
+export type PlaceholderProps = {
+ showLoadingForImport?: boolean;
+ width?: string | number;
+ height?: string | number;
+ placeholderStyle?: CSSProperties;
+} & {
+ [key: string]: any;
+};
diff --git a/superset-frontend/src/components/AuditInfo/index.tsx b/superset-frontend/src/components/AuditInfo/index.tsx
index ae594fa7d8c..75aaa5d3936 100644
--- a/superset-frontend/src/components/AuditInfo/index.tsx
+++ b/superset-frontend/src/components/AuditInfo/index.tsx
@@ -16,15 +16,10 @@
* specific language governing permissions and limitations
* under the License.
*/
-import Owner from 'src/types/Owner';
-import { Tooltip } from 'src/components/Tooltip';
import getOwnerName from 'src/utils/getOwnerName';
import { t } from '@superset-ui/core';
-
-export type ModifiedInfoProps = {
- user?: Owner;
- date: string;
-};
+import { Tooltip } from '../Tooltip';
+import type { ModifiedInfoProps } from './types';
export const ModifiedInfo = ({ user, date }: ModifiedInfoProps) => {
const dateSpan = (
@@ -44,3 +39,5 @@ export const ModifiedInfo = ({ user, date }: ModifiedInfoProps) => {
}
return dateSpan;
};
+
+export type { ModifiedInfoProps };
diff --git a/superset-frontend/src/components/AuditInfo/types.ts b/superset-frontend/src/components/AuditInfo/types.ts
new file mode 100644
index 00000000000..06166b78375
--- /dev/null
+++ b/superset-frontend/src/components/AuditInfo/types.ts
@@ -0,0 +1,24 @@
+/**
+ * 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 type Owner from 'src/types/Owner';
+
+export type ModifiedInfoProps = {
+ user?: Owner;
+ date: string;
+};
diff --git a/superset-frontend/src/components/AutoComplete/AutoComplete.stories.tsx b/superset-frontend/src/components/AutoComplete/AutoComplete.stories.tsx
index c105515e887..84c125645f4 100644
--- a/superset-frontend/src/components/AutoComplete/AutoComplete.stories.tsx
+++ b/superset-frontend/src/components/AutoComplete/AutoComplete.stories.tsx
@@ -17,10 +17,9 @@
* under the License.
*/
import { useState } from 'react';
-import { Meta, StoryObj } from '@storybook/react';
-import AutoComplete, {
- AntAutoCompleteProps,
-} from 'src/components/AutoComplete';
+import type { Meta, StoryObj } from '@storybook/react';
+import { AutoComplete } from '.';
+import type { AutoCompleteProps } from './types';
export default {
title: 'Components/AutoComplete',
@@ -244,8 +243,8 @@ const searchResult = (query: string) =>
};
});
-const AutoCompleteWithOptions = (args: AntAutoCompleteProps) => {
- const [options, setOptions] = useState([]);
+const AutoCompleteWithOptions = (args: AutoCompleteProps) => {
+ const [options, setOptions] = useState([]);
const handleSearch = (value: string) => {
setOptions(value ? searchResult(value) : []);
@@ -260,7 +259,7 @@ export const AutoCompleteStory: Story = {
style: { width: 300 },
placeholder: 'Type to search...',
},
- render: (args: AntAutoCompleteProps) => (
+ render: (args: AutoCompleteProps) => (
diff --git a/superset-frontend/src/components/AutoComplete/AutoComplete.test.tsx b/superset-frontend/src/components/AutoComplete/AutoComplete.test.tsx
index d869fd08885..93bdb3c6285 100644
--- a/superset-frontend/src/components/AutoComplete/AutoComplete.test.tsx
+++ b/superset-frontend/src/components/AutoComplete/AutoComplete.test.tsx
@@ -23,7 +23,8 @@ import {
userEvent,
waitFor,
} from 'spec/helpers/testing-library';
-import { AutoComplete, Input } from 'antd';
+import { Input } from '../Input';
+import { AutoComplete } from '.';
const searchResult = (query: string): Array<{ value: string; label: string }> =>
Array.from({ length: 3 }).map((_, idx) => ({
diff --git a/superset-frontend/src/components/AutoComplete/index.tsx b/superset-frontend/src/components/AutoComplete/index.tsx
index 67c121b5c4f..0e34ab861d0 100644
--- a/superset-frontend/src/components/AutoComplete/index.tsx
+++ b/superset-frontend/src/components/AutoComplete/index.tsx
@@ -16,10 +16,5 @@
* specific language governing permissions and limitations
* under the License.
*/
-
-import { AutoComplete } from 'antd-v5';
-import { AutoCompleteProps as AntAutoCompleteProps } from 'antd-v5/es/auto-complete';
-
-export type { AntAutoCompleteProps };
-
-export default AutoComplete;
+export { AutoComplete } from 'antd-v5';
+export type { AutoCompleteProps } from './types';
diff --git a/superset-frontend/src/components/AutoComplete/types.ts b/superset-frontend/src/components/AutoComplete/types.ts
new file mode 100644
index 00000000000..e282cdcdb3e
--- /dev/null
+++ b/superset-frontend/src/components/AutoComplete/types.ts
@@ -0,0 +1,19 @@
+/**
+ * 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.
+ */
+export type { AutoCompleteProps } from 'antd-v5/es/auto-complete';
diff --git a/superset-frontend/src/components/Avatar/Avatar.stories.tsx b/superset-frontend/src/components/Avatar/Avatar.stories.tsx
index f2ba4a5c241..5122cd8b51a 100644
--- a/superset-frontend/src/components/Avatar/Avatar.stories.tsx
+++ b/superset-frontend/src/components/Avatar/Avatar.stories.tsx
@@ -16,7 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { Avatar, AvatarProps } from '.';
+import { Avatar } from '.';
+import type { AvatarProps } from './types';
export default {
title: 'Components/Avatar',
diff --git a/superset-frontend/src/components/Avatar/Avatar.test.tsx b/superset-frontend/src/components/Avatar/Avatar.test.tsx
index 91cf1ef5e79..91fbe60d947 100644
--- a/superset-frontend/src/components/Avatar/Avatar.test.tsx
+++ b/superset-frontend/src/components/Avatar/Avatar.test.tsx
@@ -17,7 +17,7 @@
* under the License.
*/
import { render } from 'spec/helpers/testing-library';
-import { Avatar } from 'src/components/Avatar';
+import { Avatar } from '.';
test('renders with default props', async () => {
const { container } = render();
diff --git a/superset-frontend/src/components/Avatar/index.tsx b/superset-frontend/src/components/Avatar/index.tsx
index 94eb01404ae..d499c9ae2f5 100644
--- a/superset-frontend/src/components/Avatar/index.tsx
+++ b/superset-frontend/src/components/Avatar/index.tsx
@@ -18,14 +18,14 @@
*/
import { Avatar as AntdAvatar } from 'antd-v5';
-import { AvatarProps, GroupProps } from 'antd-v5/es/avatar';
+import type { AvatarProps, GroupProps as AvatarGroupProps } from './types';
export function Avatar(props: AvatarProps) {
return ;
}
-export function AvatarGroup(props: GroupProps) {
+export function AvatarGroup(props: AvatarGroupProps) {
return ;
}
-export type { AvatarProps, GroupProps };
+export type { AvatarProps, AvatarGroupProps };
diff --git a/superset-frontend/src/components/Avatar/types.ts b/superset-frontend/src/components/Avatar/types.ts
new file mode 100644
index 00000000000..d208e704438
--- /dev/null
+++ b/superset-frontend/src/components/Avatar/types.ts
@@ -0,0 +1,21 @@
+/**
+ * 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 type { AvatarProps, GroupProps } from 'antd-v5/es/avatar';
+
+export type { AvatarProps, GroupProps };
diff --git a/superset-frontend/src/components/Badge/Badge.stories.tsx b/superset-frontend/src/components/Badge/Badge.stories.tsx
index 48f25829600..9a5ff53d737 100644
--- a/superset-frontend/src/components/Badge/Badge.stories.tsx
+++ b/superset-frontend/src/components/Badge/Badge.stories.tsx
@@ -16,7 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
-import Badge, { BadgeProps } from '.';
+import { Badge } from '.';
+import type { BadgeProps } from './types';
export default {
title: 'Components/Badge',
diff --git a/superset-frontend/src/components/Badge/Badge.test.tsx b/superset-frontend/src/components/Badge/Badge.test.tsx
index cbf9bcf80eb..8f666349c7c 100644
--- a/superset-frontend/src/components/Badge/Badge.test.tsx
+++ b/superset-frontend/src/components/Badge/Badge.test.tsx
@@ -17,7 +17,7 @@
* under the License.
*/
import { render, screen } from 'spec/helpers/testing-library';
-import Badge from '.';
+import { Badge } from '.';
const mockedProps = {
count: 9,
diff --git a/superset-frontend/src/components/Badge/index.tsx b/superset-frontend/src/components/Badge/index.tsx
index 0930e3631d9..693412747ee 100644
--- a/superset-frontend/src/components/Badge/index.tsx
+++ b/superset-frontend/src/components/Badge/index.tsx
@@ -18,11 +18,9 @@
*/
import { styled } from '@superset-ui/core';
import { Badge as AntdBadge } from 'antd-v5';
-import { BadgeProps as AntdBadgeProps } from 'antd-v5/es/badge';
+import type { BadgeProps } from './types';
-export type { AntdBadgeProps as BadgeProps };
-
-const Badge = styled((props: AntdBadgeProps) => )`
+export const Badge = styled((props: BadgeProps) => )`
${({ theme, color, count }) => `
& > sup,
& > sup.antd5-badge-count {
@@ -33,4 +31,4 @@ const Badge = styled((props: AntdBadgeProps) => )`
`}
`;
-export default Badge;
+export type { BadgeProps };
diff --git a/superset-frontend/src/components/Badge/types.ts b/superset-frontend/src/components/Badge/types.ts
new file mode 100644
index 00000000000..bf4c0228d42
--- /dev/null
+++ b/superset-frontend/src/components/Badge/types.ts
@@ -0,0 +1,21 @@
+/**
+ * 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 type { BadgeProps } from 'antd-v5/es/badge';
+
+export type { BadgeProps };
diff --git a/superset-frontend/src/components/Breadcrumb/index.tsx b/superset-frontend/src/components/Breadcrumb/index.tsx
index 8f761f6330e..1b5dd15df9a 100644
--- a/superset-frontend/src/components/Breadcrumb/index.tsx
+++ b/superset-frontend/src/components/Breadcrumb/index.tsx
@@ -16,6 +16,5 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { Breadcrumb as AntdBreadcrumb } from 'antd-v5';
-
-export const Breadcrumb = AntdBreadcrumb;
+export { Breadcrumb } from 'antd-v5';
+export type { BreadcrumbProps } from './types';
diff --git a/superset-frontend/src/components/CronPicker/index.ts b/superset-frontend/src/components/Breadcrumb/types.ts
similarity index 92%
rename from superset-frontend/src/components/CronPicker/index.ts
rename to superset-frontend/src/components/Breadcrumb/types.ts
index 17838fbb2d6..fe8bd1e3baa 100644
--- a/superset-frontend/src/components/CronPicker/index.ts
+++ b/superset-frontend/src/components/Breadcrumb/types.ts
@@ -16,5 +16,4 @@
* specific language governing permissions and limitations
* under the License.
*/
-
-export * from './CronPicker';
+export type { BreadcrumbProps } from 'antd-v5/es/breadcrumb';
diff --git a/superset-frontend/src/components/Button/Button.stories.tsx b/superset-frontend/src/components/Button/Button.stories.tsx
index 84d10ad8ab5..4f3b7275cca 100644
--- a/superset-frontend/src/components/Button/Button.stories.tsx
+++ b/superset-frontend/src/components/Button/Button.stories.tsx
@@ -16,7 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
-import Button, { ButtonProps } from './index';
+import { Button } from '.';
+import type { ButtonProps } from './types';
type ButtonStyle = Pick;
type ButtonStyleValue = ButtonStyle[keyof ButtonStyle];
diff --git a/superset-frontend/src/components/Button/Button.test.tsx b/superset-frontend/src/components/Button/Button.test.tsx
index bbb72e5d454..25c41faf2d8 100644
--- a/superset-frontend/src/components/Button/Button.test.tsx
+++ b/superset-frontend/src/components/Button/Button.test.tsx
@@ -17,7 +17,7 @@
* under the License.
*/
import { fireEvent, render } from 'spec/helpers/testing-library';
-import Button from '.';
+import { Button } from '.';
import {
ButtonGallery,
SIZES as buttonSizes,
diff --git a/superset-frontend/src/components/Button/index.tsx b/superset-frontend/src/components/Button/index.tsx
index 1ee748fcb3e..4d0a0f96ab0 100644
--- a/superset-frontend/src/components/Button/index.tsx
+++ b/superset-frontend/src/components/Button/index.tsx
@@ -16,48 +16,22 @@
* specific language governing permissions and limitations
* under the License.
*/
-import {
- Children,
- ReactElement,
- ReactNode,
- Fragment,
- MouseEventHandler,
-} from 'react';
+import { Children, ReactElement, Fragment } from 'react';
import cx from 'classnames';
import { Button as AntdButton } from 'antd-v5';
import { useTheme } from '@superset-ui/core';
-import { Tooltip, TooltipProps } from 'src/components/Tooltip';
-import {
- ButtonProps as AntdButtonProps,
+import { Tooltip } from '../Tooltip';
+import type {
+ ButtonColorType,
+ ButtonProps,
+ ButtonStyle,
ButtonType,
ButtonVariantType,
- ButtonColorType,
-} from 'antd-v5/es/button';
+ OnClickHandler,
+} from './types';
-export type OnClickHandler = MouseEventHandler;
-
-export type ButtonStyle =
- | 'primary'
- | 'secondary'
- | 'tertiary'
- | 'danger'
- | 'link'
- | 'dashed';
-
-export type ButtonSize = 'default' | 'small' | 'xsmall';
-
-export type ButtonProps = Omit &
- Pick & {
- tooltip?: ReactNode;
- className?: string;
- buttonSize?: ButtonSize;
- buttonStyle?: ButtonStyle;
- cta?: boolean;
- showMarginRight?: boolean;
- };
-
-export default function Button(props: ButtonProps) {
+export function Button(props: ButtonProps) {
const {
tooltip,
placement,
@@ -189,3 +163,5 @@ export default function Button(props: ButtonProps) {
return button;
}
+
+export type { ButtonProps, OnClickHandler };
diff --git a/superset-frontend/src/components/Button/types.ts b/superset-frontend/src/components/Button/types.ts
new file mode 100644
index 00000000000..232ba31fe9d
--- /dev/null
+++ b/superset-frontend/src/components/Button/types.ts
@@ -0,0 +1,51 @@
+/**
+ * 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 type { MouseEventHandler, ReactNode } from 'react';
+import type {
+ ButtonProps as AntdButtonProps,
+ ButtonType,
+ ButtonVariantType,
+ ButtonColorType,
+} from 'antd-v5/es/button';
+import type { TooltipPlacement } from '../Tooltip/types';
+
+export type { AntdButtonProps, ButtonType, ButtonVariantType, ButtonColorType };
+
+export type OnClickHandler = MouseEventHandler;
+
+export type ButtonStyle =
+ | 'primary'
+ | 'secondary'
+ | 'tertiary'
+ | 'danger'
+ | 'link'
+ | 'dashed';
+
+export type ButtonSize = 'default' | 'small' | 'xsmall';
+
+export type ButtonProps = Omit & {
+ placement?: TooltipPlacement;
+ tooltip?: ReactNode;
+ className?: string;
+ buttonSize?: ButtonSize;
+ buttonStyle?: ButtonStyle;
+ cta?: boolean;
+ showMarginRight?: boolean;
+};
diff --git a/superset-frontend/src/components/ButtonGroup/ButtonGroup.stories.tsx b/superset-frontend/src/components/ButtonGroup/ButtonGroup.stories.tsx
index 3706eb99bd0..bdd3f07b6b3 100644
--- a/superset-frontend/src/components/ButtonGroup/ButtonGroup.stories.tsx
+++ b/superset-frontend/src/components/ButtonGroup/ButtonGroup.stories.tsx
@@ -16,9 +16,10 @@
* specific language governing permissions and limitations
* under the License.
*/
-import Button, { ButtonProps } from 'src/components/Button';
-import { STYLES, SIZES } from 'src/components/Button/Button.stories';
-import ButtonGroup from './index';
+import { Button } from '../Button';
+import type { ButtonProps } from '../Button/types';
+import { STYLES, SIZES } from '../Button/Button.stories';
+import { ButtonGroup } from '.';
export default {
title: 'Components/ButtonGroup',
diff --git a/superset-frontend/src/components/ButtonGroup/ButtonGroup.test.tsx b/superset-frontend/src/components/ButtonGroup/ButtonGroup.test.tsx
index b99b9907a78..62362eb970d 100644
--- a/superset-frontend/src/components/ButtonGroup/ButtonGroup.test.tsx
+++ b/superset-frontend/src/components/ButtonGroup/ButtonGroup.test.tsx
@@ -18,8 +18,8 @@
*/
import { render, screen } from 'spec/helpers/testing-library';
-import Button from 'src/components/Button';
-import ButtonGroup from '.';
+import { Button } from '../Button';
+import { ButtonGroup } from '.';
test('renders 1 button', () => {
render(
diff --git a/superset-frontend/src/components/ButtonGroup/index.tsx b/superset-frontend/src/components/ButtonGroup/index.tsx
index a4db7f34c18..89c373c1e2b 100644
--- a/superset-frontend/src/components/ButtonGroup/index.tsx
+++ b/superset-frontend/src/components/ButtonGroup/index.tsx
@@ -16,15 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { ReactNode } from 'react';
+import type { ButtonGroupProps } from './types';
-export interface ButtonGroupProps {
- className?: string;
- children: ReactNode;
- expand?: boolean;
-}
-
-export default function ButtonGroup(props: ButtonGroupProps) {
+export function ButtonGroup(props: ButtonGroupProps) {
const { className, children } = props;
return (
);
}
+
+export type { ButtonGroupProps };
diff --git a/superset-frontend/src/components/ButtonGroup/types.ts b/superset-frontend/src/components/ButtonGroup/types.ts
new file mode 100644
index 00000000000..e5fe9e64204
--- /dev/null
+++ b/superset-frontend/src/components/ButtonGroup/types.ts
@@ -0,0 +1,26 @@
+/**
+ * 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 type { ReactNode } from 'react';
+
+export interface ButtonGroupProps {
+ className?: string;
+ children: ReactNode;
+ expand?: boolean;
+}
diff --git a/superset-frontend/src/components/CachedLabel/CachedLabel.test.tsx b/superset-frontend/src/components/CachedLabel/CachedLabel.test.tsx
index d42bb0257f3..2e25ed99823 100644
--- a/superset-frontend/src/components/CachedLabel/CachedLabel.test.tsx
+++ b/superset-frontend/src/components/CachedLabel/CachedLabel.test.tsx
@@ -19,7 +19,8 @@
import { isValidElement } from 'react';
import { render, screen } from 'spec/helpers/testing-library';
-import CachedLabel, { CacheLabelProps } from '.';
+import { CachedLabel } from '.';
+import type { CacheLabelProps } from './types';
const defaultProps = {
onClick: () => {},
diff --git a/superset-frontend/src/components/CachedLabel/index.tsx b/superset-frontend/src/components/CachedLabel/index.tsx
index 8cd5b51f47c..b0f805ab7c0 100644
--- a/superset-frontend/src/components/CachedLabel/index.tsx
+++ b/superset-frontend/src/components/CachedLabel/index.tsx
@@ -16,21 +16,16 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { useState, MouseEventHandler, FC } from 'react';
+import { useState, FC } from 'react';
import { t } from '@superset-ui/core';
-import Label from 'src/components/Label';
-import { Tooltip } from 'src/components/Tooltip';
import { Icons } from 'src/components/Icons';
+import { Label } from '../Label';
+import { Tooltip } from '../Tooltip';
import { TooltipContent } from './TooltipContent';
+import type { CacheLabelProps } from './types';
-export interface CacheLabelProps {
- onClick?: MouseEventHandler;
- cachedTimestamp?: string;
- className?: string;
-}
-
-const CacheLabel: FC = ({
+export const CachedLabel: FC = ({
className,
onClick,
cachedTimestamp,
@@ -51,12 +46,10 @@ const CacheLabel: FC = ({
onMouseOut={() => setHovered(false)}
icon={}
>
- {/* TODO: Remove fa-icon */}
- {/* eslint-disable-next-line icons/no-fa-icons-usage */}
{t('Cached')}
);
};
-export default CacheLabel;
+export type { CacheLabelProps };
diff --git a/superset-frontend/src/components/CachedLabel/types.ts b/superset-frontend/src/components/CachedLabel/types.ts
new file mode 100644
index 00000000000..5a8b3567405
--- /dev/null
+++ b/superset-frontend/src/components/CachedLabel/types.ts
@@ -0,0 +1,26 @@
+/**
+ * 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 type { MouseEventHandler } from 'react';
+
+export interface CacheLabelProps {
+ onClick?: MouseEventHandler;
+ cachedTimestamp?: string;
+ className?: string;
+}
diff --git a/superset-frontend/src/components/Card/Card.stories.tsx b/superset-frontend/src/components/Card/Card.stories.tsx
index af3b1644c11..3009da49b92 100644
--- a/superset-frontend/src/components/Card/Card.stories.tsx
+++ b/superset-frontend/src/components/Card/Card.stories.tsx
@@ -16,7 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
-import Card, { CardProps } from '.';
+import { Card } from '.';
+import type { CardProps } from './types';
export default {
title: 'Components/Card',
diff --git a/superset-frontend/src/components/Card/Card.test.tsx b/superset-frontend/src/components/Card/Card.test.tsx
index 2c353d0924c..2254b4d3c17 100644
--- a/superset-frontend/src/components/Card/Card.test.tsx
+++ b/superset-frontend/src/components/Card/Card.test.tsx
@@ -17,7 +17,7 @@
* under the License.
*/
import { render, waitFor } from 'spec/helpers/testing-library';
-import Card from '.';
+import { Card } from '.';
afterEach(async () => {
// Wait for any pending effects to complete
diff --git a/superset-frontend/src/components/Card/index.tsx b/superset-frontend/src/components/Card/index.tsx
index 2afdf04a230..2c872ca342d 100644
--- a/superset-frontend/src/components/Card/index.tsx
+++ b/superset-frontend/src/components/Card/index.tsx
@@ -18,13 +18,9 @@
*/
import { SupersetTheme } from '@superset-ui/core';
import { Card as AntdCard } from 'antd-v5';
-import { CardProps as AntdCardProps } from 'antd-v5/es/card';
+import type { CardProps } from './types';
-export interface CardProps extends AntdCardProps {
- padded?: boolean;
-}
-
-const Card = ({ padded, ...props }: CardProps) => (
+const CustomCard = ({ padded, ...props }: CardProps) => (
({
@@ -35,6 +31,6 @@ const Card = ({ padded, ...props }: CardProps) => (
/>
);
-export default Object.assign(Card, {
+export const Card = Object.assign(CustomCard, {
Meta: AntdCard.Meta,
});
diff --git a/superset-frontend/src/components/Card/types.ts b/superset-frontend/src/components/Card/types.ts
new file mode 100644
index 00000000000..8e7f0512469
--- /dev/null
+++ b/superset-frontend/src/components/Card/types.ts
@@ -0,0 +1,23 @@
+/**
+ * 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 type { CardProps as AntdCardProps } from 'antd-v5/es/card';
+
+export interface CardProps extends AntdCardProps {
+ padded?: boolean;
+}
diff --git a/superset-frontend/src/components/CertifiedBadge/CertifiedBadge.stories.tsx b/superset-frontend/src/components/CertifiedBadge/CertifiedBadge.stories.tsx
index 01883e3c33b..92df41a4690 100644
--- a/superset-frontend/src/components/CertifiedBadge/CertifiedBadge.stories.tsx
+++ b/superset-frontend/src/components/CertifiedBadge/CertifiedBadge.stories.tsx
@@ -17,7 +17,8 @@
* under the License.
*/
import { configure as configureTranslation } from '@superset-ui/core';
-import CertifiedBadge, { CertifiedBadgeProps } from '.';
+import { CertifiedBadge } from '.';
+import type { CertifiedBadgeProps } from './types';
configureTranslation();
diff --git a/superset-frontend/src/components/CertifiedBadge/CertifiedBadge.test.tsx b/superset-frontend/src/components/CertifiedBadge/CertifiedBadge.test.tsx
index 39612e66760..b67c0eca446 100644
--- a/superset-frontend/src/components/CertifiedBadge/CertifiedBadge.test.tsx
+++ b/superset-frontend/src/components/CertifiedBadge/CertifiedBadge.test.tsx
@@ -22,9 +22,8 @@ import {
userEvent,
waitFor,
} from 'spec/helpers/testing-library';
-import CertifiedBadge, {
- CertifiedBadgeProps,
-} from 'src/components/CertifiedBadge';
+import { CertifiedBadge } from '.';
+import type { CertifiedBadgeProps } from './types';
const asyncRender = (props?: CertifiedBadgeProps) =>
waitFor(() => render());
diff --git a/superset-frontend/src/components/CertifiedBadge/index.tsx b/superset-frontend/src/components/CertifiedBadge/index.tsx
index 8eb14f26469..144f924bd78 100644
--- a/superset-frontend/src/components/CertifiedBadge/index.tsx
+++ b/superset-frontend/src/components/CertifiedBadge/index.tsx
@@ -17,16 +17,11 @@
* under the License.
*/
import { t, useTheme } from '@superset-ui/core';
-import { Icons, IconType } from 'src/components/Icons';
-import { Tooltip } from 'src/components/Tooltip';
+import { Icons } from 'src/components/Icons';
+import { Tooltip } from '../Tooltip';
+import type { CertifiedBadgeProps } from './types';
-export interface CertifiedBadgeProps {
- certifiedBy?: string;
- details?: string;
- size?: IconType['iconSize'];
-}
-
-function CertifiedBadge({
+export function CertifiedBadge({
certifiedBy,
details,
size = 'l',
@@ -51,5 +46,3 @@ function CertifiedBadge({
);
}
-
-export default CertifiedBadge;
diff --git a/superset-frontend/src/components/CertifiedBadge/types.ts b/superset-frontend/src/components/CertifiedBadge/types.ts
new file mode 100644
index 00000000000..947ec0082f9
--- /dev/null
+++ b/superset-frontend/src/components/CertifiedBadge/types.ts
@@ -0,0 +1,25 @@
+/**
+ * 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 type { IconType } from 'src/components/Icons/types';
+
+export interface CertifiedBadgeProps {
+ certifiedBy?: string;
+ details?: string;
+ size?: IconType['iconSize'];
+}
diff --git a/superset-frontend/src/components/Chart/Chart.tsx b/superset-frontend/src/components/Chart/Chart.tsx
index dd618304784..c7264a449f5 100644
--- a/superset-frontend/src/components/Chart/Chart.tsx
+++ b/superset-frontend/src/components/Chart/Chart.tsx
@@ -30,9 +30,7 @@ import {
ChartDataResponse,
} from '@superset-ui/core';
import { PLACEHOLDER_DATASOURCE } from 'src/dashboard/constants';
-import Loading from 'src/components/Loading';
-import { EmptyState } from 'src/components/EmptyState';
-import ErrorBoundary from 'src/components/ErrorBoundary';
+import { EmptyState, ErrorBoundary, Loading } from 'src/components';
import { Logger, LOG_ACTIONS_RENDER_CHART } from 'src/logger/LogUtils';
import { URL_PARAMS } from 'src/constants';
import { getUrlParam } from 'src/utils/urlUtils';
diff --git a/superset-frontend/src/components/Chart/ChartContextMenu/ChartContextMenu.tsx b/superset-frontend/src/components/Chart/ChartContextMenu/ChartContextMenu.tsx
index efea8cc23f8..a1e08b3af17 100644
--- a/superset-frontend/src/components/Chart/ChartContextMenu/ChartContextMenu.tsx
+++ b/superset-frontend/src/components/Chart/ChartContextMenu/ChartContextMenu.tsx
@@ -43,7 +43,7 @@ import {
import { RootState } from 'src/dashboard/types';
import { Menu } from 'src/components/Menu';
import { usePermissions } from 'src/hooks/usePermissions';
-import { Dropdown } from 'src/components/Dropdown';
+import { Dropdown } from 'src/components';
import { updateDataMask } from 'src/dataMask/actions';
import DrillByModal from 'src/components/Chart/DrillBy/DrillByModal';
import { useVerboseMap } from 'src/hooks/apiResources/datasets';
diff --git a/superset-frontend/src/components/Chart/ChartErrorMessage.test.tsx b/superset-frontend/src/components/Chart/ChartErrorMessage.test.tsx
index 6d05a7b9df1..98c099d3266 100644
--- a/superset-frontend/src/components/Chart/ChartErrorMessage.test.tsx
+++ b/superset-frontend/src/components/Chart/ChartErrorMessage.test.tsx
@@ -22,9 +22,9 @@ import { ChartSource } from 'src/types/ChartSource';
import { useChartOwnerNames } from 'src/hooks/apiResources';
import { ResourceStatus } from 'src/hooks/apiResources/apiResources';
import { ErrorType } from '@superset-ui/core';
+import type { ErrorMessageComponentProps } from 'src/components/ErrorMessage/types';
+import { getErrorMessageComponentRegistry } from 'src/components';
import { ChartErrorMessage } from './ChartErrorMessage';
-import { ErrorMessageComponentProps } from '../ErrorMessage/types';
-import getErrorMessageComponentRegistry from '../ErrorMessage/getErrorMessageComponentRegistry';
// Mock the useChartOwnerNames hook
jest.mock('src/hooks/apiResources', () => ({
diff --git a/superset-frontend/src/components/Chart/ChartErrorMessage.tsx b/superset-frontend/src/components/Chart/ChartErrorMessage.tsx
index b6d3a851063..3a5d31d3766 100644
--- a/superset-frontend/src/components/Chart/ChartErrorMessage.tsx
+++ b/superset-frontend/src/components/Chart/ChartErrorMessage.tsx
@@ -20,7 +20,7 @@
import { ClientErrorObject, SupersetError } from '@superset-ui/core';
import { FC } from 'react';
import { useChartOwnerNames } from 'src/hooks/apiResources';
-import ErrorMessageWithStackTrace from 'src/components/ErrorMessage/ErrorMessageWithStackTrace';
+import { ErrorMessageWithStackTrace } from 'src/components';
import { ChartSource } from 'src/types/ChartSource';
export type Props = {
diff --git a/superset-frontend/src/components/Chart/ChartRenderer.jsx b/superset-frontend/src/components/Chart/ChartRenderer.jsx
index 302f98bd455..8589deb851f 100644
--- a/superset-frontend/src/components/Chart/ChartRenderer.jsx
+++ b/superset-frontend/src/components/Chart/ChartRenderer.jsx
@@ -30,7 +30,7 @@ import {
FeatureFlag,
} from '@superset-ui/core';
import { Logger, LOG_ACTIONS_RENDER_CHART } from 'src/logger/LogUtils';
-import { EmptyState } from 'src/components/EmptyState';
+import { EmptyState } from 'src/components';
import { ChartSource } from 'src/types/ChartSource';
import ChartContextMenu from './ChartContextMenu/ChartContextMenu';
diff --git a/superset-frontend/src/components/Chart/DisabledMenuItemTooltip.tsx b/superset-frontend/src/components/Chart/DisabledMenuItemTooltip.tsx
index 93fac5cb6f0..fdaa296f4df 100644
--- a/superset-frontend/src/components/Chart/DisabledMenuItemTooltip.tsx
+++ b/superset-frontend/src/components/Chart/DisabledMenuItemTooltip.tsx
@@ -20,7 +20,7 @@
import { ReactNode } from 'react';
import { css, SupersetTheme } from '@superset-ui/core';
import { Icons } from 'src/components/Icons';
-import { Tooltip } from 'src/components/Tooltip';
+import { Tooltip } from 'src/components';
export const MenuItemTooltip = ({
title,
diff --git a/superset-frontend/src/components/Chart/DrillBy/DrillByMenuItems.tsx b/superset-frontend/src/components/Chart/DrillBy/DrillByMenuItems.tsx
index 4a65f7f281c..099e7d329c8 100644
--- a/superset-frontend/src/components/Chart/DrillBy/DrillByMenuItems.tsx
+++ b/superset-frontend/src/components/Chart/DrillBy/DrillByMenuItems.tsx
@@ -46,9 +46,8 @@ import rison from 'rison';
import { debounce } from 'lodash';
import { FixedSizeList as List } from 'react-window';
import { Icons } from 'src/components/Icons';
-import { Input } from 'src/components/Input';
import { useToasts } from 'src/components/MessageToasts/withToasts';
-import Loading from 'src/components/Loading';
+import { Input, Loading } from 'src/components';
import {
cachedSupersetGet,
supersetGetCache,
diff --git a/superset-frontend/src/components/Chart/DrillBy/DrillByModal.tsx b/superset-frontend/src/components/Chart/DrillBy/DrillByModal.tsx
index bf7c6ae9ba6..67c3690dbb7 100644
--- a/superset-frontend/src/components/Chart/DrillBy/DrillByModal.tsx
+++ b/superset-frontend/src/components/Chart/DrillBy/DrillByModal.tsx
@@ -33,16 +33,20 @@ import {
} from '@superset-ui/core';
import { useDispatch, useSelector } from 'react-redux';
import { Link } from 'react-router-dom';
-import Modal from 'src/components/Modal';
-import Loading from 'src/components/Loading';
-import Button from 'src/components/Button';
+import {
+ Button,
+ Alert,
+ Modal,
+ Loading,
+ Breadcrumb,
+ Flex,
+} from 'src/components';
import { RootState } from 'src/dashboard/types';
import { DashboardPageIdContext } from 'src/dashboard/containers/DashboardPage';
import { postFormData } from 'src/explore/exploreUtils/formData';
import { simpleFilterToAdhoc } from 'src/utils/simpleFilterToAdhoc';
import { useDatasetMetadataBar } from 'src/features/datasets/metadataBar/useDatasetMetadataBar';
import { useToasts } from 'src/components/MessageToasts/withToasts';
-import Alert from 'src/components/Alert';
import { logEvent } from 'src/logger/actions';
import {
LOG_ACTIONS_DRILL_BY_BREADCRUMB_CLICKED,
@@ -52,8 +56,6 @@ import {
} from 'src/logger/LogUtils';
import { findPermission } from 'src/utils/findPermission';
import { getQuerySettings } from 'src/explore/exploreUtils';
-import { Breadcrumb } from 'src/components/Breadcrumb';
-import { Flex } from 'src/components/Flex';
import { Dataset, DrillByType } from '../types';
import DrillByChart from './DrillByChart';
import { ContextMenuItem } from '../ChartContextMenu/ChartContextMenu';
diff --git a/superset-frontend/src/components/Chart/DrillDetail/DrillDetailMenuItems.test.tsx b/superset-frontend/src/components/Chart/DrillDetail/DrillDetailMenuItems.test.tsx
index f9b474d4316..9e720d6cc85 100644
--- a/superset-frontend/src/components/Chart/DrillDetail/DrillDetailMenuItems.test.tsx
+++ b/superset-frontend/src/components/Chart/DrillDetail/DrillDetailMenuItems.test.tsx
@@ -144,12 +144,13 @@ const setupMenu = (filters: BinaryQueryObjectFilterClause[]) => {
* Drill to Detail modal should appear with correct initial filters
*/
const expectDrillToDetailModal = async (
- buttonName: string,
+ buttonName: string | null,
filters: BinaryQueryObjectFilterClause[] = [],
) => {
- const button = screen.getByRole('menuitem', { name: buttonName });
-
- userEvent.click(button);
+ if (buttonName) {
+ const button = screen.getByRole('menuitem', { name: buttonName });
+ userEvent.click(button);
+ }
const modal = await screen.findByRole('dialog', {
name: `Drill to detail: ${chartName}`,
});
@@ -282,15 +283,14 @@ const expectDrillToDetailByAll = async (
'drill-to-detail-by-submenu',
);
- const menuItemName = 'Drill to detail by all';
const drillToDetailBySubmenuItem = await within(
drillToDetailBySubMenus[1],
- ).findByRole('menuitem', {
- name: /Drill to detail by\s*all/i,
- });
+ ).findByText(/all/i);
await expectMenuItemEnabled(drillToDetailBySubmenuItem);
- await expectDrillToDetailModal(menuItemName, filters);
+
+ userEvent.click(drillToDetailBySubmenuItem);
+ await expectDrillToDetailModal(null, filters);
};
beforeAll(() => {
@@ -398,7 +398,7 @@ test('context menu for supported chart, dimensions, filter B', async () => {
await expectDrillToDetailByDimension(filterB);
});
-test.skip('context menu for supported chart, dimensions, all filters', async () => {
+test('context menu for supported chart, dimensions, all filters', async () => {
const filters = [filterA, filterB];
setupMenu(filters);
await expectDrillToDetailByAll(filters);
diff --git a/superset-frontend/src/components/Chart/DrillDetail/DrillDetailModal.tsx b/superset-frontend/src/components/Chart/DrillDetail/DrillDetailModal.tsx
index 240acdc45c6..5535a9551b3 100644
--- a/superset-frontend/src/components/Chart/DrillDetail/DrillDetailModal.tsx
+++ b/superset-frontend/src/components/Chart/DrillDetail/DrillDetailModal.tsx
@@ -26,8 +26,7 @@ import {
t,
useTheme,
} from '@superset-ui/core';
-import Modal from 'src/components/Modal';
-import Button from 'src/components/Button';
+import { Button, Modal } from 'src/components';
import { useSelector } from 'react-redux';
import { DashboardPageIdContext } from 'src/dashboard/containers/DashboardPage';
import { Slice } from 'src/types/Chart';
diff --git a/superset-frontend/src/components/Chart/DrillDetail/DrillDetailPane.tsx b/superset-frontend/src/components/Chart/DrillDetail/DrillDetailPane.tsx
index c26edd1a332..191423f805f 100644
--- a/superset-frontend/src/components/Chart/DrillDetail/DrillDetailPane.tsx
+++ b/superset-frontend/src/components/Chart/DrillDetail/DrillDetailPane.tsx
@@ -37,11 +37,10 @@ import {
useTheme,
} from '@superset-ui/core';
import { useResizeDetector } from 'react-resize-detector';
-import Loading from 'src/components/Loading';
import BooleanCell from 'src/components/Table/cell-renderers/BooleanCell';
import NullCell from 'src/components/Table/cell-renderers/NullCell';
import TimeCell from 'src/components/Table/cell-renderers/TimeCell';
-import { EmptyState } from 'src/components/EmptyState';
+import { EmptyState, Loading } from 'src/components';
import { getDatasourceSamples } from 'src/components/Chart/chartAction';
import Table, { ColumnsType, TableSize } from 'src/components/Table';
import HeaderWithRadioGroup from 'src/components/Table/header-renderers/HeaderWithRadioGroup';
diff --git a/superset-frontend/src/components/Chart/MenuItemWithTruncation.tsx b/superset-frontend/src/components/Chart/MenuItemWithTruncation.tsx
index cf77427cc77..d9fda901474 100644
--- a/superset-frontend/src/components/Chart/MenuItemWithTruncation.tsx
+++ b/superset-frontend/src/components/Chart/MenuItemWithTruncation.tsx
@@ -20,7 +20,7 @@
import { ReactNode, CSSProperties } from 'react';
import { css, truncationCSS, useCSSTextTruncation } from '@superset-ui/core';
import { Menu } from 'src/components/Menu';
-import { Tooltip } from 'src/components/Tooltip';
+import { Tooltip } from 'src/components';
import { MenuItemProps } from 'antd-v5';
export type MenuItemWithTruncationProps = {
diff --git a/superset-frontend/src/components/Checkbox/Checkbox.stories.tsx b/superset-frontend/src/components/Checkbox/Checkbox.stories.tsx
index b222fab6368..afa3c211555 100644
--- a/superset-frontend/src/components/Checkbox/Checkbox.stories.tsx
+++ b/superset-frontend/src/components/Checkbox/Checkbox.stories.tsx
@@ -18,8 +18,8 @@
*/
import { useArgs } from '@storybook/preview-api';
import { useState } from 'react';
-import type { CheckboxChangeEvent } from 'antd/es/checkbox';
-import Checkbox, { CheckboxProps } from '.';
+import { Checkbox } from '.';
+import type { CheckboxProps, CheckboxChangeEvent } from './types';
export default {
title: 'Components/Checkbox',
diff --git a/superset-frontend/src/components/Checkbox/Checkbox.test.tsx b/superset-frontend/src/components/Checkbox/Checkbox.test.tsx
index 56301e51eb1..b53e6da30a6 100644
--- a/superset-frontend/src/components/Checkbox/Checkbox.test.tsx
+++ b/superset-frontend/src/components/Checkbox/Checkbox.test.tsx
@@ -22,7 +22,8 @@ import {
userEvent,
waitFor,
} from 'spec/helpers/testing-library';
-import Checkbox, { CheckboxProps } from '.';
+import { Checkbox } from '.';
+import type { CheckboxProps } from './types';
const mockedProps: CheckboxProps = {
checked: false,
diff --git a/superset-frontend/src/components/Checkbox/index.tsx b/superset-frontend/src/components/Checkbox/index.tsx
index 9245065eda5..3be0ba89701 100644
--- a/superset-frontend/src/components/Checkbox/index.tsx
+++ b/superset-frontend/src/components/Checkbox/index.tsx
@@ -16,9 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-export { default } from 'src/components/Checkbox/Checkbox';
-export type {
- CheckboxProps,
- CheckboxChangeEvent,
-} from 'src/components/Checkbox/Checkbox';
-export * from 'src/components/Checkbox/CheckboxIcons';
+import { Checkbox } from 'antd-v5';
+
+export { Checkbox };
+export type { CheckboxProps, CheckboxChangeEvent } from './types';
diff --git a/superset-frontend/src/components/Checkbox/types.ts b/superset-frontend/src/components/Checkbox/types.ts
new file mode 100644
index 00000000000..1bf479e151e
--- /dev/null
+++ b/superset-frontend/src/components/Checkbox/types.ts
@@ -0,0 +1,19 @@
+/**
+ * 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.
+ */
+export type { CheckboxProps, CheckboxChangeEvent } from 'antd-v5/es/checkbox';
diff --git a/superset-frontend/src/components/Collapse/Collapse.stories.tsx b/superset-frontend/src/components/Collapse/Collapse.stories.tsx
index 10186da8e4f..c3ae01a5a31 100644
--- a/superset-frontend/src/components/Collapse/Collapse.stories.tsx
+++ b/superset-frontend/src/components/Collapse/Collapse.stories.tsx
@@ -16,7 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
-import Collapse, { CollapseProps } from '.';
+import { Collapse } from '.';
+import type { CollapseProps } from './types';
export default {
title: 'Components/Collapse',
diff --git a/superset-frontend/src/components/Collapse/Collapse.test.tsx b/superset-frontend/src/components/Collapse/Collapse.test.tsx
index 80f0687ae44..4e9f74fe0cd 100644
--- a/superset-frontend/src/components/Collapse/Collapse.test.tsx
+++ b/superset-frontend/src/components/Collapse/Collapse.test.tsx
@@ -18,7 +18,8 @@
*/
import { render, screen } from 'spec/helpers/testing-library';
import userEvent from '@testing-library/user-event';
-import Collapse, { CollapseProps } from '.';
+import { Collapse } from '.';
+import type { CollapseProps } from './types';
function renderCollapse(props?: CollapseProps) {
return render(
diff --git a/superset-frontend/src/components/Collapse/index.tsx b/superset-frontend/src/components/Collapse/index.tsx
index c8e2b16b0e6..faf1eda5ecc 100644
--- a/superset-frontend/src/components/Collapse/index.tsx
+++ b/superset-frontend/src/components/Collapse/index.tsx
@@ -17,16 +17,12 @@
* under the License.
*/
import { styled } from '@superset-ui/core';
-import {
- Collapse as AntdCollapse,
- CollapseProps as AntdCollapseProps,
-} from 'antd-v5';
+import { Collapse as AntdCollapse } from 'antd-v5';
+import type { CollapseProps } from './types';
-export interface CollapseProps extends AntdCollapseProps {
- animateArrows?: boolean;
-}
-
-const Collapse = styled((props: CollapseProps) => )`
+export const Collapse = styled((props: CollapseProps) => (
+
+))`
.antd5-collapse-item {
.antd5-collapse-header {
.antd5-collapse-arrow svg {
@@ -80,4 +76,4 @@ const Collapse = styled((props: CollapseProps) => )`
}
`;
-export default Collapse;
+export type { CollapseProps };
diff --git a/superset-frontend/src/components/Collapse/types.ts b/superset-frontend/src/components/Collapse/types.ts
new file mode 100644
index 00000000000..54731170f55
--- /dev/null
+++ b/superset-frontend/src/components/Collapse/types.ts
@@ -0,0 +1,23 @@
+/**
+ * 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 type { CollapseProps as AntdCollapseProps } from 'antd-v5';
+
+export interface CollapseProps extends AntdCollapseProps {
+ animateArrows?: boolean;
+}
diff --git a/superset-frontend/src/components/ConfirmStatusChange/ConfirmStatusChange.stories.tsx b/superset-frontend/src/components/ConfirmStatusChange/ConfirmStatusChange.stories.tsx
index fbe3ecf87a0..132cea64c88 100644
--- a/superset-frontend/src/components/ConfirmStatusChange/ConfirmStatusChange.stories.tsx
+++ b/superset-frontend/src/components/ConfirmStatusChange/ConfirmStatusChange.stories.tsx
@@ -16,8 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
-import Button from 'src/components/Button';
-import ConfirmStatusChange, { ConfirmStatusChangeProps, Callback } from '.';
+import { Button } from 'src/components';
+import { ConfirmStatusChange } from '.';
+import type { ConfirmStatusChangeProps, Callback } from './types';
export default {
title: 'Components/ConfirmStatusChange',
diff --git a/superset-frontend/src/components/ConfirmStatusChange/ConfirmStatusChange.test.jsx b/superset-frontend/src/components/ConfirmStatusChange/ConfirmStatusChange.test.jsx
index bb8da13af16..2138a61d84f 100644
--- a/superset-frontend/src/components/ConfirmStatusChange/ConfirmStatusChange.test.jsx
+++ b/superset-frontend/src/components/ConfirmStatusChange/ConfirmStatusChange.test.jsx
@@ -17,8 +17,8 @@
* under the License.
*/
import { fireEvent, render, waitFor } from 'spec/helpers/testing-library';
-import Button from 'src/components/Button';
-import ConfirmStatusChange from 'src/components/ConfirmStatusChange';
+import { Button } from '../Button';
+import { ConfirmStatusChange } from '.';
const mockedProps = {
title: 'please confirm',
diff --git a/superset-frontend/src/components/ConfirmStatusChange/index.tsx b/superset-frontend/src/components/ConfirmStatusChange/index.tsx
index fe795065c70..ff2ba0cf63d 100644
--- a/superset-frontend/src/components/ConfirmStatusChange/index.tsx
+++ b/superset-frontend/src/components/ConfirmStatusChange/index.tsx
@@ -16,20 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { useState, ReactNode } from 'react';
+import { useState } from 'react';
-import DeleteModal from 'src/components/DeleteModal';
+import { DeleteModal } from '../DeleteModal';
+import type { ConfirmStatusChangeProps } from './types';
-export type Callback = (...args: any[]) => void;
-
-export interface ConfirmStatusChangeProps {
- title: ReactNode;
- description: ReactNode;
- onConfirm: Callback;
- children: (showConfirm: Callback) => ReactNode;
-}
-
-export default function ConfirmStatusChange({
+export function ConfirmStatusChange({
title,
description,
onConfirm,
@@ -81,3 +73,5 @@ export default function ConfirmStatusChange({
>
);
}
+
+export type { ConfirmStatusChangeProps };
diff --git a/superset-frontend/src/components/ConfirmStatusChange/types.ts b/superset-frontend/src/components/ConfirmStatusChange/types.ts
new file mode 100644
index 00000000000..cd80743220d
--- /dev/null
+++ b/superset-frontend/src/components/ConfirmStatusChange/types.ts
@@ -0,0 +1,28 @@
+/**
+ * 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 type { ReactNode } from 'react';
+
+export type Callback = (...args: any[]) => void;
+
+export interface ConfirmStatusChangeProps {
+ title: ReactNode;
+ description: ReactNode;
+ onConfirm: Callback;
+ children: (showConfirm: Callback) => ReactNode;
+}
diff --git a/superset-frontend/src/components/CopyToClipboard/CopyToClipboard.stories.tsx b/superset-frontend/src/components/CopyToClipboard/CopyToClipboard.stories.tsx
index 268427ad5d4..c725ce032df 100644
--- a/superset-frontend/src/components/CopyToClipboard/CopyToClipboard.stories.tsx
+++ b/superset-frontend/src/components/CopyToClipboard/CopyToClipboard.stories.tsx
@@ -16,10 +16,10 @@
* specific language governing permissions and limitations
* under the License.
*/
-import Button from 'src/components/Button';
import { Icons } from 'src/components/Icons';
import ToastContainer from 'src/components/MessageToasts/ToastContainer';
-import CopyToClipboard from '.';
+import { Button } from '../Button';
+import { CopyToClipboard } from '.';
export default {
title: 'Components/CopyToClipboard',
diff --git a/superset-frontend/src/components/CopyToClipboard/CopyToClipboard.test.tsx b/superset-frontend/src/components/CopyToClipboard/CopyToClipboard.test.tsx
index 7d1542d669b..4164cb45459 100644
--- a/superset-frontend/src/components/CopyToClipboard/CopyToClipboard.test.tsx
+++ b/superset-frontend/src/components/CopyToClipboard/CopyToClipboard.test.tsx
@@ -22,7 +22,7 @@ import {
userEvent,
waitFor,
} from 'spec/helpers/testing-library';
-import CopyToClipboard from '.';
+import { CopyToClipboard } from '.';
test('renders with default props', () => {
const text = 'Text';
diff --git a/superset-frontend/src/components/CopyToClipboard/index.tsx b/superset-frontend/src/components/CopyToClipboard/index.tsx
index 10f2f750049..06a0d934a45 100644
--- a/superset-frontend/src/components/CopyToClipboard/index.tsx
+++ b/superset-frontend/src/components/CopyToClipboard/index.tsx
@@ -16,24 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { Component, cloneElement, ReactNode, ReactElement } from 'react';
+import { Component, cloneElement, ReactElement } from 'react';
import { t } from '@superset-ui/core';
-import { Tooltip } from 'src/components/Tooltip';
-import withToasts from 'src/components/MessageToasts/withToasts';
import copyTextToClipboard from 'src/utils/copy';
-
-export interface CopyToClipboardProps {
- copyNode?: ReactNode;
- getText?: (callback: (data: string) => void) => void;
- onCopyEnd?: () => void;
- shouldShowText?: boolean;
- text?: string;
- wrapped?: boolean;
- tooltipText?: string;
- addDangerToast: (msg: string) => void;
- addSuccessToast: (msg: string) => void;
- hideTooltip?: boolean;
-}
+import withToasts from '../MessageToasts/withToasts';
+import { Tooltip } from '../Tooltip';
+import type { CopyToClipboardProps } from './types';
const defaultProps: Partial = {
copyNode: {t('Copy')},
@@ -44,7 +32,7 @@ const defaultProps: Partial = {
hideTooltip: false,
};
-class CopyToClipboard extends Component {
+class CopyToClip extends Component {
static defaultProps = defaultProps;
constructor(props: CopyToClipboardProps) {
@@ -134,4 +122,5 @@ class CopyToClipboard extends Component {
}
}
-export default withToasts(CopyToClipboard);
+export const CopyToClipboard = withToasts(CopyToClip);
+export type { CopyToClipboardProps };
diff --git a/superset-frontend/src/components/CopyToClipboard/types.ts b/superset-frontend/src/components/CopyToClipboard/types.ts
new file mode 100644
index 00000000000..10d87e8decf
--- /dev/null
+++ b/superset-frontend/src/components/CopyToClipboard/types.ts
@@ -0,0 +1,32 @@
+/**
+ * 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 type { ReactNode } from 'react';
+
+export interface CopyToClipboardProps {
+ copyNode?: ReactNode;
+ getText?: (callback: (data: string) => void) => void;
+ onCopyEnd?: () => void;
+ shouldShowText?: boolean;
+ text?: string;
+ wrapped?: boolean;
+ tooltipText?: string;
+ addDangerToast: (msg: string) => void;
+ addSuccessToast: (msg: string) => void;
+ hideTooltip?: boolean;
+}
diff --git a/superset-frontend/src/components/CronPicker/CronPicker.stories.tsx b/superset-frontend/src/components/CronPicker/CronPicker.stories.tsx
index de5373e52ca..1bc2748f939 100644
--- a/superset-frontend/src/components/CronPicker/CronPicker.stories.tsx
+++ b/superset-frontend/src/components/CronPicker/CronPicker.stories.tsx
@@ -17,9 +17,10 @@
* under the License.
*/
import { useState, useRef, useCallback } from 'react';
-import { Divider } from 'src/components/Divider';
-import { Input } from 'src/components/Input';
-import { CronPicker, CronError, CronProps } from '.';
+import { Divider } from '../Divider';
+import { Input } from '../Input';
+import { CronPicker } from '.';
+import type { CronError, CronProps } from './types';
export default {
title: 'Components/CronPicker',
diff --git a/superset-frontend/src/components/CronPicker/CronPicker.test.tsx b/superset-frontend/src/components/CronPicker/CronPicker.test.tsx
index 48203a2dc88..cbe8ae37dd1 100644
--- a/superset-frontend/src/components/CronPicker/CronPicker.test.tsx
+++ b/superset-frontend/src/components/CronPicker/CronPicker.test.tsx
@@ -19,7 +19,7 @@
import { render } from 'spec/helpers/testing-library';
import * as ReactCronPicker from 'react-js-cron';
-import { CronPicker } from './CronPicker';
+import { CronPicker } from '.';
const spy = jest.spyOn(ReactCronPicker, 'default');
diff --git a/superset-frontend/src/components/CronPicker/CronPicker.tsx b/superset-frontend/src/components/CronPicker/index.tsx
similarity index 97%
rename from superset-frontend/src/components/CronPicker/CronPicker.tsx
rename to superset-frontend/src/components/CronPicker/index.tsx
index 927f31661d7..abbddaf9b3d 100644
--- a/superset-frontend/src/components/CronPicker/CronPicker.tsx
+++ b/superset-frontend/src/components/CronPicker/index.tsx
@@ -17,9 +17,8 @@
* under the License.
*/
import { styled, t } from '@superset-ui/core';
-import ReactCronPicker, { Locale, CronProps } from 'react-js-cron';
-
-export * from 'react-js-cron';
+import ReactCronPicker from 'react-js-cron';
+import type { Locale, CronProps } from './types';
export const LOCALE: Locale = {
everyText: t('every'),
@@ -200,3 +199,5 @@ export const CronPicker = styled((props: CronProps) => (
}
`}
`;
+
+export type { CronError } from './types';
diff --git a/superset-frontend/src/components/CronPicker/types.ts b/superset-frontend/src/components/CronPicker/types.ts
new file mode 100644
index 00000000000..ca2dba02624
--- /dev/null
+++ b/superset-frontend/src/components/CronPicker/types.ts
@@ -0,0 +1,20 @@
+/**
+ * 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.
+ */
+
+export type { Locale, CronError, CronProps } from 'react-js-cron';
diff --git a/superset-frontend/src/components/DatabaseSelector/DatabaseSelector.test.tsx b/superset-frontend/src/components/DatabaseSelector/DatabaseSelector.test.tsx
index 6aa7a766188..aff12b547b3 100644
--- a/superset-frontend/src/components/DatabaseSelector/DatabaseSelector.test.tsx
+++ b/superset-frontend/src/components/DatabaseSelector/DatabaseSelector.test.tsx
@@ -27,8 +27,9 @@ import {
waitFor,
} from 'spec/helpers/testing-library';
import { api } from 'src/hooks/apiResources/queryApi';
-import DatabaseSelector, { DatabaseSelectorProps } from '.';
import { EmptyState } from '../EmptyState';
+import { DatabaseSelector } from '.';
+import type { DatabaseSelectorProps } from './types';
const createProps = (): DatabaseSelectorProps => ({
db: {
diff --git a/superset-frontend/src/components/DatabaseSelector/index.tsx b/superset-frontend/src/components/DatabaseSelector/index.tsx
index 628587fc23a..1399b8e91a1 100644
--- a/superset-frontend/src/components/DatabaseSelector/index.tsx
+++ b/superset-frontend/src/components/DatabaseSelector/index.tsx
@@ -25,12 +25,7 @@ import {
useCallback,
} from 'react';
import { styled, SupersetClient, SupersetError, t } from '@superset-ui/core';
-import type { LabeledValue as AntdLabeledValue } from 'src/components/Select';
import rison from 'rison';
-import { Select, AsyncSelect } from 'src/components';
-import ErrorMessageWithStackTrace from 'src/components/ErrorMessage/ErrorMessageWithStackTrace';
-import Label from 'src/components/Label';
-import { FormLabel } from 'src/components/Form';
import RefreshLabel from 'src/components/RefreshLabel';
import { useToasts } from 'src/components/MessageToasts/withToasts';
import {
@@ -39,6 +34,17 @@ import {
useSchemas,
SchemaOption,
} from 'src/hooks/apiResources';
+import { Label } from '../Label';
+import { Select, AsyncSelect } from '../Select';
+import { FormLabel } from '../Form';
+import { ErrorMessageWithStackTrace } from '../ErrorMessage';
+
+import type { LabeledValue as AntdLabeledValue } from '../Select';
+import type {
+ DatabaseSelectorProps,
+ DatabaseValue,
+ DatabaseObject,
+} from './types';
const DatabaseSelectorWrapper = styled.div`
${({ theme }) => `
@@ -83,38 +89,6 @@ const LabelStyle = styled.div`
}
`;
-type DatabaseValue = {
- label: ReactNode;
- value: number;
- id: number;
- database_name: string;
- backend?: string;
-};
-
-export type DatabaseObject = {
- id: number;
- database_name: string;
- backend?: string;
- allow_multi_catalog?: boolean;
-};
-
-export interface DatabaseSelectorProps {
- db?: DatabaseObject | null;
- emptyState?: ReactNode;
- formMode?: boolean;
- getDbList?: (arg0: any) => void;
- handleError: (msg: string) => void;
- isDatabaseSelectEnabled?: boolean;
- onDbChange?: (db: DatabaseObject) => void;
- onEmptyResults?: (searchText?: string) => void;
- onCatalogChange?: (catalog?: string) => void;
- catalog?: string | null;
- onSchemaChange?: (schema?: string) => void;
- schema?: string;
- readOnly?: boolean;
- sqlLabMode?: boolean;
-}
-
const SelectLabel = ({
backend,
databaseName,
@@ -137,7 +111,7 @@ interface AntdLabeledValueWithOrder extends AntdLabeledValue {
order: number;
}
-export default function DatabaseSelector({
+export function DatabaseSelector({
db,
formMode = false,
emptyState,
@@ -454,3 +428,5 @@ export default function DatabaseSelector({
);
}
+
+export type { DatabaseObject };
diff --git a/superset-frontend/src/components/DatabaseSelector/types.ts b/superset-frontend/src/components/DatabaseSelector/types.ts
new file mode 100644
index 00000000000..7130a8da1d6
--- /dev/null
+++ b/superset-frontend/src/components/DatabaseSelector/types.ts
@@ -0,0 +1,51 @@
+/**
+ * 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 type { ReactNode } from 'react';
+
+export type DatabaseValue = {
+ label: ReactNode;
+ value: number;
+ id: number;
+ database_name: string;
+ backend?: string;
+};
+
+export type DatabaseObject = {
+ id: number;
+ database_name: string;
+ backend?: string;
+ allow_multi_catalog?: boolean;
+};
+
+export interface DatabaseSelectorProps {
+ db?: DatabaseObject | null;
+ emptyState?: ReactNode;
+ formMode?: boolean;
+ getDbList?: (arg0: any) => void;
+ handleError: (msg: string) => void;
+ isDatabaseSelectEnabled?: boolean;
+ onDbChange?: (db: DatabaseObject) => void;
+ onEmptyResults?: (searchText?: string) => void;
+ onCatalogChange?: (catalog?: string) => void;
+ catalog?: string | null;
+ onSchemaChange?: (schema?: string) => void;
+ schema?: string;
+ readOnly?: boolean;
+ sqlLabMode?: boolean;
+}
diff --git a/superset-frontend/src/components/Datasource/ChangeDatasourceModal.test.jsx b/superset-frontend/src/components/Datasource/ChangeDatasourceModal.test.jsx
index 64a9716ef42..060f6149a12 100644
--- a/superset-frontend/src/components/Datasource/ChangeDatasourceModal.test.jsx
+++ b/superset-frontend/src/components/Datasource/ChangeDatasourceModal.test.jsx
@@ -21,8 +21,8 @@ import configureStore from 'redux-mock-store';
import fetchMock from 'fetch-mock';
import thunk from 'redux-thunk';
import sinon from 'sinon';
-import { ChangeDatasourceModal } from 'src/components/Datasource';
import mockDatasource from 'spec/fixtures/mockDatasource';
+import { ChangeDatasourceModal } from '.';
const mockStore = configureStore([thunk]);
const store = mockStore({});
diff --git a/superset-frontend/src/components/Datasource/ChangeDatasourceModal.tsx b/superset-frontend/src/components/Datasource/ChangeDatasourceModal.tsx
index 48524167321..8c0bbe1ae23 100644
--- a/superset-frontend/src/components/Datasource/ChangeDatasourceModal.tsx
+++ b/superset-frontend/src/components/Datasource/ChangeDatasourceModal.tsx
@@ -25,7 +25,6 @@ import {
ChangeEvent,
} from 'react';
-import Alert from 'src/components/Alert';
import {
SupersetClient,
t,
@@ -34,21 +33,23 @@ import {
} from '@superset-ui/core';
import TableView, { EmptyWrapperType } from 'src/components/TableView';
import { ServerPagination, SortByType } from 'src/components/TableView/types';
-import StyledModal from 'src/components/Modal';
-import Button from 'src/components/Button';
import { useListViewResource } from 'src/views/CRUD/hooks';
import Dataset from 'src/types/Dataset';
import { useDebouncedEffect } from 'src/explore/exploreUtils';
import { SLOW_DEBOUNCE } from 'src/constants';
-import Loading from 'src/components/Loading';
-import { Input } from 'src/components/Input';
import {
PAGE_SIZE as DATASET_PAGE_SIZE,
SORT_BY as DATASET_SORT_BY,
} from 'src/features/datasets/constants';
import withToasts from 'src/components/MessageToasts/withToasts';
import { InputRef } from 'antd-v5';
-import FacePile from '../FacePile';
+import { Loading } from '../Loading';
+import { Input } from '../Input';
+import { FacePile } from '../FacePile';
+import { Button } from '../Button';
+import { Alert } from '../Alert';
+import { Modal } from '../Modal';
+import type { Datasource, ChangeDatasourceModalProps } from './types';
const CONFIRM_WARNING_MESSAGE = t(
'Warning! Changing the dataset may break the chart if the metadata does not exist.',
@@ -59,22 +60,7 @@ const CHANGE_WARNING_MSG = t(
'on columns or metadata that does not exist in the target dataset',
);
-interface Datasource {
- type: string;
- id: number;
- uid: string;
-}
-
-interface ChangeDatasourceModalProps {
- addDangerToast: (msg: string) => void;
- addSuccessToast: (msg: string) => void;
- onChange: (uid: string) => void;
- onDatasourceSave: (datasource: object, errors?: Array) => {};
- onHide: () => void;
- show: boolean;
-}
-
-const CustomStyledModal = styled(StyledModal)`
+const CustomStyledModal = styled(Modal)`
.antd5-modal-body {
display: flex;
flex-direction: column;
diff --git a/superset-frontend/src/components/Datasource/CollectionTable.tsx b/superset-frontend/src/components/Datasource/CollectionTable.tsx
index 6c105fa425f..075be69a902 100644
--- a/superset-frontend/src/components/Datasource/CollectionTable.tsx
+++ b/superset-frontend/src/components/Datasource/CollectionTable.tsx
@@ -16,68 +16,23 @@
* specific language governing permissions and limitations
* under the License.
*/
-import {
- ReactNode,
- DetailedHTMLProps,
- TdHTMLAttributes,
- PureComponent,
-} from 'react';
+import { PureComponent } from 'react';
import { nanoid } from 'nanoid';
import { InfoTooltipWithTrigger } from '@superset-ui/chart-controls';
import { t, styled } from '@superset-ui/core';
-import Button from 'src/components/Button';
import { Icons } from 'src/components/Icons';
+import { Button } from '../Button';
import Fieldset from './Fieldset';
import { recurseReactClone } from './utils';
-
-interface CRUDCollectionProps {
- allowAddItem?: boolean;
- allowDeletes?: boolean;
- collection: Record[];
- columnLabels?: Record;
- columnLabelTooltips?: Record;
- emptyMessage?: ReactNode;
- expandFieldset?: ReactNode;
- extraButtons?: ReactNode;
- itemGenerator?: () => any;
- itemCellProps?: ((
- val: unknown,
- label: string,
- record: any,
- ) => DetailedHTMLProps<
- TdHTMLAttributes,
- HTMLTableCellElement
- >)[];
- itemRenderers?: ((
- val: unknown,
- onChange: () => void,
- label: string,
- record: any,
- ) => ReactNode)[];
- onChange?: (arg0: any) => void;
- tableColumns: any[];
- sortColumns: string[];
- stickyHeader?: boolean;
-}
-
-type Sort = number | string | boolean | any;
-
-enum SortOrder {
- Asc = 1,
- Desc = 2,
- Unsorted = 0,
-}
-
-interface CRUDCollectionState {
- collection: Record;
- collectionArray: Record[];
- expandedColumns: Record;
- sortColumn: string;
- sort: SortOrder;
-}
+import {
+ SortOrder,
+ type CRUDCollectionProps,
+ type CRUDCollectionState,
+ type Sort,
+} from './types';
function createCollectionArray(collection: Record) {
return Object.keys(collection).map(k => collection[k]);
diff --git a/superset-frontend/src/components/Datasource/DatasourceEditor.jsx b/superset-frontend/src/components/Datasource/DatasourceEditor.jsx
index e5c3d7d13d9..601162c50bc 100644
--- a/superset-frontend/src/components/Datasource/DatasourceEditor.jsx
+++ b/superset-frontend/src/components/Datasource/DatasourceEditor.jsx
@@ -20,9 +20,6 @@ import rison from 'rison';
import { PureComponent, useCallback } from 'react';
import PropTypes from 'prop-types';
import { Radio } from 'src/components/Radio';
-import Card from 'src/components/Card';
-import Alert from 'src/components/Alert';
-import Badge from 'src/components/Badge';
import {
css,
isFeatureEnabled,
@@ -35,25 +32,28 @@ import {
withTheme,
getClientErrorObject,
} from '@superset-ui/core';
-import { Row, Col } from 'src/components/Grid';
-import { Select, AsyncSelect } from 'src/components';
-import { FormLabel } from 'src/components/Form';
-import Button from 'src/components/Button';
import Tabs from 'src/components/Tabs';
-import CertifiedBadge from 'src/components/CertifiedBadge';
import WarningIconWithTooltip from 'src/components/WarningIconWithTooltip';
-import DatabaseSelector from 'src/components/DatabaseSelector';
-import Label from 'src/components/Label';
-import Loading from 'src/components/Loading';
import TableSelector from 'src/components/TableSelector';
-import EditableTitle from 'src/components/EditableTitle';
import CheckboxControl from 'src/explore/components/controls/CheckboxControl';
import TextControl from 'src/explore/components/controls/TextControl';
import TextAreaControl from 'src/explore/components/controls/TextAreaControl';
import SpatialControl from 'src/explore/components/controls/SpatialControl';
import withToasts from 'src/components/MessageToasts/withToasts';
-import { Icons } from 'src/components/Icons';
import CurrencyControl from 'src/explore/components/controls/CurrencyControl';
+import { Loading } from '../Loading';
+import { Alert } from '../Alert';
+import { Badge } from '../Badge';
+import { Card } from '../Card';
+import { Select, AsyncSelect } from '../Select';
+import { Button } from '../Button';
+import { CertifiedBadge } from '../CertifiedBadge';
+import { DatabaseSelector } from '../DatabaseSelector';
+import { EditableTitle } from '../EditableTitle';
+import { FormLabel } from '../Form';
+import { Row, Col } from '../Grid';
+import { Icons } from '../Icons';
+import { Label } from '../Label';
import CollectionTable from './CollectionTable';
import Fieldset from './Fieldset';
import Field from './Field';
diff --git a/superset-frontend/src/components/Datasource/DatasourceModal.test.jsx b/superset-frontend/src/components/Datasource/DatasourceModal.test.jsx
index af20f8f4ae2..23f2cb2e0c5 100644
--- a/superset-frontend/src/components/Datasource/DatasourceModal.test.jsx
+++ b/superset-frontend/src/components/Datasource/DatasourceModal.test.jsx
@@ -28,8 +28,8 @@ import {
import fetchMock from 'fetch-mock';
import sinon from 'sinon';
import { SupersetClient } from '@superset-ui/core';
-import { DatasourceModal } from 'src/components/Datasource';
import mockDatasource from 'spec/fixtures/mockDatasource';
+import { DatasourceModal } from '.';
// Define your constants here
const SAVE_ENDPOINT = 'glob:*/api/v1/dataset/7';
diff --git a/superset-frontend/src/components/Datasource/DatasourceModal.tsx b/superset-frontend/src/components/Datasource/DatasourceModal.tsx
index 7629434195a..d0367ffc2c4 100644
--- a/superset-frontend/src/components/Datasource/DatasourceModal.tsx
+++ b/superset-frontend/src/components/Datasource/DatasourceModal.tsx
@@ -18,8 +18,6 @@
*/
import { FunctionComponent, useState, useRef } from 'react';
import { useDispatch, useSelector } from 'react-redux';
-import Alert from 'src/components/Alert';
-import Button from 'src/components/Button';
import {
isDefined,
styled,
@@ -32,9 +30,6 @@ import {
} from '@superset-ui/core';
import { Icons } from 'src/components/Icons';
-import Modal from 'src/components/Modal';
-import AsyncEsmComponent from 'src/components/AsyncEsmComponent';
-import ErrorMessageWithStackTrace from 'src/components/ErrorMessage/ErrorMessageWithStackTrace';
import withToasts from 'src/components/MessageToasts/withToasts';
import {
startMetaDataLoading,
@@ -45,7 +40,13 @@ import {
fetchSyncedColumns,
updateColumns,
} from 'src/components/Datasource/utils';
-import { DatasetObject } from '../../features/datasets/types';
+import type { DatasetObject } from 'src/features/datasets/types';
+import { ErrorMessageWithStackTrace } from '../ErrorMessage';
+import { AsyncEsmComponent } from '../AsyncEsmComponent';
+import { Button } from '../Button';
+import { Alert } from '../Alert';
+import { Modal } from '../Modal';
+import type { DatasourceModalProps } from './types';
const DatasourceEditor = AsyncEsmComponent(() => import('./DatasourceEditor'));
@@ -74,16 +75,6 @@ const StyledDatasourceModal = styled(Modal)`
}
`;
-interface DatasourceModalProps {
- addSuccessToast: (msg: string) => void;
- addDangerToast: (msg: string) => void;
- datasource: DatasetObject;
- onChange: () => {};
- onDatasourceSave: (datasource: object, errors?: Array) => {};
- onHide: () => {};
- show: boolean;
-}
-
function buildExtraJsonObject(
item: DatasetObject['metrics'][0] | DatasetObject['columns'][0],
) {
diff --git a/superset-frontend/src/components/Datasource/Field.test.tsx b/superset-frontend/src/components/Datasource/Field.test.tsx
index 5a5b171d8bc..6e4a8083718 100644
--- a/superset-frontend/src/components/Datasource/Field.test.tsx
+++ b/superset-frontend/src/components/Datasource/Field.test.tsx
@@ -17,7 +17,7 @@
* under the License.
*/
import { fireEvent, render, screen } from 'spec/helpers/testing-library';
-import { Input } from 'src/components/Input';
+import { Input } from '../Input';
import Field from './Field';
diff --git a/superset-frontend/src/components/Datasource/Field.tsx b/superset-frontend/src/components/Datasource/Field.tsx
index eeebe612732..071cb5a2da9 100644
--- a/superset-frontend/src/components/Datasource/Field.tsx
+++ b/superset-frontend/src/components/Datasource/Field.tsx
@@ -19,8 +19,8 @@
import { useCallback, ReactNode, ReactElement, cloneElement } from 'react';
import { css, SupersetTheme } from '@superset-ui/core';
-import { Tooltip } from 'src/components/Tooltip';
-import { FormItem, FormLabel } from 'src/components/Form';
+import { FormItem, FormLabel } from '../Form';
+import { Tooltip } from '../Tooltip';
const formItemInlineCss = css`
.antd5-form-item-control-input-content {
diff --git a/superset-frontend/src/components/Datasource/Fieldset.tsx b/superset-frontend/src/components/Datasource/Fieldset.tsx
index 3d93f37ba5c..066f1dd855f 100644
--- a/superset-frontend/src/components/Datasource/Fieldset.tsx
+++ b/superset-frontend/src/components/Datasource/Fieldset.tsx
@@ -17,7 +17,7 @@
* under the License.
*/
import { ReactNode, PureComponent } from 'react';
-import { Form } from 'src/components/Form';
+import { Form } from '../Form';
import { recurseReactClone } from './utils';
import Field from './Field';
diff --git a/superset-frontend/src/components/Datasource/index.tsx b/superset-frontend/src/components/Datasource/index.tsx
index de28b24c4cb..59cc0dc8023 100644
--- a/superset-frontend/src/components/Datasource/index.tsx
+++ b/superset-frontend/src/components/Datasource/index.tsx
@@ -20,3 +20,4 @@ import ChangeDatasourceModal from './ChangeDatasourceModal';
import DatasourceModal from './DatasourceModal';
export { ChangeDatasourceModal, DatasourceModal };
+export type { DatasourceModalProps, ChangeDatasourceModalProps } from './types';
diff --git a/superset-frontend/src/components/Datasource/types.ts b/superset-frontend/src/components/Datasource/types.ts
new file mode 100644
index 00000000000..b5acefe880d
--- /dev/null
+++ b/superset-frontend/src/components/Datasource/types.ts
@@ -0,0 +1,91 @@
+/**
+ * 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 type { ReactNode, DetailedHTMLProps, TdHTMLAttributes } from 'react';
+import type { DatasetObject } from 'src/features/datasets/types';
+
+export interface Datasource {
+ type: string;
+ id: number;
+ uid: string;
+}
+
+export interface DatasourceModalProps {
+ addSuccessToast: (msg: string) => void;
+ addDangerToast: (msg: string) => void;
+ datasource: DatasetObject;
+ onChange: () => {};
+ onDatasourceSave: (datasource: object, errors?: Array) => {};
+ onHide: () => {};
+ show: boolean;
+}
+
+export interface ChangeDatasourceModalProps {
+ addDangerToast: (msg: string) => void;
+ addSuccessToast: (msg: string) => void;
+ onChange: (uid: string) => void;
+ onDatasourceSave: (datasource: object, errors?: Array) => {};
+ onHide: () => void;
+ show: boolean;
+}
+
+export interface CRUDCollectionProps {
+ allowAddItem?: boolean;
+ allowDeletes?: boolean;
+ collection: Record[];
+ columnLabels?: Record;
+ columnLabelTooltips?: Record;
+ emptyMessage?: ReactNode;
+ expandFieldset?: ReactNode;
+ extraButtons?: ReactNode;
+ itemGenerator?: () => any;
+ itemCellProps?: ((
+ val: unknown,
+ label: string,
+ record: any,
+ ) => DetailedHTMLProps<
+ TdHTMLAttributes,
+ HTMLTableCellElement
+ >)[];
+ itemRenderers?: ((
+ val: unknown,
+ onChange: () => void,
+ label: string,
+ record: any,
+ ) => ReactNode)[];
+ onChange?: (arg0: any) => void;
+ tableColumns: any[];
+ sortColumns: string[];
+ stickyHeader?: boolean;
+}
+
+export type Sort = number | string | boolean | any;
+
+export enum SortOrder {
+ Asc = 1,
+ Desc = 2,
+ Unsorted = 0,
+}
+
+export interface CRUDCollectionState {
+ collection: Record;
+ collectionArray: Record[];
+ expandedColumns: Record;
+ sortColumn: string;
+ sort: SortOrder;
+}
diff --git a/superset-frontend/src/components/DatePicker/DatePicker.stories.tsx b/superset-frontend/src/components/DatePicker/DatePicker.stories.tsx
index 8b39be7cb10..6043effffb5 100644
--- a/superset-frontend/src/components/DatePicker/DatePicker.stories.tsx
+++ b/superset-frontend/src/components/DatePicker/DatePicker.stories.tsx
@@ -16,8 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { DatePickerProps } from 'antd-v5';
-import { RangePickerProps } from 'antd-v5/es/date-picker';
+import type { DatePickerProps, RangePickerProps } from './types';
import { DatePicker, RangePicker } from '.';
export default {
diff --git a/superset-frontend/src/components/DatePicker/index.tsx b/superset-frontend/src/components/DatePicker/index.tsx
index a9b1f465f43..dc4e09506c4 100644
--- a/superset-frontend/src/components/DatePicker/index.tsx
+++ b/superset-frontend/src/components/DatePicker/index.tsx
@@ -16,8 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { DatePicker as AntdDatePicker, DatePickerProps } from 'antd-v5';
+import { DatePicker as AntdDatePicker } from 'antd-v5';
import { css } from '@superset-ui/core';
+import type { DatePickerProps, RangePickerProps } from './types';
export const DatePicker = (props: DatePickerProps) => (
(
// eslint-disable-next-line prefer-destructuring
export const RangePicker: typeof AntdDatePicker.RangePicker =
AntdDatePicker.RangePicker;
+
+export type { DatePickerProps, RangePickerProps };
diff --git a/superset-frontend/src/components/DatePicker/types.ts b/superset-frontend/src/components/DatePicker/types.ts
new file mode 100644
index 00000000000..92761866654
--- /dev/null
+++ b/superset-frontend/src/components/DatePicker/types.ts
@@ -0,0 +1,20 @@
+/**
+ * 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.
+ */
+export type { RangePickerProps } from 'antd-v5/es/date-picker';
+export type { DatePickerProps } from 'antd-v5';
diff --git a/superset-frontend/src/components/DeleteModal/DeleteModal.test.tsx b/superset-frontend/src/components/DeleteModal/DeleteModal.test.tsx
index 86e9ff21e8a..2f579e2e721 100644
--- a/superset-frontend/src/components/DeleteModal/DeleteModal.test.tsx
+++ b/superset-frontend/src/components/DeleteModal/DeleteModal.test.tsx
@@ -17,7 +17,7 @@
* under the License.
*/
import { render, screen, userEvent } from 'spec/helpers/testing-library';
-import DeleteModal from '.';
+import { DeleteModal } from '.';
test('Must display title and content', () => {
const props = {
diff --git a/superset-frontend/src/components/DeleteModal/index.tsx b/superset-frontend/src/components/DeleteModal/index.tsx
index 4fb9dbaaa34..d90ddbdf919 100644
--- a/superset-frontend/src/components/DeleteModal/index.tsx
+++ b/superset-frontend/src/components/DeleteModal/index.tsx
@@ -17,10 +17,11 @@
* under the License.
*/
import { t, styled } from '@superset-ui/core';
-import { useState, ReactNode, ChangeEvent } from 'react';
-import { Input } from 'src/components/Input';
-import Modal from 'src/components/Modal';
-import { FormLabel } from 'src/components/Form';
+import { useState, ChangeEvent } from 'react';
+import { FormLabel } from '../Form';
+import { Input } from '../Input';
+import { Modal } from '../Modal';
+import type { DeleteModalProps } from './types';
const StyledDiv = styled.div`
padding-top: 8px;
@@ -35,15 +36,7 @@ const DescriptionContainer = styled.div`
padding-top: 16px;
`;
-interface DeleteModalProps {
- description: ReactNode;
- onConfirm: () => void;
- onHide: () => void;
- open: boolean;
- title: ReactNode;
-}
-
-export default function DeleteModal({
+export function DeleteModal({
description,
onConfirm,
onHide,
@@ -104,3 +97,5 @@ export default function DeleteModal({
);
}
+
+export type { DeleteModalProps };
diff --git a/superset-frontend/src/components/DeleteModal/types.ts b/superset-frontend/src/components/DeleteModal/types.ts
new file mode 100644
index 00000000000..f0ba7ff188b
--- /dev/null
+++ b/superset-frontend/src/components/DeleteModal/types.ts
@@ -0,0 +1,28 @@
+/**
+ * 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 type { ReactNode } from 'react';
+
+export interface DeleteModalProps {
+ description: ReactNode;
+ onConfirm: () => void;
+ onHide: () => void;
+ open: boolean;
+ title: ReactNode;
+}
diff --git a/superset-frontend/src/components/Divider/Divider.stories.tsx b/superset-frontend/src/components/Divider/Divider.stories.tsx
index 5b5c2f6183c..903fa3b238b 100644
--- a/superset-frontend/src/components/Divider/Divider.stories.tsx
+++ b/superset-frontend/src/components/Divider/Divider.stories.tsx
@@ -16,7 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { Divider, DividerProps } from 'src/components/Divider';
+import { Divider } from '.';
+import type { DividerProps } from './types';
export default {
title: 'Components/Divider',
diff --git a/superset-frontend/src/components/Divider/index.tsx b/superset-frontend/src/components/Divider/index.tsx
index 1e0110c8233..7e648c7445a 100644
--- a/superset-frontend/src/components/Divider/index.tsx
+++ b/superset-frontend/src/components/Divider/index.tsx
@@ -18,10 +18,10 @@
*/
import { Divider as AntdDivider } from 'antd-v5';
-import type { DividerProps } from 'antd-v5/es/divider';
+import type { DividerProps } from './types';
export function Divider(props: DividerProps) {
return ;
}
-export { DividerProps };
+export type { DividerProps };
diff --git a/superset-frontend/src/components/Divider/types.ts b/superset-frontend/src/components/Divider/types.ts
new file mode 100644
index 00000000000..ba4a29c621d
--- /dev/null
+++ b/superset-frontend/src/components/Divider/types.ts
@@ -0,0 +1,22 @@
+/**
+ * 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 type { DividerProps } from 'antd-v5/es/divider';
+
+export { DividerProps };
diff --git a/superset-frontend/src/components/Dropdown/Dropdown.stories.tsx b/superset-frontend/src/components/Dropdown/Dropdown.stories.tsx
index ad4bada55e4..5f0f9717caf 100644
--- a/superset-frontend/src/components/Dropdown/Dropdown.stories.tsx
+++ b/superset-frontend/src/components/Dropdown/Dropdown.stories.tsx
@@ -17,7 +17,8 @@
* under the License.
*/
import { Menu } from 'src/components/Menu';
-import { MenuDotsDropdown, MenuDotsDropdownProps } from '.';
+import { MenuDotsDropdown } from '.';
+import type { MenuDotsDropdownProps } from './types';
export default {
title: 'Components/Dropdown',
diff --git a/superset-frontend/src/components/Dropdown/Dropdown.test.tsx b/superset-frontend/src/components/Dropdown/Dropdown.test.tsx
index 192a2fdea94..65ae7208c60 100644
--- a/superset-frontend/src/components/Dropdown/Dropdown.test.tsx
+++ b/superset-frontend/src/components/Dropdown/Dropdown.test.tsx
@@ -18,7 +18,7 @@
*/
import { render, fireEvent, screen } from 'spec/helpers/testing-library';
-import { NoAnimationDropdown } from './index'; // adjust the import path as needed
+import { NoAnimationDropdown } from '.';
const props = {
overlay:
Test Overlay
,
diff --git a/superset-frontend/src/components/Dropdown/index.tsx b/superset-frontend/src/components/Dropdown/index.tsx
index 95a60eab459..b634b15b169 100644
--- a/superset-frontend/src/components/Dropdown/index.tsx
+++ b/superset-frontend/src/components/Dropdown/index.tsx
@@ -16,20 +16,16 @@
* specific language governing permissions and limitations
* under the License.
*/
-import {
- ReactElement,
- ReactNode,
- FocusEvent,
- KeyboardEvent,
- cloneElement,
-} from 'react';
+import { ReactElement, cloneElement } from 'react';
-import {
- Dropdown as AntdDropdown,
- DropdownProps as AntdDropdownProps,
-} from 'antd-v5';
+import { Dropdown as AntdDropdown, DropdownProps } from 'antd-v5';
import { styled } from '@superset-ui/core';
import { Icons } from 'src/components/Icons';
+import {
+ IconOrientation,
+ type NoAnimationDropdownProps,
+ type MenuDotsDropdownProps,
+} from './types';
const MenuDots = styled.div`
width: ${({ theme }) => theme.sizeUnit * 0.75}px;
@@ -76,16 +72,6 @@ const MenuDotsWrapper = styled.div`
padding-left: ${({ theme }) => theme.sizeUnit}px;
`;
-export enum IconOrientation {
- Vertical = 'vertical',
- Horizontal = 'horizontal',
-}
-
-export interface MenuDotsDropdownProps extends AntdDropdownProps {
- overlay?: ReactElement;
- iconOrientation?: IconOrientation;
-}
-
const RenderIcon = (
iconOrientation: IconOrientation = IconOrientation.Vertical,
) => {
@@ -110,12 +96,6 @@ export const MenuDotsDropdown = ({
);
-export interface NoAnimationDropdownProps extends AntdDropdownProps {
- children: ReactNode;
- onBlur?: (e: FocusEvent) => void;
- onKeyDown?: (e: KeyboardEvent) => void;
-}
-
export const NoAnimationDropdown = (props: NoAnimationDropdownProps) => {
const { children, onBlur, onKeyDown, ...rest } = props;
const childrenWithProps = cloneElement(children as ReactElement, {
@@ -130,7 +110,8 @@ export const NoAnimationDropdown = (props: NoAnimationDropdownProps) => {
);
};
-export type DropdownProps = AntdDropdownProps;
export const Dropdown = (props: DropdownProps) => (
);
+
+export type { DropdownProps, NoAnimationDropdownProps, MenuDotsDropdownProps };
diff --git a/superset-frontend/src/components/Dropdown/types.ts b/superset-frontend/src/components/Dropdown/types.ts
new file mode 100644
index 00000000000..9a2476d5c14
--- /dev/null
+++ b/superset-frontend/src/components/Dropdown/types.ts
@@ -0,0 +1,38 @@
+/**
+ * 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 type { DropdownProps as AntdDropdownProps } from 'antd-v5';
+import type { ReactElement, ReactNode, FocusEvent, KeyboardEvent } from 'react';
+
+export enum IconOrientation {
+ Vertical = 'vertical',
+ Horizontal = 'horizontal',
+}
+
+export interface MenuDotsDropdownProps extends AntdDropdownProps {
+ overlay?: ReactElement;
+ iconOrientation?: IconOrientation;
+}
+
+export interface NoAnimationDropdownProps extends AntdDropdownProps {
+ children: ReactNode;
+ onBlur?: (e: FocusEvent) => void;
+ onKeyDown?: (e: KeyboardEvent) => void;
+}
+
+export type DropdownProps = AntdDropdownProps;
diff --git a/superset-frontend/src/components/DropdownButton/DropdownButton.stories.tsx b/superset-frontend/src/components/DropdownButton/DropdownButton.stories.tsx
index 9f661a72804..851d0abcc46 100644
--- a/superset-frontend/src/components/DropdownButton/DropdownButton.stories.tsx
+++ b/superset-frontend/src/components/DropdownButton/DropdownButton.stories.tsx
@@ -17,7 +17,8 @@
* under the License.
*/
import { Menu } from 'src/components/Menu';
-import { DropdownButton, DropdownButtonProps } from '.';
+import { DropdownButton } from '.';
+import type { DropdownButtonProps } from './types';
export default {
title: 'Components/DropdownButton',
diff --git a/superset-frontend/src/components/DropdownButton/index.tsx b/superset-frontend/src/components/DropdownButton/index.tsx
index 1eb2f5adfad..d9d39b88186 100644
--- a/superset-frontend/src/components/DropdownButton/index.tsx
+++ b/superset-frontend/src/components/DropdownButton/index.tsx
@@ -16,17 +16,11 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { type ComponentProps } from 'react';
-
import { Dropdown } from 'antd-v5';
-import { Tooltip, TooltipPlacement } from 'src/components/Tooltip';
import { kebabCase } from 'lodash';
import { css, useTheme } from '@superset-ui/core';
-
-export type DropdownButtonProps = ComponentProps & {
- tooltip?: string;
- tooltipPlacement?: TooltipPlacement;
-};
+import { Tooltip } from '../Tooltip';
+import type { DropdownButtonProps } from './types';
export const DropdownButton = ({
dropdownRender,
@@ -87,3 +81,5 @@ export const DropdownButton = ({
}
return button;
};
+
+export type { DropdownButtonProps };
diff --git a/superset-frontend/src/components/DropdownButton/types.ts b/superset-frontend/src/components/DropdownButton/types.ts
new file mode 100644
index 00000000000..50b15006ffd
--- /dev/null
+++ b/superset-frontend/src/components/DropdownButton/types.ts
@@ -0,0 +1,27 @@
+/**
+ * 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 { type ComponentProps } from 'react';
+
+import { Dropdown } from 'antd-v5';
+import type { TooltipPlacement } from '../Tooltip/types';
+
+export type DropdownButtonProps = ComponentProps & {
+ tooltip?: string;
+ tooltipPlacement?: TooltipPlacement;
+};
diff --git a/superset-frontend/src/components/DropdownContainer/DropdownContainer.stories.tsx b/superset-frontend/src/components/DropdownContainer/DropdownContainer.stories.tsx
index a6766e620da..ad99b6b00f7 100644
--- a/superset-frontend/src/components/DropdownContainer/DropdownContainer.stories.tsx
+++ b/superset-frontend/src/components/DropdownContainer/DropdownContainer.stories.tsx
@@ -19,9 +19,10 @@
import { useRef, useCallback, useState } from 'react';
import { isEqual } from 'lodash';
import { css } from '@superset-ui/core';
-import { Select } from 'src/components';
-import Button from '../Button';
-import DropdownContainer, { DropdownContainerProps, Ref } from '.';
+import { Button } from '../Button';
+import { Select } from '../Select';
+import type { DropdownContainerProps, DropdownRef } from './types';
+import { DropdownContainer } from '.';
export default {
title: 'Design System/Components/DropdownContainer',
@@ -62,7 +63,7 @@ const generateItems = (overflowingState?: OverflowingState) =>
export const Component = (props: DropdownContainerProps) => {
const [items, setItems] = useState([]);
const [overflowingState, setOverflowingState] = useState();
- const containerRef = useRef(null);
+ const containerRef = useRef(null);
const onOverflowingStateChange = useCallback(
value => {
if (!isEqual(overflowingState, value)) {
diff --git a/superset-frontend/src/components/DropdownContainer/DropdownContainer.test.tsx b/superset-frontend/src/components/DropdownContainer/DropdownContainer.test.tsx
index 7833a1313be..69dcba0f340 100644
--- a/superset-frontend/src/components/DropdownContainer/DropdownContainer.test.tsx
+++ b/superset-frontend/src/components/DropdownContainer/DropdownContainer.test.tsx
@@ -17,9 +17,9 @@
* under the License.
*/
import { screen, render, userEvent } from 'spec/helpers/testing-library';
-import Button from '../Button';
-import { Icons } from '../Icons';
-import DropdownContainer from '.';
+import { Icons } from 'src/components/Icons';
+import { Button } from '../Button';
+import { DropdownContainer } from '.';
const generateItems = (n: number) =>
Array.from({ length: n }).map((_, i) => ({
diff --git a/superset-frontend/src/components/DropdownContainer/index.tsx b/superset-frontend/src/components/DropdownContainer/index.tsx
index f8a0db2a8a0..dec6c1b4852 100644
--- a/superset-frontend/src/components/DropdownContainer/index.tsx
+++ b/superset-frontend/src/components/DropdownContainer/index.tsx
@@ -17,10 +17,8 @@
* under the License.
*/
import {
- CSSProperties,
cloneElement,
forwardRef,
- ReactElement,
RefObject,
useEffect,
useImperativeHandle,
@@ -28,93 +26,25 @@ import {
useMemo,
useState,
useRef,
- ReactNode,
} from 'react';
import { Global } from '@emotion/react';
import { css, t, useTheme, usePrevious } from '@superset-ui/core';
import { useResizeDetector } from 'react-resize-detector';
-import Badge from '../Badge';
-import { Icons } from '../Icons';
-import Button from '../Button';
-import Popover from '../Popover';
+import { Icons } from 'src/components/Icons';
+import { Badge } from '../Badge';
+import { Button } from '../Button';
import { Tooltip } from '../Tooltip';
+import Popover from '../Popover';
+import type {
+ DropdownContainerProps,
+ DropdownItem,
+ DropdownRef,
+} from './types';
const MAX_HEIGHT = 500;
-/**
- * Container item.
- */
-export interface Item {
- /**
- * String that uniquely identifies the item.
- */
- id: string;
- /**
- * The element to be rendered.
- */
- element: ReactElement;
-}
-
-/**
- * Horizontal container that displays overflowed items in a dropdown.
- * It shows an indicator of how many items are currently overflowing.
- */
-export interface DropdownContainerProps {
- /**
- * Array of items. The id property is used to uniquely identify
- * the elements when rendering or dealing with event handlers.
- */
- items: Item[];
- /**
- * Event handler called every time an element moves between
- * main container and dropdown.
- */
- onOverflowingStateChange?: (overflowingState: {
- notOverflowed: string[];
- overflowed: string[];
- }) => void;
- /**
- * Option to customize the content of the dropdown.
- */
- dropdownContent?: (overflowedItems: Item[]) => ReactElement;
- /**
- * Dropdown ref.
- */
- dropdownRef?: RefObject;
- /**
- * Dropdown additional style properties.
- */
- dropdownStyle?: CSSProperties;
- /**
- * Displayed count in the dropdown trigger.
- */
- dropdownTriggerCount?: number;
- /**
- * Icon of the dropdown trigger.
- */
- dropdownTriggerIcon?: ReactElement;
- /**
- * Text of the dropdown trigger.
- */
- dropdownTriggerText?: string;
- /**
- * Text of the dropdown trigger tooltip
- */
- dropdownTriggerTooltip?: ReactNode | null;
- /**
- * Main container additional style properties.
- */
- style?: CSSProperties;
- /**
- * Force render popover content before it's first opened
- */
- forceRender?: boolean;
-}
-
-export type Ref = HTMLDivElement & { open: () => void };
-
-const DropdownContainer = forwardRef(
+export const DropdownContainer = forwardRef(
(
{
items,
@@ -129,7 +59,7 @@ const DropdownContainer = forwardRef(
forceRender,
style,
}: DropdownContainerProps,
- outerRef: RefObject,
+ outerRef: RefObject,
) => {
const theme = useTheme();
const { ref, width = 0 } = useResizeDetector();
@@ -147,7 +77,7 @@ const DropdownContainer = forwardRef(
const [showOverflow, setShowOverflow] = useState(false);
- const reduceItems = (items: Item[]): [Item[], string[]] =>
+ const reduceItems = (items: DropdownItem[]): [DropdownItem[], string[]] =>
items.reduce(
([items, ids], item) => {
items.push({
@@ -157,7 +87,7 @@ const DropdownContainer = forwardRef(
ids.push(item.id);
return [items, ids];
},
- [[], []] as [Item[], string[]],
+ [[], []] as [DropdownItem[], string[]],
);
const [notOverflowedItems, notOverflowedIds] = useMemo(
@@ -415,4 +345,4 @@ const DropdownContainer = forwardRef(
},
);
-export default DropdownContainer;
+export type { DropdownItem, DropdownRef };
diff --git a/superset-frontend/src/components/DropdownContainer/types.ts b/superset-frontend/src/components/DropdownContainer/types.ts
new file mode 100644
index 00000000000..ea2c33050ea
--- /dev/null
+++ b/superset-frontend/src/components/DropdownContainer/types.ts
@@ -0,0 +1,91 @@
+/**
+ * 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 type { CSSProperties, ReactElement, RefObject, ReactNode } from 'react';
+
+/**
+ * Container item.
+ */
+export interface DropdownItem {
+ /**
+ * String that uniquely identifies the item.
+ */
+ id: string;
+ /**
+ * The element to be rendered.
+ */
+ element: ReactElement;
+}
+
+/**
+ * Horizontal container that displays overflowed items in a dropdown.
+ * It shows an indicator of how many items are currently overflowing.
+ */
+export interface DropdownContainerProps {
+ /**
+ * Array of items. The id property is used to uniquely identify
+ * the elements when rendering or dealing with event handlers.
+ */
+ items: DropdownItem[];
+ /**
+ * Event handler called every time an element moves between
+ * main container and dropdown.
+ */
+ onOverflowingStateChange?: (overflowingState: {
+ notOverflowed: string[];
+ overflowed: string[];
+ }) => void;
+ /**
+ * Option to customize the content of the dropdown.
+ */
+ dropdownContent?: (overflowedItems: DropdownItem[]) => ReactElement;
+ /**
+ * Dropdown ref.
+ */
+ dropdownRef?: RefObject;
+ /**
+ * Dropdown additional style properties.
+ */
+ dropdownStyle?: CSSProperties;
+ /**
+ * Displayed count in the dropdown trigger.
+ */
+ dropdownTriggerCount?: number;
+ /**
+ * Icon of the dropdown trigger.
+ */
+ dropdownTriggerIcon?: ReactElement;
+ /**
+ * Text of the dropdown trigger.
+ */
+ dropdownTriggerText?: string;
+ /**
+ * Text of the dropdown trigger tooltip
+ */
+ dropdownTriggerTooltip?: ReactNode | null;
+ /**
+ * Main container additional style properties.
+ */
+ style?: CSSProperties;
+ /**
+ * Force render popover content before it's first opened
+ */
+ forceRender?: boolean;
+}
+
+export type DropdownRef = HTMLDivElement & { open: () => void };
diff --git a/superset-frontend/src/components/DynamicEditableTitle/DynamicEditableTitle.test.tsx b/superset-frontend/src/components/DynamicEditableTitle/DynamicEditableTitle.test.tsx
index 40b04be1cd9..f70859cfb06 100644
--- a/superset-frontend/src/components/DynamicEditableTitle/DynamicEditableTitle.test.tsx
+++ b/superset-frontend/src/components/DynamicEditableTitle/DynamicEditableTitle.test.tsx
@@ -17,7 +17,7 @@
* under the License.
*/
import { render, screen, userEvent } from 'spec/helpers/testing-library';
-import DynamicEditableTitle from '.';
+import { DynamicEditableTitle } from '.';
const createProps = (overrides: Record = {}) => ({
title: 'Chart title',
diff --git a/superset-frontend/src/components/DynamicEditableTitle/index.tsx b/superset-frontend/src/components/DynamicEditableTitle/index.tsx
index 695a4071ab1..a68547fe698 100644
--- a/superset-frontend/src/components/DynamicEditableTitle/index.tsx
+++ b/superset-frontend/src/components/DynamicEditableTitle/index.tsx
@@ -28,16 +28,9 @@ import {
useState,
} from 'react';
import { css, SupersetTheme, t } from '@superset-ui/core';
-import { Tooltip } from 'src/components/Tooltip';
import { useResizeDetector } from 'react-resize-detector';
-
-export type DynamicEditableTitleProps = {
- title: string;
- placeholder: string;
- onSave: (title: string) => void;
- canEdit: boolean;
- label: string | undefined;
-};
+import { Tooltip } from '../Tooltip';
+import type { DynamicEditableTitleProps } from './types';
const titleStyles = (theme: SupersetTheme) => css`
display: flex;
@@ -79,7 +72,7 @@ const titleStyles = (theme: SupersetTheme) => css`
}
`;
-const DynamicEditableTitle = memo(
+export const DynamicEditableTitle = memo(
({
title,
placeholder,
@@ -226,4 +219,5 @@ const DynamicEditableTitle = memo(
);
},
);
-export default DynamicEditableTitle;
+
+export type { DynamicEditableTitleProps } from './types';
diff --git a/superset-frontend/src/components/DynamicEditableTitle/types.ts b/superset-frontend/src/components/DynamicEditableTitle/types.ts
new file mode 100644
index 00000000000..c52801388ae
--- /dev/null
+++ b/superset-frontend/src/components/DynamicEditableTitle/types.ts
@@ -0,0 +1,25 @@
+/**
+ * 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.
+ */
+export type DynamicEditableTitleProps = {
+ title: string;
+ placeholder: string;
+ onSave: (title: string) => void;
+ canEdit: boolean;
+ label: string | undefined;
+};
diff --git a/superset-frontend/src/components/DynamicPlugins/index.tsx b/superset-frontend/src/components/DynamicPlugins/index.tsx
index 7650e062596..28538a53ea3 100644
--- a/superset-frontend/src/components/DynamicPlugins/index.tsx
+++ b/superset-frontend/src/components/DynamicPlugins/index.tsx
@@ -28,25 +28,10 @@ import {
makeApi,
} from '@superset-ui/core';
import { omitBy } from 'lodash';
+import type { Plugin, PluginAction, PluginContextType } from './types';
const metadataRegistry = getChartMetadataRegistry();
-export type PluginContextType = {
- loading: boolean;
- /** These are actually only the dynamic plugins */
- dynamicPlugins: {
- [key: string]: {
- key: string;
- mounting: boolean;
- error: null | Error;
- };
- };
- keys: string[];
- /** Mounted means the plugin's js bundle has been imported */
- mountedPluginMetadata: Record;
- fetchAll: () => void;
-};
-
const dummyPluginContext: PluginContextType = {
loading: true,
dynamicPlugins: {},
@@ -71,33 +56,6 @@ export const PluginContext = createContext(dummyPluginContext);
*/
export const usePluginContext = () => useContext(PluginContext);
-// the plugin returned from the API
-type Plugin = {
- name: string;
- key: string;
- bundle_url: string;
- id: number;
-};
-
-// when a plugin completes loading
-type CompleteAction = {
- type: 'complete';
- key: string;
- error: null | Error;
-};
-
-// when plugins start loading
-type BeginAction = {
- type: 'begin';
- keys: string[];
-};
-
-type ChangedKeysAction = {
- type: 'changed keys';
-};
-
-type PluginAction = BeginAction | CompleteAction | ChangedKeysAction;
-
function getRegistryData() {
return {
keys: metadataRegistry.keys(),
@@ -229,3 +187,5 @@ export const DynamicPluginProvider: FC = ({ children }) => {
);
};
+
+export type { PluginContextType };
diff --git a/superset-frontend/src/components/DynamicPlugins/types.ts b/superset-frontend/src/components/DynamicPlugins/types.ts
new file mode 100644
index 00000000000..24a6bfdfac1
--- /dev/null
+++ b/superset-frontend/src/components/DynamicPlugins/types.ts
@@ -0,0 +1,62 @@
+/**
+ * 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 type { ChartMetadata } from '@superset-ui/core';
+
+export type PluginContextType = {
+ loading: boolean;
+ /** These are actually only the dynamic plugins */
+ dynamicPlugins: {
+ [key: string]: {
+ key: string;
+ mounting: boolean;
+ error: null | Error;
+ };
+ };
+ keys: string[];
+ /** Mounted means the plugin's js bundle has been imported */
+ mountedPluginMetadata: Record;
+ fetchAll: () => void;
+};
+
+// the plugin returned from the API
+export type Plugin = {
+ name: string;
+ key: string;
+ bundle_url: string;
+ id: number;
+};
+
+// when a plugin completes loading
+export type CompleteAction = {
+ type: 'complete';
+ key: string;
+ error: null | Error;
+};
+
+// when plugins start loading
+export type BeginAction = {
+ type: 'begin';
+ keys: string[];
+};
+
+export type ChangedKeysAction = {
+ type: 'changed keys';
+};
+
+export type PluginAction = BeginAction | CompleteAction | ChangedKeysAction;
diff --git a/superset-frontend/src/components/EditableTitle/EditableTitle.stories.tsx b/superset-frontend/src/components/EditableTitle/EditableTitle.stories.tsx
index 5ec902054f3..a0bca59a026 100644
--- a/superset-frontend/src/components/EditableTitle/EditableTitle.stories.tsx
+++ b/superset-frontend/src/components/EditableTitle/EditableTitle.stories.tsx
@@ -16,7 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
-import EditableTitle, { EditableTitleProps } from '.';
+import { EditableTitle } from '.';
+import type { EditableTitleProps } from './types';
export default {
title: 'Components/EditableTitle',
diff --git a/superset-frontend/src/components/EditableTitle/EditableTitle.test.tsx b/superset-frontend/src/components/EditableTitle/EditableTitle.test.tsx
index 12ecfacf780..77c036e1e94 100644
--- a/superset-frontend/src/components/EditableTitle/EditableTitle.test.tsx
+++ b/superset-frontend/src/components/EditableTitle/EditableTitle.test.tsx
@@ -17,8 +17,7 @@
* under the License.
*/
import { fireEvent, getByRole, render } from 'spec/helpers/testing-library';
-
-import EditableTable from 'src/components/EditableTitle';
+import { EditableTitle as EditableTable } from '.';
const mockEvent = {
target: {
diff --git a/superset-frontend/src/components/EditableTitle/index.tsx b/superset-frontend/src/components/EditableTitle/index.tsx
index 73047e2b84e..fa11623187e 100644
--- a/superset-frontend/src/components/EditableTitle/index.tsx
+++ b/superset-frontend/src/components/EditableTitle/index.tsx
@@ -20,32 +20,15 @@ import { useEffect, useState, useRef } from 'react';
import { Link } from 'react-router-dom';
import cx from 'classnames';
import { css, styled, SupersetTheme, t } from '@superset-ui/core';
-import { Tooltip } from 'src/components/Tooltip';
-import CertifiedBadge from '../CertifiedBadge';
-
-export interface EditableTitleProps {
- canEdit?: boolean;
- editing?: boolean;
- emptyText?: string;
- extraClasses?: Array | string;
- multiLine?: boolean;
- noPermitTooltip?: string;
- onSaveTitle: (arg0: string) => void;
- showTooltip?: boolean;
- style?: object;
- title?: string;
- defaultTitle?: string;
- placeholder?: string;
- certifiedBy?: string;
- certificationDetails?: string;
- url?: string;
-}
+import { CertifiedBadge } from '../CertifiedBadge';
+import { Tooltip } from '../Tooltip';
+import type { EditableTitleProps } from './types';
const StyledCertifiedBadge = styled(CertifiedBadge)`
vertical-align: middle;
`;
-export default function EditableTitle({
+export function EditableTitle({
canEdit = false,
editing = false,
extraClasses,
@@ -263,3 +246,5 @@ export default function EditableTitle({
);
}
+
+export type { EditableTitleProps };
diff --git a/superset-frontend/src/components/EditableTitle/types.ts b/superset-frontend/src/components/EditableTitle/types.ts
new file mode 100644
index 00000000000..d21799c752b
--- /dev/null
+++ b/superset-frontend/src/components/EditableTitle/types.ts
@@ -0,0 +1,35 @@
+/**
+ * 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.
+ */
+export interface EditableTitleProps {
+ canEdit?: boolean;
+ editing?: boolean;
+ emptyText?: string;
+ extraClasses?: Array | string;
+ multiLine?: boolean;
+ noPermitTooltip?: string;
+ onSaveTitle: (arg0: string) => void;
+ showTooltip?: boolean;
+ style?: object;
+ title?: string;
+ defaultTitle?: string;
+ placeholder?: string;
+ certifiedBy?: string;
+ certificationDetails?: string;
+ url?: string;
+}
diff --git a/superset-frontend/src/components/EmptyState/Empty.tsx b/superset-frontend/src/components/EmptyState/Empty.tsx
index b507027c64d..2384cc142e6 100644
--- a/superset-frontend/src/components/EmptyState/Empty.tsx
+++ b/superset-frontend/src/components/EmptyState/Empty.tsx
@@ -27,3 +27,5 @@ export const Empty = Object.assign(
PRESENTED_IMAGE_DEFAULT: AntdEmpty.PRESENTED_IMAGE_DEFAULT,
},
);
+
+export type { EmptyProps };
diff --git a/superset-frontend/src/components/EmptyState/EmptyState.stories.tsx b/superset-frontend/src/components/EmptyState/EmptyState.stories.tsx
index 2849c648da8..03c7f23cc99 100644
--- a/superset-frontend/src/components/EmptyState/EmptyState.stories.tsx
+++ b/superset-frontend/src/components/EmptyState/EmptyState.stories.tsx
@@ -18,7 +18,7 @@
* under the License.
*/
import { Meta, StoryFn } from '@storybook/react';
-import { Row, Col } from 'antd';
+import { Row, Col } from 'antd'; // TODO: Remove antd
import { EmptyState, imageMap } from '.';
const emptyStates = [
diff --git a/superset-frontend/src/components/EmptyState/index.tsx b/superset-frontend/src/components/EmptyState/index.tsx
index c063dfef251..63aa682f40a 100644
--- a/superset-frontend/src/components/EmptyState/index.tsx
+++ b/superset-frontend/src/components/EmptyState/index.tsx
@@ -18,7 +18,6 @@
*/
import { ReactNode, SyntheticEvent } from 'react';
import { styled, css, SupersetTheme, t } from '@superset-ui/core';
-import Button from 'src/components/Button';
// Importing svg images
import FilterResultsImage from 'src/assets/images/filter-results.svg';
@@ -36,7 +35,9 @@ import EmptySqlChartImage from 'src/assets/images/empty_sql_chart.svg';
import EmptyQueryImage from 'src/assets/images/empty-query.svg';
import EmptyTableImage from 'src/assets/images/empty-table.svg';
import EmptyImage from 'src/assets/images/empty.svg';
+import { Button } from '../Button';
import { Empty } from './Empty';
+import type { EmptyStateProps, EmptyStateSize } from './types';
export const imageMap = {
'chart.svg': ,
@@ -56,18 +57,6 @@ export const imageMap = {
'vector.svg': ,
};
-type EmptyStateSize = 'small' | 'medium' | 'large';
-
-export type EmptyStateProps = {
- title?: ReactNode;
- description?: ReactNode;
- image?: ReactNode | string;
- buttonText?: ReactNode;
- buttonAction?: (event: SyntheticEvent) => void;
- size?: EmptyStateSize;
- children?: ReactNode;
-};
-
const EmptyStateContainer = styled.div`
${({ theme }) => css`
display: flex;
@@ -112,13 +101,6 @@ const Description = styled.p<{ size: EmptyStateSize }>`
`}
`;
-const ActionButton = styled(Button)`
- ${({ theme }) => css`
- margin-top: ${theme.sizeUnit * 4}px;
- z-index: 1;
- `}
-`;
-
const getImageHeight = (size: EmptyStateSize) => {
switch (size) {
case 'small':
@@ -185,15 +167,21 @@ export const EmptyState: React.FC = ({
)}
{buttonText && buttonAction && (
- css`
+ margin-top: ${theme.sizeUnit * 4}px;
+ z-index: 1;
+ `}
>
{buttonText}
-
+
)}
{children}
);
+
+export type { EmptyStateProps };
diff --git a/superset-frontend/src/components/EmptyState/types.ts b/superset-frontend/src/components/EmptyState/types.ts
new file mode 100644
index 00000000000..76147a6ba68
--- /dev/null
+++ b/superset-frontend/src/components/EmptyState/types.ts
@@ -0,0 +1,31 @@
+/**
+ * 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 type { ReactNode, SyntheticEvent } from 'react';
+
+export type EmptyStateSize = 'small' | 'medium' | 'large';
+
+export type EmptyStateProps = {
+ title?: ReactNode;
+ description?: ReactNode;
+ image?: ReactNode | string;
+ buttonText?: ReactNode;
+ buttonAction?: (event: SyntheticEvent) => void;
+ size?: EmptyStateSize;
+ children?: ReactNode;
+};
diff --git a/superset-frontend/src/components/ErrorBoundary/ErrorBoundary.test.tsx b/superset-frontend/src/components/ErrorBoundary/ErrorBoundary.test.tsx
index 3d04008293b..1b167667a94 100644
--- a/superset-frontend/src/components/ErrorBoundary/ErrorBoundary.test.tsx
+++ b/superset-frontend/src/components/ErrorBoundary/ErrorBoundary.test.tsx
@@ -18,7 +18,8 @@
*/
import { ReactElement } from 'react';
import { render, screen } from 'spec/helpers/testing-library';
-import ErrorBoundary, { ErrorBoundaryProps } from '.';
+import type { ErrorBoundaryProps } from './types';
+import { ErrorBoundary } from '.';
const mockedProps: Partial = {
children: Error children,
diff --git a/superset-frontend/src/components/ErrorBoundary/index.tsx b/superset-frontend/src/components/ErrorBoundary/index.tsx
index c7e60d577f8..1550f5e4f0c 100644
--- a/superset-frontend/src/components/ErrorBoundary/index.tsx
+++ b/superset-frontend/src/components/ErrorBoundary/index.tsx
@@ -16,23 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { Component, ErrorInfo, ReactNode } from 'react';
+import { Component, ErrorInfo } from 'react';
import { t } from '@superset-ui/core';
-import ErrorAlert from 'src/components/ErrorMessage/ErrorAlert';
+import { ErrorAlert } from '../ErrorMessage';
+import type { ErrorBoundaryProps, ErrorBoundaryState } from './types';
-export interface ErrorBoundaryProps {
- children: ReactNode;
- onError?: (error: Error, info: ErrorInfo) => void;
- showMessage?: boolean;
- className?: string;
-}
-
-interface ErrorBoundaryState {
- error: Error | null;
- info: ErrorInfo | null;
-}
-
-export default class ErrorBoundary extends Component<
+export class ErrorBoundary extends Component<
ErrorBoundaryProps,
ErrorBoundaryState
> {
@@ -70,3 +59,5 @@ export default class ErrorBoundary extends Component<
return this.props.children;
}
}
+
+export type { ErrorBoundaryProps };
diff --git a/superset-frontend/src/components/ErrorBoundary/types.ts b/superset-frontend/src/components/ErrorBoundary/types.ts
new file mode 100644
index 00000000000..48b32124999
--- /dev/null
+++ b/superset-frontend/src/components/ErrorBoundary/types.ts
@@ -0,0 +1,31 @@
+/**
+ * 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 type { ErrorInfo, ReactNode } from 'react';
+
+export interface ErrorBoundaryProps {
+ children: ReactNode;
+ onError?: (error: Error, info: ErrorInfo) => void;
+ showMessage?: boolean;
+ className?: string;
+}
+
+export interface ErrorBoundaryState {
+ error: Error | null;
+ info: ErrorInfo | null;
+}
diff --git a/superset-frontend/src/components/ErrorMessage/BasicErrorAlert.test.tsx b/superset-frontend/src/components/ErrorMessage/BasicErrorAlert.test.tsx
index ad0a97b0116..3b9f1a70490 100644
--- a/superset-frontend/src/components/ErrorMessage/BasicErrorAlert.test.tsx
+++ b/superset-frontend/src/components/ErrorMessage/BasicErrorAlert.test.tsx
@@ -19,7 +19,7 @@
import { render, screen } from 'spec/helpers/testing-library';
import { ErrorLevel, supersetTheme } from '@superset-ui/core';
-import BasicErrorAlert from './BasicErrorAlert';
+import { BasicErrorAlert } from './BasicErrorAlert';
jest.mock(
'src/components/Icons/AsyncIcon',
diff --git a/superset-frontend/src/components/ErrorMessage/BasicErrorAlert.tsx b/superset-frontend/src/components/ErrorMessage/BasicErrorAlert.tsx
index 6f915442b06..27a90054b61 100644
--- a/superset-frontend/src/components/ErrorMessage/BasicErrorAlert.tsx
+++ b/superset-frontend/src/components/ErrorMessage/BasicErrorAlert.tsx
@@ -36,7 +36,7 @@ interface BasicErrorAlertProps {
level?: ErrorLevel;
}
-export default function BasicErrorAlert({
+export function BasicErrorAlert({
body,
level = 'error',
title,
diff --git a/superset-frontend/src/components/ErrorMessage/DatabaseErrorMessage.test.tsx b/superset-frontend/src/components/ErrorMessage/DatabaseErrorMessage.test.tsx
index b9a98b7ced3..fd8ddee9e0c 100644
--- a/superset-frontend/src/components/ErrorMessage/DatabaseErrorMessage.test.tsx
+++ b/superset-frontend/src/components/ErrorMessage/DatabaseErrorMessage.test.tsx
@@ -19,7 +19,7 @@
import { ErrorLevel, ErrorSource, ErrorTypeEnum } from '@superset-ui/core';
import { render, screen, userEvent } from 'spec/helpers/testing-library';
-import DatabaseErrorMessage from './DatabaseErrorMessage';
+import { DatabaseErrorMessage } from './DatabaseErrorMessage';
jest.mock(
'src/components/Icons/AsyncIcon',
diff --git a/superset-frontend/src/components/ErrorMessage/DatabaseErrorMessage.tsx b/superset-frontend/src/components/ErrorMessage/DatabaseErrorMessage.tsx
index 7e9e69ea7ec..aec41e8f5f5 100644
--- a/superset-frontend/src/components/ErrorMessage/DatabaseErrorMessage.tsx
+++ b/superset-frontend/src/components/ErrorMessage/DatabaseErrorMessage.tsx
@@ -19,9 +19,9 @@
import { ReactNode } from 'react';
import { t, tn } from '@superset-ui/core';
-import { ErrorMessageComponentProps } from './types';
-import IssueCode from './IssueCode';
-import ErrorAlert from './ErrorAlert';
+import type { ErrorMessageComponentProps } from './types';
+import { IssueCode } from './IssueCode';
+import { ErrorAlert } from './ErrorAlert';
interface DatabaseErrorExtra {
owners?: string[];
@@ -32,7 +32,7 @@ interface DatabaseErrorExtra {
engine_name: string | null;
}
-function DatabaseErrorMessage({
+export function DatabaseErrorMessage({
error,
source,
subtitle,
@@ -89,5 +89,3 @@ function DatabaseErrorMessage({
/>
);
}
-
-export default DatabaseErrorMessage;
diff --git a/superset-frontend/src/components/ErrorMessage/DatasetNotFoundErrorMessage.test.tsx b/superset-frontend/src/components/ErrorMessage/DatasetNotFoundErrorMessage.test.tsx
index f54e29272cc..76d5eefa416 100644
--- a/superset-frontend/src/components/ErrorMessage/DatasetNotFoundErrorMessage.test.tsx
+++ b/superset-frontend/src/components/ErrorMessage/DatasetNotFoundErrorMessage.test.tsx
@@ -19,7 +19,7 @@
import { ErrorLevel, ErrorSource, ErrorTypeEnum } from '@superset-ui/core';
import { render, screen } from 'spec/helpers/testing-library';
-import DatasetNotFoundErrorMessage from './DatasetNotFoundErrorMessage';
+import { DatasetNotFoundErrorMessage } from './DatasetNotFoundErrorMessage';
jest.mock(
'src/components/Icons/AsyncIcon',
diff --git a/superset-frontend/src/components/ErrorMessage/DatasetNotFoundErrorMessage.tsx b/superset-frontend/src/components/ErrorMessage/DatasetNotFoundErrorMessage.tsx
index 238b345c348..0da2973796a 100644
--- a/superset-frontend/src/components/ErrorMessage/DatasetNotFoundErrorMessage.tsx
+++ b/superset-frontend/src/components/ErrorMessage/DatasetNotFoundErrorMessage.tsx
@@ -18,10 +18,10 @@
*/
import { t } from '@superset-ui/core';
-import { ErrorMessageComponentProps } from './types';
-import ErrorAlert from './ErrorAlert';
+import type { ErrorMessageComponentProps } from './types';
+import { ErrorAlert } from './ErrorAlert';
-function DatasetNotFoundErrorMessage({
+export function DatasetNotFoundErrorMessage({
error,
subtitle,
}: ErrorMessageComponentProps) {
@@ -35,5 +35,3 @@ function DatasetNotFoundErrorMessage({
/>
);
}
-
-export default DatasetNotFoundErrorMessage;
diff --git a/superset-frontend/src/components/ErrorMessage/ErrorAlert.stories.tsx b/superset-frontend/src/components/ErrorMessage/ErrorAlert.stories.tsx
index 89b38314eb3..e746afd747b 100644
--- a/superset-frontend/src/components/ErrorMessage/ErrorAlert.stories.tsx
+++ b/superset-frontend/src/components/ErrorMessage/ErrorAlert.stories.tsx
@@ -17,10 +17,10 @@
* under the License.
*/
import { Meta, StoryFn } from '@storybook/react';
-import Layout from 'src/components/Layout';
-import { Row, Col } from 'src/components/Grid';
-import Card from 'src/components/Card';
-import ErrorAlert from './ErrorAlert';
+import { Layout } from '../Layout';
+import { Card } from '../Card';
+import { Row, Col } from '../Grid';
+import { ErrorAlert } from './ErrorAlert';
const { Content } = Layout;
diff --git a/superset-frontend/src/components/ErrorMessage/ErrorAlert.test.tsx b/superset-frontend/src/components/ErrorMessage/ErrorAlert.test.tsx
index 706d59f1219..b6f819f409d 100644
--- a/superset-frontend/src/components/ErrorMessage/ErrorAlert.test.tsx
+++ b/superset-frontend/src/components/ErrorMessage/ErrorAlert.test.tsx
@@ -19,7 +19,7 @@
import { screen, fireEvent } from '@testing-library/react';
import { render } from 'spec/helpers/testing-library';
-import ErrorAlert from './ErrorAlert';
+import { ErrorAlert } from './ErrorAlert';
describe('ErrorAlert', () => {
it('renders the error message correctly', () => {
diff --git a/superset-frontend/src/components/ErrorMessage/ErrorAlert.tsx b/superset-frontend/src/components/ErrorMessage/ErrorAlert.tsx
index f1d31ba928a..0e4c332592a 100644
--- a/superset-frontend/src/components/ErrorMessage/ErrorAlert.tsx
+++ b/superset-frontend/src/components/ErrorMessage/ErrorAlert.tsx
@@ -17,28 +17,14 @@
* under the License.
*/
import { useState } from 'react';
-import { Tooltip } from 'src/components/Tooltip';
-import Modal from 'src/components/Modal';
import { Icons } from 'src/components/Icons';
-import Alert from 'src/components/Alert';
import { t, useTheme } from '@superset-ui/core';
+import { Tooltip } from '../Tooltip';
+import { Alert } from '../Alert';
+import { Modal } from '../Modal';
+import type { ErrorAlertProps } from './types';
-export interface ErrorAlertProps {
- errorType?: string; // Strong text on the first line
- message: React.ReactNode | string; // Text shown on the first line
- type?: 'warning' | 'error' | 'info'; // Allows only 'warning' or 'error'
- description?: React.ReactNode; // Text shown under the first line, not collapsible
- descriptionDetails?: React.ReactNode | string; // Text shown under the first line, collapsible
- descriptionDetailsCollapsed?: boolean; // Hides the collapsible section unless "Show more" is clicked, default true
- descriptionPre?: boolean; // Uses pre-style to break lines, default true
- compact?: boolean; // Shows the error icon with tooltip and modal, default false
- children?: React.ReactNode; // Additional content to show in the modal
- closable?: boolean; // Show close button, default true
- showIcon?: boolean; // Show icon, default true
- className?: string;
-}
-
-const ErrorAlert: React.FC = ({
+export const ErrorAlert: React.FC = ({
errorType = t('Error'),
message,
type = 'error',
@@ -112,7 +98,7 @@ const ErrorAlert: React.FC = ({
message={errorType}
description={renderDescription()}
type={type}
- showIcon
+ showIcon={showIcon}
closable={closable}
className={className}
/>
@@ -141,5 +127,3 @@ const ErrorAlert: React.FC = ({
return renderAlert(closable);
};
-
-export default ErrorAlert;
diff --git a/superset-frontend/src/components/ErrorMessage/ErrorMessageWithStackTrace.test.tsx b/superset-frontend/src/components/ErrorMessage/ErrorMessageWithStackTrace.test.tsx
index f9a3415ace2..b9003b5bfec 100644
--- a/superset-frontend/src/components/ErrorMessage/ErrorMessageWithStackTrace.test.tsx
+++ b/superset-frontend/src/components/ErrorMessage/ErrorMessageWithStackTrace.test.tsx
@@ -19,8 +19,8 @@
import { ErrorLevel, ErrorSource, ErrorTypeEnum } from '@superset-ui/core';
import { render, screen, userEvent } from 'spec/helpers/testing-library';
-import ErrorMessageWithStackTrace from './ErrorMessageWithStackTrace';
-import BasicErrorAlert from './BasicErrorAlert';
+import { ErrorMessageWithStackTrace } from './ErrorMessageWithStackTrace';
+import { BasicErrorAlert } from './BasicErrorAlert';
jest.mock(
'src/components/Icons/AsyncIcon',
diff --git a/superset-frontend/src/components/ErrorMessage/ErrorMessageWithStackTrace.tsx b/superset-frontend/src/components/ErrorMessage/ErrorMessageWithStackTrace.tsx
index b993927a7cd..86f36bcd723 100644
--- a/superset-frontend/src/components/ErrorMessage/ErrorMessageWithStackTrace.tsx
+++ b/superset-frontend/src/components/ErrorMessage/ErrorMessageWithStackTrace.tsx
@@ -18,8 +18,8 @@
*/
import { ReactNode } from 'react';
import { ErrorSource, t, SupersetError } from '@superset-ui/core';
-import getErrorMessageComponentRegistry from './getErrorMessageComponentRegistry';
-import ErrorAlert from './ErrorAlert';
+import { getErrorMessageComponentRegistry } from './getErrorMessageComponentRegistry';
+import { ErrorAlert } from './ErrorAlert';
const DEFAULT_TITLE = t('Unexpected error');
@@ -38,7 +38,7 @@ type Props = {
compact?: boolean;
};
-export default function ErrorMessageWithStackTrace({
+export function ErrorMessageWithStackTrace({
title = DEFAULT_TITLE,
error,
subtitle,
diff --git a/superset-frontend/src/components/ErrorMessage/FrontendNetworkErrorMessage.test.tsx b/superset-frontend/src/components/ErrorMessage/FrontendNetworkErrorMessage.test.tsx
index c364501c67d..32026052eed 100644
--- a/superset-frontend/src/components/ErrorMessage/FrontendNetworkErrorMessage.test.tsx
+++ b/superset-frontend/src/components/ErrorMessage/FrontendNetworkErrorMessage.test.tsx
@@ -19,7 +19,7 @@
import { ErrorLevel, ErrorSource, ErrorTypeEnum } from '@superset-ui/core';
import { render, screen, userEvent } from 'spec/helpers/testing-library';
-import FrontendNetworkErrorMessage from './FrontendNetworkErrorMessage';
+import { FrontendNetworkErrorMessage } from './FrontendNetworkErrorMessage';
jest.mock(
'src/components/Icons/AsyncIcon',
diff --git a/superset-frontend/src/components/ErrorMessage/FrontendNetworkErrorMessage.tsx b/superset-frontend/src/components/ErrorMessage/FrontendNetworkErrorMessage.tsx
index 303735ca49d..11a32a9682c 100644
--- a/superset-frontend/src/components/ErrorMessage/FrontendNetworkErrorMessage.tsx
+++ b/superset-frontend/src/components/ErrorMessage/FrontendNetworkErrorMessage.tsx
@@ -18,10 +18,10 @@
*/
import { t } from '@superset-ui/core';
-import { ErrorMessageComponentProps } from './types';
-import ErrorAlert from './ErrorAlert';
+import type { ErrorMessageComponentProps } from './types';
+import { ErrorAlert } from './ErrorAlert';
-function FrontendNetworkErrorMessage({
+export function FrontendNetworkErrorMessage({
error,
subtitle,
compact,
@@ -36,4 +36,3 @@ function FrontendNetworkErrorMessage({
/>
);
}
-export default FrontendNetworkErrorMessage;
diff --git a/superset-frontend/src/components/ErrorMessage/InvalidSQLErrorMessage.test.tsx b/superset-frontend/src/components/ErrorMessage/InvalidSQLErrorMessage.test.tsx
index 423566aa3a9..b19fa219b28 100644
--- a/superset-frontend/src/components/ErrorMessage/InvalidSQLErrorMessage.test.tsx
+++ b/superset-frontend/src/components/ErrorMessage/InvalidSQLErrorMessage.test.tsx
@@ -18,7 +18,7 @@
import { render, cleanup } from 'spec/helpers/testing-library';
import { ErrorLevel, ErrorSource, ErrorTypeEnum } from '@superset-ui/core';
-import InvalidSQLErrorMessage from './InvalidSQLErrorMessage';
+import { InvalidSQLErrorMessage } from './InvalidSQLErrorMessage';
const defaultProps = {
error: {
diff --git a/superset-frontend/src/components/ErrorMessage/InvalidSQLErrorMessage.tsx b/superset-frontend/src/components/ErrorMessage/InvalidSQLErrorMessage.tsx
index 21236e92a02..e25fa3aea9c 100644
--- a/superset-frontend/src/components/ErrorMessage/InvalidSQLErrorMessage.tsx
+++ b/superset-frontend/src/components/ErrorMessage/InvalidSQLErrorMessage.tsx
@@ -18,8 +18,8 @@
*/
import { t } from '@superset-ui/core';
-import { ErrorMessageComponentProps } from './types';
-import ErrorAlert from './ErrorAlert';
+import type { ErrorMessageComponentProps } from './types';
+import { ErrorAlert } from './ErrorAlert';
interface SupersetParseErrorExtra {
sql: string;
@@ -31,7 +31,7 @@ interface SupersetParseErrorExtra {
/*
* Component for showing syntax errors in SQL Lab.
*/
-function InvalidSQLErrorMessage({
+export function InvalidSQLErrorMessage({
error,
source,
subtitle,
@@ -60,5 +60,3 @@ function InvalidSQLErrorMessage({
/>
);
}
-
-export default InvalidSQLErrorMessage;
diff --git a/superset-frontend/src/components/ErrorMessage/IssueCode.test.tsx b/superset-frontend/src/components/ErrorMessage/IssueCode.test.tsx
index 7e75ae9067b..7c711397419 100644
--- a/superset-frontend/src/components/ErrorMessage/IssueCode.test.tsx
+++ b/superset-frontend/src/components/ErrorMessage/IssueCode.test.tsx
@@ -18,7 +18,7 @@
*/
import { render, screen } from 'spec/helpers/testing-library';
-import IssueCode from './IssueCode';
+import { IssueCode } from './IssueCode';
const mockedProps = {
code: 1,
diff --git a/superset-frontend/src/components/ErrorMessage/IssueCode.tsx b/superset-frontend/src/components/ErrorMessage/IssueCode.tsx
index af8ab9c7910..e0aacdbaab0 100644
--- a/superset-frontend/src/components/ErrorMessage/IssueCode.tsx
+++ b/superset-frontend/src/components/ErrorMessage/IssueCode.tsx
@@ -24,7 +24,7 @@ interface IssueCodeProps {
message: string;
}
-export default function IssueCode({ code, message }: IssueCodeProps) {
+export function IssueCode({ code, message }: IssueCodeProps) {
const theme = useTheme();
return (
<>
diff --git a/superset-frontend/src/components/ErrorMessage/MarshmallowErrorMessage.test.tsx b/superset-frontend/src/components/ErrorMessage/MarshmallowErrorMessage.test.tsx
index bde3ee0667b..c2f0a938ba7 100644
--- a/superset-frontend/src/components/ErrorMessage/MarshmallowErrorMessage.test.tsx
+++ b/superset-frontend/src/components/ErrorMessage/MarshmallowErrorMessage.test.tsx
@@ -19,7 +19,7 @@
import { render, screen, fireEvent } from 'spec/helpers/testing-library';
import { ErrorLevel, ErrorTypeEnum } from '@superset-ui/core';
-import MarshmallowErrorMessage from './MarshmallowErrorMessage';
+import { MarshmallowErrorMessage } from './MarshmallowErrorMessage';
describe('MarshmallowErrorMessage', () => {
const mockError = {
diff --git a/superset-frontend/src/components/ErrorMessage/MarshmallowErrorMessage.tsx b/superset-frontend/src/components/ErrorMessage/MarshmallowErrorMessage.tsx
index 0251de7882d..19f11fbef35 100644
--- a/superset-frontend/src/components/ErrorMessage/MarshmallowErrorMessage.tsx
+++ b/superset-frontend/src/components/ErrorMessage/MarshmallowErrorMessage.tsx
@@ -20,8 +20,8 @@ import { JSONTree } from 'react-json-tree';
import { styled, t } from '@superset-ui/core';
import { useJsonTreeTheme } from 'src/hooks/useJsonTreeTheme';
-import Collapse from 'src/components/Collapse';
-import { ErrorMessageComponentProps } from './types';
+import { Collapse } from '../Collapse';
+import type { ErrorMessageComponentProps } from './types';
interface MarshmallowErrorExtra {
messages: object;
@@ -64,7 +64,7 @@ const extractInvalidValues = (messages: object, payload: object): string[] => {
return invalidValues;
};
-export default function MarshmallowErrorMessage({
+export function MarshmallowErrorMessage({
error,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
source = 'crud',
diff --git a/superset-frontend/src/components/ErrorMessage/OAuth2RedirectMessage.test.tsx b/superset-frontend/src/components/ErrorMessage/OAuth2RedirectMessage.test.tsx
index 3edc1b7d6a6..99ecf894dc9 100644
--- a/superset-frontend/src/components/ErrorMessage/OAuth2RedirectMessage.test.tsx
+++ b/superset-frontend/src/components/ErrorMessage/OAuth2RedirectMessage.test.tsx
@@ -22,10 +22,10 @@ import { Provider } from 'react-redux';
import { createStore } from 'redux';
import { render, fireEvent, waitFor } from 'spec/helpers/testing-library';
import { ErrorLevel, ErrorSource, ErrorTypeEnum } from '@superset-ui/core';
-import OAuth2RedirectMessage from 'src/components/ErrorMessage/OAuth2RedirectMessage';
import { reRunQuery } from 'src/SqlLab/actions/sqlLab';
import { triggerQuery } from 'src/components/Chart/chartAction';
import { onRefresh } from 'src/dashboard/actions/dashboardState';
+import { OAuth2RedirectMessage } from '.';
// Mock the Redux store
const mockStore = createStore(() => ({
diff --git a/superset-frontend/src/components/ErrorMessage/OAuth2RedirectMessage.tsx b/superset-frontend/src/components/ErrorMessage/OAuth2RedirectMessage.tsx
index 0e2bad17d1c..0c5073dd57d 100644
--- a/superset-frontend/src/components/ErrorMessage/OAuth2RedirectMessage.tsx
+++ b/superset-frontend/src/components/ErrorMessage/OAuth2RedirectMessage.tsx
@@ -27,8 +27,8 @@ import { triggerQuery } from 'src/components/Chart/chartAction';
import { onRefresh } from 'src/dashboard/actions/dashboardState';
import { QueryResponse, t } from '@superset-ui/core';
-import { ErrorMessageComponentProps } from './types';
-import ErrorAlert from './ErrorAlert';
+import type { ErrorMessageComponentProps } from './types';
+import { ErrorAlert } from './ErrorAlert';
interface OAuth2RedirectExtra {
url: string;
@@ -59,7 +59,7 @@ interface OAuth2RedirectExtra {
* by the backend and sent from the opened tab to the original tab. For extra security,
* we also check that the source of the message is the opened tab via a ref.
*/
-function OAuth2RedirectMessage({
+export function OAuth2RedirectMessage({
error,
source,
}: ErrorMessageComponentProps) {
@@ -175,5 +175,3 @@ function OAuth2RedirectMessage({
/>
);
}
-
-export default OAuth2RedirectMessage;
diff --git a/superset-frontend/src/components/ErrorMessage/ParameterErrorMessage.test.tsx b/superset-frontend/src/components/ErrorMessage/ParameterErrorMessage.test.tsx
index e2fc8b92e80..1ad69a21d0a 100644
--- a/superset-frontend/src/components/ErrorMessage/ParameterErrorMessage.test.tsx
+++ b/superset-frontend/src/components/ErrorMessage/ParameterErrorMessage.test.tsx
@@ -19,7 +19,7 @@
import { ErrorLevel, ErrorSource, ErrorTypeEnum } from '@superset-ui/core';
import { render, screen, userEvent } from 'spec/helpers/testing-library';
-import ParameterErrorMessage from './ParameterErrorMessage';
+import { ParameterErrorMessage } from './ParameterErrorMessage';
jest.mock(
'src/components/Icons/AsyncIcon',
diff --git a/superset-frontend/src/components/ErrorMessage/ParameterErrorMessage.tsx b/superset-frontend/src/components/ErrorMessage/ParameterErrorMessage.tsx
index 5fbf31d1ffd..5a333fc3c17 100644
--- a/superset-frontend/src/components/ErrorMessage/ParameterErrorMessage.tsx
+++ b/superset-frontend/src/components/ErrorMessage/ParameterErrorMessage.tsx
@@ -21,8 +21,8 @@ import { t, tn } from '@superset-ui/core';
import levenshtein from 'js-levenshtein';
import { ErrorMessageComponentProps } from './types';
-import IssueCode from './IssueCode';
-import ErrorAlert from './ErrorAlert';
+import { IssueCode } from './IssueCode';
+import { ErrorAlert } from './ErrorAlert';
interface ParameterErrorExtra {
undefined_parameters?: string[];
@@ -51,7 +51,7 @@ const findMatches = (undefinedParameters: string[], templateKeys: string[]) => {
return matches;
};
-function ParameterErrorMessage({
+export function ParameterErrorMessage({
error,
source = 'sqllab',
subtitle,
@@ -117,5 +117,3 @@ function ParameterErrorMessage({
/>
);
}
-
-export default ParameterErrorMessage;
diff --git a/superset-frontend/src/components/ErrorMessage/TimeoutErrorMessage.test.tsx b/superset-frontend/src/components/ErrorMessage/TimeoutErrorMessage.test.tsx
index 8fb2e3d041d..fa10f0a474c 100644
--- a/superset-frontend/src/components/ErrorMessage/TimeoutErrorMessage.test.tsx
+++ b/superset-frontend/src/components/ErrorMessage/TimeoutErrorMessage.test.tsx
@@ -19,7 +19,7 @@
import { ErrorSource, ErrorTypeEnum, ErrorLevel } from '@superset-ui/core';
import { render, screen, userEvent } from 'spec/helpers/testing-library';
-import TimeoutErrorMessage from './TimeoutErrorMessage';
+import { TimeoutErrorMessage } from './TimeoutErrorMessage';
jest.mock(
'src/components/Icons/AsyncIcon',
diff --git a/superset-frontend/src/components/ErrorMessage/TimeoutErrorMessage.tsx b/superset-frontend/src/components/ErrorMessage/TimeoutErrorMessage.tsx
index f0df59e1474..64d3e48ff75 100644
--- a/superset-frontend/src/components/ErrorMessage/TimeoutErrorMessage.tsx
+++ b/superset-frontend/src/components/ErrorMessage/TimeoutErrorMessage.tsx
@@ -19,9 +19,9 @@
import { ReactNode } from 'react';
import { t, tn } from '@superset-ui/core';
-import { ErrorMessageComponentProps } from './types';
-import IssueCode from './IssueCode';
-import ErrorAlert from './ErrorAlert';
+import type { ErrorMessageComponentProps } from './types';
+import { IssueCode } from './IssueCode';
+import { ErrorAlert } from './ErrorAlert';
interface TimeoutErrorExtra {
issue_codes: {
@@ -32,7 +32,7 @@ interface TimeoutErrorExtra {
timeout: number;
}
-function TimeoutErrorMessage({
+export function TimeoutErrorMessage({
error,
source,
}: ErrorMessageComponentProps) {
@@ -97,5 +97,3 @@ function TimeoutErrorMessage({
/>
);
}
-
-export default TimeoutErrorMessage;
diff --git a/superset-frontend/src/components/ErrorMessage/getErrorMessageComponentRegistry.test.tsx b/superset-frontend/src/components/ErrorMessage/getErrorMessageComponentRegistry.test.tsx
index 03c7c4be705..0d54b546571 100644
--- a/superset-frontend/src/components/ErrorMessage/getErrorMessageComponentRegistry.test.tsx
+++ b/superset-frontend/src/components/ErrorMessage/getErrorMessageComponentRegistry.test.tsx
@@ -16,8 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
-import getErrorMessageComponentRegistry from 'src/components/ErrorMessage/getErrorMessageComponentRegistry';
-import { ErrorMessageComponentProps } from 'src/components/ErrorMessage/types';
+import type { ErrorMessageComponentProps } from './types';
+import { getErrorMessageComponentRegistry } from './getErrorMessageComponentRegistry';
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const ERROR_MESSAGE_COMPONENT = (_: ErrorMessageComponentProps) => (
diff --git a/superset-frontend/src/components/ErrorMessage/getErrorMessageComponentRegistry.ts b/superset-frontend/src/components/ErrorMessage/getErrorMessageComponentRegistry.ts
index 9f69f9ab2d8..3e6f057edc8 100644
--- a/superset-frontend/src/components/ErrorMessage/getErrorMessageComponentRegistry.ts
+++ b/superset-frontend/src/components/ErrorMessage/getErrorMessageComponentRegistry.ts
@@ -17,7 +17,7 @@
* under the License.
*/
import { Registry, makeSingleton, OverwritePolicy } from '@superset-ui/core';
-import { ErrorMessageComponent } from './types';
+import type { ErrorMessageComponent } from './types';
class ErrorMessageComponentRegistry extends Registry<
ErrorMessageComponent,
@@ -31,8 +31,6 @@ class ErrorMessageComponentRegistry extends Registry<
}
}
-const getErrorMessageComponentRegistry = makeSingleton(
+export const getErrorMessageComponentRegistry = makeSingleton(
ErrorMessageComponentRegistry,
);
-
-export default getErrorMessageComponentRegistry;
diff --git a/superset-frontend/src/components/ErrorMessage/index.tsx b/superset-frontend/src/components/ErrorMessage/index.tsx
new file mode 100644
index 00000000000..c8898acfc31
--- /dev/null
+++ b/superset-frontend/src/components/ErrorMessage/index.tsx
@@ -0,0 +1,33 @@
+/**
+ * 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.
+ */
+export { BasicErrorAlert } from './BasicErrorAlert';
+export { DatabaseErrorMessage } from './DatabaseErrorMessage';
+export { DatasetNotFoundErrorMessage } from './DatasetNotFoundErrorMessage';
+export { ErrorAlert } from './ErrorAlert';
+export { ErrorMessageWithStackTrace } from './ErrorMessageWithStackTrace';
+export { getErrorMessageComponentRegistry } from './getErrorMessageComponentRegistry';
+export { FrontendNetworkErrorMessage } from './FrontendNetworkErrorMessage';
+export { InvalidSQLErrorMessage } from './InvalidSQLErrorMessage';
+export { IssueCode } from './IssueCode';
+export { MarshmallowErrorMessage } from './MarshmallowErrorMessage';
+export { OAuth2RedirectMessage } from './OAuth2RedirectMessage';
+export { ParameterErrorMessage } from './ParameterErrorMessage';
+export { TimeoutErrorMessage } from './TimeoutErrorMessage';
+
+export type { ErrorAlertProps, ErrorMessageComponentProps } from './types';
diff --git a/superset-frontend/src/components/ErrorMessage/types.ts b/superset-frontend/src/components/ErrorMessage/types.ts
index bb3d39c255f..de38332fa6b 100644
--- a/superset-frontend/src/components/ErrorMessage/types.ts
+++ b/superset-frontend/src/components/ErrorMessage/types.ts
@@ -17,8 +17,8 @@
* under the License.
*/
-import { ReactNode, ComponentType } from 'react';
-import { ErrorSource, SupersetError } from '@superset-ui/core';
+import type { ReactNode, ComponentType } from 'react';
+import type { ErrorSource, SupersetError } from '@superset-ui/core';
export type ErrorMessageComponentProps | null> =
{
@@ -29,3 +29,18 @@ export type ErrorMessageComponentProps | null> =
};
export type ErrorMessageComponent = ComponentType;
+
+export interface ErrorAlertProps {
+ errorType?: string; // Strong text on the first line
+ message: React.ReactNode | string; // Text shown on the first line
+ type?: 'warning' | 'error' | 'info'; // Allows only 'warning' or 'error'
+ description?: React.ReactNode; // Text shown under the first line, not collapsible
+ descriptionDetails?: React.ReactNode | string; // Text shown under the first line, collapsible
+ descriptionDetailsCollapsed?: boolean; // Hides the collapsible section unless "Show more" is clicked, default true
+ descriptionPre?: boolean; // Uses pre-style to break lines, default true
+ compact?: boolean; // Shows the error icon with tooltip and modal, default false
+ children?: React.ReactNode; // Additional content to show in the modal
+ closable?: boolean; // Show close button, default true
+ showIcon?: boolean; // Show icon, default true
+ className?: string;
+}
diff --git a/superset-frontend/src/components/FacePile/FacePile.stories.tsx b/superset-frontend/src/components/FacePile/FacePile.stories.tsx
index d9db309a6db..b3e122c056a 100644
--- a/superset-frontend/src/components/FacePile/FacePile.stories.tsx
+++ b/superset-frontend/src/components/FacePile/FacePile.stories.tsx
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-import FacePile from '.';
+import { FacePile } from '.';
export default {
title: 'Components/FacePile',
diff --git a/superset-frontend/src/components/FacePile/FacePile.test.tsx b/superset-frontend/src/components/FacePile/FacePile.test.tsx
index f947ad4c8e2..80fade7d8ce 100644
--- a/superset-frontend/src/components/FacePile/FacePile.test.tsx
+++ b/superset-frontend/src/components/FacePile/FacePile.test.tsx
@@ -18,7 +18,7 @@
*/
import { act, fireEvent, render, screen } from 'spec/helpers/testing-library';
import { store } from 'src/views/store';
-import FacePile from '.';
+import { FacePile } from '.';
import { getRandomColor } from './utils';
const users = [...new Array(10)].map((_, i) => ({
diff --git a/superset-frontend/src/components/FacePile/index.tsx b/superset-frontend/src/components/FacePile/index.tsx
index b4c12c48f47..f060e41ed28 100644
--- a/superset-frontend/src/components/FacePile/index.tsx
+++ b/superset-frontend/src/components/FacePile/index.tsx
@@ -16,25 +16,21 @@
* specific language governing permissions and limitations
* under the License.
*/
-import type Owner from 'src/types/Owner';
+
import {
getCategoricalSchemeRegistry,
isFeatureEnabled,
FeatureFlag,
} from '@superset-ui/core';
import getOwnerName from 'src/utils/getOwnerName';
-import { Tooltip } from 'src/components/Tooltip';
-import { Avatar, AvatarGroup } from 'src/components/Avatar';
+import { Tooltip } from '../Tooltip';
+import { Avatar, AvatarGroup } from '../Avatar';
import { getRandomColor } from './utils';
-
-interface FacePileProps {
- users: Owner[];
- maxCount?: number;
-}
+import type { FacePileProps } from './types';
const colorList = getCategoricalSchemeRegistry().get()?.colors ?? [];
-export default function FacePile({ users, maxCount = 4 }: FacePileProps) {
+export function FacePile({ users, maxCount = 4 }: FacePileProps) {
return (
{users.map(user => {
@@ -64,3 +60,5 @@ export default function FacePile({ users, maxCount = 4 }: FacePileProps) {
);
}
+
+export type { FacePileProps };
diff --git a/superset-frontend/src/components/FacePile/types.ts b/superset-frontend/src/components/FacePile/types.ts
new file mode 100644
index 00000000000..2fffa11b0e5
--- /dev/null
+++ b/superset-frontend/src/components/FacePile/types.ts
@@ -0,0 +1,24 @@
+/**
+ * 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 type Owner from 'src/types/Owner';
+
+export interface FacePileProps {
+ users: Owner[];
+ maxCount?: number;
+}
diff --git a/superset-frontend/src/components/FaveStar/FaveStar.stories.tsx b/superset-frontend/src/components/FaveStar/FaveStar.stories.tsx
index 7c993d6fac2..6834c4495c2 100644
--- a/superset-frontend/src/components/FaveStar/FaveStar.stories.tsx
+++ b/superset-frontend/src/components/FaveStar/FaveStar.stories.tsx
@@ -17,7 +17,7 @@
* under the License.
*/
import type { Meta, StoryObj } from '@storybook/react';
-import FaveStar from 'src/components/FaveStar';
+import { FaveStar } from '.';
export default {
title: 'Components/FaveStar',
diff --git a/superset-frontend/src/components/FaveStar/FaveStar.test.tsx b/superset-frontend/src/components/FaveStar/FaveStar.test.tsx
index f8c63500f6a..89a51085768 100644
--- a/superset-frontend/src/components/FaveStar/FaveStar.test.tsx
+++ b/superset-frontend/src/components/FaveStar/FaveStar.test.tsx
@@ -18,7 +18,7 @@
*/
import { render, screen, userEvent } from 'spec/helpers/testing-library';
-import FaveStar from '.';
+import { FaveStar } from '.';
jest.mock('src/components/Tooltip', () => ({
Tooltip: (props: any) => ,
diff --git a/superset-frontend/src/components/FaveStar/index.tsx b/superset-frontend/src/components/FaveStar/index.tsx
index d349640ba97..c150fc3a839 100644
--- a/superset-frontend/src/components/FaveStar/index.tsx
+++ b/superset-frontend/src/components/FaveStar/index.tsx
@@ -20,16 +20,9 @@
import { useCallback, useEffect, MouseEvent } from 'react';
import { css, t, styled, useTheme } from '@superset-ui/core';
-import { Tooltip } from 'src/components/Tooltip';
import { Icons } from 'src/components/Icons';
-
-export interface FaveStarProps {
- itemId: number;
- isStarred?: boolean;
- showTooltip?: boolean;
- saveFaveStar(id: number, isStarred: boolean): any;
- fetchFaveStar?: (id: number) => void;
-}
+import { Tooltip } from '../Tooltip';
+import type { FaveStarProps } from './types';
const StyledLink = styled.a`
${({ theme }) => css`
@@ -39,7 +32,7 @@ const StyledLink = styled.a`
`};
`;
-const FaveStar = ({
+export const FaveStar = ({
itemId,
isStarred,
showTooltip,
@@ -96,4 +89,5 @@ const FaveStar = ({
return content;
};
-export default FaveStar;
+
+export type { FaveStarProps };
diff --git a/superset-frontend/src/components/FaveStar/types.ts b/superset-frontend/src/components/FaveStar/types.ts
new file mode 100644
index 00000000000..cc69a957167
--- /dev/null
+++ b/superset-frontend/src/components/FaveStar/types.ts
@@ -0,0 +1,25 @@
+/**
+ * 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.
+ */
+export interface FaveStarProps {
+ itemId: number;
+ isStarred?: boolean;
+ showTooltip?: boolean;
+ saveFaveStar(id: number, isStarred: boolean): any;
+ fetchFaveStar?: (id: number) => void;
+}
diff --git a/superset-frontend/src/components/FilterableTable/FilterableTable.stories.tsx b/superset-frontend/src/components/FilterableTable/FilterableTable.stories.tsx
index f4525f304e5..d77e270d079 100644
--- a/superset-frontend/src/components/FilterableTable/FilterableTable.stories.tsx
+++ b/superset-frontend/src/components/FilterableTable/FilterableTable.stories.tsx
@@ -16,7 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
-import FilterableTable, { FilterableTableProps } from '.';
+import type { FilterableTableProps } from './types';
+import { FilterableTable } from '.';
export default {
title: 'Components/FilterableTable',
diff --git a/superset-frontend/src/components/FilterableTable/FilterableTable.test.tsx b/superset-frontend/src/components/FilterableTable/FilterableTable.test.tsx
index 8e07d0e97f4..b5a5ceaeec5 100644
--- a/superset-frontend/src/components/FilterableTable/FilterableTable.test.tsx
+++ b/superset-frontend/src/components/FilterableTable/FilterableTable.test.tsx
@@ -17,7 +17,6 @@
* under the License.
*/
import { isValidElement } from 'react';
-import FilterableTable from 'src/components/FilterableTable';
import {
render,
screen,
@@ -25,6 +24,7 @@ import {
within,
} from 'spec/helpers/testing-library';
import { setupAGGridModules } from 'src/setup/setupAGGridModules';
+import { FilterableTable } from '.';
describe('FilterableTable', () => {
beforeAll(() => {
diff --git a/superset-frontend/src/components/FilterableTable/index.tsx b/superset-frontend/src/components/FilterableTable/index.tsx
index 920e7d68cd6..989aad50315 100644
--- a/superset-frontend/src/components/FilterableTable/index.tsx
+++ b/superset-frontend/src/components/FilterableTable/index.tsx
@@ -18,9 +18,13 @@
*/
import { useMemo, useRef, useCallback } from 'react';
import { styled } from '@superset-ui/core';
+import type { ColDef } from '../GridTable/types';
+import { GridSize } from '../GridTable/constants';
+import { GridTable } from '../GridTable';
import { useCellContentParser } from './useCellContentParser';
import { renderResultCell } from './utils';
-import GridTable, { GridSize, ColDef } from '../GridTable';
+
+import type { FilterableTableProps, Datum, CellDataType } from './types';
// This regex handles all possible number formats in javascript, including ints, floats,
// exponential notation, NaN, and Infinity.
@@ -32,23 +36,6 @@ const StyledFilterableTable = styled.div`
overflow: hidden;
`;
-type CellDataType = string | number | null;
-type Datum = Record;
-
-export interface FilterableTableProps {
- orderedColumnKeys: string[];
- data: Record[];
- height: number;
- filterText?: string;
- headerHeight?: number;
- overscanColumnCount?: number;
- overscanRowCount?: number;
- rowHeight?: number;
- striped?: boolean;
- expandedColumns?: string[];
- allowHTML?: boolean;
-}
-
const parseNumberFromString = (value: string | number | null) => {
if (typeof value === 'string' && ONLY_NUMBER_REGEX.test(value)) {
return parseFloat(value);
@@ -76,7 +63,7 @@ const sortResults = (valueA: string | number, valueB: string | number) => {
return aValue < bValue ? -1 : 1;
};
-const FilterableTable = ({
+export const FilterableTable = ({
orderedColumnKeys,
data,
height,
@@ -159,4 +146,4 @@ const FilterableTable = ({
);
};
-export default FilterableTable;
+export type { FilterableTableProps };
diff --git a/superset-frontend/src/components/FilterableTable/types.ts b/superset-frontend/src/components/FilterableTable/types.ts
new file mode 100644
index 00000000000..97292aedd45
--- /dev/null
+++ b/superset-frontend/src/components/FilterableTable/types.ts
@@ -0,0 +1,34 @@
+/**
+ * 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.
+ */
+export type CellDataType = string | number | null;
+export type Datum = Record;
+
+export interface FilterableTableProps {
+ orderedColumnKeys: string[];
+ data: Record[];
+ height: number;
+ filterText?: string;
+ headerHeight?: number;
+ overscanColumnCount?: number;
+ overscanRowCount?: number;
+ rowHeight?: number;
+ striped?: boolean;
+ expandedColumns?: string[];
+ allowHTML?: boolean;
+}
diff --git a/superset-frontend/src/components/FilterableTable/utils.tsx b/superset-frontend/src/components/FilterableTable/utils.tsx
index a4e4a4c8445..c0c8b576657 100644
--- a/superset-frontend/src/components/FilterableTable/utils.tsx
+++ b/superset-frontend/src/components/FilterableTable/utils.tsx
@@ -16,8 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { JsonModal, safeJsonObjectParse } from 'src/components/JsonModal';
import { t, safeHtmlSpan } from '@superset-ui/core';
+import { JsonModal } from '../JsonModal';
+import { safeJsonObjectParse } from '../JsonModal/utils';
import { NULL_STRING, CellDataType } from './useCellContentParser';
type CellParams = {
diff --git a/superset-frontend/src/components/FlashProvider/FlashProvider.test.tsx b/superset-frontend/src/components/FlashProvider/FlashProvider.test.tsx
index f7e41d9a766..6b93e4009d7 100644
--- a/superset-frontend/src/components/FlashProvider/FlashProvider.test.tsx
+++ b/superset-frontend/src/components/FlashProvider/FlashProvider.test.tsx
@@ -20,7 +20,8 @@
import { render, screen } from 'spec/helpers/testing-library';
import { Provider } from 'react-redux';
import { store } from 'src/views/store';
-import FlashProvider, { FlashMessage } from './index';
+import type { FlashMessage } from './types';
+import { FlashProvider } from '.';
test('Rerendering correctly with default props', () => {
const messages: FlashMessage[] = [];
diff --git a/superset-frontend/src/components/FlashProvider/index.tsx b/superset-frontend/src/components/FlashProvider/index.tsx
index b9e8e4a8e21..d6c07d4652b 100644
--- a/superset-frontend/src/components/FlashProvider/index.tsx
+++ b/superset-frontend/src/components/FlashProvider/index.tsx
@@ -18,9 +18,7 @@
*/
import { useToasts } from 'src/components/MessageToasts/withToasts';
import { useComponentDidMount } from '@superset-ui/core';
-
-type FlashMessageType = 'info' | 'alert' | 'danger' | 'warning' | 'success';
-export type FlashMessage = [FlashMessageType, string];
+import type { FlashMessage } from './types';
interface Props {
children: JSX.Element;
@@ -35,7 +33,7 @@ const flashObj = {
success: 'addSuccessToast',
};
-export default function FlashProvider({ children, messages }: Props) {
+export function FlashProvider({ children, messages }: Props) {
const toasts = useToasts();
useComponentDidMount(() => {
messages.forEach(message => {
@@ -49,3 +47,5 @@ export default function FlashProvider({ children, messages }: Props) {
});
return children;
}
+
+export type { FlashMessage };
diff --git a/superset-frontend/src/components/FlashProvider/types.ts b/superset-frontend/src/components/FlashProvider/types.ts
new file mode 100644
index 00000000000..8716eb985bb
--- /dev/null
+++ b/superset-frontend/src/components/FlashProvider/types.ts
@@ -0,0 +1,20 @@
+/**
+ * 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.
+ */
+type FlashMessageType = 'info' | 'alert' | 'danger' | 'warning' | 'success';
+export type FlashMessage = [FlashMessageType, string];
diff --git a/superset-frontend/src/components/Flex/Flex.stories.tsx b/superset-frontend/src/components/Flex/Flex.stories.tsx
index 7e7b1c5b194..d666ee920d0 100644
--- a/superset-frontend/src/components/Flex/Flex.stories.tsx
+++ b/superset-frontend/src/components/Flex/Flex.stories.tsx
@@ -17,8 +17,9 @@
* under the License.
*/
-import { Flex, FlexProps } from 'src/components/Flex';
import { css } from '@superset-ui/core';
+import { Flex } from '.';
+import type { FlexProps } from './types';
export default {
title: 'Design System/Components/Flex',
diff --git a/superset-frontend/src/components/Flex/Flex.test.tsx b/superset-frontend/src/components/Flex/Flex.test.tsx
index 863c3a012ca..dbbca7983e0 100644
--- a/superset-frontend/src/components/Flex/Flex.test.tsx
+++ b/superset-frontend/src/components/Flex/Flex.test.tsx
@@ -18,7 +18,7 @@
*/
import { render } from 'spec/helpers/testing-library';
-import { Flex } from 'src/components/Flex';
+import { Flex } from '.';
test('should render', () => {
const { container } = render(
diff --git a/superset-frontend/src/components/Flex/index.tsx b/superset-frontend/src/components/Flex/index.tsx
index bed64a5949d..5f04bd6327b 100644
--- a/superset-frontend/src/components/Flex/index.tsx
+++ b/superset-frontend/src/components/Flex/index.tsx
@@ -18,10 +18,10 @@
*/
import { Flex as AntdFlex } from 'antd-v5';
-import { ComponentProps } from 'react';
-
-export type FlexProps = ComponentProps;
+import type { FlexProps } from './types';
export function Flex(props: FlexProps) {
return ;
}
+
+export type { FlexProps };
diff --git a/superset-frontend/src/components/Flex/types.ts b/superset-frontend/src/components/Flex/types.ts
new file mode 100644
index 00000000000..dda4ea762f2
--- /dev/null
+++ b/superset-frontend/src/components/Flex/types.ts
@@ -0,0 +1,22 @@
+/**
+ * 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 { Flex as AntdFlex } from 'antd-v5';
+import { ComponentProps } from 'react';
+
+export type FlexProps = ComponentProps;
diff --git a/superset-frontend/src/components/Form/Form.tsx b/superset-frontend/src/components/Form/Form.tsx
index dcbcc173a34..113d36953ab 100644
--- a/superset-frontend/src/components/Form/Form.tsx
+++ b/superset-frontend/src/components/Form/Form.tsx
@@ -17,18 +17,16 @@
* under the License.
*/
import { Form as AntdForm } from 'antd-v5';
-import { FormProps, FormInstance, FormItemProps } from 'antd-v5/es/form';
+import { FormProps } from './types';
-function Form(props: FormProps) {
+function CustomForm(props: FormProps) {
return ;
}
-export default Object.assign(Form, {
+export const Form = Object.assign(CustomForm, {
useForm: AntdForm.useForm,
Item: AntdForm.Item,
List: AntdForm.List,
ErrorList: AntdForm.ErrorList,
Provider: AntdForm.Provider,
});
-
-export type { FormProps, FormInstance, FormItemProps };
diff --git a/superset-frontend/src/components/Form/FormItem.tsx b/superset-frontend/src/components/Form/FormItem.tsx
index 84bd2b180d6..e77296213b0 100644
--- a/superset-frontend/src/components/Form/FormItem.tsx
+++ b/superset-frontend/src/components/Form/FormItem.tsx
@@ -19,7 +19,7 @@
import { Form } from 'antd-v5';
import { styled } from '@superset-ui/core';
-const StyledItem = styled(Form.Item)`
+export const FormItem = styled(Form.Item)`
${({ theme }) => `
margin-bottom: 0;
.antd5-form-item-label {
@@ -40,5 +40,3 @@ const StyledItem = styled(Form.Item)`
}
`}
`;
-
-export default StyledItem;
diff --git a/superset-frontend/src/components/Form/FormLabel.tsx b/superset-frontend/src/components/Form/FormLabel.tsx
index 6e33fb98a6e..f6b3fcbdfd3 100644
--- a/superset-frontend/src/components/Form/FormLabel.tsx
+++ b/superset-frontend/src/components/Form/FormLabel.tsx
@@ -40,7 +40,7 @@ const Label = styled.label<{ required?: boolean }>`
`}
`;
-export default function FormLabel({
+export function FormLabel({
children,
htmlFor,
required = false,
diff --git a/superset-frontend/src/components/Form/LabeledErrorBoundInput.stories.tsx b/superset-frontend/src/components/Form/LabeledErrorBoundInput.stories.tsx
index dbe922200d2..28b2b5f1add 100644
--- a/superset-frontend/src/components/Form/LabeledErrorBoundInput.stories.tsx
+++ b/superset-frontend/src/components/Form/LabeledErrorBoundInput.stories.tsx
@@ -17,9 +17,8 @@
* under the License.
*/
import { useState } from 'react';
-import LabeledErrorBoundInput, {
- LabeledErrorBoundInputProps,
-} from './LabeledErrorBoundInput';
+import type { LabeledErrorBoundInputProps } from './types';
+import { LabeledErrorBoundInput } from './LabeledErrorBoundInput';
export default {
title: 'Components/Form/LabeledErrorBoundInput',
diff --git a/superset-frontend/src/components/Form/LabeledErrorBoundInput.test.jsx b/superset-frontend/src/components/Form/LabeledErrorBoundInput.test.jsx
index c5ed00830d2..03cfdf15ea5 100644
--- a/superset-frontend/src/components/Form/LabeledErrorBoundInput.test.jsx
+++ b/superset-frontend/src/components/Form/LabeledErrorBoundInput.test.jsx
@@ -17,7 +17,7 @@
* under the License.
*/
import { render, fireEvent, screen } from 'spec/helpers/testing-library';
-import LabeledErrorBoundInput from 'src/components/Form/LabeledErrorBoundInput';
+import { LabeledErrorBoundInput } from './LabeledErrorBoundInput';
const defaultProps = {
id: 1,
diff --git a/superset-frontend/src/components/Form/LabeledErrorBoundInput.tsx b/superset-frontend/src/components/Form/LabeledErrorBoundInput.tsx
index a4f37676b61..1e0be2ae195 100644
--- a/superset-frontend/src/components/Form/LabeledErrorBoundInput.tsx
+++ b/superset-frontend/src/components/Form/LabeledErrorBoundInput.tsx
@@ -17,30 +17,15 @@
* under the License.
*/
import { styled, css, SupersetTheme, t } from '@superset-ui/core';
-import { Tooltip } from 'src/components/Tooltip';
-import { Input } from 'src/components/Input';
-import InfoTooltip from 'src/components/InfoTooltip';
import { Icons } from 'src/components/Icons';
-import Button from 'src/components/Button';
import errorIcon from 'src/assets/images/icons/error.svg';
-import FormItem from './FormItem';
-import FormLabel from './FormLabel';
-
-export interface LabeledErrorBoundInputProps {
- label?: string;
- validationMethods:
- | { onBlur: (value: any) => void }
- | { onChange: (value: any) => void };
- errorMessage?: string | null;
- helpText?: string;
- required?: boolean;
- hasTooltip?: boolean;
- tooltipText?: string | null;
- id?: string;
- classname?: string;
- visibilityToggle?: boolean;
- [x: string]: any;
-}
+import { Button } from '../Button';
+import { InfoTooltip } from '../InfoTooltip';
+import { Input } from '../Input';
+import { Tooltip } from '../Tooltip';
+import { FormItem } from './FormItem';
+import { FormLabel } from './FormLabel';
+import type { LabeledErrorBoundInputProps } from './types';
const StyledInput = styled(Input)`
margin: ${({ theme }) => `${theme.sizeUnit}px 0 ${theme.sizeUnit * 2}px`};
@@ -99,7 +84,7 @@ const iconReset = css`
}
`;
-const LabeledErrorBoundInput = ({
+export const LabeledErrorBoundInput = ({
label,
validationMethods,
errorMessage,
@@ -169,5 +154,3 @@ const LabeledErrorBoundInput = ({
);
-
-export default LabeledErrorBoundInput;
diff --git a/superset-frontend/src/components/Form/index.tsx b/superset-frontend/src/components/Form/index.tsx
index 7af2de01738..ba225fb56dc 100644
--- a/superset-frontend/src/components/Form/index.tsx
+++ b/superset-frontend/src/components/Form/index.tsx
@@ -16,10 +16,10 @@
* specific language governing permissions and limitations
* under the License.
*/
-import Form, { FormProps, FormItemProps, FormInstance } from './Form';
-import FormItem from './FormItem';
-import FormLabel from './FormLabel';
-import LabeledErrorBoundInput from './LabeledErrorBoundInput';
+import { Form } from './Form';
+import { FormItem } from './FormItem';
+import { FormLabel } from './FormLabel';
+import { LabeledErrorBoundInput } from './LabeledErrorBoundInput';
export { Form, FormItem, FormLabel, LabeledErrorBoundInput };
-export type { FormProps, FormItemProps, FormInstance };
+export type { FormInstance, FormProps, FormItemProps } from './types';
diff --git a/superset-frontend/src/components/Form/types.ts b/superset-frontend/src/components/Form/types.ts
new file mode 100644
index 00000000000..50d82c16d06
--- /dev/null
+++ b/superset-frontend/src/components/Form/types.ts
@@ -0,0 +1,35 @@
+/**
+ * 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.
+ */
+export type { FormProps, FormInstance, FormItemProps } from 'antd-v5/es/form';
+
+export interface LabeledErrorBoundInputProps {
+ label?: string;
+ validationMethods:
+ | { onBlur: (value: any) => void }
+ | { onChange: (value: any) => void };
+ errorMessage?: string | null;
+ helpText?: string;
+ required?: boolean;
+ hasTooltip?: boolean;
+ tooltipText?: string | null;
+ id?: string;
+ classname?: string;
+ visibilityToggle?: boolean;
+ [x: string]: any;
+}
diff --git a/superset-frontend/src/components/FormRow/FormRow.test.jsx b/superset-frontend/src/components/FormRow/FormRow.test.jsx
deleted file mode 100644
index 66bf5977b18..00000000000
--- a/superset-frontend/src/components/FormRow/FormRow.test.jsx
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * 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 { render } from 'spec/helpers/testing-library';
-
-import TextControl from 'src/explore/components/controls/TextControl';
-import FormRow from 'src/components/FormRow';
-
-jest.mock('@superset-ui/chart-controls', () => ({
- ...jest.requireActual('@superset-ui/chart-controls'),
- InfoTooltipWithTrigger: () => ,
-}));
-jest.mock('src/components/Grid', () => ({
- ...jest.requireActual('src/components'),
- Row: ({ children }) =>
{children}
,
- Col: ({ children }) =>
{children}
,
-}));
-
-const defaultProps = {
- label: 'Hello',
- tooltip: 'A tooltip',
- control: ,
-};
-
-const setup = (overrideProps = {}) => {
- const props = {
- ...defaultProps,
- ...overrideProps,
- };
- return render();
-};
-
-test('renders an InfoTooltipWithTrigger only if needed', () => {
- const { getByTestId, queryByTestId, rerender } = setup();
- expect(getByTestId('mock-info-tooltip')).toBeInTheDocument();
- rerender();
- expect(queryByTestId('mock-info-tooltip')).not.toBeInTheDocument();
-});
-
-test('renders a Row and 2 Cols', () => {
- const { getByTestId, getAllByTestId } = setup();
- expect(getByTestId('mock-row')).toBeInTheDocument();
- expect(getAllByTestId('mock-col')).toHaveLength(2);
-});
diff --git a/superset-frontend/src/components/FormRow/index.jsx b/superset-frontend/src/components/FormRow/index.jsx
deleted file mode 100644
index 5cbf1763eb9..00000000000
--- a/superset-frontend/src/components/FormRow/index.jsx
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * 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 PropTypes from 'prop-types';
-import { Row, Col } from 'src/components/Grid';
-
-import { InfoTooltipWithTrigger } from '@superset-ui/chart-controls';
-
-const STYLE_ROW = { marginTop: '5px', minHeight: '30px' };
-const STYLE_RALIGN = { textAlign: 'right' };
-
-const propTypes = {
- label: PropTypes.string.isRequired,
- tooltip: PropTypes.string,
- control: PropTypes.node.isRequired,
- isCheckbox: PropTypes.bool,
-};
-
-const defaultProps = {
- tooltip: null,
- isCheckbox: false,
-};
-
-export default function FormRow({ label, tooltip, control, isCheckbox }) {
- const labelAndTooltip = (
-
- {label}{' '}
- {tooltip && (
-
- )}
-
- );
- if (isCheckbox) {
- return (
-
-
- {control}
-
-
- {labelAndTooltip}
-
-
- );
- }
- return (
-
-
- {labelAndTooltip}
-
-
- {control}
-
-
- );
-}
-FormRow.propTypes = propTypes;
-FormRow.defaultProps = defaultProps;
diff --git a/superset-frontend/src/components/GenericLink/GenericLink.test.tsx b/superset-frontend/src/components/GenericLink/GenericLink.test.tsx
index 33681823ea3..7d30215e2e1 100644
--- a/superset-frontend/src/components/GenericLink/GenericLink.test.tsx
+++ b/superset-frontend/src/components/GenericLink/GenericLink.test.tsx
@@ -18,7 +18,7 @@
*/
import { render, screen } from 'spec/helpers/testing-library';
-import { GenericLink } from './GenericLink';
+import { GenericLink } from '.';
test('renders', () => {
render(Link to Explore, {
diff --git a/superset-frontend/src/components/GenericLink/GenericLink.tsx b/superset-frontend/src/components/GenericLink/index.tsx
similarity index 100%
rename from superset-frontend/src/components/GenericLink/GenericLink.tsx
rename to superset-frontend/src/components/GenericLink/index.tsx
diff --git a/superset-frontend/src/components/Grid/Grid.stories.tsx b/superset-frontend/src/components/Grid/Grid.stories.tsx
index aabe727f456..30137208660 100644
--- a/superset-frontend/src/components/Grid/Grid.stories.tsx
+++ b/superset-frontend/src/components/Grid/Grid.stories.tsx
@@ -19,7 +19,8 @@
import { Meta, StoryObj } from '@storybook/react';
import Slider from 'src/components/Slider/index';
import { useState } from 'react';
-import { Row, Col, ColProps, RowProps } from './index';
+import { Row, Col } from '.';
+import type { ColProps, RowProps } from './types';
export default {
title: 'Design System/Components/Grid',
diff --git a/superset-frontend/src/components/Grid/Grid.test.tsx b/superset-frontend/src/components/Grid/Grid.test.tsx
index 45d46881d83..36174906e09 100644
--- a/superset-frontend/src/components/Grid/Grid.test.tsx
+++ b/superset-frontend/src/components/Grid/Grid.test.tsx
@@ -18,7 +18,7 @@
*/
import { render, screen } from '@testing-library/react';
import '@testing-library/jest-dom';
-import { Col, Row } from './index';
+import { Col, Row } from '.';
describe('Grid Component', () => {
it('should render the grid with rows and columns', async () => {
diff --git a/superset-frontend/src/components/Grid/index.tsx b/superset-frontend/src/components/Grid/index.tsx
index 016de2c24b5..0b65a4db16a 100644
--- a/superset-frontend/src/components/Grid/index.tsx
+++ b/superset-frontend/src/components/Grid/index.tsx
@@ -16,11 +16,5 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { Row, Col, Grid as AntdGrid } from 'antd-v5';
-import type { ColProps, ColSize } from 'antd-v5/es/col';
-import type { RowProps } from 'antd-v5/es/row';
-
-export type { ColProps, ColSize, RowProps };
-
-export { Row, Col };
-export default AntdGrid;
+export { Row, Col, Grid } from 'antd-v5';
+export type { RowProps, ColProps } from './types';
diff --git a/superset-frontend/src/components/Grid/types.ts b/superset-frontend/src/components/Grid/types.ts
new file mode 100644
index 00000000000..d0595b3ff73
--- /dev/null
+++ b/superset-frontend/src/components/Grid/types.ts
@@ -0,0 +1,20 @@
+/**
+ * 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.
+ */
+export type { ColProps, ColSize } from 'antd-v5/es/col';
+export type { RowProps } from 'antd-v5/es/row';
diff --git a/superset-frontend/src/components/GridTable/GridTable.test.tsx b/superset-frontend/src/components/GridTable/GridTable.test.tsx
index 849831af6a2..09b7b0e699f 100644
--- a/superset-frontend/src/components/GridTable/GridTable.test.tsx
+++ b/superset-frontend/src/components/GridTable/GridTable.test.tsx
@@ -18,12 +18,7 @@
*/
import { render } from 'spec/helpers/testing-library';
import { setupAGGridModules } from 'src/setup/setupAGGridModules';
-import GridTable from '.';
-
-jest.mock('src/components/ErrorBoundary', () => ({
- __esModule: true,
- default: ({ children }: { children: React.ReactNode }) => <>{children}>,
-}));
+import { GridTable } from '.';
const mockedProps = {
queryId: 'abc',
diff --git a/superset-frontend/src/components/GridTable/Header.test.tsx b/superset-frontend/src/components/GridTable/Header.test.tsx
index 47b16115ff4..cbd3a677126 100644
--- a/superset-frontend/src/components/GridTable/Header.test.tsx
+++ b/superset-frontend/src/components/GridTable/Header.test.tsx
@@ -18,20 +18,25 @@
*/
import type { Column, GridApi } from 'ag-grid-community';
import { act, fireEvent, render } from 'spec/helpers/testing-library';
-import Header from './Header';
+import { Header } from './Header';
import { PIVOT_COL_ID } from './constants';
jest.mock('src/components/Dropdown', () => ({
Dropdown: () => ,
}));
-jest.mock('src/components/Icons', () => ({
- Icons: {
- Sort: jest.fn(() => ),
- SortAsc: jest.fn(() => ),
- SortDesc: jest.fn(() => ),
- },
-}));
+jest.mock('src/components/Icons', () => {
+ const actualIcons = jest.requireActual('src/components/Icons');
+ return {
+ __esModule: true,
+ Icons: {
+ ...actualIcons.Icons, // retain the real `Icons` export
+ Sort: jest.fn(() => ),
+ SortAsc: jest.fn(() => ),
+ SortDesc: jest.fn(() => ),
+ },
+ };
+});
class MockApi extends EventTarget {
getAllDisplayedColumns() {
diff --git a/superset-frontend/src/components/GridTable/Header.tsx b/superset-frontend/src/components/GridTable/Header.tsx
index 3de3eac5071..402112a731c 100644
--- a/superset-frontend/src/components/GridTable/Header.tsx
+++ b/superset-frontend/src/components/GridTable/Header.tsx
@@ -22,7 +22,7 @@ import type { Column, GridApi } from 'ag-grid-community';
import { Icons } from 'src/components/Icons';
import { PIVOT_COL_ID } from './constants';
-import HeaderMenu from './HeaderMenu';
+import { HeaderMenu } from './HeaderMenu';
interface Params {
enableFilterButton?: boolean;
@@ -80,7 +80,7 @@ const IconPlaceholder = styled.div`
top: 0;
`;
-const Header: React.FC = ({
+export const Header: React.FC = ({
enableFilterButton,
enableSorting,
displayName,
@@ -195,5 +195,3 @@ const Header: React.FC = ({
>
);
};
-
-export default Header;
diff --git a/superset-frontend/src/components/GridTable/HeaderMenu.test.tsx b/superset-frontend/src/components/GridTable/HeaderMenu.test.tsx
index 2b8dbc11abb..525383425ee 100644
--- a/superset-frontend/src/components/GridTable/HeaderMenu.test.tsx
+++ b/superset-frontend/src/components/GridTable/HeaderMenu.test.tsx
@@ -23,7 +23,7 @@ import {
waitFor,
screen,
} from 'spec/helpers/testing-library';
-import HeaderMenu from './HeaderMenu';
+import { HeaderMenu } from './HeaderMenu';
jest.mock('src/components/Menu', () => {
const Menu = ({ children }: { children: React.ReactChild }) => (
diff --git a/superset-frontend/src/components/GridTable/HeaderMenu.tsx b/superset-frontend/src/components/GridTable/HeaderMenu.tsx
index c9e14c4b1a8..0a6d7eb5516 100644
--- a/superset-frontend/src/components/GridTable/HeaderMenu.tsx
+++ b/superset-frontend/src/components/GridTable/HeaderMenu.tsx
@@ -21,9 +21,10 @@ import { styled, t } from '@superset-ui/core';
import type { Column, ColumnPinnedType, GridApi } from 'ag-grid-community';
import { Icons } from 'src/components/Icons';
-import { MenuDotsDropdown, DropdownProps } from 'src/components/Dropdown';
import { Menu } from 'src/components/Menu';
import copyTextToClipboard from 'src/utils/copy';
+import { MenuDotsDropdown } from '../Dropdown';
+import type { DropdownProps } from '../Dropdown/types';
import { PIVOT_COL_ID } from './constants';
const IconEmpty = styled.span`
@@ -41,7 +42,7 @@ type Params = {
onVisibleChange: DropdownProps['onOpenChange'];
};
-const HeaderMenu: React.FC = ({
+export const HeaderMenu: React.FC = ({
colId,
api,
pinnedLeft,
@@ -242,5 +243,3 @@ const HeaderMenu: React.FC = ({
/>
);
};
-
-export default HeaderMenu;
diff --git a/superset-frontend/src/components/GridTable/index.tsx b/superset-frontend/src/components/GridTable/index.tsx
index bdf313dd4c7..795536dce00 100644
--- a/superset-frontend/src/components/GridTable/index.tsx
+++ b/superset-frontend/src/components/GridTable/index.tsx
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { ReactNode, useCallback, useMemo } from 'react';
+import { useCallback, useMemo } from 'react';
import { Global } from '@emotion/react';
import { css, useTheme } from '@superset-ui/core';
@@ -27,61 +27,20 @@ import 'ag-grid-community/styles/ag-grid.css';
import 'ag-grid-community/styles/ag-theme-quartz.css';
import copyTextToClipboard from 'src/utils/copy';
-import ErrorBoundary from 'src/components/ErrorBoundary';
+import { ErrorBoundary } from '../ErrorBoundary';
import { PIVOT_COL_ID, GridSize } from './constants';
-import Header from './Header';
+import { Header } from './Header';
+import type { TableProps } from './types';
const gridComponents = {
agColumnHeader: Header,
};
-export { GridSize };
-
-export type ColDef = {
- type: string;
- field: string;
-};
-
-export interface TableProps {
- /**
- * Data that will populate the each row and map to the column key.
- */
- data: RecordType[];
- /**
- * Table column definitions.
- */
- columns: {
- label: string;
- headerName?: string;
- width?: number;
- comparator?: (valueA: string | number, valueB: string | number) => number;
- render?: (value: any) => ReactNode;
- }[];
-
- size?: GridSize;
-
- externalFilter?: AgGridReactProps['doesExternalFilterPass'];
-
- height: number;
-
- columnReorderable?: boolean;
-
- sortable?: boolean;
-
- enableActions?: boolean;
-
- showRowNumber?: boolean;
-
- usePagination?: boolean;
-
- striped?: boolean;
-}
-
const onSortChanged: AgGridReactProps['onSortChanged'] = ({ api }) =>
api.refreshCells();
-function GridTable({
+export function GridTable({
data,
columns,
sortable = true,
@@ -261,4 +220,4 @@ function GridTable({
);
}
-export default GridTable;
+export type { TableProps };
diff --git a/superset-frontend/src/components/GridTable/types.ts b/superset-frontend/src/components/GridTable/types.ts
new file mode 100644
index 00000000000..8dda781f6cf
--- /dev/null
+++ b/superset-frontend/src/components/GridTable/types.ts
@@ -0,0 +1,62 @@
+/**
+ * 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 { ReactNode } from 'react';
+
+import type { AgGridReactProps } from 'ag-grid-react';
+import { GridSize } from './constants';
+
+export type ColDef = {
+ type: string;
+ field: string;
+};
+
+export interface TableProps {
+ /**
+ * Data that will populate the each row and map to the column key.
+ */
+ data: RecordType[];
+ /**
+ * Table column definitions.
+ */
+ columns: {
+ label: string;
+ headerName?: string;
+ width?: number;
+ comparator?: (valueA: string | number, valueB: string | number) => number;
+ render?: (value: any) => ReactNode;
+ }[];
+
+ size?: GridSize;
+
+ externalFilter?: AgGridReactProps['doesExternalFilterPass'];
+
+ height: number;
+
+ columnReorderable?: boolean;
+
+ sortable?: boolean;
+
+ enableActions?: boolean;
+
+ showRowNumber?: boolean;
+
+ usePagination?: boolean;
+
+ striped?: boolean;
+}
diff --git a/superset-frontend/src/components/IconButton/IconButton.stories.tsx b/superset-frontend/src/components/IconButton/IconButton.stories.tsx
index d537ad472d8..acf1085b3e3 100644
--- a/superset-frontend/src/components/IconButton/IconButton.stories.tsx
+++ b/superset-frontend/src/components/IconButton/IconButton.stories.tsx
@@ -17,7 +17,7 @@
* under the License.
*/
import { Meta, StoryObj } from '@storybook/react';
-import { IconButton } from 'src/components/IconButton';
+import { IconButton } from '.';
export default {
title: 'Components/IconButton',
diff --git a/superset-frontend/src/components/IconButton/IconButton.test.tsx b/superset-frontend/src/components/IconButton/IconButton.test.tsx
index dc45fe003ec..4ee67d030f1 100644
--- a/superset-frontend/src/components/IconButton/IconButton.test.tsx
+++ b/superset-frontend/src/components/IconButton/IconButton.test.tsx
@@ -17,7 +17,7 @@
* under the License.
*/
import { render, screen, fireEvent } from 'spec/helpers/testing-library';
-import { IconButton } from 'src/components/IconButton';
+import { IconButton } from '.';
const defaultProps = {
buttonText: 'This is the IconButton text',
diff --git a/superset-frontend/src/components/IconButton/index.tsx b/superset-frontend/src/components/IconButton/index.tsx
index 51345943583..2d45312a598 100644
--- a/superset-frontend/src/components/IconButton/index.tsx
+++ b/superset-frontend/src/components/IconButton/index.tsx
@@ -19,12 +19,13 @@
// eslint-disable-next-line
import Typography from 'src/components/Typography';
-import { Tooltip } from 'src/components/Tooltip';
-import Card, { CardProps } from 'src/components/Card';
import { Icons } from 'src/components/Icons';
import { SupersetTheme, css } from '@superset-ui/core';
+import { Card } from '../Card';
+import { Tooltip } from '../Tooltip';
+import { CardProps } from '../Card/types';
-export interface IconButtonProps extends CardProps {
+interface IconButtonProps extends CardProps {
buttonText: string;
icon: string;
altText?: string;
@@ -51,7 +52,7 @@ const IconButton: React.FC = ({
const renderIcon = () => {
const iconContent = icon ? (
= ({
};
export { IconButton };
+export type { IconButtonProps };
diff --git a/superset-frontend/src/components/IconTooltip/IconTooltip.stories.tsx b/superset-frontend/src/components/IconTooltip/IconTooltip.stories.tsx
index e17cc66ebe2..b9ecf894f2c 100644
--- a/superset-frontend/src/components/IconTooltip/IconTooltip.stories.tsx
+++ b/superset-frontend/src/components/IconTooltip/IconTooltip.stories.tsx
@@ -18,7 +18,8 @@
*/
import { Icons } from 'src/components/Icons';
import { css, useTheme } from '@superset-ui/core';
-import { IconTooltip, Props } from '.';
+import { IconTooltip } from '.';
+import type { IconTooltipProps } from './types';
export default {
title: 'Components/IconTooltip',
@@ -41,7 +42,7 @@ const PLACEMENTS = [
const theme = useTheme();
-export const InteractiveIconTooltip = (args: Props) => (
+export const InteractiveIconTooltip = (args: IconTooltipProps) => (