diff --git a/.github/workflows/superset-frontend.yml b/.github/workflows/superset-frontend.yml index ac7c01d98e2..3665c6f0591 100644 --- a/.github/workflows/superset-frontend.yml +++ b/.github/workflows/superset-frontend.yml @@ -121,24 +121,6 @@ jobs: files: merged-output/coverage-summary.json slug: apache/superset - core-cover: - needs: frontend-build - if: needs.frontend-build.outputs.should-run == 'true' - runs-on: ubuntu-24.04 - steps: - - name: Download Docker Image Artifact - uses: actions/download-artifact@v4 - with: - name: docker-image - - - name: Load Docker Image - run: docker load < docker-image.tar.gz - - - name: superset-ui/core coverage - run: | - docker run --rm $TAG bash -c \ - "npm run core:cover" - lint-frontend: needs: frontend-build if: needs.frontend-build.outputs.should-run == 'true' diff --git a/superset-frontend/.eslintrc.js b/superset-frontend/.eslintrc.js index d4f4648a35a..59f003c2936 100644 --- a/superset-frontend/.eslintrc.js +++ b/superset-frontend/.eslintrc.js @@ -52,7 +52,7 @@ const restrictedImportsRules = { message: 'Lodash Memoize is unsafe! Please use memoize-one instead', }, 'no-testing-library-react': { - name: '@testing-library/react', + name: '@superset-ui/core/spec', message: 'Please use spec/helpers/testing-library instead', }, 'no-testing-library-react-dom-utils': { @@ -97,6 +97,15 @@ module.exports = { // resolve modules from `/superset_frontend/node_modules` and `/superset_frontend` moduleDirectory: ['node_modules', '.'], }, + typescript: { + alwaysTryTypes: true, + project: [ + './tsconfig.json', + './packages/superset-ui-core/tsconfig.json', + './packages/superset-ui-chart-controls/', + './plugins/*/tsconfig.json', + ], + }, }, // only allow import from top level of module 'import/core-modules': importCoreModules, @@ -326,7 +335,9 @@ module.exports = { rules: { 'import/no-extraneous-dependencies': [ 'error', - { devDependencies: true }, + { + devDependencies: true, + }, ], 'no-only-tests/no-only-tests': 'error', 'max-classes-per-file': 0, diff --git a/superset-frontend/jest.config.js b/superset-frontend/jest.config.js index 6c9dd85cd51..517c91767fd 100644 --- a/superset-frontend/jest.config.js +++ b/superset-frontend/jest.config.js @@ -28,7 +28,9 @@ module.exports = { '^src/(.*)$': '/src/$1', '^spec/(.*)$': '/spec/$1', // mapping plugins of superset-ui to source code - '@superset-ui/(.*)$': '/node_modules/@superset-ui/$1/src', + '^@superset-ui/([^/]+)/(.*)$': + '/node_modules/@superset-ui/$1/src/$2', + '^@superset-ui/([^/]+)$': '/node_modules/@superset-ui/$1/src', }, testEnvironment: 'jsdom', modulePathIgnorePatterns: ['/packages/generator-superset'], diff --git a/superset-frontend/package-lock.json b/superset-frontend/package-lock.json index 5ebf2e1f37a..3ff13ccdb79 100644 --- a/superset-frontend/package-lock.json +++ b/superset-frontend/package-lock.json @@ -14,7 +14,6 @@ "src/setup/*" ], "dependencies": { - "@ant-design/icons": "^5.2.6", "@emotion/cache": "^11.4.0", "@emotion/react": "^11.14.0", "@emotion/styled": "^11.3.0", @@ -54,20 +53,16 @@ "@visx/tooltip": "^3.0.0", "@visx/xychart": "^3.5.1", "abortcontroller-polyfill": "^1.7.8", - "ace-builds": "^1.41.0", "ag-grid-community": "33.1.1", "ag-grid-react": "33.1.1", "antd": "^5.24.6", - "brace": "^0.11.1", "chrono-node": "^2.7.8", "classnames": "^2.2.5", - "core-js": "^3.38.1", "d3-color": "^3.1.0", "d3-scale": "^2.1.2", "dayjs": "^1.11.13", "dom-to-image-more": "^3.2.0", "dom-to-pdf": "^0.3.2", - "dompurify": "^3.2.4", "echarts": "^5.6.0", "emotion-rgba": "0.0.12", "eslint-plugin-i18n-strings": "file:eslint-rules/eslint-plugin-i18n-strings", @@ -106,18 +101,15 @@ "rc-trigger": "^5.3.4", "re-resizable": "^6.10.1", "react": "^17.0.2", - "react-ace": "^10.1.0", "react-checkbox-tree": "^1.8.0", "react-color": "^2.13.8", "react-diff-viewer-continued": "^3.4.0", "react-dnd": "^11.1.3", "react-dnd-html5-backend": "^11.1.3", "react-dom": "^17.0.2", - "react-draggable": "^4.4.6", "react-google-recaptcha": "^3.1.0", "react-hot-loader": "^4.13.1", "react-intersection-observer": "^9.16.0", - "react-js-cron": "^2.1.2", "react-json-tree": "^0.17.0", "react-lines-ellipsis": "^0.15.4", "react-loadable": "^5.5.0", @@ -131,14 +123,12 @@ "react-syntax-highlighter": "^15.4.5", "react-table": "^7.8.0", "react-transition-group": "^4.4.5", - "react-ultimate-pagination": "^1.3.2", "react-virtualized-auto-sizer": "^1.0.25", "react-window": "^1.8.10", "redux": "^4.2.1", "redux-localstorage": "^0.4.1", "redux-thunk": "^2.1.0", "redux-undo": "^1.0.0-beta9-9-7", - "regenerator-runtime": "^0.14.1", "rimraf": "^6.0.1", "rison": "^0.1.1", "scroll-into-view-if-needed": "^3.1.0", @@ -197,7 +187,6 @@ "@types/enzyme": "^3.10.18", "@types/fetch-mock": "^7.3.2", "@types/jest": "^29.5.14", - "@types/jquery": "^3.5.8", "@types/js-levenshtein": "^1.1.3", "@types/json-bigint": "^1.0.4", "@types/math-expression-evaluator": "^1.3.3", @@ -212,7 +201,6 @@ "@types/react-resizable": "^3.0.8", "@types/react-router-dom": "^5.3.3", "@types/react-syntax-highlighter": "^15.5.13", - "@types/react-table": "^7.7.20", "@types/react-transition-group": "^4.4.12", "@types/react-ultimate-pagination": "^1.2.4", "@types/react-virtualized-auto-sizer": "^1.0.4", @@ -245,6 +233,7 @@ "eslint": "^8.56.0", "eslint-config-airbnb": "^19.0.4", "eslint-config-prettier": "^7.2.0", + "eslint-import-resolver-alias": "^1.1.2", "eslint-import-resolver-typescript": "^3.7.0", "eslint-plugin-cypress": "^3.6.0", "eslint-plugin-file-progress": "^1.5.0", @@ -307,6 +296,12 @@ "engines": { "node": "^20.16.0", "npm": "^10.8.1" + }, + "peerDependencies": { + "ace-builds": "^1.41.0", + "core-js": "^3.38.1", + "react-ace": "^10.1.0", + "regenerator-runtime": "^0.14.1" } }, "eslint-rules/eslint-i18n-strings": { @@ -12696,7 +12691,6 @@ "version": "1.8.8", "resolved": "https://registry.npmjs.org/@types/react-window/-/react-window-1.8.8.tgz", "integrity": "sha512-8Ls660bHR1AUA2kuRvVG9D/4XpRC6wjAaPT9dil7Ckc76eP9TKWZwwmgfq8Q1LANX3QNDnoU4Zp48A3w+zK69Q==", - "dev": true, "license": "MIT", "dependencies": { "@types/react": "*" @@ -19562,6 +19556,13 @@ "integrity": "sha512-dArJ32hchFsrQ8uMiTBLq256MpnZjeuBtdHpaDlYuQyjU0CVzCJl/BVW+SkszaAeH95D/8gxqAhgx0ouAWAfRg==", "license": "BSD-3-Clause" }, + "node_modules/d3v3": { + "name": "d3", + "version": "3.5.17", + "resolved": "https://registry.npmjs.org/d3/-/d3-3.5.17.tgz", + "integrity": "sha512-yFk/2idb8OHPKkbAL8QaOaqENNoMhIaSHZerk3oQsECwkObkCpJyjYwCe+OHiq6UEdhe1m8ZGARRRO3ljFjlKg==", + "license": "BSD-3-Clause" + }, "node_modules/damerau-levenshtein": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/damerau-levenshtein/-/damerau-levenshtein-1.0.8.tgz", @@ -22078,6 +22079,19 @@ "eslint": ">=7.0.0" } }, + "node_modules/eslint-import-resolver-alias": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-alias/-/eslint-import-resolver-alias-1.1.2.tgz", + "integrity": "sha512-WdviM1Eu834zsfjHtcGHtGfcu+F30Od3V7I9Fi57uhBEwPkjDcii7/yW8jAT+gOhn4P/vOxxNAXbFAKsrrc15w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + }, + "peerDependencies": { + "eslint-plugin-import": ">=1.4.0" + } + }, "node_modules/eslint-import-resolver-node": { "version": "0.3.9", "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.9.tgz", @@ -52292,7 +52306,6 @@ "@testing-library/react-hooks": "*", "@testing-library/user-event": "*", "ace-builds": "^1.4.14", - "antd": "^5.24.6", "brace": "^0.11.1", "memoize-one": "^5.1.1", "react": "^17.0.2", @@ -52305,24 +52318,38 @@ "version": "0.20.4", "license": "Apache-2.0", "dependencies": { + "@ant-design/icons": "^5.2.6", "@babel/runtime": "^7.25.6", "@fontsource/fira-code": "^5.0.18", "@fontsource/inter": "^5.0.20", "@types/json-bigint": "^1.0.4", "@visx/responsive": "^3.12.0", + "ace-builds": "^1.41.0", + "brace": "^0.11.1", + "classnames": "^2.2.5", + "core-js": "^3.38.1", "csstype": "^3.1.3", "d3-format": "^1.3.2", "d3-interpolate": "^3.0.1", "d3-scale": "^3.0.0", "d3-time": "^3.1.0", "d3-time-format": "^4.1.0", + "dayjs": "^1.11.13", + "dompurify": "^3.2.4", "fetch-retry": "^6.0.0", "jed": "^1.1.1", "lodash": "^4.17.21", "math-expression-evaluator": "^2.0.6", "pretty-ms": "^9.2.0", + "re-resizable": "^6.10.1", + "react-ace": "^10.1.0", + "react-draggable": "^4.4.6", "react-error-boundary": "^5.0.0", + "react-js-cron": "^2.1.2", "react-markdown": "^8.0.7", + "react-resize-detector": "^7.1.2", + "react-ultimate-pagination": "^1.3.2", + "regenerator-runtime": "^0.14.1", "rehype-raw": "^7.0.0", "rehype-sanitize": "^6.0.0", "remark-gfm": "^3.0.1", @@ -52341,10 +52368,12 @@ "@types/d3-time-format": "^4.0.3", "@types/enzyme": "^3.10.18", "@types/fetch-mock": "^7.3.8", + "@types/jquery": "^3.5.8", "@types/lodash": "^4.17.16", "@types/math-expression-evaluator": "^1.3.3", "@types/node": "^22.10.3", "@types/prop-types": "^15.7.2", + "@types/react-table": "^7.7.20", "@types/rison": "0.1.0", "@types/seedrandom": "^3.0.8", "fetch-mock": "^11.1.4", @@ -52363,6 +52392,7 @@ "@testing-library/user-event": "*", "@types/react": "*", "@types/react-loadable": "*", + "@types/react-window": "^1.8.8", "@types/tinycolor2": "*", "antd": "^5.24.6", "nanoid": "^5.0.9", @@ -53319,8 +53349,7 @@ "@superset-ui/legacy-preset-chart-nvd3": "*", "@superset-ui/plugin-chart-echarts": "*", "@superset-ui/plugin-chart-table": "*", - "@superset-ui/plugin-chart-word-cloud": "*", - "antd": "^5.24.6" + "@superset-ui/plugin-chart-word-cloud": "*" } }, "packages/superset-ui-demo/node_modules/@storybook/builder-webpack5": { @@ -54020,7 +54049,7 @@ "version": "0.20.3", "license": "Apache-2.0", "dependencies": { - "d3": "^3.5.17", + "d3v3": "npm:d3@3.5.17", "prop-types": "^15.8.1" }, "peerDependencies": { @@ -54362,7 +54391,6 @@ "@testing-library/user-event": "*", "@types/classnames": "*", "@types/react": "*", - "antd": "^5.24.6", "match-sorter": "^6.3.3", "react": "^17.0.2", "react-dom": "^17.0.2" diff --git a/superset-frontend/package.json b/superset-frontend/package.json index 85758ea2358..75b4add8452 100644 --- a/superset-frontend/package.json +++ b/superset-frontend/package.json @@ -70,6 +70,7 @@ "storybook": "cross-env NODE_ENV=development BABEL_ENV=development storybook dev -p 6006", "tdd": "cross-env NODE_ENV=test NODE_OPTIONS=\"--max-old-space-size=8192\" jest --watch", "test": "cross-env NODE_ENV=test NODE_OPTIONS=\"--max-old-space-size=8192\" jest --max-workers=80% --silent", + "test-loud": "cross-env NODE_ENV=test NODE_OPTIONS=\"--max-old-space-size=8192\" jest --max-workers=80%", "type": "tsc --noEmit", "update-maps": "jupyter nbconvert --to notebook --execute --inplace 'plugins/legacy-plugin-chart-country-map/scripts/Country Map GeoJSON Generator.ipynb' -Xfrozen_modules=off", "validate-release": "../RELEASING/validate_this_release.sh" @@ -81,7 +82,6 @@ "last 3 edge versions" ], "dependencies": { - "@ant-design/icons": "^5.2.6", "@emotion/cache": "^11.4.0", "@emotion/react": "^11.14.0", "@emotion/styled": "^11.3.0", @@ -121,20 +121,16 @@ "@visx/tooltip": "^3.0.0", "@visx/xychart": "^3.5.1", "abortcontroller-polyfill": "^1.7.8", - "ace-builds": "^1.41.0", "ag-grid-community": "33.1.1", "ag-grid-react": "33.1.1", "antd": "^5.24.6", - "brace": "^0.11.1", "chrono-node": "^2.7.8", "classnames": "^2.2.5", - "core-js": "^3.38.1", "d3-color": "^3.1.0", "d3-scale": "^2.1.2", "dayjs": "^1.11.13", "dom-to-image-more": "^3.2.0", "dom-to-pdf": "^0.3.2", - "dompurify": "^3.2.4", "echarts": "^5.6.0", "emotion-rgba": "0.0.12", "eslint-plugin-i18n-strings": "file:eslint-rules/eslint-plugin-i18n-strings", @@ -173,18 +169,15 @@ "rc-trigger": "^5.3.4", "re-resizable": "^6.10.1", "react": "^17.0.2", - "react-ace": "^10.1.0", "react-checkbox-tree": "^1.8.0", "react-color": "^2.13.8", "react-diff-viewer-continued": "^3.4.0", "react-dnd": "^11.1.3", "react-dnd-html5-backend": "^11.1.3", "react-dom": "^17.0.2", - "react-draggable": "^4.4.6", "react-google-recaptcha": "^3.1.0", "react-hot-loader": "^4.13.1", "react-intersection-observer": "^9.16.0", - "react-js-cron": "^2.1.2", "react-json-tree": "^0.17.0", "react-lines-ellipsis": "^0.15.4", "react-loadable": "^5.5.0", @@ -198,14 +191,12 @@ "react-syntax-highlighter": "^15.4.5", "react-table": "^7.8.0", "react-transition-group": "^4.4.5", - "react-ultimate-pagination": "^1.3.2", "react-virtualized-auto-sizer": "^1.0.25", "react-window": "^1.8.10", "redux": "^4.2.1", "redux-localstorage": "^0.4.1", "redux-thunk": "^2.1.0", "redux-undo": "^1.0.0-beta9-9-7", - "regenerator-runtime": "^0.14.1", "rimraf": "^6.0.1", "rison": "^0.1.1", "scroll-into-view-if-needed": "^3.1.0", @@ -264,7 +255,6 @@ "@types/enzyme": "^3.10.18", "@types/fetch-mock": "^7.3.2", "@types/jest": "^29.5.14", - "@types/jquery": "^3.5.8", "@types/js-levenshtein": "^1.1.3", "@types/json-bigint": "^1.0.4", "@types/math-expression-evaluator": "^1.3.3", @@ -279,7 +269,6 @@ "@types/react-resizable": "^3.0.8", "@types/react-router-dom": "^5.3.3", "@types/react-syntax-highlighter": "^15.5.13", - "@types/react-table": "^7.7.20", "@types/react-transition-group": "^4.4.12", "@types/react-ultimate-pagination": "^1.2.4", "@types/react-virtualized-auto-sizer": "^1.0.4", @@ -312,6 +301,7 @@ "eslint": "^8.56.0", "eslint-config-airbnb": "^19.0.4", "eslint-config-prettier": "^7.2.0", + "eslint-import-resolver-alias": "^1.1.2", "eslint-import-resolver-typescript": "^3.7.0", "eslint-plugin-cypress": "^3.6.0", "eslint-plugin-file-progress": "^1.5.0", @@ -371,6 +361,12 @@ "webpack-sources": "^3.2.3", "webpack-visualizer-plugin2": "^1.1.0" }, + "peerDependencies": { + "ace-builds": "^1.41.0", + "core-js": "^3.38.1", + "react-ace": "^10.1.0", + "regenerator-runtime": "^0.14.1" + }, "engines": { "node": "^20.16.0", "npm": "^10.8.1" diff --git a/superset-frontend/packages/superset-ui-chart-controls/package.json b/superset-frontend/packages/superset-ui-chart-controls/package.json index ea9353f7e33..060ba39b5d0 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/package.json +++ b/superset-frontend/packages/superset-ui-chart-controls/package.json @@ -40,7 +40,6 @@ "@testing-library/react-hooks": "*", "@testing-library/user-event": "*", "ace-builds": "^1.4.14", - "antd": "^5.24.6", "brace": "^0.11.1", "memoize-one": "^5.1.1", "react": "^17.0.2", diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/components/CertifiedIconWithTooltip.tsx b/superset-frontend/packages/superset-ui-chart-controls/src/components/CertifiedIconWithTooltip.tsx index 6124834c573..18cedfbca9a 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/src/components/CertifiedIconWithTooltip.tsx +++ b/superset-frontend/packages/superset-ui-chart-controls/src/components/CertifiedIconWithTooltip.tsx @@ -18,7 +18,7 @@ */ import { kebabCase } from 'lodash'; import { t, useTheme, styled } from '@superset-ui/core'; -import Tooltip from './Tooltip'; +import { Tooltip } from '@superset-ui/core/components'; interface CertifiedIconWithTooltipProps { certifiedBy?: string | null; diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/components/ColumnOption.tsx b/superset-frontend/packages/superset-ui-chart-controls/src/components/ColumnOption.tsx index 801363e51c7..763bf0a7d11 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/src/components/ColumnOption.tsx +++ b/superset-frontend/packages/superset-ui-chart-controls/src/components/ColumnOption.tsx @@ -17,8 +17,12 @@ * under the License. */ import { useState, ReactNode, useLayoutEffect, RefObject } from 'react'; -import { css, SafeMarkdown, styled, SupersetTheme } from '@superset-ui/core'; -import { Tooltip } from './Tooltip'; +import { css, styled, SupersetTheme } from '@superset-ui/core'; +import { + SafeMarkdown, + Tooltip, + InfoTooltip, +} from '@superset-ui/core/components'; import { ColumnTypeLabel } from './ColumnTypeLabel/ColumnTypeLabel'; import CertifiedIconWithTooltip from './CertifiedIconWithTooltip'; import { ColumnMeta } from '../types'; @@ -28,7 +32,6 @@ import { getColumnTypeTooltipNode, } from './labelUtils'; import { SQLPopover } from './SQLPopover'; -import { InfoTooltipWithTrigger } from './InfoTooltipWithTrigger'; export type ColumnOptionProps = { column: ColumnMeta; @@ -98,7 +101,7 @@ export function ColumnOption({ /> )} {warningMarkdown && ( - } label={`warn-${column.column_name}`} diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/components/ControlHeader.tsx b/superset-frontend/packages/superset-ui-chart-controls/src/components/ControlHeader.tsx index 944591bb111..472c83b156f 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/src/components/ControlHeader.tsx +++ b/superset-frontend/packages/superset-ui-chart-controls/src/components/ControlHeader.tsx @@ -19,8 +19,7 @@ import { ReactNode } from 'react'; import { t, css } from '@superset-ui/core'; import { InfoCircleOutlined } from '@ant-design/icons'; -import { InfoTooltipWithTrigger } from './InfoTooltipWithTrigger'; -import { Tooltip } from './Tooltip'; +import { InfoTooltip, Tooltip } from '@superset-ui/core/components'; type ValidationError = string; @@ -61,7 +60,7 @@ export function ControlHeader({ {description && ( - - )} {warningMarkdown && ( - } label={`warn-${metric.metric_name}`} diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/components/SQLPopover.tsx b/superset-frontend/packages/superset-ui-chart-controls/src/components/SQLPopover.tsx index 89b9626e75e..af0ff77db9e 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/src/components/SQLPopover.tsx +++ b/superset-frontend/packages/superset-ui-chart-controls/src/components/SQLPopover.tsx @@ -17,9 +17,8 @@ * under the License. */ import { useEffect, useState } from 'react'; -import { Popover } from 'antd'; +import { Popover, type PopoverProps } from '@superset-ui/core/components'; import type ReactAce from 'react-ace'; -import type { PopoverProps } from 'antd/es/popover'; import { CalculatorOutlined } from '@ant-design/icons'; import { css, styled, useTheme, t } from '@superset-ui/core'; diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/components/Select.tsx b/superset-frontend/packages/superset-ui-chart-controls/src/components/Select.tsx index 421f97887c4..4831dcba107 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/src/components/Select.tsx +++ b/superset-frontend/packages/superset-ui-chart-controls/src/components/Select.tsx @@ -18,9 +18,9 @@ */ import { useState, ReactNode } from 'react'; import { - Select as AntdSelect, - type SelectProps as AntdSelectProps, -} from 'antd'; + RawAntdSelect as AntdSelect, + type RawAntdSelectProps as AntdSelectProps, +} from '@superset-ui/core/components'; export const { Option }: any = AntdSelect; diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/components/Tooltip.tsx b/superset-frontend/packages/superset-ui-chart-controls/src/components/Tooltip.tsx deleted file mode 100644 index 52865a5e407..00000000000 --- a/superset-frontend/packages/superset-ui-chart-controls/src/components/Tooltip.tsx +++ /dev/null @@ -1,58 +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 { useTheme } from '@superset-ui/core'; -import { Tooltip as BaseTooltip } from 'antd'; -import { - TooltipProps as BaseTooltipProps, - TooltipPlacement as BaseTooltipPlacement, -} from 'antd/es/tooltip'; - -export type TooltipProps = BaseTooltipProps; -export type TooltipPlacement = BaseTooltipPlacement; - -export const Tooltip = ({ - overlayStyle = {}, - color, - ...props -}: BaseTooltipProps) => { - const theme = useTheme(); - const defaultColor = `${theme.colors.grayscale.dark2}e6`; - return ( - - ); -}; - -export default Tooltip; diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/index.ts b/superset-frontend/packages/superset-ui-chart-controls/src/index.ts index e58bc940385..dc1d89e476c 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/src/index.ts +++ b/superset-frontend/packages/superset-ui-chart-controls/src/index.ts @@ -18,6 +18,11 @@ */ import * as sectionsModule from './sections'; +export { + Tooltip, + TooltipPlacement, + TooltipProps, +} from '@superset-ui/core/components'; export * from './utils'; export * from './constants'; export * from './operators'; @@ -25,14 +30,12 @@ export * from './operators'; // can't do `export * as sections from './sections'`, babel-transformer will fail export const sections = sectionsModule; -export * from './components/InfoTooltipWithTrigger'; export * from './components/ColumnOption'; export * from './components/ColumnTypeLabel/ColumnTypeLabel'; export * from './components/ControlSubSectionHeader'; export * from './components/Dropdown'; export * from './components/Menu'; export * from './components/MetricOption'; -export * from './components/Tooltip'; export * from './components/ControlHeader'; export * from './shared-controls'; diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/components/RadioButtonControl.tsx b/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/components/RadioButtonControl.tsx index c3dbda75c7a..edf67179655 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/components/RadioButtonControl.tsx +++ b/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/components/RadioButtonControl.tsx @@ -18,7 +18,7 @@ */ import { ReactNode } from 'react'; import { JsonValue } from '@superset-ui/core'; -import { Radio } from 'antd'; +import { Radio } from '@superset-ui/core/components'; import { ControlHeader } from '../../components/ControlHeader'; // [value, label] diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/types.ts b/superset-frontend/packages/superset-ui-chart-controls/src/types.ts index 71517884daa..3fbd234c1d4 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/src/types.ts +++ b/superset-frontend/packages/superset-ui-chart-controls/src/types.ts @@ -300,7 +300,7 @@ export interface FilterOption { data: T; } -// Ref: superset-frontend/src/components/Select/SupersetStyledSelect.tsx +// Ref: superset-frontend/@superset-ui/core/components/Select/SupersetStyledSelect.tsx export interface SelectControlConfig< O extends SelectOption = SelectOption, T extends SelectControlType = SelectControlType, diff --git a/superset-frontend/packages/superset-ui-chart-controls/test/components/ColumnOption.test.tsx b/superset-frontend/packages/superset-ui-chart-controls/test/components/ColumnOption.test.tsx index 68c6f626330..e0b3f8f30dd 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/test/components/ColumnOption.test.tsx +++ b/superset-frontend/packages/superset-ui-chart-controls/test/components/ColumnOption.test.tsx @@ -17,7 +17,7 @@ * under the License. */ import '@testing-library/jest-dom'; -import { render } from '@testing-library/react'; +import { render } from '@superset-ui/core/spec'; import { ThemeProvider, supersetTheme, @@ -26,19 +26,20 @@ import { import { ColumnOption, ColumnOptionProps } from '../../src'; -jest.mock('../../src/components/SQLPopover', () => ({ +jest.mock('@superset-ui/chart-controls/components/SQLPopover', () => ({ SQLPopover: () =>
, })); -jest.mock('../../src/components/ColumnTypeLabel/ColumnTypeLabel', () => ({ - ColumnTypeLabel: ({ type }: { type: string }) => ( -
{type}
- ), -})); +jest.mock( + '@superset-ui/chart-controls/components/ColumnTypeLabel/ColumnTypeLabel', + () => ({ + ColumnTypeLabel: ({ type }: { type: string }) => ( +
{type}
+ ), + }), +); -jest.mock('../../src/components/InfoTooltipWithTrigger', () => ({ - InfoTooltipWithTrigger: () => ( -
- ), +jest.mock('@superset-ui/core/components/InfoTooltip', () => ({ + InfoTooltip: () =>
, })); const defaultProps: ColumnOptionProps = { @@ -117,11 +118,11 @@ test('dttm column has correct column label if showType is true', () => { String(GenericDataType.Temporal), ); }); -test('doesnt show InfoTooltipWithTrigger when no warning', () => { +test('doesnt show InfoTooltip when no warning', () => { const { queryByText } = setup(); - expect(queryByText('mock-info-tooltip-with-trigger')).not.toBeInTheDocument(); + expect(queryByText('mock-tooltip')).not.toBeInTheDocument(); }); -test('shows a warning with InfoTooltipWithTrigger when it contains warning', () => { +test('shows a warning with InfoTooltip when it contains warning', () => { const { getByTestId } = setup({ ...defaultProps, column: { @@ -129,5 +130,5 @@ test('shows a warning with InfoTooltipWithTrigger when it contains warning', () warning_text: 'This is a warning', }, }); - expect(getByTestId('mock-info-tooltip-with-trigger')).toBeInTheDocument(); + expect(getByTestId('mock-tooltip')).toBeInTheDocument(); }); diff --git a/superset-frontend/packages/superset-ui-chart-controls/test/components/ColumnTypeLabel.test.tsx b/superset-frontend/packages/superset-ui-chart-controls/test/components/ColumnTypeLabel.test.tsx index 603ac9172eb..350820207eb 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/test/components/ColumnTypeLabel.test.tsx +++ b/superset-frontend/packages/superset-ui-chart-controls/test/components/ColumnTypeLabel.test.tsx @@ -17,7 +17,7 @@ * under the License. */ import { isValidElement } from 'react'; -import { render, screen } from '@testing-library/react'; +import { render, screen } from '@superset-ui/core/spec'; import '@testing-library/jest-dom'; import { GenericDataType } from '@superset-ui/core'; diff --git a/superset-frontend/packages/superset-ui-chart-controls/test/components/InfoTooltipWithTrigger.test.tsx b/superset-frontend/packages/superset-ui-chart-controls/test/components/InfoTooltipWithTrigger.test.tsx index d243b1fd9f8..f195813861a 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/test/components/InfoTooltipWithTrigger.test.tsx +++ b/superset-frontend/packages/superset-ui-chart-controls/test/components/InfoTooltipWithTrigger.test.tsx @@ -17,11 +17,11 @@ * under the License. */ import '@testing-library/jest-dom'; -import { fireEvent, render } from '@testing-library/react'; +import { fireEvent, render } from '@superset-ui/core/spec'; import { ThemeProvider, supersetTheme } from '@superset-ui/core'; -import { InfoTooltipWithTrigger, InfoTooltipWithTriggerProps } from '../../src'; +import { InfoTooltip, InfoTooltipProps } from '@superset-ui/core/components'; -jest.mock('../../src/components/Tooltip', () => ({ +jest.mock('@superset-ui/core/components/Tooltip', () => ({ Tooltip: ({ children }: { children: React.ReactNode }) => (
{children}
), @@ -29,10 +29,10 @@ jest.mock('../../src/components/Tooltip', () => ({ const defaultProps = {}; -const setup = (props: Partial = {}) => +const setup = (props: Partial = {}) => render( - + , ); diff --git a/superset-frontend/packages/superset-ui-chart-controls/test/components/MetricOption.test.tsx b/superset-frontend/packages/superset-ui-chart-controls/test/components/MetricOption.test.tsx index 03da5df2ffc..8782de01a4a 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/test/components/MetricOption.test.tsx +++ b/superset-frontend/packages/superset-ui-chart-controls/test/components/MetricOption.test.tsx @@ -17,27 +17,31 @@ * under the License. */ import '@testing-library/jest-dom'; -import { render } from '@testing-library/react'; +import { render } from '@superset-ui/core/spec'; import { ThemeProvider, supersetTheme } from '@superset-ui/core'; -import { MetricOption, MetricOptionProps } from '../../src'; +import { + MetricOption, + MetricOptionProps, +} from '../../src/components/MetricOption'; -jest.mock('../../src/components/InfoTooltipWithTrigger', () => ({ - InfoTooltipWithTrigger: () => ( -
- ), +jest.mock('@superset-ui/core/components/InfoTooltip', () => ({ + InfoTooltip: () =>
, })); -jest.mock('../../src/components/ColumnTypeLabel/ColumnTypeLabel', () => ({ - ColumnTypeLabel: () =>
, -})); jest.mock( - '../../src/components/Tooltip', + '@superset-ui/chart-controls/components/ColumnTypeLabel/ColumnTypeLabel', + () => ({ + ColumnTypeLabel: () =>
, + }), +); +jest.mock( + '@superset-ui/core/components/Tooltip', () => ({ children }: { children: React.ReactNode }) => (
{children}
), ); -jest.mock('../../src/components/SQLPopover', () => ({ +jest.mock('@superset-ui/chart-controls/components/SQLPopover', () => ({ SQLPopover: () =>
, })); @@ -68,9 +72,9 @@ test('shows a label with verbose_name', () => { expect(lbl).toHaveLength(1); expect(`${lbl[0].textContent}`).toEqual(defaultProps.metric.verbose_name); }); -test('shows a InfoTooltipWithTrigger', () => { +test('shows a InfoTooltip', () => { const { getByTestId } = setup(); - expect(getByTestId('mock-info-tooltip-with-trigger')).toBeInTheDocument(); + expect(getByTestId('mock-tooltip')).toBeInTheDocument(); }); test('shows SQL Popover trigger', () => { const { getByTestId } = setup(); @@ -85,14 +89,14 @@ test('shows a label with metric_name when no verbose_name', () => { }); expect(getByText(defaultProps.metric.metric_name)).toBeInTheDocument(); }); -test('doesnt show InfoTooltipWithTrigger when no warning', () => { +test('doesnt show InfoTooltip when no warning', () => { const { queryByText } = setup({ metric: { ...defaultProps.metric, warning_text: '', }, }); - expect(queryByText('mock-info-tooltip-with-trigger')).not.toBeInTheDocument(); + expect(queryByText('mock-tooltip')).not.toBeInTheDocument(); }); test('sets target="_blank" when openInNewWindow is true', () => { const { getByRole } = setup({ diff --git a/superset-frontend/packages/superset-ui-chart-controls/test/components/labelUtils.test.tsx b/superset-frontend/packages/superset-ui-chart-controls/test/components/labelUtils.test.tsx index 9b5b760f791..c90b65fb674 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/test/components/labelUtils.test.tsx +++ b/superset-frontend/packages/superset-ui-chart-controls/test/components/labelUtils.test.tsx @@ -17,7 +17,7 @@ * under the License. */ import { ReactElement } from 'react'; -import { render, screen } from '@testing-library/react'; +import { render, screen } from '@superset-ui/core/spec'; import '@testing-library/jest-dom'; import { ThemeProvider, supersetTheme } from '@superset-ui/core'; import { diff --git a/superset-frontend/packages/superset-ui-core/.eslintrc b/superset-frontend/packages/superset-ui-core/.eslintrc new file mode 100644 index 00000000000..e0ff7c67bb8 --- /dev/null +++ b/superset-frontend/packages/superset-ui-core/.eslintrc @@ -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. + */ +{ + "plugins": ["jest", "jest-dom", "no-only-tests", "testing-library"], + "env": { + "jest/globals": true + }, + "settings": { + "jest": { + "version": "detect" + } + }, + "extends": [ + "plugin:jest/recommended", + "plugin:jest-dom/recommended", + "plugin:testing-library/react" + ], + "overrides": [ + { + "files": [ + "**/*.stories.*", + "**/*.overview.*", + "**/fixtures.*" + ], + "rules": { + "import/no-extraneous-dependencies": "off" + } + } + ], + "rules": { + "import/no-extraneous-dependencies": ["error", { "devDependencies": true }], + "jest/consistent-test-it": "error", + "no-only-tests/no-only-tests": "error", + "prefer-promise-reject-errors": 0, + + "testing-library/no-node-access": "off", + "testing-library/prefer-screen-queries": "off", + "testing-library/no-container": "off", + "testing-library/await-async-queries": "off", + "testing-library/await-async-utils": "off", + "testing-library/no-await-sync-events": "off", + "testing-library/no-render-in-lifecycle": "off", + "testing-library/no-unnecessary-act": "off", + "testing-library/no-wait-for-multiple-assertions": "off", + "testing-library/await-async-events": "off", + "testing-library/no-wait-for-side-effects": "off", + "testing-library/prefer-presence-queries": "off", + "testing-library/render-result-naming-convention": "off", + "testing-library/prefer-find-by": "off", + "testing-library/no-manual-cleanup": "off" + } +} diff --git a/superset-frontend/packages/superset-ui-core/__mocks__/mockExportObject.js b/superset-frontend/packages/superset-ui-core/__mocks__/mockExportObject.js new file mode 100644 index 00000000000..ab22d88b5b2 --- /dev/null +++ b/superset-frontend/packages/superset-ui-core/__mocks__/mockExportObject.js @@ -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. + */ +module.exports = {}; diff --git a/superset-frontend/packages/superset-ui-core/__mocks__/mockExportString.js b/superset-frontend/packages/superset-ui-core/__mocks__/mockExportString.js new file mode 100644 index 00000000000..5b7f1d6da96 --- /dev/null +++ b/superset-frontend/packages/superset-ui-core/__mocks__/mockExportString.js @@ -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. + */ +module.exports = 'test-file-stub'; diff --git a/superset-frontend/packages/superset-ui-core/__mocks__/svgrMock.tsx b/superset-frontend/packages/superset-ui-core/__mocks__/svgrMock.tsx new file mode 100644 index 00000000000..4f1178bee8d --- /dev/null +++ b/superset-frontend/packages/superset-ui-core/__mocks__/svgrMock.tsx @@ -0,0 +1,29 @@ +/** + * 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 { SVGProps, forwardRef } from 'react'; + +const SvgrMock = forwardRef>( + (props, ref) => , +); + +SvgrMock.displayName = 'SvgrMock'; + +export const ReactComponent = SvgrMock; +export default SvgrMock; diff --git a/superset-frontend/packages/superset-ui-core/package.json b/superset-frontend/packages/superset-ui-core/package.json index 26bd3494599..2b760997b56 100644 --- a/superset-frontend/packages/superset-ui-core/package.json +++ b/superset-frontend/packages/superset-ui-core/package.json @@ -24,23 +24,37 @@ "lib" ], "dependencies": { + "@ant-design/icons": "^5.2.6", "@babel/runtime": "^7.25.6", "@fontsource/fira-code": "^5.0.18", "@fontsource/inter": "^5.0.20", "@types/json-bigint": "^1.0.4", + "ace-builds": "^1.41.0", + "brace": "^0.11.1", + "classnames": "^2.2.5", "csstype": "^3.1.3", + "core-js": "^3.38.1", "d3-format": "^1.3.2", + "dayjs": "^1.11.13", "d3-interpolate": "^3.0.1", "d3-scale": "^3.0.0", "d3-time": "^3.1.0", "d3-time-format": "^4.1.0", + "dompurify": "^3.2.4", "fetch-retry": "^6.0.0", "jed": "^1.1.1", "lodash": "^4.17.21", "math-expression-evaluator": "^2.0.6", "pretty-ms": "^9.2.0", + "re-resizable": "^6.10.1", + "react-ace": "^10.1.0", + "react-js-cron": "^2.1.2", + "react-draggable": "^4.4.6", + "react-resize-detector": "^7.1.2", + "react-ultimate-pagination": "^1.3.2", "react-error-boundary": "^5.0.0", "react-markdown": "^8.0.7", + "regenerator-runtime": "^0.14.1", "rehype-raw": "^7.0.0", "rehype-sanitize": "^6.0.0", "remark-gfm": "^3.0.1", @@ -58,8 +72,10 @@ "@types/d3-scale": "^2.1.1", "@types/d3-time": "^3.0.4", "@types/d3-time-format": "^4.0.3", + "@types/react-table": "^7.7.20", "@types/enzyme": "^3.10.18", "@types/fetch-mock": "^7.3.8", + "@types/jquery": "^3.5.8", "@types/lodash": "^4.17.16", "@types/math-expression-evaluator": "^1.3.3", "@types/node": "^22.10.3", @@ -83,6 +99,7 @@ "@testing-library/user-event": "*", "@types/react": "*", "@types/react-loadable": "*", + "@types/react-window": "^1.8.8", "@types/tinycolor2": "*", "nanoid": "^5.0.9", "react": "^17.0.2", @@ -91,5 +108,27 @@ }, "publishConfig": { "access": "public" + }, + "exports": { + ".": { + "import": "./esm/index.js", + "require": "./lib/index.js", + "types": "./lib/index.d.ts" + }, + "./components/*": { + "import": "./esm/components/*/index.js", + "require": "./lib/components/*/index.js", + "types": "./lib/components/*/index.d.ts" + }, + "./components": { + "import": "./esm/components/index.js", + "require": "./lib/components/index.js", + "types": "./lib/components/index.d.ts" + }, + "./utils/*": { + "import": "./esm/utils/*.js", + "require": "./lib/utils/*.js", + "types": "./lib/utils/*.d.ts" + } } } diff --git a/superset-frontend/src/components/Alert/Alert.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/Alert/Alert.stories.tsx similarity index 100% rename from superset-frontend/src/components/Alert/Alert.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Alert/Alert.stories.tsx diff --git a/superset-frontend/src/components/Alert/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/Alert/index.tsx similarity index 100% rename from superset-frontend/src/components/Alert/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Alert/index.tsx diff --git a/superset-frontend/src/components/Alert/types.ts b/superset-frontend/packages/superset-ui-core/src/components/Alert/types.ts similarity index 100% rename from superset-frontend/src/components/Alert/types.ts rename to superset-frontend/packages/superset-ui-core/src/components/Alert/types.ts diff --git a/superset-frontend/src/components/AntdThemeProvider/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/AntdThemeProvider/index.tsx similarity index 100% rename from superset-frontend/src/components/AntdThemeProvider/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/AntdThemeProvider/index.tsx diff --git a/superset-frontend/src/components/AsyncAceEditor/AsyncAceEditor.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/AsyncAceEditor/AsyncAceEditor.stories.tsx similarity index 100% rename from superset-frontend/src/components/AsyncAceEditor/AsyncAceEditor.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/AsyncAceEditor/AsyncAceEditor.stories.tsx diff --git a/superset-frontend/src/components/AsyncAceEditor/AsyncAceEditor.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/AsyncAceEditor/AsyncAceEditor.test.tsx similarity index 97% rename from superset-frontend/src/components/AsyncAceEditor/AsyncAceEditor.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/AsyncAceEditor/AsyncAceEditor.test.tsx index b0170a36e7c..151b1db1a93 100644 --- a/superset-frontend/src/components/AsyncAceEditor/AsyncAceEditor.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/AsyncAceEditor/AsyncAceEditor.test.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { render, screen, waitFor } from 'spec/helpers/testing-library'; +import { render, screen, waitFor } from '@superset-ui/core/spec'; import { AsyncAceEditor, SQLEditor, diff --git a/superset-frontend/src/components/AsyncAceEditor/Tooltip.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/AsyncAceEditor/Tooltip.test.tsx similarity index 100% rename from superset-frontend/src/components/AsyncAceEditor/Tooltip.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/AsyncAceEditor/Tooltip.test.tsx diff --git a/superset-frontend/src/components/AsyncAceEditor/Tooltip.tsx b/superset-frontend/packages/superset-ui-core/src/components/AsyncAceEditor/Tooltip.tsx similarity index 100% rename from superset-frontend/src/components/AsyncAceEditor/Tooltip.tsx rename to superset-frontend/packages/superset-ui-core/src/components/AsyncAceEditor/Tooltip.tsx diff --git a/superset-frontend/src/components/AsyncAceEditor/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/AsyncAceEditor/index.tsx similarity index 59% rename from superset-frontend/src/components/AsyncAceEditor/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/AsyncAceEditor/index.tsx index cb75630a067..e4292b25b5b 100644 --- a/superset-frontend/src/components/AsyncAceEditor/index.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/AsyncAceEditor/index.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { forwardRef, useEffect, ComponentType } from 'react'; +import { forwardRef, useEffect, useCallback, ComponentType } from 'react'; import type { Editor as OrigEditor, @@ -30,8 +30,7 @@ import type { IAceEditorProps } from 'react-ace'; import { AsyncEsmComponent, PlaceholderProps, -} from 'src/components/AsyncEsmComponent'; -import useEffectEvent from 'src/hooks/useEffectEvent'; +} from '@superset-ui/core/components/AsyncEsmComponent'; import { useTheme, css } from '@superset-ui/core'; import { Global } from '@emotion/react'; @@ -156,9 +155,10 @@ export function AsyncAceEditor( }, ref, ) { - const supersetTheme = useTheme(); + const token = useTheme(); const langTools = acequire('ace/ext/language_tools'); - const setCompleters = useEffectEvent( + + const setCompleters = useCallback( (keywords: AceCompleterKeyword[]) => { const completer = { getCompletions: ( @@ -181,7 +181,9 @@ export function AsyncAceEditor( }; langTools.setCompleters([completer]); }, + [langTools, mode], ); + useEffect(() => { if (keywords) { setCompleters(keywords); @@ -193,36 +195,148 @@ export function AsyncAceEditor( .ant-tag { + margin-right: 0px; + } + } + } + + /* Adjust the searchbox to match theme */ + .ace_search { + background-color: ${token.colorBgContainer} !important; + color: ${token.colorText} !important; + border: 1px solid ${token.colorBorder} !important; + } + + .ace_search_field { + background-color: ${token.colorBgContainer} !important; + color: ${token.colorText} !important; + border: 1px solid ${token.colorBorder} !important; + } + + .ace_button { + background-color: ${token.colorBgElevated} !important; + color: ${token.colorText} !important; + border: 1px solid ${token.colorBorder} !important; + } + + .ace_button:hover { + background-color: ${token.colorPrimaryBg} !important; } `} /> diff --git a/superset-frontend/src/components/AsyncAceEditor/types.ts b/superset-frontend/packages/superset-ui-core/src/components/AsyncAceEditor/types.ts similarity index 100% rename from superset-frontend/src/components/AsyncAceEditor/types.ts rename to superset-frontend/packages/superset-ui-core/src/components/AsyncAceEditor/types.ts diff --git a/superset-frontend/src/components/AsyncEsmComponent/AsyncEsmComponent.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/AsyncEsmComponent/AsyncEsmComponent.stories.tsx similarity index 100% rename from superset-frontend/src/components/AsyncEsmComponent/AsyncEsmComponent.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/AsyncEsmComponent/AsyncEsmComponent.stories.tsx diff --git a/superset-frontend/src/components/AsyncEsmComponent/AsyncEsmComponent.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/AsyncEsmComponent/AsyncEsmComponent.test.tsx similarity index 97% rename from superset-frontend/src/components/AsyncEsmComponent/AsyncEsmComponent.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/AsyncEsmComponent/AsyncEsmComponent.test.tsx index 8c16c800ecc..82a88a322f9 100644 --- a/superset-frontend/src/components/AsyncEsmComponent/AsyncEsmComponent.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/AsyncEsmComponent/AsyncEsmComponent.test.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { render, screen } from 'spec/helpers/testing-library'; +import { render, screen } from '@superset-ui/core/spec'; import { AsyncEsmComponent } from '.'; const Placeholder = () => Loading...; diff --git a/superset-frontend/src/components/AsyncEsmComponent/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/AsyncEsmComponent/index.tsx similarity index 100% rename from superset-frontend/src/components/AsyncEsmComponent/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/AsyncEsmComponent/index.tsx diff --git a/superset-frontend/src/components/AsyncEsmComponent/types.ts b/superset-frontend/packages/superset-ui-core/src/components/AsyncEsmComponent/types.ts similarity index 100% rename from superset-frontend/src/components/AsyncEsmComponent/types.ts rename to superset-frontend/packages/superset-ui-core/src/components/AsyncEsmComponent/types.ts diff --git a/superset-frontend/src/components/AutoComplete/AutoComplete.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/AutoComplete/AutoComplete.stories.tsx similarity index 100% rename from superset-frontend/src/components/AutoComplete/AutoComplete.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/AutoComplete/AutoComplete.stories.tsx diff --git a/superset-frontend/src/components/AutoComplete/AutoComplete.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/AutoComplete/AutoComplete.test.tsx similarity index 85% rename from superset-frontend/src/components/AutoComplete/AutoComplete.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/AutoComplete/AutoComplete.test.tsx index 93bdb3c6285..a69e2924cf2 100644 --- a/superset-frontend/src/components/AutoComplete/AutoComplete.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/AutoComplete/AutoComplete.test.tsx @@ -17,12 +17,7 @@ * under the License. */ import { useState } from 'react'; -import { - render, - screen, - userEvent, - waitFor, -} from 'spec/helpers/testing-library'; +import { render, screen, userEvent, waitFor } from '@superset-ui/core/spec'; import { Input } from '../Input'; import { AutoComplete } from '.'; @@ -49,17 +44,17 @@ const AutoCompleteTest = () => { }; describe('AutoComplete Component', () => { - test('renders input field', () => { + it('renders input field', () => { render(); expect( screen.getByPlaceholderText('Type to search...'), ).toBeInTheDocument(); }); - test('shows options when user types', async () => { + it('shows options when user types', async () => { render(); const input = screen.getByPlaceholderText('Type to search...'); - userEvent.type(input, 'test'); + await userEvent.type(input, 'test'); await waitFor(() => { expect(screen.getByText('test result 0')).toBeInTheDocument(); @@ -68,16 +63,16 @@ describe('AutoComplete Component', () => { }); }); - test('selecting an option updates input value', async () => { + it('selecting an option updates input value', async () => { render(); const input = screen.getByPlaceholderText('Type to search...'); - userEvent.type(input, 'test'); + await userEvent.type(input, 'test'); await waitFor(() => { expect(screen.getByText('test result 0')).toBeInTheDocument(); }); - userEvent.click(screen.getByText('test result 0')); + await userEvent.click(screen.getByText('test result 0')); expect(input).toHaveValue('test0'); }); }); diff --git a/superset-frontend/src/components/AutoComplete/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/AutoComplete/index.tsx similarity index 100% rename from superset-frontend/src/components/AutoComplete/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/AutoComplete/index.tsx diff --git a/superset-frontend/src/components/AutoComplete/types.ts b/superset-frontend/packages/superset-ui-core/src/components/AutoComplete/types.ts similarity index 100% rename from superset-frontend/src/components/AutoComplete/types.ts rename to superset-frontend/packages/superset-ui-core/src/components/AutoComplete/types.ts diff --git a/superset-frontend/src/components/Avatar/Avatar.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/Avatar/Avatar.stories.tsx similarity index 100% rename from superset-frontend/src/components/Avatar/Avatar.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Avatar/Avatar.stories.tsx diff --git a/superset-frontend/src/components/Avatar/Avatar.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/Avatar/Avatar.test.tsx similarity index 94% rename from superset-frontend/src/components/Avatar/Avatar.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Avatar/Avatar.test.tsx index 91fbe60d947..41b3d494925 100644 --- a/superset-frontend/src/components/Avatar/Avatar.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Avatar/Avatar.test.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { render } from 'spec/helpers/testing-library'; +import { render } from '@superset-ui/core/spec'; import { Avatar } from '.'; test('renders with default props', async () => { diff --git a/superset-frontend/src/components/Avatar/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/Avatar/index.tsx similarity index 100% rename from superset-frontend/src/components/Avatar/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Avatar/index.tsx diff --git a/superset-frontend/src/components/Avatar/types.ts b/superset-frontend/packages/superset-ui-core/src/components/Avatar/types.ts similarity index 100% rename from superset-frontend/src/components/Avatar/types.ts rename to superset-frontend/packages/superset-ui-core/src/components/Avatar/types.ts diff --git a/superset-frontend/src/components/Badge/Badge.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/Badge/Badge.stories.tsx similarity index 100% rename from superset-frontend/src/components/Badge/Badge.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Badge/Badge.stories.tsx diff --git a/superset-frontend/src/components/Badge/Badge.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/Badge/Badge.test.tsx similarity index 95% rename from superset-frontend/src/components/Badge/Badge.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Badge/Badge.test.tsx index 8f666349c7c..98fa396bfb6 100644 --- a/superset-frontend/src/components/Badge/Badge.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Badge/Badge.test.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { render, screen } from 'spec/helpers/testing-library'; +import { render, screen } from '@superset-ui/core/spec'; import { Badge } from '.'; const mockedProps = { diff --git a/superset-frontend/src/components/Badge/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/Badge/index.tsx similarity index 100% rename from superset-frontend/src/components/Badge/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Badge/index.tsx diff --git a/superset-frontend/src/components/Badge/types.ts b/superset-frontend/packages/superset-ui-core/src/components/Badge/types.ts similarity index 100% rename from superset-frontend/src/components/Badge/types.ts rename to superset-frontend/packages/superset-ui-core/src/components/Badge/types.ts diff --git a/superset-frontend/src/components/Breadcrumb/Breadcrumb.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/Breadcrumb/Breadcrumb.stories.tsx similarity index 100% rename from superset-frontend/src/components/Breadcrumb/Breadcrumb.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Breadcrumb/Breadcrumb.stories.tsx diff --git a/superset-frontend/src/components/Breadcrumb/Breadcrumb.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/Breadcrumb/Breadcrumb.test.tsx similarity index 92% rename from superset-frontend/src/components/Breadcrumb/Breadcrumb.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Breadcrumb/Breadcrumb.test.tsx index 5edcf805f02..bd45b713059 100644 --- a/superset-frontend/src/components/Breadcrumb/Breadcrumb.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Breadcrumb/Breadcrumb.test.tsx @@ -16,12 +16,12 @@ * specific language governing permissions and limitations * under the License. */ -import { render, screen } from '@testing-library/react'; +import { render, screen } from '@superset-ui/core/spec'; import '@testing-library/jest-dom'; import { Breadcrumb } from '.'; describe('Breadcrumb Component', () => { - test('renders breadcrumb items correctly', () => { + it('renders breadcrumb items correctly', () => { render( Home diff --git a/superset-frontend/src/components/Breadcrumb/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/Breadcrumb/index.tsx similarity index 100% rename from superset-frontend/src/components/Breadcrumb/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Breadcrumb/index.tsx diff --git a/superset-frontend/src/components/Breadcrumb/types.ts b/superset-frontend/packages/superset-ui-core/src/components/Breadcrumb/types.ts similarity index 100% rename from superset-frontend/src/components/Breadcrumb/types.ts rename to superset-frontend/packages/superset-ui-core/src/components/Breadcrumb/types.ts diff --git a/superset-frontend/src/components/Button/Button.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/Button/Button.stories.tsx similarity index 100% rename from superset-frontend/src/components/Button/Button.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Button/Button.stories.tsx diff --git a/superset-frontend/src/components/Button/Button.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/Button/Button.test.tsx similarity index 96% rename from superset-frontend/src/components/Button/Button.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Button/Button.test.tsx index 25c41faf2d8..2f2c16db27b 100644 --- a/superset-frontend/src/components/Button/Button.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Button/Button.test.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { fireEvent, render } from 'spec/helpers/testing-library'; +import { fireEvent, render } from '@superset-ui/core/spec'; import { Button } from '.'; import { ButtonGallery, diff --git a/superset-frontend/src/components/Button/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/Button/index.tsx similarity index 100% rename from superset-frontend/src/components/Button/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Button/index.tsx diff --git a/superset-frontend/src/components/Button/types.ts b/superset-frontend/packages/superset-ui-core/src/components/Button/types.ts similarity index 95% rename from superset-frontend/src/components/Button/types.ts rename to superset-frontend/packages/superset-ui-core/src/components/Button/types.ts index 2a8b102be75..92e29eaeed3 100644 --- a/superset-frontend/src/components/Button/types.ts +++ b/superset-frontend/packages/superset-ui-core/src/components/Button/types.ts @@ -24,7 +24,7 @@ import type { ButtonVariantType, ButtonColorType, } from 'antd/es/button'; -import { IconType } from 'src/components/Icons/types'; +import { IconType } from '@superset-ui/core/components/Icons/types'; import type { TooltipPlacement } from '../Tooltip/types'; export type { AntdButtonProps, ButtonType, ButtonVariantType, ButtonColorType }; diff --git a/superset-frontend/src/components/ButtonGroup/ButtonGroup.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/ButtonGroup/ButtonGroup.stories.tsx similarity index 100% rename from superset-frontend/src/components/ButtonGroup/ButtonGroup.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/ButtonGroup/ButtonGroup.stories.tsx diff --git a/superset-frontend/src/components/ButtonGroup/ButtonGroup.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/ButtonGroup/ButtonGroup.test.tsx similarity index 96% rename from superset-frontend/src/components/ButtonGroup/ButtonGroup.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/ButtonGroup/ButtonGroup.test.tsx index 62362eb970d..986027a9628 100644 --- a/superset-frontend/src/components/ButtonGroup/ButtonGroup.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/ButtonGroup/ButtonGroup.test.tsx @@ -17,7 +17,7 @@ * under the License. */ -import { render, screen } from 'spec/helpers/testing-library'; +import { render, screen } from '@superset-ui/core/spec'; import { Button } from '../Button'; import { ButtonGroup } from '.'; diff --git a/superset-frontend/src/components/ButtonGroup/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/ButtonGroup/index.tsx similarity index 100% rename from superset-frontend/src/components/ButtonGroup/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/ButtonGroup/index.tsx diff --git a/superset-frontend/src/components/ButtonGroup/types.ts b/superset-frontend/packages/superset-ui-core/src/components/ButtonGroup/types.ts similarity index 100% rename from superset-frontend/src/components/ButtonGroup/types.ts rename to superset-frontend/packages/superset-ui-core/src/components/ButtonGroup/types.ts diff --git a/superset-frontend/src/components/CachedLabel/CachedLabel.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/CachedLabel/CachedLabel.test.tsx similarity index 95% rename from superset-frontend/src/components/CachedLabel/CachedLabel.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/CachedLabel/CachedLabel.test.tsx index 2e25ed99823..59d9d63088c 100644 --- a/superset-frontend/src/components/CachedLabel/CachedLabel.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/CachedLabel/CachedLabel.test.tsx @@ -18,7 +18,7 @@ */ import { isValidElement } from 'react'; -import { render, screen } from 'spec/helpers/testing-library'; +import { render, screen } from '@superset-ui/core/spec'; import { CachedLabel } from '.'; import type { CacheLabelProps } from './types'; diff --git a/superset-frontend/src/components/CachedLabel/TooltipContent.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/CachedLabel/TooltipContent.test.tsx similarity index 92% rename from superset-frontend/src/components/CachedLabel/TooltipContent.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/CachedLabel/TooltipContent.test.tsx index a9ba7babc04..72629c868b2 100644 --- a/superset-frontend/src/components/CachedLabel/TooltipContent.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/CachedLabel/TooltipContent.test.tsx @@ -17,8 +17,8 @@ * under the License. */ -import { render, screen } from 'spec/helpers/testing-library'; -import { extendedDayjs } from 'src/utils/dates'; +import { render, screen } from '@superset-ui/core/spec'; +import { extendedDayjs } from '../../utils/dates'; import { TooltipContent } from './TooltipContent'; test('Rendering TooltipContent correctly - no timestep', () => { diff --git a/superset-frontend/src/components/CachedLabel/TooltipContent.tsx b/superset-frontend/packages/superset-ui-core/src/components/CachedLabel/TooltipContent.tsx similarity index 96% rename from superset-frontend/src/components/CachedLabel/TooltipContent.tsx rename to superset-frontend/packages/superset-ui-core/src/components/CachedLabel/TooltipContent.tsx index fc0b5914f6b..470e2aa4a50 100644 --- a/superset-frontend/src/components/CachedLabel/TooltipContent.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/CachedLabel/TooltipContent.tsx @@ -18,8 +18,8 @@ */ import { FC } from 'react'; -import { extendedDayjs } from 'src/utils/dates'; import { t } from '@superset-ui/core'; +import { extendedDayjs } from '../../utils/dates'; interface Props { cachedTimestamp?: string; diff --git a/superset-frontend/src/components/CachedLabel/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/CachedLabel/index.tsx similarity index 96% rename from superset-frontend/src/components/CachedLabel/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/CachedLabel/index.tsx index bf1f55fdee4..3a535377622 100644 --- a/superset-frontend/src/components/CachedLabel/index.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/CachedLabel/index.tsx @@ -19,7 +19,7 @@ import { useState, FC } from 'react'; import { t } from '@superset-ui/core'; -import { Icons } from 'src/components/Icons'; +import { Icons } from '@superset-ui/core/components/Icons'; import { Label } from '../Label'; import { Tooltip } from '../Tooltip'; import { TooltipContent } from './TooltipContent'; diff --git a/superset-frontend/src/components/CachedLabel/types.ts b/superset-frontend/packages/superset-ui-core/src/components/CachedLabel/types.ts similarity index 100% rename from superset-frontend/src/components/CachedLabel/types.ts rename to superset-frontend/packages/superset-ui-core/src/components/CachedLabel/types.ts diff --git a/superset-frontend/src/components/Card/Card.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/Card/Card.stories.tsx similarity index 100% rename from superset-frontend/src/components/Card/Card.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Card/Card.stories.tsx diff --git a/superset-frontend/src/components/Card/Card.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/Card/Card.test.tsx similarity index 94% rename from superset-frontend/src/components/Card/Card.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Card/Card.test.tsx index 2254b4d3c17..5f4028cda2f 100644 --- a/superset-frontend/src/components/Card/Card.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Card/Card.test.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { render, waitFor } from 'spec/helpers/testing-library'; +import { render, waitFor } from '@superset-ui/core/spec'; import { Card } from '.'; afterEach(async () => { diff --git a/superset-frontend/src/components/Card/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/Card/index.tsx similarity index 100% rename from superset-frontend/src/components/Card/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Card/index.tsx diff --git a/superset-frontend/src/components/Card/types.ts b/superset-frontend/packages/superset-ui-core/src/components/Card/types.ts similarity index 100% rename from superset-frontend/src/components/Card/types.ts rename to superset-frontend/packages/superset-ui-core/src/components/Card/types.ts diff --git a/superset-frontend/src/components/CertifiedBadge/CertifiedBadge.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/CertifiedBadge/CertifiedBadge.stories.tsx similarity index 100% rename from superset-frontend/src/components/CertifiedBadge/CertifiedBadge.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/CertifiedBadge/CertifiedBadge.stories.tsx diff --git a/superset-frontend/src/components/CertifiedBadge/CertifiedBadge.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/CertifiedBadge/CertifiedBadge.test.tsx similarity index 88% rename from superset-frontend/src/components/CertifiedBadge/CertifiedBadge.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/CertifiedBadge/CertifiedBadge.test.tsx index b67c0eca446..000f04ac666 100644 --- a/superset-frontend/src/components/CertifiedBadge/CertifiedBadge.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/CertifiedBadge/CertifiedBadge.test.tsx @@ -16,12 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { - render, - screen, - userEvent, - waitFor, -} from 'spec/helpers/testing-library'; +import { render, screen, userEvent, waitFor } from '@superset-ui/core/spec'; import { CertifiedBadge } from '.'; import type { CertifiedBadgeProps } from './types'; @@ -35,20 +30,20 @@ test('renders with default props', async () => { test('renders a tooltip when hovered', async () => { await asyncRender(); - userEvent.hover(screen.getByRole('img')); + await userEvent.hover(screen.getByRole('img')); expect(await screen.findByRole('tooltip')).toBeInTheDocument(); }); test('renders with certified by', async () => { const certifiedBy = 'Trusted Authority'; await asyncRender({ certifiedBy }); - userEvent.hover(screen.getByRole('img')); + await userEvent.hover(screen.getByRole('img')); expect(await screen.findByRole('tooltip')).toHaveTextContent(certifiedBy); }); test('renders with details', async () => { const details = 'All requirements have been met.'; await asyncRender({ details }); - userEvent.hover(screen.getByRole('img')); + await userEvent.hover(screen.getByRole('img')); expect(await screen.findByRole('tooltip')).toHaveTextContent(details); }); diff --git a/superset-frontend/src/components/CertifiedBadge/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/CertifiedBadge/index.tsx similarity index 96% rename from superset-frontend/src/components/CertifiedBadge/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/CertifiedBadge/index.tsx index 144f924bd78..4eff6bf4d50 100644 --- a/superset-frontend/src/components/CertifiedBadge/index.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/CertifiedBadge/index.tsx @@ -17,7 +17,7 @@ * under the License. */ import { t, useTheme } from '@superset-ui/core'; -import { Icons } from 'src/components/Icons'; +import { Icons } from '@superset-ui/core/components/Icons'; import { Tooltip } from '../Tooltip'; import type { CertifiedBadgeProps } from './types'; diff --git a/superset-frontend/src/components/CertifiedBadge/types.ts b/superset-frontend/packages/superset-ui-core/src/components/CertifiedBadge/types.ts similarity index 92% rename from superset-frontend/src/components/CertifiedBadge/types.ts rename to superset-frontend/packages/superset-ui-core/src/components/CertifiedBadge/types.ts index 947ec0082f9..71f8b4c909f 100644 --- a/superset-frontend/src/components/CertifiedBadge/types.ts +++ b/superset-frontend/packages/superset-ui-core/src/components/CertifiedBadge/types.ts @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import type { IconType } from 'src/components/Icons/types'; +import type { IconType } from '@superset-ui/core/components/Icons/types'; export interface CertifiedBadgeProps { certifiedBy?: string; diff --git a/superset-frontend/src/components/Checkbox/Checkbox.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/Checkbox/Checkbox.stories.tsx similarity index 100% rename from superset-frontend/src/components/Checkbox/Checkbox.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Checkbox/Checkbox.stories.tsx diff --git a/superset-frontend/src/components/Checkbox/Checkbox.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/Checkbox/Checkbox.test.tsx similarity index 80% rename from superset-frontend/src/components/Checkbox/Checkbox.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Checkbox/Checkbox.test.tsx index b53e6da30a6..0b88e0297ab 100644 --- a/superset-frontend/src/components/Checkbox/Checkbox.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Checkbox/Checkbox.test.tsx @@ -16,12 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { - render, - screen, - userEvent, - waitFor, -} from 'spec/helpers/testing-library'; +import { render, screen, userEvent, waitFor } from '@superset-ui/core/spec'; import { Checkbox } from '.'; import type { CheckboxProps } from './types'; @@ -44,37 +39,37 @@ describe('Checkbox Component', () => { }); describe('Rendering', () => { - test('should render correctly', async () => { + it('should render correctly', async () => { const { container } = await asyncRender(); expect(container).toBeInTheDocument(); }); - test('should render the label', async () => { + it('should render the label', async () => { await asyncRender(); expect(screen.getByText('Checkbox Label')).toBeInTheDocument(); }); - test('should render the checkbox', async () => { + it('should render the checkbox', async () => { await asyncRender(); expect(screen.getByRole('checkbox')).toBeInTheDocument(); }); }); describe('States', () => { - test('should render as unchecked when checked is false', async () => { + it('should render as unchecked when checked is false', async () => { await asyncRender(); const checkbox = screen.getByRole('checkbox'); expect(checkbox).not.toBeChecked(); }); - test('should render as checked when checked is true', async () => { + it('should render as checked when checked is true', async () => { const checkedProps = { ...mockedProps, checked: true }; await asyncRender(checkedProps); const checkbox = screen.getByRole('checkbox'); expect(checkbox).toBeChecked(); }); - test('should render as indeterminate when indeterminate is true', async () => { + it('should render as indeterminate when indeterminate is true', async () => { const indeterminateProps = { ...mockedProps, indeterminate: true }; await asyncRender(indeterminateProps); const checkbox = screen.getByRole('checkbox'); @@ -82,7 +77,7 @@ describe('Checkbox Component', () => { expect((checkbox as HTMLInputElement).indeterminate).toBe(true); }); - test('should render as disabled when disabled prop is true', async () => { + it('should render as disabled when disabled prop is true', async () => { const disabledProps = { ...mockedProps, disabled: true }; await asyncRender(disabledProps); expect(screen.getByRole('checkbox')).toBeDisabled(); @@ -90,14 +85,14 @@ describe('Checkbox Component', () => { }); describe('Interactions', () => { - test('should call the onChange handler when clicked', async () => { + it('should call the onChange handler when clicked', async () => { await asyncRender(); const checkbox = screen.getByRole('checkbox'); await userEvent.click(checkbox); expect(mockedProps.onChange).toHaveBeenCalledTimes(1); }); - test('should not call the onChange handler when disabled and clicked', async () => { + it('should not call the onChange handler when disabled and clicked', async () => { const mockOnChange = jest.fn(); const disabledProps = { ...mockedProps, @@ -113,7 +108,7 @@ describe('Checkbox Component', () => { expect(mockOnChange).not.toHaveBeenCalled(); }); - test('calls onChange handler successfully', async () => { + it('calls onChange handler successfully', async () => { const mockAction = jest.fn(); render(); const checkboxInput = screen.getByRole('checkbox'); diff --git a/superset-frontend/src/components/Checkbox/CheckboxIcons.tsx b/superset-frontend/packages/superset-ui-core/src/components/Checkbox/CheckboxIcons.tsx similarity index 100% rename from superset-frontend/src/components/Checkbox/CheckboxIcons.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Checkbox/CheckboxIcons.tsx diff --git a/superset-frontend/src/components/Checkbox/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/Checkbox/index.tsx similarity index 100% rename from superset-frontend/src/components/Checkbox/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Checkbox/index.tsx diff --git a/superset-frontend/src/components/Checkbox/types.ts b/superset-frontend/packages/superset-ui-core/src/components/Checkbox/types.ts similarity index 100% rename from superset-frontend/src/components/Checkbox/types.ts rename to superset-frontend/packages/superset-ui-core/src/components/Checkbox/types.ts diff --git a/superset-frontend/src/components/Collapse/Collapse.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/Collapse/Collapse.stories.tsx similarity index 100% rename from superset-frontend/src/components/Collapse/Collapse.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Collapse/Collapse.stories.tsx diff --git a/superset-frontend/src/components/Collapse/Collapse.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/Collapse/Collapse.test.tsx similarity index 90% rename from superset-frontend/src/components/Collapse/Collapse.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Collapse/Collapse.test.tsx index 4e9f74fe0cd..664215d88ad 100644 --- a/superset-frontend/src/components/Collapse/Collapse.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Collapse/Collapse.test.tsx @@ -16,8 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { render, screen } from 'spec/helpers/testing-library'; -import userEvent from '@testing-library/user-event'; +import { render, screen, userEvent } from '@superset-ui/core/spec'; import { Collapse } from '.'; import type { CollapseProps } from './types'; @@ -63,25 +62,25 @@ test('renders with one item expanded by default', () => { expect(screen.queryByText('Content 2')).not.toBeInTheDocument(); }); -test('expands on click', () => { +test('expands on click', async () => { renderCollapse(); expect(screen.queryByText('Content 1')).not.toBeInTheDocument(); expect(screen.queryByText('Content 2')).not.toBeInTheDocument(); - userEvent.click(screen.getAllByRole('button')[0]); + await userEvent.click(screen.getAllByRole('button')[0]); expect(screen.getByText('Content 1')).toBeInTheDocument(); expect(screen.queryByText('Content 2')).not.toBeInTheDocument(); }); -test('collapses on click', () => { +test('collapses on click', async () => { renderCollapse({ defaultActiveKey: ['1'] }); expect(screen.getByText('Content 1')).toBeInTheDocument(); expect(screen.queryByText('Content 2')).not.toBeInTheDocument(); - userEvent.click(screen.getAllByRole('button')[0]); + await userEvent.click(screen.getAllByRole('button')[0]); expect(screen.getByText('Content 1').parentNode).toHaveClass( 'ant-collapse-content-hidden', diff --git a/superset-frontend/src/components/Collapse/Collapse.tsx b/superset-frontend/packages/superset-ui-core/src/components/Collapse/Collapse.tsx similarity index 100% rename from superset-frontend/src/components/Collapse/Collapse.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Collapse/Collapse.tsx diff --git a/superset-frontend/src/components/Collapse/CollapseLabelInModal.tsx b/superset-frontend/packages/superset-ui-core/src/components/Collapse/CollapseLabelInModal.tsx similarity index 94% rename from superset-frontend/src/components/Collapse/CollapseLabelInModal.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Collapse/CollapseLabelInModal.tsx index 24935810c77..611ad304623 100644 --- a/superset-frontend/src/components/Collapse/CollapseLabelInModal.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Collapse/CollapseLabelInModal.tsx @@ -16,8 +16,8 @@ * under the License. */ import { useTheme } from '@superset-ui/core'; -import { Typography } from 'src/components/Typography'; -import { Icons } from 'src/components'; +import { Typography } from '@superset-ui/core/components/Typography'; +import { Icons } from '@superset-ui/core/components'; interface CollapseLabelInModalProps { title: React.ReactNode; diff --git a/superset-frontend/src/components/Collapse/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/Collapse/index.tsx similarity index 100% rename from superset-frontend/src/components/Collapse/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Collapse/index.tsx diff --git a/superset-frontend/src/components/Collapse/types.ts b/superset-frontend/packages/superset-ui-core/src/components/Collapse/types.ts similarity index 100% rename from superset-frontend/src/components/Collapse/types.ts rename to superset-frontend/packages/superset-ui-core/src/components/Collapse/types.ts diff --git a/superset-frontend/src/components/ConfirmStatusChange/ConfirmStatusChange.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/ConfirmStatusChange/ConfirmStatusChange.stories.tsx similarity index 96% rename from superset-frontend/src/components/ConfirmStatusChange/ConfirmStatusChange.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/ConfirmStatusChange/ConfirmStatusChange.stories.tsx index 132cea64c88..e61157329dc 100644 --- a/superset-frontend/src/components/ConfirmStatusChange/ConfirmStatusChange.stories.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/ConfirmStatusChange/ConfirmStatusChange.stories.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { Button } from 'src/components'; +import { Button } from '@superset-ui/core/components'; import { ConfirmStatusChange } from '.'; import type { ConfirmStatusChangeProps, Callback } from './types'; diff --git a/superset-frontend/src/components/ConfirmStatusChange/ConfirmStatusChange.test.jsx b/superset-frontend/packages/superset-ui-core/src/components/ConfirmStatusChange/ConfirmStatusChange.test.jsx similarity index 96% rename from superset-frontend/src/components/ConfirmStatusChange/ConfirmStatusChange.test.jsx rename to superset-frontend/packages/superset-ui-core/src/components/ConfirmStatusChange/ConfirmStatusChange.test.jsx index 2138a61d84f..bd84ca1a285 100644 --- a/superset-frontend/src/components/ConfirmStatusChange/ConfirmStatusChange.test.jsx +++ b/superset-frontend/packages/superset-ui-core/src/components/ConfirmStatusChange/ConfirmStatusChange.test.jsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { fireEvent, render, waitFor } from 'spec/helpers/testing-library'; +import { fireEvent, render, waitFor } from '@superset-ui/core/spec'; import { Button } from '../Button'; import { ConfirmStatusChange } from '.'; diff --git a/superset-frontend/src/components/ConfirmStatusChange/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/ConfirmStatusChange/index.tsx similarity index 100% rename from superset-frontend/src/components/ConfirmStatusChange/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/ConfirmStatusChange/index.tsx diff --git a/superset-frontend/src/components/ConfirmStatusChange/types.ts b/superset-frontend/packages/superset-ui-core/src/components/ConfirmStatusChange/types.ts similarity index 100% rename from superset-frontend/src/components/ConfirmStatusChange/types.ts rename to superset-frontend/packages/superset-ui-core/src/components/ConfirmStatusChange/types.ts diff --git a/superset-frontend/src/components/CronPicker/CronPicker.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/CronPicker/CronPicker.stories.tsx similarity index 100% rename from superset-frontend/src/components/CronPicker/CronPicker.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/CronPicker/CronPicker.stories.tsx diff --git a/superset-frontend/src/components/CronPicker/CronPicker.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/CronPicker/CronPicker.test.tsx similarity index 96% rename from superset-frontend/src/components/CronPicker/CronPicker.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/CronPicker/CronPicker.test.tsx index cbe8ae37dd1..3a95f27e556 100644 --- a/superset-frontend/src/components/CronPicker/CronPicker.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/CronPicker/CronPicker.test.tsx @@ -17,7 +17,7 @@ * under the License. */ -import { render } from 'spec/helpers/testing-library'; +import { render } from '@superset-ui/core/spec'; import * as ReactCronPicker from 'react-js-cron'; import { CronPicker } from '.'; diff --git a/superset-frontend/src/components/CronPicker/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/CronPicker/index.tsx similarity index 98% rename from superset-frontend/src/components/CronPicker/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/CronPicker/index.tsx index 54afd218e83..71f4545eba8 100644 --- a/superset-frontend/src/components/CronPicker/index.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/CronPicker/index.tsx @@ -20,6 +20,9 @@ import { styled, t } from '@superset-ui/core'; import ReactCronPicker from 'react-js-cron'; import type { Locale, CronProps } from './types'; +// Styles for the crontab-related lib +import 'react-js-cron/dist/styles.css'; + export const LOCALE: Locale = { everyText: t('every'), emptyMonths: t('every month'), diff --git a/superset-frontend/src/components/CronPicker/types.ts b/superset-frontend/packages/superset-ui-core/src/components/CronPicker/types.ts similarity index 100% rename from superset-frontend/src/components/CronPicker/types.ts rename to superset-frontend/packages/superset-ui-core/src/components/CronPicker/types.ts diff --git a/superset-frontend/src/components/DatePicker/DatePicker.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/DatePicker/DatePicker.stories.tsx similarity index 100% rename from superset-frontend/src/components/DatePicker/DatePicker.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/DatePicker/DatePicker.stories.tsx diff --git a/superset-frontend/src/components/DatePicker/DatePicker.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/DatePicker/DatePicker.test.tsx similarity index 95% rename from superset-frontend/src/components/DatePicker/DatePicker.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/DatePicker/DatePicker.test.tsx index 463c3ace578..eac06ac80cf 100644 --- a/superset-frontend/src/components/DatePicker/DatePicker.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/DatePicker/DatePicker.test.tsx @@ -17,7 +17,7 @@ * under the License. */ -import { render } from 'spec/helpers/testing-library'; +import { render } from '@superset-ui/core/spec'; import { DatePicker, RangePicker } from '.'; test('should render date picker', () => { diff --git a/superset-frontend/src/components/DatePicker/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/DatePicker/index.tsx similarity index 100% rename from superset-frontend/src/components/DatePicker/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/DatePicker/index.tsx diff --git a/superset-frontend/src/components/DatePicker/types.ts b/superset-frontend/packages/superset-ui-core/src/components/DatePicker/types.ts similarity index 100% rename from superset-frontend/src/components/DatePicker/types.ts rename to superset-frontend/packages/superset-ui-core/src/components/DatePicker/types.ts diff --git a/superset-frontend/src/components/DeleteModal/DeleteModal.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/DeleteModal/DeleteModal.test.tsx similarity index 87% rename from superset-frontend/src/components/DeleteModal/DeleteModal.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/DeleteModal/DeleteModal.test.tsx index 2f579e2e721..c04362cda0e 100644 --- a/superset-frontend/src/components/DeleteModal/DeleteModal.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/DeleteModal/DeleteModal.test.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { render, screen, userEvent } from 'spec/helpers/testing-library'; +import { render, userEvent, screen } from '@superset-ui/core/spec'; import { DeleteModal } from '.'; test('Must display title and content', () => { @@ -34,7 +34,7 @@ test('Must display title and content', () => { expect(screen.getByTestId('test-description')).toBeInTheDocument(); }); -test('Calling "onHide"', () => { +test('Calling "onHide"', async () => { const props = { title:
Title
, description:
Description
, @@ -48,12 +48,12 @@ test('Calling "onHide"', () => { expect(props.onConfirm).toHaveBeenCalledTimes(0); // type "del" in the input - userEvent.type(screen.getByTestId('delete-modal-input'), 'del'); + await userEvent.type(screen.getByTestId('delete-modal-input'), 'del'); expect(screen.getByTestId('delete-modal-input')).toHaveValue('del'); // close the modal expect(screen.getByText('×')).toBeInTheDocument(); - userEvent.click(screen.getByText('×')); + await userEvent.click(screen.getByText('×')); expect(props.onHide).toHaveBeenCalledTimes(1); expect(props.onConfirm).toHaveBeenCalledTimes(0); @@ -61,7 +61,7 @@ test('Calling "onHide"', () => { expect(screen.getByTestId('delete-modal-input')).toHaveValue(''); }); -test('Calling "onConfirm" only after typing "delete" in the input', () => { +test('Calling "onConfirm" only after typing "delete" in the input', async () => { const props = { title:
Title
, description:
Description
, @@ -76,12 +76,12 @@ test('Calling "onConfirm" only after typing "delete" in the input', () => { expect(props.onConfirm).toHaveBeenCalledTimes(0); // do not execute "onConfirm" if you have not typed "delete" - userEvent.click(screen.getByText('Delete')); + await userEvent.click(screen.getByText('Delete')); expect(props.onConfirm).toHaveBeenCalledTimes(0); // execute "onConfirm" if you have typed "delete" - userEvent.type(screen.getByTestId('delete-modal-input'), 'delete'); - userEvent.click(screen.getByText('Delete')); + await userEvent.type(screen.getByTestId('delete-modal-input'), 'delete'); + await userEvent.click(screen.getByText('Delete')); expect(props.onConfirm).toHaveBeenCalledTimes(1); // confirm input has been cleared diff --git a/superset-frontend/src/components/DeleteModal/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/DeleteModal/index.tsx similarity index 100% rename from superset-frontend/src/components/DeleteModal/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/DeleteModal/index.tsx diff --git a/superset-frontend/src/components/DeleteModal/types.ts b/superset-frontend/packages/superset-ui-core/src/components/DeleteModal/types.ts similarity index 100% rename from superset-frontend/src/components/DeleteModal/types.ts rename to superset-frontend/packages/superset-ui-core/src/components/DeleteModal/types.ts diff --git a/superset-frontend/src/components/DesignSystem.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/DesignSystem.stories.tsx similarity index 100% rename from superset-frontend/src/components/DesignSystem.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/DesignSystem.stories.tsx diff --git a/superset-frontend/src/components/Divider/Divider.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/Divider/Divider.stories.tsx similarity index 100% rename from superset-frontend/src/components/Divider/Divider.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Divider/Divider.stories.tsx diff --git a/superset-frontend/src/components/Divider/Divider.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/Divider/Divider.test.tsx similarity index 94% rename from superset-frontend/src/components/Divider/Divider.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Divider/Divider.test.tsx index 8148754c0e0..8767adde014 100644 --- a/superset-frontend/src/components/Divider/Divider.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Divider/Divider.test.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { render } from 'spec/helpers/testing-library'; +import { render } from '@superset-ui/core/spec'; import { Divider } from '.'; test('should render', () => { diff --git a/superset-frontend/src/components/Divider/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/Divider/index.tsx similarity index 100% rename from superset-frontend/src/components/Divider/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Divider/index.tsx diff --git a/superset-frontend/src/components/Divider/types.ts b/superset-frontend/packages/superset-ui-core/src/components/Divider/types.ts similarity index 100% rename from superset-frontend/src/components/Divider/types.ts rename to superset-frontend/packages/superset-ui-core/src/components/Divider/types.ts diff --git a/superset-frontend/src/components/Dropdown/Dropdown.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/Dropdown/Dropdown.stories.tsx similarity index 96% rename from superset-frontend/src/components/Dropdown/Dropdown.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Dropdown/Dropdown.stories.tsx index 5f0f9717caf..29d8998806c 100644 --- a/superset-frontend/src/components/Dropdown/Dropdown.stories.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Dropdown/Dropdown.stories.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { Menu } from 'src/components/Menu'; +import { Menu } from '@superset-ui/core/components/Menu'; import { MenuDotsDropdown } from '.'; import type { MenuDotsDropdownProps } from './types'; diff --git a/superset-frontend/src/components/Dropdown/Dropdown.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/Dropdown/Dropdown.test.tsx similarity index 96% rename from superset-frontend/src/components/Dropdown/Dropdown.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Dropdown/Dropdown.test.tsx index 65ae7208c60..9baaef9adbf 100644 --- a/superset-frontend/src/components/Dropdown/Dropdown.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Dropdown/Dropdown.test.tsx @@ -17,7 +17,7 @@ * under the License. */ -import { render, fireEvent, screen } from 'spec/helpers/testing-library'; +import { render, fireEvent, screen } from '@superset-ui/core/spec'; import { NoAnimationDropdown } from '.'; const props = { diff --git a/superset-frontend/src/components/Dropdown/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/Dropdown/index.tsx similarity index 98% rename from superset-frontend/src/components/Dropdown/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Dropdown/index.tsx index b3ffde7341a..4b1e0c449b5 100644 --- a/superset-frontend/src/components/Dropdown/index.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Dropdown/index.tsx @@ -20,7 +20,7 @@ import { ReactElement, cloneElement } from 'react'; import { Dropdown as AntdDropdown, DropdownProps } from 'antd'; import { styled } from '@superset-ui/core'; -import { Icons } from 'src/components/Icons'; +import { Icons } from '@superset-ui/core/components/Icons'; import { IconOrientation, type NoAnimationDropdownProps, diff --git a/superset-frontend/src/components/Dropdown/types.ts b/superset-frontend/packages/superset-ui-core/src/components/Dropdown/types.ts similarity index 100% rename from superset-frontend/src/components/Dropdown/types.ts rename to superset-frontend/packages/superset-ui-core/src/components/Dropdown/types.ts diff --git a/superset-frontend/src/components/DropdownButton/DropdownButton.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/DropdownButton/DropdownButton.stories.tsx similarity index 96% rename from superset-frontend/src/components/DropdownButton/DropdownButton.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/DropdownButton/DropdownButton.stories.tsx index 851d0abcc46..b406d9b4da5 100644 --- a/superset-frontend/src/components/DropdownButton/DropdownButton.stories.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/DropdownButton/DropdownButton.stories.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { Menu } from 'src/components/Menu'; +import { Menu } from '@superset-ui/core/components/Menu'; import { DropdownButton } from '.'; import type { DropdownButtonProps } from './types'; diff --git a/superset-frontend/src/components/DropdownButton/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/DropdownButton/index.tsx similarity index 100% rename from superset-frontend/src/components/DropdownButton/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/DropdownButton/index.tsx diff --git a/superset-frontend/src/components/DropdownButton/types.ts b/superset-frontend/packages/superset-ui-core/src/components/DropdownButton/types.ts similarity index 100% rename from superset-frontend/src/components/DropdownButton/types.ts rename to superset-frontend/packages/superset-ui-core/src/components/DropdownButton/types.ts diff --git a/superset-frontend/src/components/DropdownContainer/DropdownContainer.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/DropdownContainer/DropdownContainer.stories.tsx similarity index 100% rename from superset-frontend/src/components/DropdownContainer/DropdownContainer.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/DropdownContainer/DropdownContainer.stories.tsx diff --git a/superset-frontend/packages/superset-ui-core/src/components/DropdownContainer/DropdownContainer.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/DropdownContainer/DropdownContainer.test.tsx new file mode 100644 index 00000000000..f46b151c7a3 --- /dev/null +++ b/superset-frontend/packages/superset-ui-core/src/components/DropdownContainer/DropdownContainer.test.tsx @@ -0,0 +1,180 @@ +/** + * 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 { screen, render } from '@superset-ui/core/spec'; +import { Button, DropdownContainer, Icons } from '..'; + +const generateItems = (n: number) => + Array.from({ length: n }).map((_, i) => ({ + id: `el-${i + 1}`, + element: , + })); + +const ITEMS = generateItems(10); + +beforeEach(() => { + // Reset any mocks + jest.restoreAllMocks(); + + // Mock ResizeObserver globally + global.ResizeObserver = jest.fn().mockImplementation(() => ({ + observe: jest.fn(), + unobserve: jest.fn(), + disconnect: jest.fn(), + })); +}); + +test('renders children', () => { + render(); + expect(screen.getByText('Element 1')).toBeInTheDocument(); + expect(screen.getByText('Element 2')).toBeInTheDocument(); + expect(screen.getByText('Element 3')).toBeInTheDocument(); +}); + +test('renders children with custom horizontal spacing', () => { + render(); + expect(screen.getByTestId('container')).toHaveStyle('gap: 20px'); +}); + +test('does not render a dropdown button when not overflowing', () => { + render(); + expect(screen.queryByText('More')).not.toBeInTheDocument(); +}); + +test('renders component with dropdown trigger icon prop without error', () => { + render( + } + />, + ); + // Component should render without error + expect(screen.getByText('Element 1')).toBeInTheDocument(); +}); + +test('renders component with dropdown trigger text prop without error', () => { + const customText = 'Custom text'; + render( + , + ); + // Component should render without error + expect(screen.getByText('Element 1')).toBeInTheDocument(); +}); + +test('renders component with dropdown trigger count prop without error', () => { + const customCount = 99; + render( + , + ); + // Component should render without error + expect(screen.getByText('Element 1')).toBeInTheDocument(); +}); + +test('renders component with dropdown style prop without error', () => { + render( + , + ); + // Component should render without error + expect(screen.getByText('Element 1')).toBeInTheDocument(); +}); + +test('renders component with onOverflowingStateChange prop without error', () => { + const onOverflowingStateChange = jest.fn(); + render( + , + ); + // Component should render without error + expect(screen.getByText('Element 1')).toBeInTheDocument(); +}); + +test('renders component with custom dropdown content prop without error', () => { + const customDropdownContent =
Custom content
; + render( + customDropdownContent} + />, + ); + // Component should render without error + expect(screen.getByText('Element 1')).toBeInTheDocument(); +}); + +test('renders component with dropdown trigger tooltip prop without error', () => { + render( + , + ); + // Component should render without error + expect(screen.getByText('Element 1')).toBeInTheDocument(); +}); + +// Tests that can work without complex overflow mocking +test('container has correct test id', () => { + render(); + expect(screen.getByTestId('container')).toBeInTheDocument(); +}); + +test('renders all provided items when not overflowing', () => { + const items = generateItems(3); + render(); + + items.forEach((item, index) => { + expect(screen.getByText(`Element ${index + 1}`)).toBeInTheDocument(); + }); +}); + +test('accepts custom style props', () => { + const customStyle = { backgroundColor: 'red', padding: '10px' }; + render(); + + const container = screen.getByTestId('container'); + expect(container).toHaveStyle('background-color: red'); + expect(container).toHaveStyle('padding: 10px'); +}); + +// Integration test that doesn't rely on specific overflow behavior +test('component renders and functions without throwing errors', () => { + const onOverflowingStateChange = jest.fn(); + + expect(() => { + render( + , + ); + }).not.toThrow(); + + // Basic functionality test + expect(screen.getByText('Element 1')).toBeInTheDocument(); +}); diff --git a/superset-frontend/src/components/DropdownContainer/Overview.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/DropdownContainer/Overview.stories.tsx similarity index 100% rename from superset-frontend/src/components/DropdownContainer/Overview.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/DropdownContainer/Overview.stories.tsx diff --git a/superset-frontend/src/components/DropdownContainer/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/DropdownContainer/index.tsx similarity index 98% rename from superset-frontend/src/components/DropdownContainer/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/DropdownContainer/index.tsx index 15ed6355334..b9835e3e132 100644 --- a/superset-frontend/src/components/DropdownContainer/index.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/DropdownContainer/index.tsx @@ -31,11 +31,7 @@ import { import { Global } from '@emotion/react'; import { css, t, useTheme, usePrevious } from '@superset-ui/core'; import { useResizeDetector } from 'react-resize-detector'; -import { Icons } from 'src/components/Icons'; -import { Badge } from '../Badge'; -import { Button } from '../Button'; -import { Tooltip } from '../Tooltip'; -import Popover from '../Popover'; +import { Badge, Icons, Button, Tooltip, Popover } from '..'; import type { DropdownContainerProps, DropdownItem, diff --git a/superset-frontend/src/components/DropdownContainer/types.ts b/superset-frontend/packages/superset-ui-core/src/components/DropdownContainer/types.ts similarity index 100% rename from superset-frontend/src/components/DropdownContainer/types.ts rename to superset-frontend/packages/superset-ui-core/src/components/DropdownContainer/types.ts diff --git a/superset-frontend/src/components/DynamicEditableTitle/DynamicEditableTitle.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/DynamicEditableTitle/DynamicEditableTitle.test.tsx similarity index 83% rename from superset-frontend/src/components/DynamicEditableTitle/DynamicEditableTitle.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/DynamicEditableTitle/DynamicEditableTitle.test.tsx index 544f408b179..c8e0ba13314 100644 --- a/superset-frontend/src/components/DynamicEditableTitle/DynamicEditableTitle.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/DynamicEditableTitle/DynamicEditableTitle.test.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { render, screen, userEvent } from 'spec/helpers/testing-library'; +import { render, screen, userEvent } from '@superset-ui/core/spec'; import { DynamicEditableTitle } from '.'; const createProps = (overrides: Record = {}) => ({ @@ -43,26 +43,26 @@ describe('Chart editable title', () => { expect(screen.getByText('Add the name of the chart')).toBeVisible(); }); - it('click, edit and save title', () => { + it('click, edit and save title', async () => { const props = createProps(); render(); const textboxElement = screen.getByRole('textbox'); - userEvent.click(textboxElement); - userEvent.type(textboxElement, ' edited'); + await userEvent.click(textboxElement); + await userEvent.type(textboxElement, ' edited'); expect(screen.getByText('Chart title edited')).toBeVisible(); - userEvent.type(textboxElement, '{enter}'); + await userEvent.type(textboxElement, '{enter}'); expect(props.onSave).toHaveBeenCalled(); }); - it('renders in non-editable mode', () => { + it('renders in non-editable mode', async () => { const props = createProps({ canEdit: false }); render(); const titleElement = screen.getByLabelText('Chart title'); const inputElement = screen.getByRole('textbox'); expect(inputElement).toBeDisabled(); expect(titleElement).toBeVisible(); - userEvent.click(titleElement); - userEvent.type(titleElement, ' edited{enter}'); + await userEvent.click(titleElement); + await userEvent.type(titleElement, ' edited{enter}'); expect(props.onSave).not.toHaveBeenCalled(); }); }); diff --git a/superset-frontend/src/components/DynamicEditableTitle/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/DynamicEditableTitle/index.tsx similarity index 100% rename from superset-frontend/src/components/DynamicEditableTitle/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/DynamicEditableTitle/index.tsx diff --git a/superset-frontend/src/components/DynamicEditableTitle/types.ts b/superset-frontend/packages/superset-ui-core/src/components/DynamicEditableTitle/types.ts similarity index 100% rename from superset-frontend/src/components/DynamicEditableTitle/types.ts rename to superset-frontend/packages/superset-ui-core/src/components/DynamicEditableTitle/types.ts diff --git a/superset-frontend/src/components/EditableTitle/EditableTitle.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/EditableTitle/EditableTitle.stories.tsx similarity index 100% rename from superset-frontend/src/components/EditableTitle/EditableTitle.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/EditableTitle/EditableTitle.stories.tsx diff --git a/superset-frontend/src/components/EditableTitle/EditableTitle.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/EditableTitle/EditableTitle.test.tsx similarity index 91% rename from superset-frontend/src/components/EditableTitle/EditableTitle.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/EditableTitle/EditableTitle.test.tsx index 82955594f3b..4440c116e24 100644 --- a/superset-frontend/src/components/EditableTitle/EditableTitle.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/EditableTitle/EditableTitle.test.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { fireEvent, render } from 'spec/helpers/testing-library'; +import { fireEvent, render } from '@superset-ui/core/spec'; import { EditableTitle } from '.'; const mockEvent = { @@ -48,7 +48,7 @@ test('should not render an input if it is not editable', () => { }); describe('should handle click', () => { - test('should enable editing mode on click', () => { + it('should enable editing mode on click', () => { const { getByTestId, container } = render(); fireEvent.click(getByTestId('textarea-editable-title-input')); @@ -59,7 +59,7 @@ describe('should handle click', () => { }); describe('should handle change', () => { - test('should change title', () => { + it('should change title', () => { const { getByTestId } = render(); const textarea = getByTestId('textarea-editable-title-input'); fireEvent.change(textarea, mockEvent); @@ -74,7 +74,7 @@ describe('should handle blur', () => { return selectors; }; - test('should trigger callback', () => { + it('should trigger callback', () => { const callback = jest.fn(); const { getByTestId } = setup({ onSaveTitle: callback }); fireEvent.change(getByTestId('textarea-editable-title-input'), mockEvent); @@ -83,7 +83,7 @@ describe('should handle blur', () => { expect(callback).toHaveBeenCalledWith('new title'); }); - test('should not trigger callback', () => { + it('should not trigger callback', () => { const callback = jest.fn(); const { getByTestId } = setup({ onSaveTitle: callback }); fireEvent.blur(getByTestId('textarea-editable-title-input')); @@ -91,7 +91,7 @@ describe('should handle blur', () => { expect(callback).not.toHaveBeenCalled(); }); - test('should not save empty title', () => { + it('should not save empty title', () => { const callback = jest.fn(); const { getByTestId } = setup({ onSaveTitle: callback }); const textarea = getByTestId('textarea-editable-title-input'); diff --git a/superset-frontend/src/components/EditableTitle/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/EditableTitle/index.tsx similarity index 92% rename from superset-frontend/src/components/EditableTitle/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/EditableTitle/index.tsx index 9e2afdcecda..3be6fd3f29e 100644 --- a/superset-frontend/src/components/EditableTitle/index.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/EditableTitle/index.tsx @@ -17,9 +17,8 @@ * under the License. */ -import { css, styled, SupersetTheme, t } from '@superset-ui/core'; +import { css, styled, t } from '@superset-ui/core'; import { useEffect, useState, useRef } from 'react'; -import { Link } from 'react-router-dom'; import cx from 'classnames'; import { Tooltip } from '../Tooltip'; import { CertifiedBadge } from '../CertifiedBadge'; @@ -82,7 +81,7 @@ export function EditableTitle({ placeholder = '', certifiedBy, certificationDetails, - url, + renderLink, maxWidth, autoSize = true, ...rest @@ -199,7 +198,7 @@ export function EditableTitle({ value = defaultTitle || title; } - let titleComponent = ( + let titleComponent: React.ReactNode = ( css` - color: ${theme.colorText}; - text-decoration: none; - :hover { - text-decoration: underline; - } - display: inline-block; - `} - > - {value} - - ) : ( - {value} - ); + if (renderLink) { + // New approach: let caller provide the link component + titleComponent = renderLink(value || ''); + } else { + titleComponent = {value}; + } } return ( diff --git a/superset-frontend/src/components/EditableTitle/types.ts b/superset-frontend/packages/superset-ui-core/src/components/EditableTitle/types.ts similarity index 96% rename from superset-frontend/src/components/EditableTitle/types.ts rename to superset-frontend/packages/superset-ui-core/src/components/EditableTitle/types.ts index 5370a8cd336..dc615dac644 100644 --- a/superset-frontend/src/components/EditableTitle/types.ts +++ b/superset-frontend/packages/superset-ui-core/src/components/EditableTitle/types.ts @@ -30,7 +30,7 @@ export interface EditableTitleProps { placeholder?: string; certifiedBy?: string; certificationDetails?: string; - url?: string; + renderLink?: (title: string) => React.ReactNode; maxWidth?: number; autoSize?: boolean; } diff --git a/superset-frontend/src/components/EmptyState/Empty.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/EmptyState/Empty.test.tsx similarity index 94% rename from superset-frontend/src/components/EmptyState/Empty.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/EmptyState/Empty.test.tsx index 7c9ace0fc81..da5dad601e0 100644 --- a/superset-frontend/src/components/EmptyState/Empty.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/EmptyState/Empty.test.tsx @@ -17,7 +17,7 @@ * under the License. */ -import { render } from 'spec/helpers/testing-library'; +import { render } from '@superset-ui/core/spec'; import { Empty } from './Empty'; test('should render', () => { diff --git a/superset-frontend/src/components/EmptyState/Empty.tsx b/superset-frontend/packages/superset-ui-core/src/components/EmptyState/Empty.tsx similarity index 100% rename from superset-frontend/src/components/EmptyState/Empty.tsx rename to superset-frontend/packages/superset-ui-core/src/components/EmptyState/Empty.tsx diff --git a/superset-frontend/src/components/EmptyState/EmptyState.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/EmptyState/EmptyState.stories.tsx similarity index 97% rename from superset-frontend/src/components/EmptyState/EmptyState.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/EmptyState/EmptyState.stories.tsx index 949548583fe..2c58d7ca459 100644 --- a/superset-frontend/src/components/EmptyState/EmptyState.stories.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/EmptyState/EmptyState.stories.tsx @@ -18,7 +18,7 @@ * under the License. */ import { Meta, StoryFn } from '@storybook/react'; -import { Row, Col } from 'src/components'; +import { Row, Col } from '@superset-ui/core/components'; import { EmptyState, imageMap } from '.'; const emptyStates = [ diff --git a/superset-frontend/src/components/EmptyState/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/EmptyState/index.tsx similarity index 83% rename from superset-frontend/src/components/EmptyState/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/EmptyState/index.tsx index 7b33d469f92..570119ff2fc 100644 --- a/superset-frontend/src/components/EmptyState/index.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/EmptyState/index.tsx @@ -20,22 +20,21 @@ import { ReactNode, SyntheticEvent } from 'react'; import { styled, css, SupersetTheme, t } from '@superset-ui/core'; // Importing svg images -import FilterResultsImage from 'src/assets/images/filter-results.svg'; -import ChartImage from 'src/assets/images/chart.svg'; -import FilterImage from 'src/assets/images/filter.svg'; -import EmptyChartsImage from 'src/assets/images/empty-charts.svg'; -import EmptyDashboardImage from 'src/assets/images/empty-dashboard.svg'; -import UnionImage from 'src/assets/images/union.svg'; -import StarCircleImage from 'src/assets/images/star-circle.svg'; -import VectorImage from 'src/assets/images/vector.svg'; -import DocumentImage from 'src/assets/images/document.svg'; -import DatasetImage from 'src/assets/images/empty-dataset.svg'; -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 FilterResultsImage from './svgs/filter-results.svg'; +import ChartImage from '../assets/svgs/chart.svg'; +import FilterImage from './svgs/filter.svg'; +import EmptyChartsImage from './svgs/empty-charts.svg'; +import EmptyDashboardImage from './svgs/empty-dashboard.svg'; +import UnionImage from './svgs/union.svg'; +import StarCircleImage from './svgs/star-circle.svg'; +import VectorImage from './svgs/vector.svg'; +import DocumentImage from './svgs/document.svg'; +import DatasetImage from './svgs/empty-dataset.svg'; +import EmptySqlChartImage from './svgs/empty_sql_chart.svg'; +import EmptyQueryImage from './svgs/empty-query.svg'; +import EmptyTableImage from './svgs/empty-table.svg'; +import EmptyImage from './svgs/empty.svg'; +import { Button, Empty } from '..'; import type { EmptyStateProps, EmptyStateSize } from './types'; export const imageMap = { diff --git a/superset-frontend/src/assets/images/document.svg b/superset-frontend/packages/superset-ui-core/src/components/EmptyState/svgs/document.svg similarity index 100% rename from superset-frontend/src/assets/images/document.svg rename to superset-frontend/packages/superset-ui-core/src/components/EmptyState/svgs/document.svg diff --git a/superset-frontend/src/assets/images/empty-charts.svg b/superset-frontend/packages/superset-ui-core/src/components/EmptyState/svgs/empty-charts.svg similarity index 100% rename from superset-frontend/src/assets/images/empty-charts.svg rename to superset-frontend/packages/superset-ui-core/src/components/EmptyState/svgs/empty-charts.svg diff --git a/superset-frontend/src/assets/images/empty-dashboard.svg b/superset-frontend/packages/superset-ui-core/src/components/EmptyState/svgs/empty-dashboard.svg similarity index 100% rename from superset-frontend/src/assets/images/empty-dashboard.svg rename to superset-frontend/packages/superset-ui-core/src/components/EmptyState/svgs/empty-dashboard.svg diff --git a/superset-frontend/src/assets/images/empty-dataset.svg b/superset-frontend/packages/superset-ui-core/src/components/EmptyState/svgs/empty-dataset.svg similarity index 100% rename from superset-frontend/src/assets/images/empty-dataset.svg rename to superset-frontend/packages/superset-ui-core/src/components/EmptyState/svgs/empty-dataset.svg diff --git a/superset-frontend/src/assets/images/empty-query.svg b/superset-frontend/packages/superset-ui-core/src/components/EmptyState/svgs/empty-query.svg similarity index 100% rename from superset-frontend/src/assets/images/empty-query.svg rename to superset-frontend/packages/superset-ui-core/src/components/EmptyState/svgs/empty-query.svg diff --git a/superset-frontend/src/assets/images/empty-table.svg b/superset-frontend/packages/superset-ui-core/src/components/EmptyState/svgs/empty-table.svg similarity index 100% rename from superset-frontend/src/assets/images/empty-table.svg rename to superset-frontend/packages/superset-ui-core/src/components/EmptyState/svgs/empty-table.svg diff --git a/superset-frontend/src/assets/images/empty.svg b/superset-frontend/packages/superset-ui-core/src/components/EmptyState/svgs/empty.svg similarity index 100% rename from superset-frontend/src/assets/images/empty.svg rename to superset-frontend/packages/superset-ui-core/src/components/EmptyState/svgs/empty.svg diff --git a/superset-frontend/src/assets/images/empty_sql_chart.svg b/superset-frontend/packages/superset-ui-core/src/components/EmptyState/svgs/empty_sql_chart.svg similarity index 100% rename from superset-frontend/src/assets/images/empty_sql_chart.svg rename to superset-frontend/packages/superset-ui-core/src/components/EmptyState/svgs/empty_sql_chart.svg diff --git a/superset-frontend/src/assets/images/filter-results.svg b/superset-frontend/packages/superset-ui-core/src/components/EmptyState/svgs/filter-results.svg similarity index 100% rename from superset-frontend/src/assets/images/filter-results.svg rename to superset-frontend/packages/superset-ui-core/src/components/EmptyState/svgs/filter-results.svg diff --git a/superset-frontend/src/assets/images/filter.svg b/superset-frontend/packages/superset-ui-core/src/components/EmptyState/svgs/filter.svg similarity index 100% rename from superset-frontend/src/assets/images/filter.svg rename to superset-frontend/packages/superset-ui-core/src/components/EmptyState/svgs/filter.svg diff --git a/superset-frontend/src/assets/images/star-circle.svg b/superset-frontend/packages/superset-ui-core/src/components/EmptyState/svgs/star-circle.svg similarity index 100% rename from superset-frontend/src/assets/images/star-circle.svg rename to superset-frontend/packages/superset-ui-core/src/components/EmptyState/svgs/star-circle.svg diff --git a/superset-frontend/src/assets/images/union.svg b/superset-frontend/packages/superset-ui-core/src/components/EmptyState/svgs/union.svg similarity index 100% rename from superset-frontend/src/assets/images/union.svg rename to superset-frontend/packages/superset-ui-core/src/components/EmptyState/svgs/union.svg diff --git a/superset-frontend/src/assets/images/vector.svg b/superset-frontend/packages/superset-ui-core/src/components/EmptyState/svgs/vector.svg similarity index 100% rename from superset-frontend/src/assets/images/vector.svg rename to superset-frontend/packages/superset-ui-core/src/components/EmptyState/svgs/vector.svg diff --git a/superset-frontend/src/components/EmptyState/types.ts b/superset-frontend/packages/superset-ui-core/src/components/EmptyState/types.ts similarity index 100% rename from superset-frontend/src/components/EmptyState/types.ts rename to superset-frontend/packages/superset-ui-core/src/components/EmptyState/types.ts diff --git a/superset-frontend/src/components/FaveStar/FaveStar.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/FaveStar/FaveStar.stories.tsx similarity index 100% rename from superset-frontend/src/components/FaveStar/FaveStar.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/FaveStar/FaveStar.stories.tsx diff --git a/superset-frontend/src/components/FaveStar/FaveStar.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/FaveStar/FaveStar.test.tsx similarity index 92% rename from superset-frontend/src/components/FaveStar/FaveStar.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/FaveStar/FaveStar.test.tsx index 89a51085768..05cbab43a6b 100644 --- a/superset-frontend/src/components/FaveStar/FaveStar.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/FaveStar/FaveStar.test.tsx @@ -17,10 +17,10 @@ * under the License. */ -import { render, screen, userEvent } from 'spec/helpers/testing-library'; +import { render, screen, userEvent } from '@superset-ui/core/spec'; import { FaveStar } from '.'; -jest.mock('src/components/Tooltip', () => ({ +jest.mock('@superset-ui/core/components/Tooltip', () => ({ Tooltip: (props: any) =>
, })); @@ -35,7 +35,7 @@ test('render right content', async () => { expect(screen.getByRole('img', { name: 'starred' })).toBeInTheDocument(); expect(props.saveFaveStar).toHaveBeenCalledTimes(0); - userEvent.click(screen.getByRole('button')); + await userEvent.click(screen.getByRole('button')); expect(props.saveFaveStar).toHaveBeenCalledTimes(1); expect(props.saveFaveStar).toHaveBeenCalledWith(props.itemId, true); @@ -43,7 +43,7 @@ test('render right content', async () => { expect(await findByRole('img', { name: 'unstarred' })).toBeInTheDocument(); expect(props.saveFaveStar).toHaveBeenCalledTimes(1); - userEvent.click(screen.getByRole('button')); + await userEvent.click(screen.getByRole('button')); expect(props.saveFaveStar).toHaveBeenCalledTimes(2); expect(props.saveFaveStar).toHaveBeenCalledWith(props.itemId, false); }); diff --git a/superset-frontend/src/components/FaveStar/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/FaveStar/index.tsx similarity index 97% rename from superset-frontend/src/components/FaveStar/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/FaveStar/index.tsx index eabacfe832d..bd51fa2a2ca 100644 --- a/superset-frontend/src/components/FaveStar/index.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/FaveStar/index.tsx @@ -20,7 +20,7 @@ import { useCallback, useEffect, MouseEvent } from 'react'; import { css, t, styled, useTheme } from '@superset-ui/core'; -import { Icons } from 'src/components/Icons'; +import { Icons } from '@superset-ui/core/components/Icons'; import { Tooltip } from '../Tooltip'; import type { FaveStarProps } from './types'; diff --git a/superset-frontend/src/components/FaveStar/types.ts b/superset-frontend/packages/superset-ui-core/src/components/FaveStar/types.ts similarity index 100% rename from superset-frontend/src/components/FaveStar/types.ts rename to superset-frontend/packages/superset-ui-core/src/components/FaveStar/types.ts diff --git a/superset-frontend/src/components/Flex/Flex.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/Flex/Flex.stories.tsx similarity index 100% rename from superset-frontend/src/components/Flex/Flex.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Flex/Flex.stories.tsx diff --git a/superset-frontend/src/components/Flex/Flex.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/Flex/Flex.test.tsx similarity index 94% rename from superset-frontend/src/components/Flex/Flex.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Flex/Flex.test.tsx index dbbca7983e0..3353b96e612 100644 --- a/superset-frontend/src/components/Flex/Flex.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Flex/Flex.test.tsx @@ -17,7 +17,7 @@ * under the License. */ -import { render } from 'spec/helpers/testing-library'; +import { render } from '@superset-ui/core/spec'; import { Flex } from '.'; test('should render', () => { diff --git a/superset-frontend/src/components/Flex/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/Flex/index.tsx similarity index 100% rename from superset-frontend/src/components/Flex/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Flex/index.tsx diff --git a/superset-frontend/src/components/Flex/types.ts b/superset-frontend/packages/superset-ui-core/src/components/Flex/types.ts similarity index 100% rename from superset-frontend/src/components/Flex/types.ts rename to superset-frontend/packages/superset-ui-core/src/components/Flex/types.ts diff --git a/superset-frontend/src/components/Form/Form.tsx b/superset-frontend/packages/superset-ui-core/src/components/Form/Form.tsx similarity index 100% rename from superset-frontend/src/components/Form/Form.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Form/Form.tsx diff --git a/superset-frontend/src/components/Form/FormItem.tsx b/superset-frontend/packages/superset-ui-core/src/components/Form/FormItem.tsx similarity index 100% rename from superset-frontend/src/components/Form/FormItem.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Form/FormItem.tsx diff --git a/superset-frontend/src/components/Form/FormLabel.tsx b/superset-frontend/packages/superset-ui-core/src/components/Form/FormLabel.tsx similarity index 100% rename from superset-frontend/src/components/Form/FormLabel.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Form/FormLabel.tsx diff --git a/superset-frontend/src/components/Form/LabeledErrorBoundInput.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/Form/LabeledErrorBoundInput.stories.tsx similarity index 100% rename from superset-frontend/src/components/Form/LabeledErrorBoundInput.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Form/LabeledErrorBoundInput.stories.tsx diff --git a/superset-frontend/src/components/Form/LabeledErrorBoundInput.test.jsx b/superset-frontend/packages/superset-ui-core/src/components/Form/LabeledErrorBoundInput.test.jsx similarity index 97% rename from superset-frontend/src/components/Form/LabeledErrorBoundInput.test.jsx rename to superset-frontend/packages/superset-ui-core/src/components/Form/LabeledErrorBoundInput.test.jsx index 03cfdf15ea5..2b66127e237 100644 --- a/superset-frontend/src/components/Form/LabeledErrorBoundInput.test.jsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Form/LabeledErrorBoundInput.test.jsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { render, fireEvent, screen } from 'spec/helpers/testing-library'; +import { render, fireEvent, screen } from '@superset-ui/core/spec'; import { LabeledErrorBoundInput } from './LabeledErrorBoundInput'; const defaultProps = { diff --git a/superset-frontend/src/components/Form/LabeledErrorBoundInput.tsx b/superset-frontend/packages/superset-ui-core/src/components/Form/LabeledErrorBoundInput.tsx similarity index 93% rename from superset-frontend/src/components/Form/LabeledErrorBoundInput.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Form/LabeledErrorBoundInput.tsx index 995b004a3d2..77d5a1c5550 100644 --- a/superset-frontend/src/components/Form/LabeledErrorBoundInput.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Form/LabeledErrorBoundInput.tsx @@ -16,15 +16,12 @@ * specific language governing permissions and limitations * under the License. */ -import { styled, css, SupersetTheme, t } from '@superset-ui/core'; -import { Icons } from 'src/components/Icons'; -import errorIcon from 'src/assets/images/icons/error.svg'; -import { Button } from '../Button'; -import { InfoTooltip } from '../InfoTooltip'; +import { styled, css, SupersetTheme, t } from '../..'; +import { error as errorIcon } from '../assets/svgs'; +import { Button, Icons, InfoTooltip, Tooltip } from '..'; import { Input } from '../Input'; -import { Tooltip } from '../Tooltip'; -import { FormItem } from './FormItem'; import { FormLabel } from './FormLabel'; +import { FormItem } from './FormItem'; import type { LabeledErrorBoundInputProps } from './types'; const StyledInput = styled(Input)` diff --git a/superset-frontend/src/components/Form/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/Form/index.tsx similarity index 100% rename from superset-frontend/src/components/Form/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Form/index.tsx diff --git a/superset-frontend/src/components/Form/types.ts b/superset-frontend/packages/superset-ui-core/src/components/Form/types.ts similarity index 100% rename from superset-frontend/src/components/Form/types.ts rename to superset-frontend/packages/superset-ui-core/src/components/Form/types.ts diff --git a/superset-frontend/src/components/Grid/Grid.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/Grid/Grid.stories.tsx similarity index 99% rename from superset-frontend/src/components/Grid/Grid.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Grid/Grid.stories.tsx index 30137208660..0a09f703ddb 100644 --- a/superset-frontend/src/components/Grid/Grid.stories.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Grid/Grid.stories.tsx @@ -17,7 +17,7 @@ * under the License. */ import { Meta, StoryObj } from '@storybook/react'; -import Slider from 'src/components/Slider/index'; +import Slider from '@superset-ui/core/components/Slider/index'; import { useState } from 'react'; import { Row, Col } from '.'; import type { ColProps, RowProps } from './types'; diff --git a/superset-frontend/src/components/Grid/Grid.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/Grid/Grid.test.tsx similarity index 95% rename from superset-frontend/src/components/Grid/Grid.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Grid/Grid.test.tsx index 36174906e09..884ce75ed3b 100644 --- a/superset-frontend/src/components/Grid/Grid.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Grid/Grid.test.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { render, screen } from '@testing-library/react'; +import { render, screen } from '@superset-ui/core/spec'; import '@testing-library/jest-dom'; import { Col, Row } from '.'; diff --git a/superset-frontend/src/components/Grid/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/Grid/index.tsx similarity index 100% rename from superset-frontend/src/components/Grid/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Grid/index.tsx diff --git a/superset-frontend/src/components/Grid/types.ts b/superset-frontend/packages/superset-ui-core/src/components/Grid/types.ts similarity index 100% rename from superset-frontend/src/components/Grid/types.ts rename to superset-frontend/packages/superset-ui-core/src/components/Grid/types.ts diff --git a/superset-frontend/src/components/IconButton/IconButton.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/IconButton/IconButton.stories.tsx similarity index 100% rename from superset-frontend/src/components/IconButton/IconButton.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/IconButton/IconButton.stories.tsx diff --git a/superset-frontend/src/components/IconButton/IconButton.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/IconButton/IconButton.test.tsx similarity index 97% rename from superset-frontend/src/components/IconButton/IconButton.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/IconButton/IconButton.test.tsx index 4ee67d030f1..16448a92467 100644 --- a/superset-frontend/src/components/IconButton/IconButton.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/IconButton/IconButton.test.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { render, screen, fireEvent } from 'spec/helpers/testing-library'; +import { render, screen, fireEvent } from '@superset-ui/core/spec'; import { IconButton } from '.'; const defaultProps = { diff --git a/superset-frontend/src/components/IconButton/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/IconButton/index.tsx similarity index 100% rename from superset-frontend/src/components/IconButton/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/IconButton/index.tsx diff --git a/superset-frontend/src/components/IconTooltip/IconTooltip.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/IconTooltip/IconTooltip.stories.tsx similarity index 96% rename from superset-frontend/src/components/IconTooltip/IconTooltip.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/IconTooltip/IconTooltip.stories.tsx index ca955071f40..b350c8c24ae 100644 --- a/superset-frontend/src/components/IconTooltip/IconTooltip.stories.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/IconTooltip/IconTooltip.stories.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { Icons } from 'src/components/Icons'; +import { Icons } from '@superset-ui/core/components/Icons'; import { css, useTheme } from '@superset-ui/core'; import { IconTooltip } from '.'; import type { IconTooltipProps } from './types'; diff --git a/superset-frontend/src/components/IconTooltip/IconTooltip.test.jsx b/superset-frontend/packages/superset-ui-core/src/components/IconTooltip/IconTooltip.test.jsx similarity index 93% rename from superset-frontend/src/components/IconTooltip/IconTooltip.test.jsx rename to superset-frontend/packages/superset-ui-core/src/components/IconTooltip/IconTooltip.test.jsx index c7467491c90..befe566eb71 100644 --- a/superset-frontend/src/components/IconTooltip/IconTooltip.test.jsx +++ b/superset-frontend/packages/superset-ui-core/src/components/IconTooltip/IconTooltip.test.jsx @@ -16,10 +16,10 @@ * specific language governing permissions and limitations * under the License. */ -import { render } from 'spec/helpers/testing-library'; +import { render } from '@superset-ui/core/spec'; import { IconTooltip } from '.'; -jest.mock('src/components/Tooltip', () => ({ +jest.mock('@superset-ui/core/components/Tooltip', () => ({ Tooltip: () =>
, })); diff --git a/superset-frontend/src/components/IconTooltip/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/IconTooltip/index.tsx similarity index 100% rename from superset-frontend/src/components/IconTooltip/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/IconTooltip/index.tsx diff --git a/superset-frontend/src/components/IconTooltip/types.ts b/superset-frontend/packages/superset-ui-core/src/components/IconTooltip/types.ts similarity index 100% rename from superset-frontend/src/components/IconTooltip/types.ts rename to superset-frontend/packages/superset-ui-core/src/components/IconTooltip/types.ts diff --git a/superset-frontend/src/components/Icons/AntdEnhanced.tsx b/superset-frontend/packages/superset-ui-core/src/components/Icons/AntdEnhanced.tsx similarity index 99% rename from superset-frontend/src/components/Icons/AntdEnhanced.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Icons/AntdEnhanced.tsx index 9a37cd6f14a..d01b5efdb55 100644 --- a/superset-frontend/src/components/Icons/AntdEnhanced.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Icons/AntdEnhanced.tsx @@ -34,6 +34,7 @@ import { BookOutlined, BugOutlined, BulbOutlined, + CalculatorOutlined, CaretUpOutlined, CaretDownOutlined, CaretLeftOutlined, @@ -157,6 +158,7 @@ const AntdIcons = { BookOutlined, BugOutlined, BulbOutlined, + CalculatorOutlined, CaretUpOutlined, CaretDownOutlined, CaretLeftOutlined, diff --git a/superset-frontend/src/components/Icons/AsyncIcon.tsx b/superset-frontend/packages/superset-ui-core/src/components/Icons/AsyncIcon.tsx similarity index 95% rename from superset-frontend/src/components/Icons/AsyncIcon.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Icons/AsyncIcon.tsx index 1ce39c25bd6..48f3521bfd3 100644 --- a/superset-frontend/src/components/Icons/AsyncIcon.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Icons/AsyncIcon.tsx @@ -18,7 +18,7 @@ */ import { FC, SVGProps, useEffect, useRef, useState } from 'react'; -import TransparentIcon from 'src/assets/images/icons/transparent.svg'; +import TransparentIcon from './svgs/transparent.svg'; import { IconType } from './types'; import { BaseIconComponent } from './BaseIcon'; diff --git a/superset-frontend/src/components/Icons/BaseIcon.tsx b/superset-frontend/packages/superset-ui-core/src/components/Icons/BaseIcon.tsx similarity index 97% rename from superset-frontend/src/components/Icons/BaseIcon.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Icons/BaseIcon.tsx index cc2c58af3c3..46c4c68905d 100644 --- a/superset-frontend/src/components/Icons/BaseIcon.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Icons/BaseIcon.tsx @@ -17,7 +17,7 @@ * under the License. */ -import { css, useTheme, themeObject } from '@superset-ui/core'; +import { css, useTheme, themeObject } from '../..'; import { AntdIconType, BaseIconProps, CustomIconType, IconType } from './types'; const genAriaLabel = (fileName: string) => { diff --git a/superset-frontend/src/components/Icons/Icons.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/Icons/Icons.stories.tsx similarity index 100% rename from superset-frontend/src/components/Icons/Icons.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Icons/Icons.stories.tsx diff --git a/superset-frontend/src/components/Icons/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/Icons/index.tsx similarity index 98% rename from superset-frontend/src/components/Icons/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Icons/index.tsx index b43ae6ca182..acb7588993a 100644 --- a/superset-frontend/src/components/Icons/index.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Icons/index.tsx @@ -20,6 +20,7 @@ import { FC } from 'react'; import { antdEnhancedIcons } from './AntdEnhanced'; import AsyncIcon from './AsyncIcon'; + import type { IconType } from './types'; /** @@ -76,3 +77,4 @@ export const Icons: IconComponentType = { ...antdEnhancedIcons, ...iconOverrides, }; +export type { IconType }; diff --git a/superset-frontend/src/assets/images/icons/transparent.svg b/superset-frontend/packages/superset-ui-core/src/components/Icons/svgs/transparent.svg similarity index 100% rename from superset-frontend/src/assets/images/icons/transparent.svg rename to superset-frontend/packages/superset-ui-core/src/components/Icons/svgs/transparent.svg diff --git a/superset-frontend/src/components/Icons/types.ts b/superset-frontend/packages/superset-ui-core/src/components/Icons/types.ts similarity index 100% rename from superset-frontend/src/components/Icons/types.ts rename to superset-frontend/packages/superset-ui-core/src/components/Icons/types.ts diff --git a/superset-frontend/src/components/Image/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/Image/index.tsx similarity index 100% rename from superset-frontend/src/components/Image/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Image/index.tsx diff --git a/superset-frontend/src/components/InfoTooltip/InfoTooltip.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/InfoTooltip/InfoTooltip.stories.tsx similarity index 95% rename from superset-frontend/src/components/InfoTooltip/InfoTooltip.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/InfoTooltip/InfoTooltip.stories.tsx index 0a0f35a41d3..2339592addc 100644 --- a/superset-frontend/src/components/InfoTooltip/InfoTooltip.stories.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/InfoTooltip/InfoTooltip.stories.tsx @@ -16,8 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import type { InfoTooltipProps } from './types'; -import { InfoTooltip } from '.'; +import { InfoTooltip, InfoTooltipProps } from '.'; export default { title: 'Components/InfoTooltip', diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/components/InfoTooltipWithTrigger.tsx b/superset-frontend/packages/superset-ui-core/src/components/InfoTooltip/index.tsx similarity index 94% rename from superset-frontend/packages/superset-ui-chart-controls/src/components/InfoTooltipWithTrigger.tsx rename to superset-frontend/packages/superset-ui-core/src/components/InfoTooltip/index.tsx index bd502f64c3a..e5ddfba57aa 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/src/components/InfoTooltipWithTrigger.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/InfoTooltip/index.tsx @@ -28,9 +28,9 @@ import { QuestionCircleOutlined, } from '@ant-design/icons'; import { Button } from 'antd'; -import { Tooltip, TooltipProps, TooltipPlacement } from './Tooltip'; +import { Tooltip, TooltipProps, TooltipPlacement } from '../Tooltip'; -export interface InfoTooltipWithTriggerProps { +export interface InfoTooltipProps { label?: string; tooltip?: TooltipProps['title']; onClick?: () => void; @@ -41,7 +41,7 @@ export interface InfoTooltipWithTriggerProps { iconSize?: 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl'; } -export const InfoTooltipWithTrigger = ({ +export const InfoTooltip = ({ type = 'info', iconSize = 's', label, @@ -50,7 +50,7 @@ export const InfoTooltipWithTrigger = ({ className = 'text-muted', placement = 'right', iconStyle, -}: InfoTooltipWithTriggerProps) => { +}: InfoTooltipProps) => { const theme = useTheme(); const infoTooltipWithTriggerVariants = useMemo( @@ -81,6 +81,7 @@ export const InfoTooltipWithTrigger = ({ , ); - userEvent.hover(screen.getByRole('button')); + await userEvent.hover(screen.getByRole('button')); await waitFor(() => expect(onOpenChange).toHaveBeenCalledTimes(1)); }); diff --git a/superset-frontend/src/components/Popover/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/Popover/index.tsx similarity index 91% rename from superset-frontend/src/components/Popover/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Popover/index.tsx index 8446840722f..f7e41b5be62 100644 --- a/superset-frontend/src/components/Popover/index.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Popover/index.tsx @@ -23,6 +23,4 @@ export interface PopoverProps extends AntdPopoverProps { forceRender?: boolean; } -const Popover = (props: PopoverProps) => ; - -export default Popover; +export const Popover = (props: PopoverProps) => ; diff --git a/superset-frontend/src/components/PopoverDropdown/PopoverDropdown.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/PopoverDropdown/PopoverDropdown.stories.tsx similarity index 100% rename from superset-frontend/src/components/PopoverDropdown/PopoverDropdown.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/PopoverDropdown/PopoverDropdown.stories.tsx diff --git a/superset-frontend/src/components/PopoverDropdown/PopoverDropdown.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/PopoverDropdown/PopoverDropdown.test.tsx similarity index 88% rename from superset-frontend/src/components/PopoverDropdown/PopoverDropdown.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/PopoverDropdown/PopoverDropdown.test.tsx index 863ef046efa..9a4f669a5b9 100644 --- a/superset-frontend/src/components/PopoverDropdown/PopoverDropdown.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/PopoverDropdown/PopoverDropdown.test.tsx @@ -16,11 +16,11 @@ * specific language governing permissions and limitations * under the License. */ -import { render, screen, userEvent } from 'spec/helpers/testing-library'; +import { render, screen, userEvent } from '@superset-ui/core/spec'; import PopoverDropdown, { PopoverDropdownProps, OptionProps, -} from 'src/components/PopoverDropdown'; +} from '@superset-ui/core/components/PopoverDropdown'; const defaultProps: PopoverDropdownProps = { id: 'popover-dropdown', @@ -42,7 +42,7 @@ test('renders with default props', async () => { test('renders the menu on click', async () => { render(); - userEvent.click(screen.getByRole('button')); + await userEvent.click(screen.getByRole('button')); expect(await screen.findByRole('menu')).toBeInTheDocument(); }); @@ -71,14 +71,14 @@ test('renders with custom option', async () => { )} />, ); - userEvent.click(screen.getByRole('button')); + await userEvent.click(screen.getByRole('button')); expect(await screen.findByText('Custom Option 1')).toBeInTheDocument(); }); test('triggers onChange', async () => { render(); - userEvent.click(screen.getByRole('button')); + await userEvent.click(screen.getByRole('button')); expect(await screen.findByText('Option 2')).toBeInTheDocument(); - userEvent.click(screen.getByText('Option 2')); + await userEvent.click(screen.getByText('Option 2')); expect(defaultProps.onChange).toHaveBeenCalled(); }); diff --git a/superset-frontend/src/components/PopoverDropdown/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/PopoverDropdown/index.tsx similarity index 96% rename from superset-frontend/src/components/PopoverDropdown/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/PopoverDropdown/index.tsx index a45b2b93a35..5b0532afa46 100644 --- a/superset-frontend/src/components/PopoverDropdown/index.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/PopoverDropdown/index.tsx @@ -19,8 +19,8 @@ import { Key } from 'react'; import cx from 'classnames'; import { styled, useTheme } from '@superset-ui/core'; -import { Menu } from 'src/components/Menu'; -import { Icons } from 'src/components/Icons'; +import { Menu } from '@superset-ui/core/components/Menu'; +import { Icons } from '@superset-ui/core/components/Icons'; import { Dropdown } from '../Dropdown'; export interface OptionProps { diff --git a/superset-frontend/src/components/PopoverSection/PopoverSection.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/PopoverSection/PopoverSection.stories.tsx similarity index 100% rename from superset-frontend/src/components/PopoverSection/PopoverSection.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/PopoverSection/PopoverSection.stories.tsx diff --git a/superset-frontend/src/components/PopoverSection/PopoverSection.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/PopoverSection/PopoverSection.test.tsx similarity index 88% rename from superset-frontend/src/components/PopoverSection/PopoverSection.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/PopoverSection/PopoverSection.test.tsx index 29978aba637..09bbb44be38 100644 --- a/superset-frontend/src/components/PopoverSection/PopoverSection.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/PopoverSection/PopoverSection.test.tsx @@ -16,8 +16,8 @@ * specific language governing permissions and limitations * under the License. */ -import { render, screen, userEvent } from 'spec/helpers/testing-library'; -import PopoverSection from 'src/components/PopoverSection'; +import { render, screen, userEvent } from '@superset-ui/core/spec'; +import PopoverSection from '.'; test('renders with default props', async () => { render( @@ -44,7 +44,7 @@ test('renders a tooltip when hovered', async () => {
, ); - userEvent.hover(screen.getAllByRole('img')[0]); + await userEvent.hover(screen.getAllByRole('img')[0]); expect(await screen.findByRole('tooltip')).toBeInTheDocument(); }); @@ -55,6 +55,6 @@ test('calls onSelect when clicked', async () => {
, ); - userEvent.click(await screen.findByRole('img')); + await userEvent.click(await screen.findByRole('img')); expect(onSelect).toHaveBeenCalled(); }); diff --git a/superset-frontend/src/components/PopoverSection/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/PopoverSection/index.tsx similarity index 97% rename from superset-frontend/src/components/PopoverSection/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/PopoverSection/index.tsx index be201a24b09..2e395e8a427 100644 --- a/superset-frontend/src/components/PopoverSection/index.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/PopoverSection/index.tsx @@ -18,7 +18,7 @@ */ import { MouseEventHandler, ReactNode } from 'react'; import { css, useTheme } from '@superset-ui/core'; -import { Icons } from 'src/components/Icons'; +import { Icons } from '@superset-ui/core/components/Icons'; import { Tooltip } from '../Tooltip'; export interface PopoverSectionProps { diff --git a/superset-frontend/src/components/ProgressBar/ProgressBar.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/ProgressBar/ProgressBar.stories.tsx similarity index 100% rename from superset-frontend/src/components/ProgressBar/ProgressBar.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/ProgressBar/ProgressBar.stories.tsx diff --git a/superset-frontend/src/components/ProgressBar/ProgressBar.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/ProgressBar/ProgressBar.test.tsx similarity index 97% rename from superset-frontend/src/components/ProgressBar/ProgressBar.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/ProgressBar/ProgressBar.test.tsx index cb419b51b5d..db606c0ff64 100644 --- a/superset-frontend/src/components/ProgressBar/ProgressBar.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/ProgressBar/ProgressBar.test.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { render, screen } from 'spec/helpers/testing-library'; +import { render, screen } from '@superset-ui/core/spec'; import ProgressBar, { ProgressBarProps } from '.'; const mockedProps: ProgressBarProps = { diff --git a/superset-frontend/src/components/ProgressBar/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/ProgressBar/index.tsx similarity index 100% rename from superset-frontend/src/components/ProgressBar/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/ProgressBar/index.tsx diff --git a/superset-frontend/src/components/Radio/Radio.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/Radio/Radio.stories.tsx similarity index 98% rename from superset-frontend/src/components/Radio/Radio.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Radio/Radio.stories.tsx index d7fb4056dad..65ba411f1c2 100644 --- a/superset-frontend/src/components/Radio/Radio.stories.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Radio/Radio.stories.tsx @@ -17,7 +17,7 @@ * under the License. */ import { css } from '@superset-ui/core'; -import { Icons } from 'src/components/Icons'; +import { Icons } from '@superset-ui/core/components/Icons'; import { Space } from '../Space'; import { Radio, type RadioProps, type RadioGroupWrapperProps } from '.'; diff --git a/superset-frontend/src/components/Radio/Radio.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/Radio/Radio.test.tsx similarity index 92% rename from superset-frontend/src/components/Radio/Radio.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Radio/Radio.test.tsx index c9ea42ed709..2601ba95f15 100644 --- a/superset-frontend/src/components/Radio/Radio.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Radio/Radio.test.tsx @@ -16,12 +16,12 @@ * specific language governing permissions and limitations * under the License. */ -import { render, screen, fireEvent } from '@testing-library/react'; +import { render, screen, fireEvent } from '@superset-ui/core/spec'; import '@testing-library/jest-dom'; import { Radio } from '.'; describe('Radio Component', () => { - test('renders radio button and allows selection', () => { + it('renders radio button and allows selection', () => { render( Option 1 diff --git a/superset-frontend/src/components/Radio/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/Radio/index.tsx similarity index 100% rename from superset-frontend/src/components/Radio/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Radio/index.tsx diff --git a/superset-frontend/src/components/RefreshLabel/RefreshLabel.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/RefreshLabel/RefreshLabel.stories.tsx similarity index 100% rename from superset-frontend/src/components/RefreshLabel/RefreshLabel.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/RefreshLabel/RefreshLabel.stories.tsx diff --git a/superset-frontend/src/components/RefreshLabel/RefreshLabel.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/RefreshLabel/RefreshLabel.test.tsx similarity index 87% rename from superset-frontend/src/components/RefreshLabel/RefreshLabel.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/RefreshLabel/RefreshLabel.test.tsx index f90c503164a..c44b207e1dc 100644 --- a/superset-frontend/src/components/RefreshLabel/RefreshLabel.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/RefreshLabel/RefreshLabel.test.tsx @@ -16,21 +16,21 @@ * specific language governing permissions and limitations * under the License. */ -import { render, screen, userEvent } from 'spec/helpers/testing-library'; -import RefreshLabel from 'src/components/RefreshLabel'; +import { render, screen, userEvent } from '@superset-ui/core/spec'; +import RefreshLabel from '@superset-ui/core/components/RefreshLabel'; test('renders with default props', async () => { render(); const refresh = await screen.findByRole('button'); expect(refresh).toBeInTheDocument(); - userEvent.hover(refresh); + await userEvent.hover(refresh); }); test('renders tooltip on hover', async () => { const tooltipText = 'Tooltip'; render(); const refresh = screen.getByRole('button'); - userEvent.hover(refresh); + await userEvent.hover(refresh); const tooltip = await screen.findByRole('tooltip'); expect(tooltip).toBeInTheDocument(); expect(tooltip).toHaveTextContent(tooltipText); @@ -40,6 +40,6 @@ test('triggers on click event', async () => { const onClick = jest.fn(); render(); const refresh = await screen.findByRole('button'); - userEvent.click(refresh); + await userEvent.click(refresh); expect(onClick).toHaveBeenCalled(); }); diff --git a/superset-frontend/src/components/RefreshLabel/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/RefreshLabel/index.tsx similarity index 92% rename from superset-frontend/src/components/RefreshLabel/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/RefreshLabel/index.tsx index 61857f2cca9..88b680ab1ec 100644 --- a/superset-frontend/src/components/RefreshLabel/index.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/RefreshLabel/index.tsx @@ -18,8 +18,8 @@ */ import { MouseEventHandler, forwardRef } from 'react'; import { SupersetTheme } from '@superset-ui/core'; -import { Icons } from 'src/components/Icons'; -import type { IconType } from 'src/components/Icons/types'; +import { Icons } from '@superset-ui/core/components/Icons'; +import type { IconType } from '@superset-ui/core/components/Icons/types'; import { Tooltip } from '../Tooltip'; export interface RefreshLabelProps { diff --git a/superset-frontend/packages/superset-ui-core/src/components/SafeMarkdown.tsx b/superset-frontend/packages/superset-ui-core/src/components/SafeMarkdown/SafeMarkdown.tsx similarity index 96% rename from superset-frontend/packages/superset-ui-core/src/components/SafeMarkdown.tsx rename to superset-frontend/packages/superset-ui-core/src/components/SafeMarkdown/SafeMarkdown.tsx index d35c2160e97..ed0a1cc4bfa 100644 --- a/superset-frontend/packages/superset-ui-core/src/components/SafeMarkdown.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/SafeMarkdown/SafeMarkdown.tsx @@ -20,7 +20,7 @@ import { useEffect, useMemo, useState } from 'react'; import rehypeSanitize, { defaultSchema } from 'rehype-sanitize'; import remarkGfm from 'remark-gfm'; import { mergeWith } from 'lodash'; -import { FeatureFlag, isFeatureEnabled } from '../utils'; +import { FeatureFlag, isFeatureEnabled } from '../../utils'; interface SafeMarkdownProps { source: string; @@ -37,7 +37,7 @@ export function getOverrideHtmlSchema( ); } -function SafeMarkdown({ +export function SafeMarkdown({ source, htmlSanitization = true, htmlSchemaOverrides = {}, @@ -85,5 +85,3 @@ function SafeMarkdown({ ); } - -export default SafeMarkdown; diff --git a/superset-frontend/src/components/Select/AsyncSelect.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/Select/AsyncSelect.stories.tsx similarity index 100% rename from superset-frontend/src/components/Select/AsyncSelect.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Select/AsyncSelect.stories.tsx diff --git a/superset-frontend/src/components/Select/AsyncSelect.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/Select/AsyncSelect.test.tsx similarity index 95% rename from superset-frontend/src/components/Select/AsyncSelect.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Select/AsyncSelect.test.tsx index 06e8e61470e..b1b97d63301 100644 --- a/superset-frontend/src/components/Select/AsyncSelect.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Select/AsyncSelect.test.tsx @@ -20,11 +20,11 @@ import { createEvent, fireEvent, render, - screen, userEvent, + screen, waitFor, within, -} from 'spec/helpers/testing-library'; +} from '@superset-ui/core/spec'; import { AsyncSelect } from '.'; const ARIA_LABEL = 'Test'; @@ -137,9 +137,9 @@ const matchOrder = async (expectedLabels: string[]) => { return true; }; -const type = (text: string) => { +const type = async (text: string) => { const select = getSelect(); - userEvent.clear(select); + await userEvent.clear(select); return userEvent.type(select, text, { delay: 10 }); }; @@ -200,7 +200,7 @@ test('does not add a new option if the value is already in the options', async ( test('inverts the selection', async () => { render(); await open(); - userEvent.click(await findSelectOption(OPTIONS[0].label)); + await userEvent.click(await findSelectOption(OPTIONS[0].label)); expect(await screen.findByLabelText('stop')).toBeInTheDocument(); }); @@ -236,7 +236,7 @@ test('should sort selected to top when in single mode', async () => { render(); const originalLabels = OPTIONS.map(option => option.label); await open(); - userEvent.click(await findSelectOption(originalLabels[1])); + await userEvent.click(await findSelectOption(originalLabels[1])); // after selection, keep the original order expect(await matchOrder(originalLabels)).toBe(true); @@ -249,7 +249,7 @@ test('should sort selected to top when in single mode', async () => { // keep clicking other items, the updated order should still based on // original order - userEvent.click(await findSelectOption(originalLabels[5])); + await userEvent.click(await findSelectOption(originalLabels[5])); await matchOrder(labels); await type('{esc}'); await open(); @@ -258,7 +258,7 @@ test('should sort selected to top when in single mode', async () => { expect(await matchOrder(labels)).toBe(true); // should revert to original order - clearAll(); + await clearAll(); await type('{esc}'); await open(); expect(await matchOrder(originalLabels)).toBe(true); @@ -270,7 +270,7 @@ test('should sort selected to the top when in multi mode', async () => { let labels = originalLabels.slice(); await open(); - userEvent.click(await findSelectOption(labels[1])); + await userEvent.click(await findSelectOption(labels[1])); expect(await matchOrder(labels)).toBe(true); await type('{esc}'); @@ -279,14 +279,14 @@ test('should sort selected to the top when in multi mode', async () => { expect(await matchOrder(labels)).toBe(true); await open(); - userEvent.click(await findSelectOption(labels[5])); + await userEvent.click(await findSelectOption(labels[5])); await type('{esc}'); await open(); labels = [labels.splice(0, 1)[0], labels.splice(4, 1)[0]].concat(labels); expect(await matchOrder(labels)).toBe(true); // should revert to original order - clearAll(); + await clearAll(); await type('{esc}'); await open(); expect(await matchOrder(originalLabels)).toBe(true); @@ -449,7 +449,7 @@ test('clear all the values', async () => { onClear={onClear} />, ); - clearAll(); + await clearAll(); expect(onClear).toHaveBeenCalled(); const values = await findAllSelectValues(); expect(values.length).toBe(0); @@ -471,7 +471,7 @@ test('adds the null option when selected in single mode', async () => { })); render(); await open(); - userEvent.click(await findSelectOption(NULL_OPTION.label)); + await userEvent.click(await findSelectOption(NULL_OPTION.label)); const values = await findAllSelectValues(); expect(values[0]).toHaveTextContent(NULL_OPTION.label); }); @@ -485,8 +485,8 @@ test('adds the null option when selected in multiple mode', async () => { , ); await open(); - userEvent.click(await findSelectOption(OPTIONS[0].label)); - userEvent.click(await findSelectOption(NULL_OPTION.label)); + await userEvent.click(await findSelectOption(OPTIONS[0].label)); + await userEvent.click(await findSelectOption(NULL_OPTION.label)); const values = await findAllSelectValues(); expect(values[0]).toHaveTextContent(OPTIONS[0].label); expect(values[1]).toHaveTextContent(NULL_OPTION.label); @@ -512,8 +512,8 @@ test('opens the select without any data', async () => { test('displays the loading indicator when opening', async () => { render(); - await waitFor(() => { - userEvent.click(getSelect()); + await waitFor(async () => { + await userEvent.click(getSelect()); expect(screen.getByText(LOADING)).toBeInTheDocument(); }); expect(screen.queryByText(LOADING)).not.toBeInTheDocument(); @@ -523,7 +523,7 @@ test('makes a selection in single mode', async () => { render(); const optionText = 'Emma'; await open(); - userEvent.click(await findSelectOption(optionText)); + await userEvent.click(await findSelectOption(optionText)); expect(await findSelectValue()).toHaveTextContent(optionText); }); @@ -531,8 +531,8 @@ test('multiple selections in multiple mode', async () => { render(); await open(); const [firstOption, secondOption] = OPTIONS; - userEvent.click(await findSelectOption(firstOption.label)); - userEvent.click(await findSelectOption(secondOption.label)); + await userEvent.click(await findSelectOption(firstOption.label)); + await userEvent.click(await findSelectOption(secondOption.label)); const values = await findAllSelectValues(); expect(values[0]).toHaveTextContent(firstOption.label); expect(values[1]).toHaveTextContent(secondOption.label); @@ -543,7 +543,7 @@ test('changes the selected item in single mode', async () => { render(); await open(); const [firstOption, secondOption] = OPTIONS; - userEvent.click(await findSelectOption(firstOption.label)); + await userEvent.click(await findSelectOption(firstOption.label)); expect(onChange).toHaveBeenCalledWith( expect.objectContaining({ label: firstOption.label, @@ -552,7 +552,7 @@ test('changes the selected item in single mode', async () => { expect.objectContaining(firstOption), ); expect(await findSelectValue()).toHaveTextContent(firstOption.label); - userEvent.click(await findSelectOption(secondOption.label)); + await userEvent.click(await findSelectOption(secondOption.label)); expect(onChange).toHaveBeenCalledWith( expect.objectContaining({ label: secondOption.label, @@ -568,8 +568,8 @@ test('deselects an item in multiple mode', async () => { await open(); const option3 = OPTIONS[2]; const option8 = OPTIONS[7]; - userEvent.click(await findSelectOption(option8.label)); - userEvent.click(await findSelectOption(option3.label)); + await userEvent.click(await findSelectOption(option8.label)); + await userEvent.click(await findSelectOption(option3.label)); let options = await findAllSelectOptions(); expect(options).toHaveLength(Math.min(defaultProps.pageSize, OPTIONS.length)); @@ -591,7 +591,7 @@ test('deselects an item in multiple mode', async () => { expect(values[0]).toHaveTextContent(option8.label); expect(values[1]).toHaveTextContent(option3.label); - userEvent.click(await findSelectOption(option3.label)); + await userEvent.click(await findSelectOption(option3.label)); values = await findAllSelectValues(); expect(values.length).toBe(1); expect(values[0]).toHaveTextContent(option8.label); @@ -848,8 +848,8 @@ test('does not fire onChange when searching but no selection', async () => { ); await open(); await type('Joh'); - userEvent.click(await findSelectOption('John')); - userEvent.click(screen.getByRole('main')); + await userEvent.click(await findSelectOption('John')); + await userEvent.click(screen.getByRole('main')); expect(onChange).toHaveBeenCalledTimes(1); }); @@ -863,7 +863,7 @@ test('fires onChange when clearing the selection in single mode', async () => { value={OPTIONS[0]} />, ); - clearAll(); + await clearAll(); expect(onChange).toHaveBeenCalledTimes(1); }); @@ -877,7 +877,7 @@ test('fires onChange when clearing the selection in multiple mode', async () => value={OPTIONS[0]} />, ); - clearAll(); + await clearAll(); expect(onChange).toHaveBeenCalledTimes(1); }); @@ -1006,9 +1006,9 @@ test('does not fire onChange if the same value is selected in single mode', asyn const optionText = 'Emma'; await open(); expect(onChange).toHaveBeenCalledTimes(0); - userEvent.click(await findSelectOption(optionText)); + await userEvent.click(await findSelectOption(optionText)); expect(onChange).toHaveBeenCalledTimes(1); - userEvent.click(await findSelectOption(optionText)); + await userEvent.click(await findSelectOption(optionText)); expect(onChange).toHaveBeenCalledTimes(1); }); diff --git a/superset-frontend/src/components/Select/AsyncSelect.tsx b/superset-frontend/packages/superset-ui-core/src/components/Select/AsyncSelect.tsx similarity index 98% rename from superset-frontend/src/components/Select/AsyncSelect.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Select/AsyncSelect.tsx index 111da65cef5..9a915657347 100644 --- a/superset-frontend/src/components/Select/AsyncSelect.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Select/AsyncSelect.tsx @@ -42,8 +42,7 @@ import { RefSelectProps, } from 'antd/es/select'; import { debounce, isEqual, uniq } from 'lodash'; -import { Icons } from 'src/components/Icons'; -import { FAST_DEBOUNCE, SLOW_DEBOUNCE } from 'src/constants'; +import { Constants, Icons } from '@superset-ui/core/components'; import { Space } from '../Space'; import { getValue, @@ -106,7 +105,7 @@ const getQueryCacheKey = (value: string, page: number, pageSize: number) => * The Static type accepts a static array of options. * The Async type accepts a promise that will return the options. * Each of the categories come with different abilities. For a comprehensive guide please refer to - * the storybook in src/components/Select/Select.stories.tsx. + * the storybook in @superset-ui/core/components/Select/Select.stories.tsx. */ const AsyncSelect = forwardRef( ( @@ -363,7 +362,7 @@ const AsyncSelect = forwardRef( ); const debouncedFetchPage = useMemo( - () => debounce(fetchPage, SLOW_DEBOUNCE), + () => debounce(fetchPage, Constants.SLOW_DEBOUNCE), [fetchPage], ); @@ -395,7 +394,7 @@ const AsyncSelect = forwardRef( } setInputValue(search); onSearch?.(searchValue); - }, FAST_DEBOUNCE); + }, Constants.FAST_DEBOUNCE); useEffect(() => () => handleOnSearch.cancel(), [handleOnSearch]); diff --git a/superset-frontend/src/components/Select/Select.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/Select/Select.stories.tsx similarity index 95% rename from superset-frontend/src/components/Select/Select.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Select/Select.stories.tsx index c174de5477f..dc64db080a9 100644 --- a/superset-frontend/src/components/Select/Select.stories.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Select/Select.stories.tsx @@ -17,7 +17,6 @@ * under the License. */ import { StoryObj } from '@storybook/react'; -import ControlHeader from 'src/explore/components/ControlHeader'; import { SelectOptionsType, SelectProps } from './types'; import { Select } from '.'; @@ -72,21 +71,6 @@ const selectPositions = [ }, ]; -const mountHeader = (type: String) => { - let header; - if (type === 'text') { - header = 'Text header'; - } else if (type === 'control') { - header = ( - - ); - } - return header; -}; - const generateOptions = (opts: SelectOptionsType, count: number) => { let generated = opts.slice(); let iteration = 0; @@ -122,7 +106,6 @@ export const InteractiveSelect: StoryObj = { ? generateOptions(options, optionsCount) : options } - header={mountHeader(header)} mode="multiple" />
diff --git a/superset-frontend/src/components/Select/Select.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/Select/Select.test.tsx similarity index 93% rename from superset-frontend/src/components/Select/Select.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Select/Select.test.tsx index 72e4029228b..588620f47bd 100644 --- a/superset-frontend/src/components/Select/Select.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Select/Select.test.tsx @@ -24,7 +24,7 @@ import { userEvent, waitFor, within, -} from 'spec/helpers/testing-library'; +} from '@superset-ui/core/spec'; import { Select } from '.'; type Option = { @@ -123,17 +123,17 @@ const matchOrder = async (expectedLabels: string[]) => { return true; }; -const type = (text: string, delay?: number, clear = true) => { +const type = async (text: string, delay?: number, clear = true) => { const select = getSelect(); if (clear) { - userEvent.clear(select); + await userEvent.clear(select); } return userEvent.type(select, text, { delay: delay ?? 10 }); }; -const clearTypedText = () => { +const clearTypedText = async () => { const select = getSelect(); - userEvent.clear(select); + await userEvent.clear(select); }; const open = () => waitFor(() => userEvent.click(getSelect())); @@ -201,7 +201,7 @@ test('does not add new options when the value is in a nested/grouped option', as test('inverts the selection', async () => { render(); const originalLabels = OPTIONS.map(option => option.label); await open(); - userEvent.click(await findSelectOption(originalLabels[1])); + await userEvent.click(await findSelectOption(originalLabels[1])); // after selection, keep the original order expect(await matchOrder(originalLabels)).toBe(true); @@ -231,7 +231,7 @@ test('should sort selected to top when in single mode', async () => { // keep clicking other items, the updated order should still based on // original order - userEvent.click(await findSelectOption(originalLabels[5])); + await userEvent.click(await findSelectOption(originalLabels[5])); await matchOrder(labels); await reopen(); labels = originalLabels.slice(); @@ -239,7 +239,7 @@ test('should sort selected to top when in single mode', async () => { expect(await matchOrder(labels)).toBe(true); // should revert to original order - clearAll(); + await clearAll(); await reopen(); expect(await matchOrder(originalLabels)).toBe(true); }); @@ -250,7 +250,7 @@ test('should sort selected to the top when in multi mode', async () => { let labels = originalLabels.slice(); await open(); - userEvent.click(await findSelectOption(labels[2])); + await userEvent.click(await findSelectOption(labels[2])); expect(await matchOrder(labels)).toBe(true); await reopen(); @@ -258,13 +258,13 @@ test('should sort selected to the top when in multi mode', async () => { expect(await matchOrder(labels)).toBe(true); await open(); - userEvent.click(await findSelectOption(labels[5])); + await userEvent.click(await findSelectOption(labels[5])); await reopen(); labels = [labels.splice(0, 1)[0], labels.splice(4, 1)[0]].concat(labels); expect(await matchOrder(labels)).toBe(true); // should revert to original order - clearAll(); + await clearAll(); await reopen(); expect(await matchOrder(originalLabels)).toBe(true); }); @@ -273,8 +273,8 @@ test('order of selected values is preserved until dropdown is closed', async () render(); await open(); - userEvent.click(await findSelectOption(NULL_OPTION.label)); + await userEvent.click(await findSelectOption(NULL_OPTION.label)); const values = await findAllSelectValues(); expect(values[0]).toHaveTextContent(NULL_OPTION.label); }); @@ -452,8 +452,8 @@ test('adds the null option when selected in multiple mode', async () => { />, ); await open(); - userEvent.click(await findSelectOption(OPTIONS[0].label)); - userEvent.click(await findSelectOption(NULL_OPTION.label)); + await userEvent.click(await findSelectOption(OPTIONS[0].label)); + await userEvent.click(await findSelectOption(NULL_OPTION.label)); const values = await findAllSelectValues(); expect(values[0]).toHaveTextContent(OPTIONS[0].label); expect(values[1]).toHaveTextContent(NULL_OPTION.label); @@ -476,7 +476,7 @@ test('makes a selection in single mode', async () => { render(); await open(); const [firstOption, secondOption] = OPTIONS; - userEvent.click(await findSelectOption(firstOption.label)); - userEvent.click(await findSelectOption(secondOption.label)); + await userEvent.click(await findSelectOption(firstOption.label)); + await userEvent.click(await findSelectOption(secondOption.label)); const values = await findAllSelectValues(); expect(values[0]).toHaveTextContent(firstOption.label); expect(values[1]).toHaveTextContent(secondOption.label); @@ -496,7 +496,7 @@ test('changes the selected item in single mode', async () => { render(); await open(); const [firstOption, secondOption] = OPTIONS; - userEvent.click(await findSelectOption(firstOption.label)); - userEvent.click(await findSelectOption(secondOption.label)); + await userEvent.click(await findSelectOption(firstOption.label)); + await userEvent.click(await findSelectOption(secondOption.label)); let values = await findAllSelectValues(); expect(values.length).toBe(2); expect(values[0]).toHaveTextContent(firstOption.label); expect(values[1]).toHaveTextContent(secondOption.label); - userEvent.click(await findSelectOption(firstOption.label)); + await userEvent.click(await findSelectOption(firstOption.label)); values = await findAllSelectValues(); expect(values.length).toBe(1); expect(values[0]).toHaveTextContent(secondOption.label); @@ -681,7 +681,9 @@ test('selects all values', async () => { />, ); await open(); - userEvent.click(await screen.findByText(selectAllButtonText(OPTIONS.length))); + await userEvent.click( + await screen.findByText(selectAllButtonText(OPTIONS.length)), + ); const values = await findAllSelectValues(); expect(values.length).toBe(1); expect(values[0]).toHaveTextContent(`+ ${OPTIONS.length} ...`); @@ -697,11 +699,13 @@ test('unselects all values', async () => { />, ); await open(); - userEvent.click(await screen.findByText(selectAllButtonText(OPTIONS.length))); + await userEvent.click( + await screen.findByText(selectAllButtonText(OPTIONS.length)), + ); let values = await findAllSelectValues(); expect(values.length).toBe(1); expect(values[0]).toHaveTextContent(`+ ${OPTIONS.length} ...`); - userEvent.click( + await userEvent.click( await screen.findByText(deselectAllButtonText(OPTIONS.length)), ); values = await findAllSelectValues(); @@ -722,7 +726,7 @@ test('deselecting a new value also removes it from the options', async () => { expect(await findSelectOption(NEW_OPTION)).toBeInTheDocument(); await type('{enter}'); clearTypedText(); - userEvent.click(await findSelectOption(NEW_OPTION)); + await userEvent.click(await findSelectOption(NEW_OPTION)); expect(await querySelectOption(NEW_OPTION)).not.toBeInTheDocument(); }); @@ -825,7 +829,7 @@ test('do not count unselected disabled options in "Select all"', async () => { test('"Deselect all" counts all selected options', async () => { render(); await open(); await type(NEW_OPTION); - userEvent.click(await findSelectOption(NEW_OPTION)); + await userEvent.click(await findSelectOption(NEW_OPTION)); clearTypedText(); await open(); - userEvent.click(await findSelectOption('Ava')); + await userEvent.click(await findSelectOption('Ava')); expect(await screen.findByText(deselectAllButtonText(2))).toBeInTheDocument(); }); @@ -868,12 +872,12 @@ test('"Select all" does not affect disabled options', async () => { // Checking Select all shouldn't affect the disabled options const selectAll = selectAllButtonText(OPTIONS.length - 1); - userEvent.click(await screen.findByText(selectAll)); + await userEvent.click(await screen.findByText(selectAll)); expect(await findSelectValue()).toHaveTextContent(options[0].label); expect(await findSelectValue()).not.toHaveTextContent(options[1].label); // Unchecking Select all shouldn't affect the disabled options - userEvent.click(await screen.findByText(selectAll)); + await userEvent.click(await screen.findByText(selectAll)); expect(await findSelectValue()).toHaveTextContent(options[0].label); expect(await findSelectValue()).not.toHaveTextContent(options[1].label); }); @@ -892,8 +896,8 @@ test('does not fire onChange when searching but no selection', async () => { ); await open(); await type('Joh'); - userEvent.click(await findSelectOption('John')); - userEvent.click(screen.getByRole('main')); + await userEvent.click(await findSelectOption('John')); + await userEvent.click(screen.getByRole('main')); expect(onChange).toHaveBeenCalledTimes(1); }); @@ -907,7 +911,7 @@ test('fires onChange when clearing the selection in single mode', async () => { value={OPTIONS[0]} />, ); - clearAll(); + await clearAll(); expect(onChange).toHaveBeenCalledTimes(1); }); @@ -921,7 +925,7 @@ test('fires onChange when clearing the selection in multiple mode', async () => value={OPTIONS[0]} />, ); - clearAll(); + await clearAll(); expect(onChange).toHaveBeenCalledTimes(1); }); @@ -1013,9 +1017,9 @@ test('does not fire onChange if the same value is selected in single mode', asyn const optionText = 'Emma'; await open(); expect(onChange).toHaveBeenCalledTimes(0); - userEvent.click(await findSelectOption(optionText)); + await userEvent.click(await findSelectOption(optionText)); expect(onChange).toHaveBeenCalledTimes(1); - userEvent.click(await findSelectOption(optionText)); + await userEvent.click(await findSelectOption(optionText)); expect(onChange).toHaveBeenCalledTimes(1); }); diff --git a/superset-frontend/src/components/Select/Select.tsx b/superset-frontend/packages/superset-ui-core/src/components/Select/Select.tsx similarity index 98% rename from superset-frontend/src/components/Select/Select.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Select/Select.tsx index 8471a5c96f4..38d254c5821 100644 --- a/superset-frontend/src/components/Select/Select.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Select/Select.tsx @@ -29,12 +29,8 @@ import { ReactElement, } from 'react'; -import { - ensureIsArray, - FAST_DEBOUNCE, - t, - usePrevious, -} from '@superset-ui/core'; +import { ensureIsArray, t, usePrevious } from '@superset-ui/core'; +import { Constants } from '@superset-ui/core/components'; import { LabeledValue as AntdLabeledValue, RefSelectProps, @@ -84,7 +80,7 @@ import { Button } from '../Button'; * The Static type accepts a static array of options. * The Async type accepts a promise that will return the options. * Each of the categories come with different abilities. For a comprehensive guide please refer to - * the storybook in src/components/Select/Select.stories.tsx. + * the storybook in @superset-ui/core/components/Select/Select.stories.tsx. */ const Select = forwardRef( ( @@ -384,7 +380,7 @@ const Select = forwardRef( setVisibleOptions(filteredOptions); setInputValue(searchValue); onSearch?.(searchValue); - }, FAST_DEBOUNCE); + }, Constants.FAST_DEBOUNCE); useEffect(() => () => handleOnSearch.cancel(), [handleOnSearch]); diff --git a/superset-frontend/src/components/Select/constants.ts b/superset-frontend/packages/superset-ui-core/src/components/Select/constants.ts similarity index 96% rename from superset-frontend/src/components/Select/constants.ts rename to superset-frontend/packages/superset-ui-core/src/components/Select/constants.ts index 84f5f01e4b0..dd2797b4a58 100644 --- a/superset-frontend/src/components/Select/constants.ts +++ b/superset-frontend/packages/superset-ui-core/src/components/Select/constants.ts @@ -17,8 +17,8 @@ * under the License. */ import { LabeledValue as AntdLabeledValue } from 'antd/es/select'; -import { rankedSearchCompare } from 'src/utils/rankedSearchCompare'; import { t } from '@superset-ui/core'; +import { rankedSearchCompare } from '../../utils/rankedSearchCompare'; import { RawValue } from './types'; export const MAX_TAG_COUNT = 4; diff --git a/superset-frontend/packages/superset-ui-core/src/components/Select/index.ts b/superset-frontend/packages/superset-ui-core/src/components/Select/index.ts new file mode 100644 index 00000000000..0b02349df8f --- /dev/null +++ b/superset-frontend/packages/superset-ui-core/src/components/Select/index.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 Select from './Select'; +import AsyncSelect from './AsyncSelect'; + +export { Select, AsyncSelect }; +export * from './types'; +export * from './styles'; +export * from './constants'; + +// TODO hack to provide vanilla antd Select and SelectProps as +// we mutated the interface quite a bit here, and some internal packages +// are still using the vanilla antd Select +export { Select as RawAntdSelect } from 'antd'; +export { type SelectProps as RawAntdSelectProps } from 'antd/es/select'; diff --git a/superset-frontend/src/components/Select/styles.tsx b/superset-frontend/packages/superset-ui-core/src/components/Select/styles.tsx similarity index 98% rename from superset-frontend/src/components/Select/styles.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Select/styles.tsx index e777d67f74c..05743d60d7c 100644 --- a/superset-frontend/src/components/Select/styles.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Select/styles.tsx @@ -18,7 +18,7 @@ */ import { styled } from '@superset-ui/core'; import { Select } from 'antd'; -import { Icons } from 'src/components/Icons'; +import { Icons } from '@superset-ui/core/components/Icons'; import { Spin } from '../Spin'; import { Flex } from '../Flex'; diff --git a/superset-frontend/src/components/Select/types.ts b/superset-frontend/packages/superset-ui-core/src/components/Select/types.ts similarity index 100% rename from superset-frontend/src/components/Select/types.ts rename to superset-frontend/packages/superset-ui-core/src/components/Select/types.ts diff --git a/superset-frontend/src/components/Select/utils.tsx b/superset-frontend/packages/superset-ui-core/src/components/Select/utils.tsx similarity index 99% rename from superset-frontend/src/components/Select/utils.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Select/utils.tsx index e74a1f9ddcb..6bdd2724b02 100644 --- a/superset-frontend/src/components/Select/utils.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Select/utils.tsx @@ -18,7 +18,7 @@ */ import { ensureIsArray, t } from '@superset-ui/core'; import { ReactElement, RefObject } from 'react'; -import { Icons } from 'src/components/Icons'; +import { Icons } from '@superset-ui/core/components/Icons'; import { LabeledValue as AntdLabeledValue, SELECT_ALL_VALUE } from '.'; import { StyledHelperText, StyledLoadingText, StyledSpin } from './styles'; import { CustomLabeledValue, RawValue, SelectOptionsType, V } from './types'; diff --git a/superset-frontend/src/components/Skeleton/Skeleton.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/Skeleton/Skeleton.stories.tsx similarity index 100% rename from superset-frontend/src/components/Skeleton/Skeleton.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Skeleton/Skeleton.stories.tsx diff --git a/superset-frontend/src/components/Skeleton/Skeleton.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/Skeleton/Skeleton.test.tsx similarity index 86% rename from superset-frontend/src/components/Skeleton/Skeleton.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Skeleton/Skeleton.test.tsx index fff2acd854e..f36778c1085 100644 --- a/superset-frontend/src/components/Skeleton/Skeleton.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Skeleton/Skeleton.test.tsx @@ -16,25 +16,25 @@ * specific language governing permissions and limitations * under the License. */ -import { render, screen } from '@testing-library/react'; +import { render, screen } from '@superset-ui/core/spec'; import '@testing-library/jest-dom'; import { Skeleton } from '.'; describe('Skeleton Component', () => { - test('renders skeleton', () => { + it('renders skeleton', () => { render(); expect(screen.getByRole('list')).toHaveClass('ant-skeleton-paragraph'); }); - test('renders skeleton with correct number of paragraph rows', () => { + it('renders skeleton with correct number of paragraph rows', () => { render(); const paragraph = screen.getByRole('list'); expect(paragraph.children.length).toBe(3); }); - test('does not render skeleton when loading is false', () => { + it('does not render skeleton when loading is false', () => { render(

Loaded Content

diff --git a/superset-frontend/src/components/Skeleton/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/Skeleton/index.tsx similarity index 100% rename from superset-frontend/src/components/Skeleton/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Skeleton/index.tsx diff --git a/superset-frontend/src/components/Slider/Slider.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/Slider/Slider.stories.tsx similarity index 100% rename from superset-frontend/src/components/Slider/Slider.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Slider/Slider.stories.tsx diff --git a/superset-frontend/src/components/Slider/Slider.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/Slider/Slider.test.tsx similarity index 95% rename from superset-frontend/src/components/Slider/Slider.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Slider/Slider.test.tsx index 8413e0ebc67..f4fa3157909 100644 --- a/superset-frontend/src/components/Slider/Slider.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Slider/Slider.test.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { render, screen } from 'spec/helpers/testing-library'; +import { render, screen } from '@superset-ui/core/spec'; import Slider from '.'; const mockedProps = { diff --git a/superset-frontend/src/components/Slider/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/Slider/index.tsx similarity index 100% rename from superset-frontend/src/components/Slider/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Slider/index.tsx diff --git a/superset-frontend/src/components/Space/Space.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/Space/Space.stories.tsx similarity index 100% rename from superset-frontend/src/components/Space/Space.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Space/Space.stories.tsx diff --git a/superset-frontend/src/components/Space/Space.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/Space/Space.test.tsx similarity index 91% rename from superset-frontend/src/components/Space/Space.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Space/Space.test.tsx index 8d73af21988..2097cecb3a8 100644 --- a/superset-frontend/src/components/Space/Space.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Space/Space.test.tsx @@ -16,8 +16,8 @@ * specific language governing permissions and limitations * under the License. */ - -import { render } from 'spec/helpers/testing-library'; +import '@testing-library/jest-dom'; +import { render } from '@superset-ui/core/spec'; import { Space } from '.'; test('should render', () => { diff --git a/superset-frontend/src/components/Space/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/Space/index.tsx similarity index 100% rename from superset-frontend/src/components/Space/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Space/index.tsx diff --git a/superset-frontend/src/components/Spin/Spin.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/Spin/Spin.test.tsx similarity index 94% rename from superset-frontend/src/components/Spin/Spin.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Spin/Spin.test.tsx index f76616110e6..a0214651a44 100644 --- a/superset-frontend/src/components/Spin/Spin.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Spin/Spin.test.tsx @@ -17,7 +17,7 @@ * under the License. */ -import { render } from 'spec/helpers/testing-library'; +import { render } from '@superset-ui/core/spec'; import { Spin } from '.'; test('renders spin with default props', () => { diff --git a/superset-frontend/src/components/Spin/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/Spin/index.tsx similarity index 100% rename from superset-frontend/src/components/Spin/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Spin/index.tsx diff --git a/superset-frontend/src/components/Steps/Steps.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/Steps/Steps.stories.tsx similarity index 100% rename from superset-frontend/src/components/Steps/Steps.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Steps/Steps.stories.tsx diff --git a/superset-frontend/src/components/Steps/Steps.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/Steps/Steps.test.tsx similarity index 94% rename from superset-frontend/src/components/Steps/Steps.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Steps/Steps.test.tsx index 53418e2f147..5c8996ac220 100644 --- a/superset-frontend/src/components/Steps/Steps.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Steps/Steps.test.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { render } from 'spec/helpers/testing-library'; +import { render } from '@superset-ui/core/spec'; import { Steps } from '.'; test('should render with default props', () => { diff --git a/superset-frontend/src/components/Steps/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/Steps/index.tsx similarity index 100% rename from superset-frontend/src/components/Steps/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Steps/index.tsx diff --git a/superset-frontend/src/components/Switch/Switch.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/Switch/Switch.stories.tsx similarity index 100% rename from superset-frontend/src/components/Switch/Switch.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Switch/Switch.stories.tsx diff --git a/superset-frontend/src/components/Switch/Switch.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/Switch/Switch.test.tsx similarity index 95% rename from superset-frontend/src/components/Switch/Switch.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Switch/Switch.test.tsx index 0e8e762d041..03a4983115a 100644 --- a/superset-frontend/src/components/Switch/Switch.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Switch/Switch.test.tsx @@ -17,7 +17,7 @@ * under the License. */ -import { render, screen } from 'spec/helpers/testing-library'; +import { render, screen } from '@superset-ui/core/spec'; import { Switch } from '.'; const mockedProps = { diff --git a/superset-frontend/src/components/Switch/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/Switch/index.tsx similarity index 100% rename from superset-frontend/src/components/Switch/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Switch/index.tsx diff --git a/superset-frontend/src/components/Table/Table.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/Table/Table.stories.tsx similarity index 100% rename from superset-frontend/src/components/Table/Table.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Table/Table.stories.tsx diff --git a/superset-frontend/src/components/Table/Table.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/Table/Table.test.tsx similarity index 96% rename from superset-frontend/src/components/Table/Table.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Table/Table.test.tsx index 9e6b716704e..48fe7327bbd 100644 --- a/superset-frontend/src/components/Table/Table.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Table/Table.test.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { render, screen, waitFor } from 'spec/helpers/testing-library'; +import { render, screen, waitFor } from '@superset-ui/core/spec'; import type { ColumnsType } from 'antd/es/table'; import { Table, TableSize } from './index'; diff --git a/superset-frontend/src/components/Table/TableOverview.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/Table/TableOverview.stories.tsx similarity index 98% rename from superset-frontend/src/components/Table/TableOverview.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Table/TableOverview.stories.tsx index 88e411e8c1e..acbb24fffbf 100644 --- a/superset-frontend/src/components/Table/TableOverview.stories.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Table/TableOverview.stories.tsx @@ -127,7 +127,7 @@ of the data object for that row, as the first argument of the sorter function. The alphabeticalSort is for columns that display a string of text. \`\`\` -import { alphabeticalSort } from 'src/components/Table/sorters'; +import { alphabeticalSort } from '@superset-ui/core/components/Table/sorters'; const basicColumns = [ { @@ -359,7 +359,7 @@ you can register \`onDragOver\` and \`onDragDrop\` event handlers on the destina as the getData key as shown below. \`\`\` -import { SUPERSET_TABLE_COLUMN } from 'src/components/table'; +import { SUPERSET_TABLE_COLUMN } from '@superset-ui/core/components/table'; const handleDrop = (ev:Event) => { const json = ev.dataTransfer?.getData?.(SUPERSET_TABLE_COLUMN); diff --git a/superset-frontend/src/components/Table/VirtualTable.tsx b/superset-frontend/packages/superset-ui-core/src/components/Table/VirtualTable.tsx similarity index 100% rename from superset-frontend/src/components/Table/VirtualTable.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Table/VirtualTable.tsx diff --git a/superset-frontend/src/components/Table/cell-renderers/ActionCell/ActionCell.overview.tsx b/superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/ActionCell/ActionCell.overview.tsx similarity index 100% rename from superset-frontend/src/components/Table/cell-renderers/ActionCell/ActionCell.overview.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/ActionCell/ActionCell.overview.tsx diff --git a/superset-frontend/src/components/Table/cell-renderers/ActionCell/ActionCell.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/ActionCell/ActionCell.stories.tsx similarity index 100% rename from superset-frontend/src/components/Table/cell-renderers/ActionCell/ActionCell.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/ActionCell/ActionCell.stories.tsx diff --git a/superset-frontend/src/components/Table/cell-renderers/ActionCell/ActionCell.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/ActionCell/ActionCell.test.tsx similarity index 87% rename from superset-frontend/src/components/Table/cell-renderers/ActionCell/ActionCell.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/ActionCell/ActionCell.test.tsx index c17ac0196b5..0da17300839 100644 --- a/superset-frontend/src/components/Table/cell-renderers/ActionCell/ActionCell.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/ActionCell/ActionCell.test.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { render, screen, userEvent } from 'spec/helpers/testing-library'; +import { render, screen, userEvent } from '@superset-ui/core/spec'; import ActionCell, { appendDataToMenu } from './index'; import { exampleMenuOptions, exampleRow } from './fixtures'; @@ -25,13 +25,13 @@ test('renders with default props', async () => { exampleMenuOptions[0].onClick = clickHandler; render(); // Open the menu - userEvent.click(await screen.findByTestId('dropdown-trigger')); + await userEvent.click(await screen.findByTestId('dropdown-trigger')); // verify all of the menu items are being displayed - exampleMenuOptions.forEach((item, index) => { + exampleMenuOptions.forEach(async (item, index) => { expect(screen.getByText(item.label)).toBeInTheDocument(); if (index === 0) { // verify the menu items' onClick gets invoked - userEvent.click(screen.getByText(item.label)); + await userEvent.click(screen.getByText(item.label)); } }); expect(clickHandler).toHaveBeenCalled(); diff --git a/superset-frontend/src/components/Table/cell-renderers/ActionCell/fixtures.ts b/superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/ActionCell/fixtures.ts similarity index 100% rename from superset-frontend/src/components/Table/cell-renderers/ActionCell/fixtures.ts rename to superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/ActionCell/fixtures.ts diff --git a/superset-frontend/src/components/Table/cell-renderers/ActionCell/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/ActionCell/index.tsx similarity index 100% rename from superset-frontend/src/components/Table/cell-renderers/ActionCell/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/ActionCell/index.tsx diff --git a/superset-frontend/src/components/Table/cell-renderers/BooleanCell/BooleanCell.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/BooleanCell/BooleanCell.stories.tsx similarity index 100% rename from superset-frontend/src/components/Table/cell-renderers/BooleanCell/BooleanCell.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/BooleanCell/BooleanCell.stories.tsx diff --git a/superset-frontend/src/components/Table/cell-renderers/BooleanCell/BooleanCell.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/BooleanCell/BooleanCell.test.tsx similarity index 75% rename from superset-frontend/src/components/Table/cell-renderers/BooleanCell/BooleanCell.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/BooleanCell/BooleanCell.test.tsx index 7853e6a892b..6060b5cfe4e 100644 --- a/superset-frontend/src/components/Table/cell-renderers/BooleanCell/BooleanCell.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/BooleanCell/BooleanCell.test.tsx @@ -16,21 +16,21 @@ * specific language governing permissions and limitations * under the License. */ -import { render, screen } from 'spec/helpers/testing-library'; -import { BOOL_FALSE_DISPLAY, BOOL_TRUE_DISPLAY } from 'src/constants'; +import { render, screen } from '@superset-ui/core/spec'; +import { Constants } from '@superset-ui/core/components'; import BooleanCell from '.'; test('renders true value', async () => { render(); - expect(screen.getByText(BOOL_TRUE_DISPLAY)).toBeInTheDocument(); + expect(screen.getByText(Constants.BOOL_TRUE_DISPLAY)).toBeInTheDocument(); }); test('renders false value', async () => { render(); - expect(screen.getByText(BOOL_FALSE_DISPLAY)).toBeInTheDocument(); + expect(screen.getByText(Constants.BOOL_FALSE_DISPLAY)).toBeInTheDocument(); }); test('renders falsy value', async () => { render(); - expect(screen.getByText(BOOL_FALSE_DISPLAY)).toBeInTheDocument(); + expect(screen.getByText(Constants.BOOL_FALSE_DISPLAY)).toBeInTheDocument(); }); diff --git a/superset-frontend/src/components/Table/cell-renderers/BooleanCell/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/BooleanCell/index.tsx similarity index 84% rename from superset-frontend/src/components/Table/cell-renderers/BooleanCell/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/BooleanCell/index.tsx index e12060737ed..353e7461f3d 100644 --- a/superset-frontend/src/components/Table/cell-renderers/BooleanCell/index.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/BooleanCell/index.tsx @@ -16,14 +16,18 @@ * specific language governing permissions and limitations * under the License. */ -import { BOOL_FALSE_DISPLAY, BOOL_TRUE_DISPLAY } from 'src/constants'; +import { Constants } from '@superset-ui/core/components'; export interface BooleanCellProps { value?: boolean; } function BooleanCell({ value }: BooleanCellProps) { - return {value ? BOOL_TRUE_DISPLAY : BOOL_FALSE_DISPLAY}; + return ( + + {value ? Constants.BOOL_TRUE_DISPLAY : Constants.BOOL_FALSE_DISPLAY} + + ); } export default BooleanCell; diff --git a/superset-frontend/src/components/Table/cell-renderers/ButtonCell/ButtonCell.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/ButtonCell/ButtonCell.stories.tsx similarity index 100% rename from superset-frontend/src/components/Table/cell-renderers/ButtonCell/ButtonCell.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/ButtonCell/ButtonCell.stories.tsx diff --git a/superset-frontend/src/components/Table/cell-renderers/ButtonCell/ButtonCell.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/ButtonCell/ButtonCell.test.tsx similarity index 94% rename from superset-frontend/src/components/Table/cell-renderers/ButtonCell/ButtonCell.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/ButtonCell/ButtonCell.test.tsx index e7162f954ab..e9a8f8c97e5 100644 --- a/superset-frontend/src/components/Table/cell-renderers/ButtonCell/ButtonCell.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/ButtonCell/ButtonCell.test.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { render, screen, userEvent } from 'spec/helpers/testing-library'; +import { render, screen, userEvent } from '@superset-ui/core/spec'; import ButtonCell from './index'; import { exampleRow } from '../fixtures'; diff --git a/superset-frontend/src/components/Table/cell-renderers/ButtonCell/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/ButtonCell/index.tsx similarity index 100% rename from superset-frontend/src/components/Table/cell-renderers/ButtonCell/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/ButtonCell/index.tsx diff --git a/superset-frontend/src/components/Table/cell-renderers/NullCell/NullCell.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/NullCell/NullCell.stories.tsx similarity index 100% rename from superset-frontend/src/components/Table/cell-renderers/NullCell/NullCell.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/NullCell/NullCell.stories.tsx diff --git a/superset-frontend/src/components/Table/cell-renderers/NullCell/NullCell.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/NullCell/NullCell.test.tsx similarity index 79% rename from superset-frontend/src/components/Table/cell-renderers/NullCell/NullCell.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/NullCell/NullCell.test.tsx index f2a2bcbf83c..b4dfdc23a11 100644 --- a/superset-frontend/src/components/Table/cell-renderers/NullCell/NullCell.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/NullCell/NullCell.test.tsx @@ -16,19 +16,19 @@ * specific language governing permissions and limitations * under the License. */ -import { render, screen } from 'spec/helpers/testing-library'; -import { supersetTheme } from '@superset-ui/core'; -import { NULL_DISPLAY } from 'src/constants'; +import { render, screen } from '@superset-ui/core/spec'; +import { supersetTheme } from '../../../..'; +import { Constants } from '../../..'; import NullCell from '.'; test('renders null value', async () => { render(); - expect(screen.getByText(NULL_DISPLAY)).toBeInTheDocument(); + expect(screen.getByText(Constants.NULL_DISPLAY)).toBeInTheDocument(); }); test('renders with gray font', async () => { render(); - expect(screen.getByText(NULL_DISPLAY)).toHaveStyle( + expect(screen.getByText(Constants.NULL_DISPLAY)).toHaveStyle( `color: ${supersetTheme.colors.grayscale.light1}`, ); }); diff --git a/superset-frontend/src/components/Table/cell-renderers/NullCell/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/NullCell/index.tsx similarity index 87% rename from superset-frontend/src/components/Table/cell-renderers/NullCell/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/NullCell/index.tsx index 52fe59af9f1..e01b7c672ec 100644 --- a/superset-frontend/src/components/Table/cell-renderers/NullCell/index.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/NullCell/index.tsx @@ -16,15 +16,15 @@ * specific language governing permissions and limitations * under the License. */ -import { styled } from '@superset-ui/core'; -import { NULL_DISPLAY } from 'src/constants'; +import { styled } from '../../../..'; +import { Constants } from '../../..'; const GrayCell = styled.span` color: ${({ theme }) => theme.colors.grayscale.light1}; `; function NullCell() { - return {NULL_DISPLAY}; + return {Constants.NULL_DISPLAY}; } export default NullCell; diff --git a/superset-frontend/src/components/Table/cell-renderers/NumericCell/NumericCell.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/NumericCell/NumericCell.stories.tsx similarity index 100% rename from superset-frontend/src/components/Table/cell-renderers/NumericCell/NumericCell.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/NumericCell/NumericCell.stories.tsx diff --git a/superset-frontend/src/components/Table/cell-renderers/NumericCell/NumericCell.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/NumericCell/NumericCell.test.tsx similarity index 96% rename from superset-frontend/src/components/Table/cell-renderers/NumericCell/NumericCell.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/NumericCell/NumericCell.test.tsx index 7319942b69b..dbda8e91ed8 100644 --- a/superset-frontend/src/components/Table/cell-renderers/NumericCell/NumericCell.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/NumericCell/NumericCell.test.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { render, screen } from 'spec/helpers/testing-library'; +import { render, screen } from '@superset-ui/core/spec'; import NumericCell, { CurrencyCode, LocaleCode, Style } from './index'; test('renders with French locale and Euro currency format', () => { diff --git a/superset-frontend/src/components/Table/cell-renderers/NumericCell/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/NumericCell/index.tsx similarity index 100% rename from superset-frontend/src/components/Table/cell-renderers/NumericCell/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/NumericCell/index.tsx diff --git a/superset-frontend/src/components/Table/cell-renderers/TimeCell/TimeCell.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/TimeCell/TimeCell.stories.tsx similarity index 100% rename from superset-frontend/src/components/Table/cell-renderers/TimeCell/TimeCell.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/TimeCell/TimeCell.stories.tsx diff --git a/superset-frontend/src/components/Table/cell-renderers/TimeCell/TimeCell.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/TimeCell/TimeCell.test.tsx similarity index 96% rename from superset-frontend/src/components/Table/cell-renderers/TimeCell/TimeCell.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/TimeCell/TimeCell.test.tsx index 30b8f2f67b2..811a7b7d2fb 100644 --- a/superset-frontend/src/components/Table/cell-renderers/TimeCell/TimeCell.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/TimeCell/TimeCell.test.tsx @@ -17,7 +17,7 @@ * under the License. */ import { TimeFormats } from '@superset-ui/core'; -import { render, screen } from 'spec/helpers/testing-library'; +import { render, screen } from '@superset-ui/core/spec'; import TimeCell from '.'; const DATE = Date.parse('2022-01-01'); diff --git a/superset-frontend/src/components/Table/cell-renderers/TimeCell/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/TimeCell/index.tsx similarity index 100% rename from superset-frontend/src/components/Table/cell-renderers/TimeCell/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/TimeCell/index.tsx diff --git a/superset-frontend/src/components/Table/cell-renderers/fixtures.ts b/superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/fixtures.ts similarity index 100% rename from superset-frontend/src/components/Table/cell-renderers/fixtures.ts rename to superset-frontend/packages/superset-ui-core/src/components/Table/cell-renderers/fixtures.ts diff --git a/superset-frontend/src/components/Table/header-renderers/HeaderWithRadioGroup.tsx b/superset-frontend/packages/superset-ui-core/src/components/Table/header-renderers/HeaderWithRadioGroup.tsx similarity index 93% rename from superset-frontend/src/components/Table/header-renderers/HeaderWithRadioGroup.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Table/header-renderers/HeaderWithRadioGroup.tsx index 5e81b9fbcec..cd54635b064 100644 --- a/superset-frontend/src/components/Table/header-renderers/HeaderWithRadioGroup.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Table/header-renderers/HeaderWithRadioGroup.tsx @@ -17,10 +17,8 @@ * under the License. */ import { useState } from 'react'; -import { css, useTheme } from '@superset-ui/core'; -import { Radio } from 'src/components/Radio'; -import { Icons } from 'src/components/Icons'; -import Popover from 'src/components/Popover'; +import { css, useTheme } from '../../..'; +import { Icons, Radio, Popover } from '../..'; export interface HeaderWithRadioGroupProps { headerTitle: string; diff --git a/superset-frontend/src/components/Table/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/Table/index.tsx similarity index 99% rename from superset-frontend/src/components/Table/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Table/index.tsx index adc0d139c4b..945183d7bd7 100644 --- a/superset-frontend/src/components/Table/index.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Table/index.tsx @@ -22,7 +22,7 @@ import { Table as AntTable } from 'antd'; import { ColumnsType, TableProps as AntTableProps } from 'antd/es/table'; import { PaginationProps } from 'antd/es/pagination'; import { t, useTheme, logging, styled } from '@superset-ui/core'; -import { Loading } from 'src/components'; +import { Loading } from '@superset-ui/core/components'; import { RowSelectionType } from 'antd/es/table/interface'; import InteractiveTableUtils from './utils/InteractiveTableUtils'; import VirtualTable, { VirtualTableProps } from './VirtualTable'; diff --git a/superset-frontend/src/components/Table/sorters.test.ts b/superset-frontend/packages/superset-ui-core/src/components/Table/sorters.test.ts similarity index 100% rename from superset-frontend/src/components/Table/sorters.test.ts rename to superset-frontend/packages/superset-ui-core/src/components/Table/sorters.test.ts diff --git a/superset-frontend/src/components/Table/sorters.ts b/superset-frontend/packages/superset-ui-core/src/components/Table/sorters.ts similarity index 100% rename from superset-frontend/src/components/Table/sorters.ts rename to superset-frontend/packages/superset-ui-core/src/components/Table/sorters.ts diff --git a/superset-frontend/src/components/Table/utils/InteractiveTableUtils.ts b/superset-frontend/packages/superset-ui-core/src/components/Table/utils/InteractiveTableUtils.ts similarity index 99% rename from superset-frontend/src/components/Table/utils/InteractiveTableUtils.ts rename to superset-frontend/packages/superset-ui-core/src/components/Table/utils/InteractiveTableUtils.ts index 94977413e2c..021ef81ff30 100644 --- a/superset-frontend/src/components/Table/utils/InteractiveTableUtils.ts +++ b/superset-frontend/packages/superset-ui-core/src/components/Table/utils/InteractiveTableUtils.ts @@ -17,7 +17,7 @@ * under the License. */ import type { ColumnsType } from 'antd/es/table'; -import { SUPERSET_TABLE_COLUMN } from 'src/components/Table'; +import { SUPERSET_TABLE_COLUMN } from '..'; import { withinRange } from './utils'; interface IInteractiveColumn extends HTMLElement { diff --git a/superset-frontend/src/components/Table/utils/utils.test.ts b/superset-frontend/packages/superset-ui-core/src/components/Table/utils/utils.test.ts similarity index 97% rename from superset-frontend/src/components/Table/utils/utils.test.ts rename to superset-frontend/packages/superset-ui-core/src/components/Table/utils/utils.test.ts index 267817d3f7e..fc60729dc98 100644 --- a/superset-frontend/src/components/Table/utils/utils.test.ts +++ b/superset-frontend/packages/superset-ui-core/src/components/Table/utils/utils.test.ts @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { cleanup } from 'spec/helpers/testing-library'; +import { cleanup } from '@superset-ui/core/spec'; import { withinRange } from './utils'; // Add cleanup after each test diff --git a/superset-frontend/src/components/Table/utils/utils.ts b/superset-frontend/packages/superset-ui-core/src/components/Table/utils/utils.ts similarity index 100% rename from superset-frontend/src/components/Table/utils/utils.ts rename to superset-frontend/packages/superset-ui-core/src/components/Table/utils/utils.ts diff --git a/superset-frontend/src/components/TableCollection/TableCollection.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/TableCollection/TableCollection.test.tsx similarity index 97% rename from superset-frontend/src/components/TableCollection/TableCollection.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/TableCollection/TableCollection.test.tsx index 43880a65f11..52461fff66a 100644 --- a/superset-frontend/src/components/TableCollection/TableCollection.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/TableCollection/TableCollection.test.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { render, screen } from 'spec/helpers/testing-library'; +import { render, screen } from '@superset-ui/core/spec'; import { renderHook } from '@testing-library/react-hooks'; import { TableInstance, useTable } from 'react-table'; import TableCollection from '.'; diff --git a/superset-frontend/src/components/TableCollection/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/TableCollection/index.tsx similarity index 97% rename from superset-frontend/src/components/TableCollection/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/TableCollection/index.tsx index 3e0fbe223ae..7ffae7ac207 100644 --- a/superset-frontend/src/components/TableCollection/index.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/TableCollection/index.tsx @@ -26,7 +26,7 @@ import { TablePropGetter, } from 'react-table'; import { styled } from '@superset-ui/core'; -import { Table, TableSize } from 'src/components/Table'; +import { Table, TableSize } from '@superset-ui/core/components/Table'; import { TableRowSelection, SorterResult } from 'antd/es/table/interface'; import { mapColumns, mapRows } from './utils'; @@ -46,6 +46,7 @@ interface TableCollectionProps { toggleRowSelected?: (rowId: string, value: boolean) => void; toggleAllRowsSelected?: (value?: boolean) => void; sticky?: boolean; + size?: TableSize; } const StyledTable = styled(Table)` @@ -104,6 +105,7 @@ function TableCollection({ toggleAllRowsSelected, prepareRow, sticky, + size = TableSize.Middle, }: TableCollectionProps) { const mappedColumns = mapColumns( columns, @@ -141,7 +143,7 @@ function TableCollection({ sticky={sticky ?? false} columns={mappedColumns} data={mappedRows} - size={TableSize.Middle} + size={size} data-test="listview-table" pagination={false} tableLayout="auto" diff --git a/superset-frontend/src/components/TableCollection/utils.tsx b/superset-frontend/packages/superset-ui-core/src/components/TableCollection/utils.tsx similarity index 76% rename from superset-frontend/src/components/TableCollection/utils.tsx rename to superset-frontend/packages/superset-ui-core/src/components/TableCollection/utils.tsx index 7859d30e197..165c5e0186a 100644 --- a/superset-frontend/src/components/TableCollection/utils.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/TableCollection/utils.tsx @@ -19,11 +19,21 @@ /** * This file contains utility functions for mapping columns and rows. - * These functions act as a compatibility layer between Ant Design Table and react-table. + * These functions act as a compatibility layer between Ant Design Table and react-table. */ import { ReactNode } from 'react'; -import { ColumnInstance, HeaderGroup, Row, CellValue } from 'react-table'; +import { + CellValue, + Row, + ColumnInstance as RTColumnInstance, + HeaderGroup as RTHeaderGroup, + UseSortByColumnOptions, + UseSortByColumnProps, + UseResizeColumnsColumnOptions, + UseResizeColumnsColumnProps, +} from 'react-table'; + import { SortOrder } from '../Table'; type TableSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl'; @@ -39,8 +49,22 @@ const COLUMN_SIZE_MAP: Record = { xxl: 200, }; +type EnhancedColumnInstance = RTColumnInstance & + Partial> & + Partial> & + Partial> & + Partial> & { + hidden?: boolean; + size?: keyof typeof COLUMN_SIZE_MAP; + }; + +type EnhancedHeaderGroup = RTHeaderGroup & { + isSorted?: boolean; + isSortedDesc?: boolean; +}; + function getSortingInfo( - headerGroups: HeaderGroup[], + headerGroups: EnhancedHeaderGroup[], headerId: string, ): { isSorted: boolean; @@ -59,8 +83,8 @@ function getSortingInfo( } export function mapColumns( - columns: ColumnInstance[], - headerGroups: HeaderGroup[], + columns: EnhancedColumnInstance[], + headerGroups: EnhancedHeaderGroup[], columnsForWrapText?: string[], ) { return columns.map(column => { @@ -87,7 +111,7 @@ export function mapColumns( }: { value: CellValue; row: { original: Row; id: string }; - column: ColumnInstance; + column: RTColumnInstance; }) => ReactNode; return cellRenderer({ diff --git a/superset-frontend/src/components/TableView/TableView.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/TableView/TableView.stories.tsx similarity index 97% rename from superset-frontend/src/components/TableView/TableView.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/TableView/TableView.stories.tsx index fb5cf5fbf3a..08c131060e1 100644 --- a/superset-frontend/src/components/TableView/TableView.stories.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/TableView/TableView.stories.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import TableView, { TableViewProps, EmptyWrapperType } from '.'; +import { TableView, TableViewProps, EmptyWrapperType } from '.'; export default { title: 'Components/TableView', diff --git a/superset-frontend/src/components/TableView/TableView.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/TableView/TableView.test.tsx similarity index 93% rename from superset-frontend/src/components/TableView/TableView.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/TableView/TableView.test.tsx index f51edc5de87..228ba4dbe34 100644 --- a/superset-frontend/src/components/TableView/TableView.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/TableView/TableView.test.tsx @@ -16,8 +16,8 @@ * specific language governing permissions and limitations * under the License. */ -import { render, screen, userEvent } from 'spec/helpers/testing-library'; -import TableView, { TableViewProps } from '.'; +import { render, screen, userEvent } from '@superset-ui/core/spec'; +import { TableView, TableViewProps } from '.'; const mockedProps: TableViewProps = { columns: [ @@ -116,19 +116,19 @@ test('should NOT render the pagination when fewer rows than page size', () => { expect(screen.queryByRole('navigation')).not.toBeInTheDocument(); }); -test('should change page when « and » buttons are clicked', () => { +test('should change page when « and » buttons are clicked', async () => { render(); const nextBtn = screen.getByText('»'); const prevBtn = screen.getByText('«'); - userEvent.click(nextBtn); + await userEvent.click(nextBtn); expect(screen.getAllByRole('cell')).toHaveLength(3); expect(screen.getByText('321')).toBeInTheDocument(); expect(screen.getByText('10')).toBeInTheDocument(); expect(screen.getByText('Kate')).toBeInTheDocument(); expect(screen.queryByText('Emily')).not.toBeInTheDocument(); - userEvent.click(prevBtn); + await userEvent.click(prevBtn); expect(screen.getAllByRole('cell')).toHaveLength(3); expect(screen.getByText('123')).toBeInTheDocument(); expect(screen.getByText('27')).toBeInTheDocument(); @@ -136,12 +136,12 @@ test('should change page when « and » buttons are clicked', () => { expect(screen.queryByText('Kate')).not.toBeInTheDocument(); }); -test('should sort by age', () => { +test('should sort by age', async () => { render(); - userEvent.click(screen.getAllByTestId('sort-header')[1]); + await userEvent.click(screen.getAllByTestId('sort-header')[1]); expect(screen.getAllByTestId('table-row-cell')[1]).toHaveTextContent('10'); - userEvent.click(screen.getAllByTestId('sort-header')[1]); + await userEvent.click(screen.getAllByTestId('sort-header')[1]); expect(screen.getAllByTestId('table-row-cell')[1]).toHaveTextContent('27'); }); diff --git a/superset-frontend/src/components/TableView/TableView.tsx b/superset-frontend/packages/superset-ui-core/src/components/TableView/TableView.tsx similarity index 94% rename from superset-frontend/src/components/TableView/TableView.tsx rename to superset-frontend/packages/superset-ui-core/src/components/TableView/TableView.tsx index c9ffbb93eb4..ce99de46492 100644 --- a/superset-frontend/src/components/TableView/TableView.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/TableView/TableView.tsx @@ -20,9 +20,10 @@ import { memo, useEffect, useRef } from 'react'; import { isEqual } from 'lodash'; import { styled, t } from '@superset-ui/core'; import { useFilters, usePagination, useSortBy, useTable } from 'react-table'; -import { Empty } from 'src/components'; -import Pagination from 'src/components/Pagination'; -import TableCollection from 'src/components/TableCollection'; +import { Empty } from '@superset-ui/core/components'; +import Pagination from '@superset-ui/core/components/Pagination'; +import TableCollection from '@superset-ui/core/components/TableCollection'; +import { TableSize } from '@superset-ui/core/components/Table'; import { SortByType, ServerPagination } from './types'; const DEFAULT_PAGE_SIZE = 10; @@ -52,6 +53,7 @@ export interface TableViewProps { scrollTopOnPagination?: boolean; small?: boolean; columnsForWrapText?: string[]; + size?: TableSize; } const EmptyWrapper = styled.div` @@ -117,7 +119,7 @@ const PaginationStyles = styled.div<{ } `; -const TableView = ({ +const RawTableView = ({ columns, data, pageSize: initialPageSize, @@ -133,6 +135,7 @@ const TableView = ({ columnsForWrapText, onServerPagination = () => {}, scrollTopOnPagination = false, + size = TableSize.Middle, ...props }: TableViewProps) => { const initialState = { @@ -219,6 +222,7 @@ const TableView = ({ columns={columns} loading={loading} setSortBy={setSortBy} + size={size} columnsForWrapText={columnsForWrapText} /> {isEmpty && ( @@ -262,4 +266,4 @@ const TableView = ({ ); }; -export default memo(TableView); +export const TableView = memo(RawTableView); diff --git a/superset-frontend/src/components/TableView/index.ts b/superset-frontend/packages/superset-ui-core/src/components/TableView/index.ts similarity index 95% rename from superset-frontend/src/components/TableView/index.ts rename to superset-frontend/packages/superset-ui-core/src/components/TableView/index.ts index c1746ed7773..0ff8aafc024 100644 --- a/superset-frontend/src/components/TableView/index.ts +++ b/superset-frontend/packages/superset-ui-core/src/components/TableView/index.ts @@ -17,4 +17,3 @@ * under the License. */ export * from './TableView'; -export { default } from './TableView'; diff --git a/superset-frontend/src/components/TableView/types.ts b/superset-frontend/packages/superset-ui-core/src/components/TableView/types.ts similarity index 100% rename from superset-frontend/src/components/TableView/types.ts rename to superset-frontend/packages/superset-ui-core/src/components/TableView/types.ts diff --git a/superset-frontend/src/components/Tabs/Tabs.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/Tabs/Tabs.stories.tsx similarity index 100% rename from superset-frontend/src/components/Tabs/Tabs.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Tabs/Tabs.stories.tsx diff --git a/superset-frontend/src/components/Tabs/Tabs.tsx b/superset-frontend/packages/superset-ui-core/src/components/Tabs/Tabs.tsx similarity index 98% rename from superset-frontend/src/components/Tabs/Tabs.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Tabs/Tabs.tsx index b5fd652e091..2688e0b5ed7 100644 --- a/superset-frontend/src/components/Tabs/Tabs.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Tabs/Tabs.tsx @@ -20,7 +20,7 @@ import { css, styled, useTheme } from '@superset-ui/core'; // eslint-disable-next-line no-restricted-imports import { Tabs as AntdTabs, TabsProps as AntdTabsProps } from 'antd'; -import { Icons } from 'src/components/Icons'; +import { Icons } from '@superset-ui/core/components/Icons'; export interface TabsProps extends AntdTabsProps { allowOverflow?: boolean; diff --git a/superset-frontend/src/components/Tabs/index.ts b/superset-frontend/packages/superset-ui-core/src/components/Tabs/index.ts similarity index 100% rename from superset-frontend/src/components/Tabs/index.ts rename to superset-frontend/packages/superset-ui-core/src/components/Tabs/index.ts diff --git a/superset-frontend/packages/superset-ui-core/src/components/Tag/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/Tag/index.tsx new file mode 100644 index 00000000000..f9b7884464a --- /dev/null +++ b/superset-frontend/packages/superset-ui-core/src/components/Tag/index.tsx @@ -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 { Tag } from 'antd'; diff --git a/superset-frontend/src/components/TelemetryPixel/TelemetryPixel.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/TelemetryPixel/TelemetryPixel.test.tsx similarity index 96% rename from superset-frontend/src/components/TelemetryPixel/TelemetryPixel.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/TelemetryPixel/TelemetryPixel.test.tsx index 089c09140e8..7d12a612d7c 100644 --- a/superset-frontend/src/components/TelemetryPixel/TelemetryPixel.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/TelemetryPixel/TelemetryPixel.test.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { render } from 'spec/helpers/testing-library'; +import { render } from '@superset-ui/core/spec'; import TelemetryPixel from '.'; const OLD_ENV = process.env; diff --git a/superset-frontend/src/components/TelemetryPixel/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/TelemetryPixel/index.tsx similarity index 100% rename from superset-frontend/src/components/TelemetryPixel/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/TelemetryPixel/index.tsx diff --git a/superset-frontend/src/components/ThemeEditor/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/ThemeEditor/index.tsx similarity index 97% rename from superset-frontend/src/components/ThemeEditor/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/ThemeEditor/index.tsx index e14cb25fa94..344da2d765e 100644 --- a/superset-frontend/src/components/ThemeEditor/index.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/ThemeEditor/index.tsx @@ -17,7 +17,7 @@ * under the License. */ import { Modal, Tooltip, Flex, Select } from 'antd'; -import { Button, JsonEditor } from 'src/components'; +import { Button, JsonEditor } from '@superset-ui/core/components'; import { themeObject, exampleThemes, @@ -25,7 +25,7 @@ import { SupersetTheme, } from '@superset-ui/core'; import { useState } from 'react'; -import { Icons } from 'src/components/Icons'; +import { Icons } from '@superset-ui/core/components/Icons'; interface ThemeEditorProps { initialTheme?: SupersetTheme; diff --git a/superset-frontend/src/components/Timer/Timer.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/Timer/Timer.stories.tsx similarity index 94% rename from superset-frontend/src/components/Timer/Timer.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Timer/Timer.stories.tsx index 3dd230944fb..e64567a100b 100644 --- a/superset-frontend/src/components/Timer/Timer.stories.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Timer/Timer.stories.tsx @@ -16,8 +16,8 @@ * specific language governing permissions and limitations * under the License. */ -import { extendedDayjs } from 'src/utils/dates'; -import Timer, { TimerProps } from './index'; +import { extendedDayjs } from '../../utils/dates'; +import { Timer, TimerProps } from '.'; export default { title: 'Components/Timer', diff --git a/superset-frontend/src/components/Timer/Timer.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/Timer/Timer.test.tsx similarity index 91% rename from superset-frontend/src/components/Timer/Timer.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Timer/Timer.test.tsx index 3e396558514..61d6a5458d5 100644 --- a/superset-frontend/src/components/Timer/Timer.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Timer/Timer.test.tsx @@ -19,9 +19,15 @@ * specific language governing permissions and limitations * under the License. */ -import { render, sleep, waitFor } from 'spec/helpers/testing-library'; -import Timer, { TimerProps } from 'src/components/Timer'; -import { now } from 'src/utils/dates'; +import { render, waitFor } from '@superset-ui/core/spec'; +import { Timer, TimerProps } from '.'; +import { now } from '../../utils/dates'; + +function sleep(time: number) { + return new Promise(resolve => { + setTimeout(resolve, time); + }); +} function parseTime(text?: string | null) { return !!text && Number(text.replace(/:/g, '')); diff --git a/superset-frontend/src/components/Timer/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/Timer/index.tsx similarity index 87% rename from superset-frontend/src/components/Timer/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Timer/index.tsx index b58f5ebd7e9..0eaa8e456b6 100644 --- a/superset-frontend/src/components/Timer/index.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Timer/index.tsx @@ -17,12 +17,9 @@ * under the License. */ import { useEffect, useRef, useState } from 'react'; -import { useTheme } from '@superset-ui/core'; -import type { LabelType } from 'src/components/Label/types'; -import { Label } from 'src/components'; -import { Icons } from 'src/components/Icons'; - -import { now, fDuration } from 'src/utils/dates'; +import { now, fDuration } from '../../utils/dates'; +import { useTheme } from '../..'; +import { Label, Icons, type LabelType } from '..'; export interface TimerProps { endTime?: number; @@ -31,7 +28,7 @@ export interface TimerProps { status?: LabelType; } -export default function Timer({ +export function Timer({ endTime, isRunning, startTime, diff --git a/superset-frontend/src/components/TimezoneSelector/TimezoneSelector.DaylightSavingTime.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/TimezoneSelector/TimezoneSelector.DaylightSavingTime.test.tsx similarity index 94% rename from superset-frontend/src/components/TimezoneSelector/TimezoneSelector.DaylightSavingTime.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/TimezoneSelector/TimezoneSelector.DaylightSavingTime.test.tsx index 98d823188ad..21fa1fc9abf 100644 --- a/superset-frontend/src/components/TimezoneSelector/TimezoneSelector.DaylightSavingTime.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/TimezoneSelector/TimezoneSelector.DaylightSavingTime.test.tsx @@ -18,12 +18,7 @@ */ import { FC } from 'react'; -import { - render, - waitFor, - screen, - userEvent, -} from 'spec/helpers/testing-library'; +import { render, waitFor, screen, userEvent } from '@superset-ui/core/spec'; import type { TimezoneSelectorProps } from './index'; const loadComponent = (mockCurrentTime?: string) => { @@ -52,7 +47,7 @@ test('render timezones in correct order for daylight saving time', async () => { ); const searchInput = screen.getByRole('combobox'); - userEvent.click(searchInput); + await userEvent.click(searchInput); const options = await waitFor(() => document.querySelectorAll('.ant-select-item-option-content'), diff --git a/superset-frontend/src/components/TimezoneSelector/TimezoneSelector.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/TimezoneSelector/TimezoneSelector.stories.tsx similarity index 100% rename from superset-frontend/src/components/TimezoneSelector/TimezoneSelector.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/TimezoneSelector/TimezoneSelector.stories.tsx diff --git a/superset-frontend/src/components/TimezoneSelector/TimezoneSelector.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/TimezoneSelector/TimezoneSelector.test.tsx similarity index 94% rename from superset-frontend/src/components/TimezoneSelector/TimezoneSelector.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/TimezoneSelector/TimezoneSelector.test.tsx index 35c3448f9d1..25df21eef2c 100644 --- a/superset-frontend/src/components/TimezoneSelector/TimezoneSelector.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/TimezoneSelector/TimezoneSelector.test.tsx @@ -17,13 +17,8 @@ * under the License. */ import { FC } from 'react'; -import { extendedDayjs } from 'src/utils/dates'; -import { - render, - screen, - userEvent, - waitFor, -} from 'spec/helpers/testing-library'; +import { render, screen, userEvent, waitFor } from '@superset-ui/core/spec'; +import { extendedDayjs } from '../../utils/dates'; import type { TimezoneSelectorProps } from './index'; const loadComponent = (mockCurrentTime?: string) => { @@ -40,9 +35,9 @@ const loadComponent = (mockCurrentTime?: string) => { const getSelectOptions = () => waitFor(() => document.querySelectorAll('.ant-select-item-option-content')); -const openSelectMenu = () => { +const openSelectMenu = async () => { const searchInput = screen.getByRole('combobox'); - userEvent.click(searchInput); + await userEvent.click(searchInput); }; jest.spyOn(extendedDayjs.tz, 'guess').mockReturnValue('America/New_York'); @@ -111,10 +106,10 @@ test('can select a timezone values and returns canonical timezone name', async ( const searchInput = screen.getByRole('combobox'); // search for mountain time - userEvent.type(searchInput, 'mou'); + await userEvent.type(searchInput, 'mou'); const findTitle = 'GMT -07:00 (Mountain Standard Time)'; const selectOption = await screen.findByTitle(findTitle); - userEvent.click(selectOption); + await userEvent.click(selectOption); expect(onTimezoneChange).toHaveBeenCalledTimes(1); expect(onTimezoneChange).toHaveBeenLastCalledWith('America/Boise'); }); diff --git a/superset-frontend/src/components/TimezoneSelector/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/TimezoneSelector/index.tsx similarity index 97% rename from superset-frontend/src/components/TimezoneSelector/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/TimezoneSelector/index.tsx index 9d6ea4479c1..3dd0ede01c2 100644 --- a/superset-frontend/src/components/TimezoneSelector/index.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/TimezoneSelector/index.tsx @@ -19,8 +19,8 @@ import { useEffect, useMemo } from 'react'; import { t } from '@superset-ui/core'; -import { Select } from 'src/components'; -import { isDST, extendedDayjs } from 'src/utils/dates'; +import { Select } from '@superset-ui/core/components'; +import { isDST, extendedDayjs } from '../../utils/dates'; const DEFAULT_TIMEZONE = { name: 'GMT Standard Time', diff --git a/superset-frontend/src/components/Tooltip/Tooltip.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/Tooltip/Tooltip.stories.tsx similarity index 100% rename from superset-frontend/src/components/Tooltip/Tooltip.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Tooltip/Tooltip.stories.tsx diff --git a/superset-frontend/src/components/Tooltip/Tooltip.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/Tooltip/Tooltip.test.tsx similarity index 84% rename from superset-frontend/src/components/Tooltip/Tooltip.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Tooltip/Tooltip.test.tsx index 1d46066f3dc..6e0c5f9a6fd 100644 --- a/superset-frontend/src/components/Tooltip/Tooltip.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Tooltip/Tooltip.test.tsx @@ -16,10 +16,8 @@ * specific language governing permissions and limitations * under the License. */ -import { render, screen, userEvent } from 'spec/helpers/testing-library'; -import { Button } from 'src/components'; -import { Icons } from 'src/components/Icons'; -import { Tooltip } from '.'; +import { render, screen, userEvent } from '@superset-ui/core/spec'; +import { Button, Icons, Tooltip } from '..'; test('starts hidden with default props', () => { render( @@ -36,7 +34,7 @@ test('renders on hover', async () => { , ); - userEvent.hover(screen.getByRole('button')); + await userEvent.hover(screen.getByRole('button')); expect(await screen.findByRole('tooltip')).toBeInTheDocument(); }); @@ -46,6 +44,6 @@ test('renders with icon child', async () => { Hover me , ); - userEvent.hover(screen.getByRole('img')); + await userEvent.hover(screen.getByRole('img')); expect(await screen.findByRole('tooltip')).toBeInTheDocument(); }); diff --git a/superset-frontend/src/components/Tooltip/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/Tooltip/index.tsx similarity index 90% rename from superset-frontend/src/components/Tooltip/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Tooltip/index.tsx index 6d2e8d71eda..ee8844a540e 100644 --- a/superset-frontend/src/components/Tooltip/index.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Tooltip/index.tsx @@ -17,7 +17,8 @@ * under the License. */ import { Tooltip as AntdTooltip } from 'antd'; -import type { TooltipProps } from './types'; + +import type { TooltipProps, TooltipPlacement } from './types'; export const Tooltip = ({ overlayStyle, ...props }: TooltipProps) => ( ( {...props} /> ); - -export type { TooltipProps }; +export type { TooltipProps, TooltipPlacement }; diff --git a/superset-frontend/src/components/Tooltip/types.ts b/superset-frontend/packages/superset-ui-core/src/components/Tooltip/types.ts similarity index 87% rename from superset-frontend/src/components/Tooltip/types.ts rename to superset-frontend/packages/superset-ui-core/src/components/Tooltip/types.ts index dbb0f2264c7..ab0f4875f21 100644 --- a/superset-frontend/src/components/Tooltip/types.ts +++ b/superset-frontend/packages/superset-ui-core/src/components/Tooltip/types.ts @@ -16,7 +16,11 @@ * specific language governing permissions and limitations * under the License. */ -export type { TooltipProps } from 'antd/es/tooltip'; +import { Tooltip } from 'antd'; + +export type TooltipProps = React.ComponentProps & { + overlayStyle?: React.CSSProperties; +}; export type TooltipPlacement = | 'top' diff --git a/superset-frontend/src/components/TooltipParagraph/TooltipParagraph.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/TooltipParagraph/TooltipParagraph.stories.tsx similarity index 100% rename from superset-frontend/src/components/TooltipParagraph/TooltipParagraph.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/TooltipParagraph/TooltipParagraph.stories.tsx diff --git a/superset-frontend/src/components/TooltipParagraph/TooltipParagraph.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/TooltipParagraph/TooltipParagraph.test.tsx similarity index 92% rename from superset-frontend/src/components/TooltipParagraph/TooltipParagraph.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/TooltipParagraph/TooltipParagraph.test.tsx index 4d3b08c11db..e42bab3d7b9 100644 --- a/superset-frontend/src/components/TooltipParagraph/TooltipParagraph.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/TooltipParagraph/TooltipParagraph.test.tsx @@ -16,12 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { - render, - screen, - userEvent, - waitFor, -} from 'spec/helpers/testing-library'; +import { render, screen, userEvent, waitFor } from '@superset-ui/core/spec'; import TooltipParagraph from '.'; test('starts hidden with default props', () => { @@ -38,7 +33,7 @@ test('not render on hover when not truncated', async () => {
, ); - userEvent.hover(screen.getByTestId('test-text')); + await userEvent.hover(screen.getByTestId('test-text')); // Wait a moment for any potential tooltip to appear await new Promise(resolve => setTimeout(resolve, 100)); @@ -63,7 +58,7 @@ test('render on hover when truncated', async () => { expect(ellipsisElement).toBeInTheDocument(); // Hover over the text - userEvent.hover(screen.getByTestId('test-text')); + await userEvent.hover(screen.getByTestId('test-text')); // In Ant Design v5, we can check if the aria-describedby attribute is present // which indicates the tooltip functionality is active diff --git a/superset-frontend/src/components/TooltipParagraph/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/TooltipParagraph/index.tsx similarity index 93% rename from superset-frontend/src/components/TooltipParagraph/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/TooltipParagraph/index.tsx index 5e767695459..3355ae22d8a 100644 --- a/superset-frontend/src/components/TooltipParagraph/index.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/TooltipParagraph/index.tsx @@ -17,7 +17,11 @@ * under the License. */ import { useState, FC } from 'react'; -import { ParagraphProps, Typography, Tooltip } from 'src/components'; +import { + ParagraphProps, + Typography, + Tooltip, +} from '@superset-ui/core/components'; const TooltipParagraph: FC = ({ children, diff --git a/superset-frontend/src/components/Tree/Tree.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/Tree/Tree.stories.tsx similarity index 99% rename from superset-frontend/src/components/Tree/Tree.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Tree/Tree.stories.tsx index e1190f089bd..84aa0d614db 100644 --- a/superset-frontend/src/components/Tree/Tree.stories.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Tree/Tree.stories.tsx @@ -17,7 +17,7 @@ * under the License. */ import { Meta, StoryObj } from '@storybook/react'; -import { Icons } from 'src/components/Icons'; +import { Icons } from '@superset-ui/core/components/Icons'; import Tree, { TreeProps, type TreeDataNode } from './index'; const meta = { diff --git a/superset-frontend/src/components/Tree/Tree.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/Tree/Tree.test.tsx similarity index 93% rename from superset-frontend/src/components/Tree/Tree.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Tree/Tree.test.tsx index ab61b5bd8df..1075bb53b65 100644 --- a/superset-frontend/src/components/Tree/Tree.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Tree/Tree.test.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { render, screen, fireEvent } from '@testing-library/react'; +import { render, screen, fireEvent } from '@superset-ui/core/spec'; import '@testing-library/jest-dom'; import Tree from './index'; @@ -32,7 +32,7 @@ const treeData = [ ]; describe('Tree Component', () => { - test('expands and collapses parent node', async () => { + it('expands and collapses parent node', async () => { render(); expect(screen.queryByText('Child 1')).not.toBeInTheDocument(); diff --git a/superset-frontend/src/components/Tree/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/Tree/index.tsx similarity index 100% rename from superset-frontend/src/components/Tree/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Tree/index.tsx diff --git a/superset-frontend/src/components/TreeSelect/TreeSelect.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/TreeSelect/TreeSelect.stories.tsx similarity index 100% rename from superset-frontend/src/components/TreeSelect/TreeSelect.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/TreeSelect/TreeSelect.stories.tsx diff --git a/superset-frontend/src/components/TreeSelect/TreeSelect.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/TreeSelect/TreeSelect.test.tsx similarity index 96% rename from superset-frontend/src/components/TreeSelect/TreeSelect.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/TreeSelect/TreeSelect.test.tsx index ce01d0affef..86077691abe 100644 --- a/superset-frontend/src/components/TreeSelect/TreeSelect.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/TreeSelect/TreeSelect.test.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { render, fireEvent, screen } from '@testing-library/react'; +import { render, fireEvent, screen } from '@superset-ui/core/spec'; import '@testing-library/jest-dom'; import { TreeSelect } from '.'; diff --git a/superset-frontend/src/components/TreeSelect/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/TreeSelect/index.tsx similarity index 100% rename from superset-frontend/src/components/TreeSelect/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/TreeSelect/index.tsx diff --git a/superset-frontend/src/components/TruncatedList/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/TruncatedList/index.tsx similarity index 98% rename from superset-frontend/src/components/TruncatedList/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/TruncatedList/index.tsx index fecaca4a783..0348d064ccd 100644 --- a/superset-frontend/src/components/TruncatedList/index.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/TruncatedList/index.tsx @@ -20,7 +20,7 @@ import { ReactNode, Key, useMemo } from 'react'; import { styled, t, useTruncation } from '@superset-ui/core'; -import { Tooltip } from 'src/components'; +import { Tooltip } from '@superset-ui/core/components'; export type TruncatedListProps = { /** diff --git a/superset-frontend/src/components/Typography/Typography.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/Typography/Typography.stories.tsx similarity index 100% rename from superset-frontend/src/components/Typography/Typography.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Typography/Typography.stories.tsx diff --git a/superset-frontend/src/components/Typography/Typography.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/Typography/Typography.test.tsx similarity index 86% rename from superset-frontend/src/components/Typography/Typography.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Typography/Typography.test.tsx index 8aaac2987ad..5382c87bdc9 100644 --- a/superset-frontend/src/components/Typography/Typography.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Typography/Typography.test.tsx @@ -16,28 +16,28 @@ * specific language governing permissions and limitations * under the License. */ -import { render, screen } from 'spec/helpers/testing-library'; +import { render, screen } from '@superset-ui/core/spec'; import '@testing-library/jest-dom'; import { Typography } from '.'; describe('Typography Component', () => { - test('renders Text component', () => { + it('renders Text component', () => { render(Text Content); expect(screen.getByText('Text Content')).toBeInTheDocument(); }); - test('renders Title component', () => { + it('renders Title component', () => { render(Title Content); expect(screen.getByText('Title Content')).toBeInTheDocument(); expect(screen.getByRole('heading', { level: 2 })).toBeInTheDocument(); }); - test('renders Paragraph component', () => { + it('renders Paragraph component', () => { render(Paragraph Content); expect(screen.getByText('Paragraph Content')).toBeInTheDocument(); }); - test('renders Link component', () => { + it('renders Link component', () => { render( Link Content @@ -48,19 +48,19 @@ describe('Typography Component', () => { expect(link).toHaveAttribute('href', 'https://example.com'); }); - test('renders strong text', () => { + it('renders strong text', () => { render(Strong Text); expect(screen.getByText('Strong Text')).toHaveStyle('font-weight: 600'); }); - test('renders underlined text', () => { + it('renders underlined text', () => { render(Underlined Text); expect(screen.getByText('Underlined Text')).toHaveStyle( 'text-decoration: underline', ); }); - test('renders disabled text', () => { + it('renders disabled text', () => { render(Disabled Text); expect(screen.getByText('Disabled Text')).toHaveClass( 'ant-typography-disabled', diff --git a/superset-frontend/src/components/Typography/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/Typography/index.tsx similarity index 100% rename from superset-frontend/src/components/Typography/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Typography/index.tsx diff --git a/superset-frontend/src/components/Upload/Upload.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/Upload/Upload.stories.tsx similarity index 100% rename from superset-frontend/src/components/Upload/Upload.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Upload/Upload.stories.tsx diff --git a/superset-frontend/src/components/Upload/Upload.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/Upload/Upload.test.tsx similarity index 87% rename from superset-frontend/src/components/Upload/Upload.test.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Upload/Upload.test.tsx index 9964c7901d8..fb0f08ed666 100644 --- a/superset-frontend/src/components/Upload/Upload.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Upload/Upload.test.tsx @@ -16,16 +16,11 @@ * specific language governing permissions and limitations * under the License. */ -import { - render, - screen, - fireEvent, - waitFor, -} from 'spec/helpers/testing-library'; -import { Button, Upload } from 'src/components'; +import { render, screen, fireEvent, waitFor } from '@superset-ui/core/spec'; +import { Button, Upload } from '..'; describe('Upload Component', () => { - test('renders upload button and triggers file upload', async () => { + it('renders upload button and triggers file upload', async () => { const handleChange = jest.fn(); render( diff --git a/superset-frontend/src/components/Upload/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/Upload/index.tsx similarity index 100% rename from superset-frontend/src/components/Upload/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/Upload/index.tsx diff --git a/superset-frontend/src/components/WarningIconWithTooltip/WarningIconWithTooltip.stories.tsx b/superset-frontend/packages/superset-ui-core/src/components/WarningIconWithTooltip/WarningIconWithTooltip.stories.tsx similarity index 100% rename from superset-frontend/src/components/WarningIconWithTooltip/WarningIconWithTooltip.stories.tsx rename to superset-frontend/packages/superset-ui-core/src/components/WarningIconWithTooltip/WarningIconWithTooltip.stories.tsx diff --git a/superset-frontend/src/components/WarningIconWithTooltip/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/WarningIconWithTooltip/index.tsx similarity index 87% rename from superset-frontend/src/components/WarningIconWithTooltip/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/WarningIconWithTooltip/index.tsx index 5732db72aaf..607eed6f7c0 100644 --- a/superset-frontend/src/components/WarningIconWithTooltip/index.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/WarningIconWithTooltip/index.tsx @@ -16,10 +16,8 @@ * specific language governing permissions and limitations * under the License. */ -import { useTheme, SafeMarkdown } from '@superset-ui/core'; -import { Icons } from 'src/components/Icons'; -import type { IconType } from 'src/components/Icons/types'; -import { Tooltip } from '../Tooltip'; +import { useTheme } from '@superset-ui/core'; +import { Icons, type IconType, SafeMarkdown, Tooltip } from '..'; export interface WarningIconWithTooltipProps { warningMarkdown: string; diff --git a/superset-frontend/packages/superset-ui-core/src/components/assets/images/.!80135!loading.gif b/superset-frontend/packages/superset-ui-core/src/components/assets/images/.!80135!loading.gif new file mode 100644 index 00000000000..e69de29bb2d diff --git a/superset-frontend/packages/superset-ui-core/src/components/assets/images/.!80342!loading.gif b/superset-frontend/packages/superset-ui-core/src/components/assets/images/.!80342!loading.gif new file mode 100644 index 00000000000..e69de29bb2d diff --git a/superset-frontend/packages/superset-ui-core/src/components/assets/images/.!80520!loading.gif b/superset-frontend/packages/superset-ui-core/src/components/assets/images/.!80520!loading.gif new file mode 100644 index 00000000000..e69de29bb2d diff --git a/superset-frontend/packages/superset-ui-core/src/components/assets/images/.!80903!loading.gif b/superset-frontend/packages/superset-ui-core/src/components/assets/images/.!80903!loading.gif new file mode 100644 index 00000000000..e69de29bb2d diff --git a/superset-frontend/src/components/Select/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/assets/images/index.ts similarity index 81% rename from superset-frontend/src/components/Select/index.tsx rename to superset-frontend/packages/superset-ui-core/src/components/assets/images/index.ts index 004c22e7f24..c272c1186cd 100644 --- a/superset-frontend/src/components/Select/index.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/assets/images/index.ts @@ -16,10 +16,6 @@ * specific language governing permissions and limitations * under the License. */ -import Select from './Select'; -import AsyncSelect from './AsyncSelect'; +import Loading from './loading.gif'; -export { Select, AsyncSelect }; -export * from './types'; -export * from './styles'; -export * from './constants'; +export { Loading }; diff --git a/superset-frontend/packages/superset-ui-core/src/components/assets/images/loading.gif b/superset-frontend/packages/superset-ui-core/src/components/assets/images/loading.gif new file mode 100644 index 00000000000..d82fc5d9244 Binary files /dev/null and b/superset-frontend/packages/superset-ui-core/src/components/assets/images/loading.gif differ diff --git a/superset-frontend/packages/superset-ui-core/src/components/assets/index.ts b/superset-frontend/packages/superset-ui-core/src/components/assets/index.ts new file mode 100644 index 00000000000..c59dc1dc385 --- /dev/null +++ b/superset-frontend/packages/superset-ui-core/src/components/assets/index.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 * from './svgs'; +export * from './images'; diff --git a/superset-frontend/src/assets/images/chart.svg b/superset-frontend/packages/superset-ui-core/src/components/assets/svgs/chart.svg similarity index 100% rename from superset-frontend/src/assets/images/chart.svg rename to superset-frontend/packages/superset-ui-core/src/components/assets/svgs/chart.svg diff --git a/superset-frontend/src/assets/images/icons/error.svg b/superset-frontend/packages/superset-ui-core/src/components/assets/svgs/error.svg similarity index 100% rename from superset-frontend/src/assets/images/icons/error.svg rename to superset-frontend/packages/superset-ui-core/src/components/assets/svgs/error.svg diff --git a/superset-frontend/packages/superset-ui-core/src/components/assets/svgs/index.ts b/superset-frontend/packages/superset-ui-core/src/components/assets/svgs/index.ts new file mode 100644 index 00000000000..e33811776f8 --- /dev/null +++ b/superset-frontend/packages/superset-ui-core/src/components/assets/svgs/index.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 chart from './chart.svg'; +import error from './error.svg'; + +export { chart, error }; diff --git a/superset-frontend/src/components/atomic-design.png b/superset-frontend/packages/superset-ui-core/src/components/atomic-design.png similarity index 100% rename from superset-frontend/src/components/atomic-design.png rename to superset-frontend/packages/superset-ui-core/src/components/atomic-design.png diff --git a/superset-frontend/packages/superset-ui-core/src/components/constants.ts b/superset-frontend/packages/superset-ui-core/src/components/constants.ts index f252d725dd2..05b681c28f4 100644 --- a/superset-frontend/packages/superset-ui-core/src/components/constants.ts +++ b/superset-frontend/packages/superset-ui-core/src/components/constants.ts @@ -17,12 +17,12 @@ * under the License. */ -/** - * Faster debounce delay for inputs without expensive operation. - */ -export const FAST_DEBOUNCE = 250; +import { t } from '..'; -/** - * Slower debounce delay for inputs with expensive API calls. - */ -export const SLOW_DEBOUNCE = 500; +export const Constants = { + FAST_DEBOUNCE: 250, + SLOW_DEBOUNCE: 500, + NULL_DISPLAY: t('N/A'), + BOOL_TRUE_DISPLAY: t('True'), + BOOL_FALSE_DISPLAY: t('False'), +}; diff --git a/superset-frontend/packages/superset-ui-core/src/components/index.ts b/superset-frontend/packages/superset-ui-core/src/components/index.ts index 6fe666c0372..25e56804fe1 100644 --- a/superset-frontend/packages/superset-ui-core/src/components/index.ts +++ b/superset-frontend/packages/superset-ui-core/src/components/index.ts @@ -1,4 +1,4 @@ -/* +/** * 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 @@ -17,5 +17,150 @@ * under the License. */ +/* + * Re-exporting of components in @superset-ui/core/components to facilitate + * their imports by other components. + * E.g. import { Select } from '@superset-ui/core/components', probably in the future from '@superset-ui/components' + */ +export * from './Input'; +export { AntdThemeProvider } from './AntdThemeProvider'; +export { + ConfirmStatusChange, + type ConfirmStatusChangeProps, +} from './ConfirmStatusChange'; +export { Alert, type AlertProps } from './Alert'; +export { CertifiedBadge } from './CertifiedBadge'; +export * from './Icons'; +export * from './Timer'; +export { + AsyncEsmComponent, + type PlaceholderProps as AsyncEsmPlaceholderProps, +} from './AsyncEsmComponent'; +export { + AsyncAceEditor, + CssEditor, + JsonEditor, + SQLEditor, + FullSQLEditor, + MarkdownEditor, + TextAreaEditor, + ConfigEditor, + type AsyncAceEditorProps, + type Editor, +} from './AsyncAceEditor'; +export { AutoComplete, type AutoCompleteProps } from './AutoComplete'; +export { + Avatar, + AvatarGroup, + type AvatarProps, + type AvatarGroupProps, +} from './Avatar'; +export { Badge, type BadgeProps } from './Badge'; +export { Button, type ButtonProps, type OnClickHandler } from './Button'; +export { ButtonGroup, type ButtonGroupProps } from './ButtonGroup'; +export { Breadcrumb, type BreadcrumbProps } from './Breadcrumb'; +export { CachedLabel, type CacheLabelProps } from './CachedLabel'; +export { Card } from './Card'; +export { + Checkbox, + type CheckboxProps, + type CheckboxChangeEvent, +} from './Checkbox'; +export { + Collapse, + type CollapseProps, + CollapseLabelInModal, + type CollapseLabelInModalProps, +} from './Collapse'; +export { CronPicker, type CronError } from './CronPicker'; +export * from './DatePicker'; +export { DeleteModal, type DeleteModalProps } from './DeleteModal'; +export { Divider, type DividerProps } from './Divider'; +export { + Dropdown, + MenuDotsDropdown, + NoAnimationDropdown, + type DropdownProps, + type NoAnimationDropdownProps, + type MenuDotsDropdownProps, +} from './Dropdown'; +export { DropdownButton, type DropdownButtonProps } from './DropdownButton'; +export { + DropdownContainer, + type DropdownItem, + type DropdownRef, +} from './DropdownContainer'; +export { + DynamicEditableTitle, + type DynamicEditableTitleProps, +} from './DynamicEditableTitle'; +export { EditableTitle, type EditableTitleProps } from './EditableTitle'; +export { EmptyState, type EmptyStateProps } from './EmptyState'; +export { Empty, type EmptyProps } from './EmptyState/Empty'; +export { FaveStar, type FaveStarProps } from './FaveStar'; +export { + Modal, + FormModal, + StyledModal, + type ModalProps, + type FormModalProps, +} from './Modal'; +export * from './ModalTrigger'; +export { Flex, type FlexProps } from './Flex'; +export { + Form, + FormItem, + FormLabel, + LabeledErrorBoundInput, + type FormInstance, + type FormProps, + type FormItemProps, +} from './Form'; +export { Grid, Row, Col, type RowProps, type ColProps } from './Grid'; +export { IconButton, type IconButtonProps } from './IconButton'; +export * from './Tooltip'; +export { Tooltip as RawAntdTooltip } from 'antd'; +export { IconTooltip, type IconTooltipProps } from './IconTooltip'; +export { InfoTooltip, type InfoTooltipProps } from './InfoTooltip'; +export { + Label, + DatasetTypeLabel, + PublishedLabel, + type LabelType, +} from './Label'; +export { LastUpdated, type LastUpdatedProps } from './LastUpdated'; +export { Layout, type LayoutProps, type SiderProps } from './Layout'; +export { List, type ListProps, type ListItemProps } from './List'; +export { + ListViewCard, + ImageLoader, + type ListViewCardProps, +} from './ListViewCard'; +export { Loading, type LoadingProps } from './Loading'; + +export { Skeleton, type SkeletonProps } from './Skeleton'; + +export { Switch, type SwitchProps } from './Switch'; + +export { TreeSelect, type TreeSelectProps } from './TreeSelect'; + +export { + Typography, + type TypographyProps, + type ParagraphProps, +} from './Typography'; + +export { Image, type ImageProps } from './Image'; +export { Upload, type UploadFile, type UploadChangeParam } from './Upload'; +// Add these to your index.ts +export * from './Menu'; +export * from './Popover'; +export * from './Radio'; +export * from './SafeMarkdown/SafeMarkdown'; +export * from './Select'; +export * from './Space'; +export * from './Steps'; +export * from './Table'; +export * from './TableView'; +export * from './Tag'; export * from './constants'; -export { default as SafeMarkdown } from './SafeMarkdown'; diff --git a/superset-frontend/packages/superset-ui-core/src/index.ts b/superset-frontend/packages/superset-ui-core/src/index.ts index 99e9b518433..ceb5d08c90e 100644 --- a/superset-frontend/packages/superset-ui-core/src/index.ts +++ b/superset-frontend/packages/superset-ui-core/src/index.ts @@ -32,7 +32,6 @@ export * from './theme'; export * from './validator'; export * from './chart'; export * from './chart-composition'; -export * from './components'; export * from './math-expression'; export * from './ui-overrides'; export * from './hooks'; diff --git a/superset-frontend/packages/superset-ui-core/src/query/api/v1/types.ts b/superset-frontend/packages/superset-ui-core/src/query/api/v1/types.ts index 06d1419e747..984eb52e5e6 100644 --- a/superset-frontend/packages/superset-ui-core/src/query/api/v1/types.ts +++ b/superset-frontend/packages/superset-ui-core/src/query/api/v1/types.ts @@ -43,7 +43,7 @@ export interface SupersetApiRequestOptions { * Superset API error types. * Ref: https://github.com/apache/incubator-superset/blob/318e5347bc6f88119725775baa4ab9a398a6f0b0/superset/errors.py#L24 * - * TODO: migrate superset-frontend/src/components/ErrorMessage/types.ts over + * TODO: migrate superset-frontend/@superset-ui/core/components/ErrorMessage/types.ts over */ export enum SupersetApiErrorType { // Generic unknown error diff --git a/superset-frontend/packages/superset-ui-core/src/spec/index.tsx b/superset-frontend/packages/superset-ui-core/src/spec/index.tsx new file mode 100644 index 00000000000..da7632b6954 --- /dev/null +++ b/superset-frontend/packages/superset-ui-core/src/spec/index.tsx @@ -0,0 +1,46 @@ +/** + * 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 userEvent from '@testing-library/user-event'; +import { ReactElement } from 'react'; +import { render, RenderOptions } from '@testing-library/react'; +import '@testing-library/jest-dom'; +import { themeObject } from '@superset-ui/core'; + +// Define the wrapper component outside +const AllTheProviders = ({ children }: { children: React.ReactNode }) => ( + + {children} + +); + +// Follow the exact pattern from RTL docs +const customRender = ( + ui: ReactElement, + options?: Omit, +) => render(ui, { wrapper: AllTheProviders, ...options }); + +export { + createEvent, + fireEvent, + screen, + waitFor, + cleanup, + within, +} from '@testing-library/react'; +export { customRender as render, userEvent }; diff --git a/superset-frontend/src/utils/dates.test.ts b/superset-frontend/packages/superset-ui-core/src/utils/dates.test.ts similarity index 99% rename from superset-frontend/src/utils/dates.test.ts rename to superset-frontend/packages/superset-ui-core/src/utils/dates.test.ts index 53d4cef846e..7395bcb5884 100644 --- a/superset-frontend/src/utils/dates.test.ts +++ b/superset-frontend/packages/superset-ui-core/src/utils/dates.test.ts @@ -23,7 +23,7 @@ import { epochTimeXDaysAgo, epochTimeXYearsAgo, extendedDayjs, -} from 'src/utils/dates'; +} from './dates'; describe('extendedDayjs', () => { it('returns dayjs object with extended methods', () => { diff --git a/superset-frontend/src/utils/dates.ts b/superset-frontend/packages/superset-ui-core/src/utils/dates.ts similarity index 100% rename from superset-frontend/src/utils/dates.ts rename to superset-frontend/packages/superset-ui-core/src/utils/dates.ts diff --git a/superset-frontend/packages/superset-ui-core/src/utils/html.test.tsx b/superset-frontend/packages/superset-ui-core/src/utils/html.test.tsx index 3f38e8c9c16..12a0a4f9f5a 100644 --- a/superset-frontend/packages/superset-ui-core/src/utils/html.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/utils/html.test.tsx @@ -27,7 +27,7 @@ import { } from './html'; describe('sanitizeHtml', () => { - test('should sanitize the HTML string', () => { + it('should sanitize the HTML string', () => { const htmlString = ''; const sanitizedString = sanitizeHtml(htmlString); expect(sanitizedString).not.toContain('script'); @@ -35,13 +35,13 @@ describe('sanitizeHtml', () => { }); describe('isProbablyHTML', () => { - test('should return true if the text contains HTML tags', () => { + it('should return true if the text contains HTML tags', () => { const htmlText = '
Some HTML content
'; const isHTML = isProbablyHTML(htmlText); expect(isHTML).toBe(true); }); - test('should return false if the text does not contain HTML tags', () => { + it('should return false if the text does not contain HTML tags', () => { const plainText = 'Just a plain text'; const isHTML = isProbablyHTML(plainText); expect(isHTML).toBe(false); @@ -52,13 +52,13 @@ describe('isProbablyHTML', () => { }); describe('sanitizeHtmlIfNeeded', () => { - test('should sanitize the HTML string if it contains HTML tags', () => { + it('should sanitize the HTML string if it contains HTML tags', () => { const htmlString = '
Some HTML content
'; const sanitizedString = sanitizeHtmlIfNeeded(htmlString); expect(sanitizedString).toEqual(htmlString); }); - test('should return the string as is if it does not contain HTML tags', () => { + it('should return the string as is if it does not contain HTML tags', () => { const plainText = 'Just a plain text'; const sanitizedString = sanitizeHtmlIfNeeded(plainText); expect(sanitizedString).toEqual(plainText); @@ -66,7 +66,7 @@ describe('sanitizeHtmlIfNeeded', () => { }); describe('safeHtmlSpan', () => { - test('should return a safe HTML span when the input is HTML', () => { + it('should return a safe HTML span when the input is HTML', () => { const htmlString = '
Some HTML content
'; const safeSpan = safeHtmlSpan(htmlString); expect(safeSpan).toEqual( @@ -77,7 +77,7 @@ describe('safeHtmlSpan', () => { ); }); - test('should return the input string as is when it is not HTML', () => { + it('should return the input string as is when it is not HTML', () => { const plainText = 'Just a plain text'; const result = safeHtmlSpan(plainText); expect(result).toEqual(plainText); @@ -85,31 +85,31 @@ describe('safeHtmlSpan', () => { }); describe('removeHTMLTags', () => { - test('should remove HTML tags from the string', () => { + it('should remove HTML tags from the string', () => { const input = '

Hello, World!

'; const output = removeHTMLTags(input); expect(output).toBe('Hello, World!'); }); - test('should return the same string when no HTML tags are present', () => { + it('should return the same string when no HTML tags are present', () => { const input = 'This is a plain text.'; const output = removeHTMLTags(input); expect(output).toBe('This is a plain text.'); }); - test('should remove nested HTML tags and return combined text content', () => { + it('should remove nested HTML tags and return combined text content', () => { const input = '

Title

Content

'; const output = removeHTMLTags(input); expect(output).toBe('TitleContent'); }); - test('should handle self-closing tags and return an empty string', () => { + it('should handle self-closing tags and return an empty string', () => { const input = 'Image'; const output = removeHTMLTags(input); expect(output).toBe(''); }); - test('should handle malformed HTML tags and remove only well-formed tags', () => { + it('should handle malformed HTML tags and remove only well-formed tags', () => { const input = '

Unclosed tag'; const output = removeHTMLTags(input); expect(output).toBe('Unclosed tag'); @@ -117,44 +117,44 @@ describe('removeHTMLTags', () => { }); describe('isJsonString', () => { - test('valid JSON object', () => { + it('valid JSON object', () => { const jsonString = '{"name": "John", "age": 30, "city": "New York"}'; expect(isJsonString(jsonString)).toBe(true); }); - test('valid JSON array', () => { + it('valid JSON array', () => { const jsonString = '[1, 2, 3, 4, 5]'; expect(isJsonString(jsonString)).toBe(true); }); - test('valid JSON string', () => { + it('valid JSON string', () => { const jsonString = '"Hello, world!"'; expect(isJsonString(jsonString)).toBe(true); }); - test('invalid JSON with syntax error', () => { + it('invalid JSON with syntax error', () => { const jsonString = '{"name": "John", "age": 30, "city": "New York"'; expect(isJsonString(jsonString)).toBe(false); }); - test('empty string', () => { + it('empty string', () => { const jsonString = ''; expect(isJsonString(jsonString)).toBe(false); }); - test('non-JSON string', () => { + it('non-JSON string', () => { const jsonString = '

Hello, World!

'; expect(isJsonString(jsonString)).toBe(false); }); - test('non-JSON formatted number', () => { + it('non-JSON formatted number', () => { const jsonString = '12345abc'; expect(isJsonString(jsonString)).toBe(false); }); }); describe('getParagraphContents', () => { - test('should return an object with keys for each paragraph tag', () => { + it('should return an object with keys for each paragraph tag', () => { const htmlString = '

First paragraph.

Second paragraph.

'; const result = getParagraphContents(htmlString); @@ -164,23 +164,23 @@ describe('getParagraphContents', () => { }); }); - test('should return null if the string is not HTML', () => { + it('should return null if the string is not HTML', () => { const nonHtmlString = 'Just a plain text string.'; expect(getParagraphContents(nonHtmlString)).toBeNull(); }); - test('should return null if there are no

tags in the HTML string', () => { + it('should return null if there are no

tags in the HTML string', () => { const htmlStringWithoutP = '

No paragraph here.
'; expect(getParagraphContents(htmlStringWithoutP)).toBeNull(); }); - test('should return an object with empty string for empty

tag', () => { + it('should return an object with empty string for empty

tag', () => { const htmlStringWithEmptyP = '

'; const result = getParagraphContents(htmlStringWithEmptyP); expect(result).toEqual({ p1: '' }); }); - test('should handle HTML strings with nested

tags correctly', () => { + it('should handle HTML strings with nested

tags correctly', () => { const htmlStringWithNestedP = '

First paragraph with nested content.

'; const result = getParagraphContents(htmlStringWithNestedP); diff --git a/superset-frontend/src/utils/rankedSearchCompare.test.ts b/superset-frontend/packages/superset-ui-core/src/utils/rankedSearchCompare.test.ts similarity index 100% rename from superset-frontend/src/utils/rankedSearchCompare.test.ts rename to superset-frontend/packages/superset-ui-core/src/utils/rankedSearchCompare.test.ts diff --git a/superset-frontend/src/utils/rankedSearchCompare.ts b/superset-frontend/packages/superset-ui-core/src/utils/rankedSearchCompare.ts similarity index 100% rename from superset-frontend/src/utils/rankedSearchCompare.ts rename to superset-frontend/packages/superset-ui-core/src/utils/rankedSearchCompare.ts diff --git a/superset-frontend/packages/superset-ui-core/test/chart-composition/ChartFrame.test.tsx b/superset-frontend/packages/superset-ui-core/test/chart-composition/ChartFrame.test.tsx index 4125bc0161e..bb4ccd12ee4 100644 --- a/superset-frontend/packages/superset-ui-core/test/chart-composition/ChartFrame.test.tsx +++ b/superset-frontend/packages/superset-ui-core/test/chart-composition/ChartFrame.test.tsx @@ -37,7 +37,7 @@ type Props = { const renderChartFrame = (props: Props) => render(); -it('renders content that requires smaller space than frame', () => { +test('renders content that requires smaller space than frame', () => { const { getByText } = renderChartFrame({ width: 400, height: 400, @@ -52,7 +52,7 @@ it('renders content that requires smaller space than frame', () => { expect(getByText('400/400')).toBeInTheDocument(); }); -it('renders content without specifying content size', () => { +test('renders content without specifying content size', () => { const { getByText } = renderChartFrame({ width: 400, height: 400, @@ -65,7 +65,7 @@ it('renders content without specifying content size', () => { expect(getByText('400/400')).toBeInTheDocument(); }); -it('renders content that requires equivalent size to frame', () => { +test('renders content that requires equivalent size to frame', () => { const { getByText } = renderChartFrame({ width: 400, height: 400, @@ -80,7 +80,7 @@ it('renders content that requires equivalent size to frame', () => { expect(getByText('400/400')).toBeInTheDocument(); }); -it('renders content that requires space larger than frame', () => { +test('renders content that requires space larger than frame', () => { const { getByText, container } = renderChartFrame({ width: 400, height: 400, @@ -97,7 +97,7 @@ it('renders content that requires space larger than frame', () => { expect(containerDiv).toHaveStyle({ overflowX: 'auto', overflowY: 'auto' }); }); -it('renders content when width is larger than frame', () => { +test('renders content when width is larger than frame', () => { const { getByText, container } = renderChartFrame({ width: 400, height: 400, @@ -113,7 +113,7 @@ it('renders content when width is larger than frame', () => { expect(containerDiv).toHaveStyle({ overflowX: 'auto', overflowY: 'hidden' }); }); -it('renders content when height is larger than frame', () => { +test('renders content when height is larger than frame', () => { const { getByText, container } = renderChartFrame({ width: 400, height: 400, diff --git a/superset-frontend/packages/superset-ui-core/test/components/SafeMarkdown.test.ts b/superset-frontend/packages/superset-ui-core/test/components/SafeMarkdown.test.ts index 4b4c826923b..93d3e4a2ecc 100644 --- a/superset-frontend/packages/superset-ui-core/test/components/SafeMarkdown.test.ts +++ b/superset-frontend/packages/superset-ui-core/test/components/SafeMarkdown.test.ts @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { getOverrideHtmlSchema } from '../../src/components/SafeMarkdown'; +import { getOverrideHtmlSchema } from '../../src/components/SafeMarkdown/SafeMarkdown'; describe('getOverrideHtmlSchema', () => { it('should append the override items', () => { diff --git a/superset-frontend/packages/superset-ui-core/test/currency-format/CurrencyFormatter.test.ts b/superset-frontend/packages/superset-ui-core/test/currency-format/CurrencyFormatter.test.ts index 5172e3b0ed3..b731b1ba498 100644 --- a/superset-frontend/packages/superset-ui-core/test/currency-format/CurrencyFormatter.test.ts +++ b/superset-frontend/packages/superset-ui-core/test/currency-format/CurrencyFormatter.test.ts @@ -23,7 +23,7 @@ import { NumberFormats, } from '@superset-ui/core'; -it('getCurrencySymbol', () => { +test('getCurrencySymbol', () => { expect( getCurrencySymbol({ symbol: 'PLN', symbolPosition: 'prefix' }), ).toEqual('PLN'); @@ -36,7 +36,7 @@ it('getCurrencySymbol', () => { ).toThrow(RangeError); }); -it('CurrencyFormatter object fields', () => { +test('CurrencyFormatter object fields', () => { const defaultCurrencyFormatter = new CurrencyFormatter({ currency: { symbol: 'USD', symbolPosition: 'prefix' }, }); @@ -60,7 +60,7 @@ it('CurrencyFormatter object fields', () => { }); }); -it('CurrencyFormatter:hasValidCurrency', () => { +test('CurrencyFormatter:hasValidCurrency', () => { const currencyFormatter = new CurrencyFormatter({ currency: { symbol: 'USD', symbolPosition: 'prefix' }, }); @@ -83,7 +83,7 @@ it('CurrencyFormatter:hasValidCurrency', () => { expect(currencyFormatterWithoutCurrency.hasValidCurrency()).toBe(false); }); -it('CurrencyFormatter:getNormalizedD3Format', () => { +test('CurrencyFormatter:getNormalizedD3Format', () => { const currencyFormatter = new CurrencyFormatter({ currency: { symbol: 'USD', symbolPosition: 'prefix' }, }); @@ -112,7 +112,7 @@ it('CurrencyFormatter:getNormalizedD3Format', () => { expect(currencyFormatter4.getNormalizedD3Format()).toEqual(',.1'); }); -it('CurrencyFormatter:format', () => { +test('CurrencyFormatter:format', () => { const VALUE = 56100057; const currencyFormatterWithPrefix = new CurrencyFormatter({ currency: { symbol: 'USD', symbolPosition: 'prefix' }, diff --git a/superset-frontend/packages/superset-ui-core/test/utils/featureFlag.test.ts b/superset-frontend/packages/superset-ui-core/test/utils/featureFlag.test.ts index 12a644c062a..b3c68f7e71d 100644 --- a/superset-frontend/packages/superset-ui-core/test/utils/featureFlag.test.ts +++ b/superset-frontend/packages/superset-ui-core/test/utils/featureFlag.test.ts @@ -18,7 +18,7 @@ */ import * as uiCore from '@superset-ui/core'; -it('initializes feature flags', () => { +test('initializes feature flags', () => { Object.defineProperty(window, 'featureFlags', { value: undefined, }); @@ -26,7 +26,7 @@ it('initializes feature flags', () => { expect(window.featureFlags).toEqual({}); }); -it('initializes feature flags with predefined values', () => { +test('initializes feature flags with predefined values', () => { Object.defineProperty(window, 'featureFlags', { value: undefined, }); @@ -37,7 +37,7 @@ it('initializes feature flags with predefined values', () => { expect(window.featureFlags).toEqual(featureFlags); }); -it('does nothing if feature flags are already initialized', () => { +test('does nothing if feature flags are already initialized', () => { const featureFlags = { DRILL_BY: false }; Object.defineProperty(window, 'featureFlags', { value: featureFlags, @@ -46,7 +46,7 @@ it('does nothing if feature flags are already initialized', () => { expect(window.featureFlags).toEqual(featureFlags); }); -it('returns false and raises console error if feature flags have not been initialized', () => { +test('returns false and raises console error if feature flags have not been initialized', () => { const logging = jest.spyOn(uiCore.logging, 'error'); Object.defineProperty(window, 'featureFlags', { value: undefined, @@ -56,14 +56,14 @@ it('returns false and raises console error if feature flags have not been initia expect(logging).toHaveBeenCalledWith('Failed to query feature flag DRILL_BY'); }); -it('returns false for unset feature flag', () => { +test('returns false for unset feature flag', () => { Object.defineProperty(window, 'featureFlags', { value: {}, }); expect(uiCore.isFeatureEnabled(uiCore.FeatureFlag.DrillBy)).toEqual(false); }); -it('returns true for set feature flag', () => { +test('returns true for set feature flag', () => { Object.defineProperty(window, 'featureFlags', { value: { DRILL_BY: true, diff --git a/superset-frontend/packages/superset-ui-core/tsconfig.json b/superset-frontend/packages/superset-ui-core/tsconfig.json index d345ae88fc0..4e39d068d5f 100644 --- a/superset-frontend/packages/superset-ui-core/tsconfig.json +++ b/superset-frontend/packages/superset-ui-core/tsconfig.json @@ -1,18 +1,24 @@ { + "extends": "../../tsconfig.base.json", "compilerOptions": { "declarationDir": "lib", "outDir": "lib", - "rootDir": "src" + "rootDir": "src", + "baseUrl": ".", + "paths": { + "src/*": ["./src/*"], + "@superset-ui/core": ["src"], + "@superset-ui/core/*": ["src/*"] + } }, "exclude": [ "lib", "test" ], - "extends": "../../tsconfig.json", "include": [ "src/**/*", - "types/**/*", - "../../types/**/*" + "spec/**/*", + "types/**/*" ], "references": [] } diff --git a/superset-frontend/src/types/ace-builds.d.ts b/superset-frontend/packages/superset-ui-core/types/ace-builds.d.ts similarity index 100% rename from superset-frontend/src/types/ace-builds.d.ts rename to superset-frontend/packages/superset-ui-core/types/ace-builds.d.ts diff --git a/superset-frontend/packages/superset-ui-core/types/assets.d.ts b/superset-frontend/packages/superset-ui-core/types/assets.d.ts new file mode 100644 index 00000000000..76f6dc1a771 --- /dev/null +++ b/superset-frontend/packages/superset-ui-core/types/assets.d.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. + */ +declare module '*.gif'; +declare module '*.svg'; +declare module '*.png'; diff --git a/superset-frontend/packages/superset-ui-core/types/brace.d.ts b/superset-frontend/packages/superset-ui-core/types/brace.d.ts new file mode 100644 index 00000000000..0b3770eebed --- /dev/null +++ b/superset-frontend/packages/superset-ui-core/types/brace.d.ts @@ -0,0 +1,29 @@ +/** + * 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. + */ +declare module 'brace/mode/sql'; +declare module 'brace/mode/markdown'; +declare module 'brace/mode/json'; +declare module 'brace/mode/css'; +declare module 'brace/mode/html'; +declare module 'brace/mode/yaml'; +declare module 'brace/mode/javascript'; +declare module 'brace/theme/textmate'; +declare module 'brace/theme/github'; +declare module 'brace/ext/language_tools'; +declare module 'brace/ext/searchbox'; diff --git a/superset-frontend/src/types/react-table-config.d.ts b/superset-frontend/packages/superset-ui-core/types/react-table-config.d.ts similarity index 100% rename from superset-frontend/src/types/react-table-config.d.ts rename to superset-frontend/packages/superset-ui-core/types/react-table-config.d.ts diff --git a/superset-frontend/packages/superset-ui-demo/package.json b/superset-frontend/packages/superset-ui-demo/package.json index 898ef2d900e..c099af9b7e5 100644 --- a/superset-frontend/packages/superset-ui-demo/package.json +++ b/superset-frontend/packages/superset-ui-demo/package.json @@ -63,7 +63,6 @@ "typescript": "^5.7.2" }, "peerDependencies": { - "antd": "^5.24.6", "@encodable/color": "=1.1.1", "@superset-ui/core": "*", "@superset-ui/legacy-plugin-chart-calendar": "*", diff --git a/superset-frontend/packages/superset-ui-demo/storybook/shared/components/VerifyCORS.tsx b/superset-frontend/packages/superset-ui-demo/storybook/shared/components/VerifyCORS.tsx index e3706afa78a..ca3b580730a 100644 --- a/superset-frontend/packages/superset-ui-demo/storybook/shared/components/VerifyCORS.tsx +++ b/superset-frontend/packages/superset-ui-demo/storybook/shared/components/VerifyCORS.tsx @@ -25,7 +25,7 @@ import { SupersetApiError, t, } from '@superset-ui/core'; -import { Button } from 'antd'; +import { Button } from '@superset-ui/core/components'; import ErrorMessage from './ErrorMessage'; export type Props = { diff --git a/superset-frontend/packages/superset-ui-demo/storybook/stories/ExampleApp.stories.jsx b/superset-frontend/packages/superset-ui-demo/storybook/stories/ExampleApp.stories.jsx index dc72528c554..85bdbbf9619 100644 --- a/superset-frontend/packages/superset-ui-demo/storybook/stories/ExampleApp.stories.jsx +++ b/superset-frontend/packages/superset-ui-demo/storybook/stories/ExampleApp.stories.jsx @@ -16,9 +16,18 @@ * specific language governing permissions and limitations * under the License. */ -import { Layout, Menu, Button, Card, Alert, Input, Table, Space } from 'antd'; +import { + Layout, + Menu, + Button, + Card, + Alert, + Input, + Table, + Space, +} from '@superset-ui/core/components'; // eslint-disable-next-line import/no-extraneous-dependencies -import { Icons } from 'src/components/Icons'; +import { Icons } from '@superset-ui/core/components/Icons'; const { Header, Content, Sider } = Layout; diff --git a/superset-frontend/plugins/legacy-plugin-chart-calendar/tsconfig.json b/superset-frontend/plugins/legacy-plugin-chart-calendar/tsconfig.json index b6bfaa2d984..b3af9a1d193 100644 --- a/superset-frontend/plugins/legacy-plugin-chart-calendar/tsconfig.json +++ b/superset-frontend/plugins/legacy-plugin-chart-calendar/tsconfig.json @@ -1,25 +1,15 @@ { + "extends": "../../tsconfig.base.json", "compilerOptions": { - "declarationDir": "lib", + "composite": true, + "rootDir": "src", "outDir": "lib", - "rootDir": "src" + "baseUrl": "." }, - "exclude": [ - "lib", - "test" - ], - "extends": "../../tsconfig.json", - "include": [ - "src/**/*", - "types/**/*", - "../../types/**/*" - ], + "include": ["src/**/*", "types/**/*"], + "exclude": ["lib", "test"], "references": [ - { - "path": "../../packages/superset-ui-chart-controls" - }, - { - "path": "../../packages/superset-ui-core" - } + { "path": "../../packages/superset-ui-core" }, + { "path": "../../packages/superset-ui-chart-controls" } ] } diff --git a/superset-frontend/plugins/legacy-plugin-chart-chord/tsconfig.json b/superset-frontend/plugins/legacy-plugin-chart-chord/tsconfig.json index b6bfaa2d984..b3af9a1d193 100644 --- a/superset-frontend/plugins/legacy-plugin-chart-chord/tsconfig.json +++ b/superset-frontend/plugins/legacy-plugin-chart-chord/tsconfig.json @@ -1,25 +1,15 @@ { + "extends": "../../tsconfig.base.json", "compilerOptions": { - "declarationDir": "lib", + "composite": true, + "rootDir": "src", "outDir": "lib", - "rootDir": "src" + "baseUrl": "." }, - "exclude": [ - "lib", - "test" - ], - "extends": "../../tsconfig.json", - "include": [ - "src/**/*", - "types/**/*", - "../../types/**/*" - ], + "include": ["src/**/*", "types/**/*"], + "exclude": ["lib", "test"], "references": [ - { - "path": "../../packages/superset-ui-chart-controls" - }, - { - "path": "../../packages/superset-ui-core" - } + { "path": "../../packages/superset-ui-core" }, + { "path": "../../packages/superset-ui-chart-controls" } ] } diff --git a/superset-frontend/plugins/legacy-plugin-chart-country-map/tsconfig.json b/superset-frontend/plugins/legacy-plugin-chart-country-map/tsconfig.json index b6bfaa2d984..b3af9a1d193 100644 --- a/superset-frontend/plugins/legacy-plugin-chart-country-map/tsconfig.json +++ b/superset-frontend/plugins/legacy-plugin-chart-country-map/tsconfig.json @@ -1,25 +1,15 @@ { + "extends": "../../tsconfig.base.json", "compilerOptions": { - "declarationDir": "lib", + "composite": true, + "rootDir": "src", "outDir": "lib", - "rootDir": "src" + "baseUrl": "." }, - "exclude": [ - "lib", - "test" - ], - "extends": "../../tsconfig.json", - "include": [ - "src/**/*", - "types/**/*", - "../../types/**/*" - ], + "include": ["src/**/*", "types/**/*"], + "exclude": ["lib", "test"], "references": [ - { - "path": "../../packages/superset-ui-chart-controls" - }, - { - "path": "../../packages/superset-ui-core" - } + { "path": "../../packages/superset-ui-core" }, + { "path": "../../packages/superset-ui-chart-controls" } ] } diff --git a/superset-frontend/plugins/legacy-plugin-chart-horizon/tsconfig.json b/superset-frontend/plugins/legacy-plugin-chart-horizon/tsconfig.json index b6bfaa2d984..b3af9a1d193 100644 --- a/superset-frontend/plugins/legacy-plugin-chart-horizon/tsconfig.json +++ b/superset-frontend/plugins/legacy-plugin-chart-horizon/tsconfig.json @@ -1,25 +1,15 @@ { + "extends": "../../tsconfig.base.json", "compilerOptions": { - "declarationDir": "lib", + "composite": true, + "rootDir": "src", "outDir": "lib", - "rootDir": "src" + "baseUrl": "." }, - "exclude": [ - "lib", - "test" - ], - "extends": "../../tsconfig.json", - "include": [ - "src/**/*", - "types/**/*", - "../../types/**/*" - ], + "include": ["src/**/*", "types/**/*"], + "exclude": ["lib", "test"], "references": [ - { - "path": "../../packages/superset-ui-chart-controls" - }, - { - "path": "../../packages/superset-ui-core" - } + { "path": "../../packages/superset-ui-core" }, + { "path": "../../packages/superset-ui-chart-controls" } ] } diff --git a/superset-frontend/plugins/legacy-plugin-chart-map-box/tsconfig.json b/superset-frontend/plugins/legacy-plugin-chart-map-box/tsconfig.json index b6bfaa2d984..b3af9a1d193 100644 --- a/superset-frontend/plugins/legacy-plugin-chart-map-box/tsconfig.json +++ b/superset-frontend/plugins/legacy-plugin-chart-map-box/tsconfig.json @@ -1,25 +1,15 @@ { + "extends": "../../tsconfig.base.json", "compilerOptions": { - "declarationDir": "lib", + "composite": true, + "rootDir": "src", "outDir": "lib", - "rootDir": "src" + "baseUrl": "." }, - "exclude": [ - "lib", - "test" - ], - "extends": "../../tsconfig.json", - "include": [ - "src/**/*", - "types/**/*", - "../../types/**/*" - ], + "include": ["src/**/*", "types/**/*"], + "exclude": ["lib", "test"], "references": [ - { - "path": "../../packages/superset-ui-chart-controls" - }, - { - "path": "../../packages/superset-ui-core" - } + { "path": "../../packages/superset-ui-core" }, + { "path": "../../packages/superset-ui-chart-controls" } ] } diff --git a/superset-frontend/plugins/legacy-plugin-chart-paired-t-test/tsconfig.json b/superset-frontend/plugins/legacy-plugin-chart-paired-t-test/tsconfig.json index b6bfaa2d984..b3af9a1d193 100644 --- a/superset-frontend/plugins/legacy-plugin-chart-paired-t-test/tsconfig.json +++ b/superset-frontend/plugins/legacy-plugin-chart-paired-t-test/tsconfig.json @@ -1,25 +1,15 @@ { + "extends": "../../tsconfig.base.json", "compilerOptions": { - "declarationDir": "lib", + "composite": true, + "rootDir": "src", "outDir": "lib", - "rootDir": "src" + "baseUrl": "." }, - "exclude": [ - "lib", - "test" - ], - "extends": "../../tsconfig.json", - "include": [ - "src/**/*", - "types/**/*", - "../../types/**/*" - ], + "include": ["src/**/*", "types/**/*"], + "exclude": ["lib", "test"], "references": [ - { - "path": "../../packages/superset-ui-chart-controls" - }, - { - "path": "../../packages/superset-ui-core" - } + { "path": "../../packages/superset-ui-core" }, + { "path": "../../packages/superset-ui-chart-controls" } ] } diff --git a/superset-frontend/plugins/legacy-plugin-chart-parallel-coordinates/package.json b/superset-frontend/plugins/legacy-plugin-chart-parallel-coordinates/package.json index e9b5f45eb99..4101769139d 100644 --- a/superset-frontend/plugins/legacy-plugin-chart-parallel-coordinates/package.json +++ b/superset-frontend/plugins/legacy-plugin-chart-parallel-coordinates/package.json @@ -29,7 +29,7 @@ "access": "public" }, "dependencies": { - "d3": "^3.5.17", + "d3v3": "npm:d3@3.5.17", "prop-types": "^15.8.1" }, "peerDependencies": { diff --git a/superset-frontend/plugins/legacy-plugin-chart-parallel-coordinates/src/ParallelCoordinates.js b/superset-frontend/plugins/legacy-plugin-chart-parallel-coordinates/src/ParallelCoordinates.js index 0529c86aff1..c2970979eb7 100644 --- a/superset-frontend/plugins/legacy-plugin-chart-parallel-coordinates/src/ParallelCoordinates.js +++ b/superset-frontend/plugins/legacy-plugin-chart-parallel-coordinates/src/ParallelCoordinates.js @@ -17,7 +17,7 @@ * under the License. */ /* eslint-disable react/sort-prop-types */ -import d3 from 'd3'; +import * as d3 from 'd3v3'; import PropTypes from 'prop-types'; import { getSequentialSchemeRegistry } from '@superset-ui/core'; diff --git a/superset-frontend/plugins/legacy-plugin-chart-parallel-coordinates/tsconfig.json b/superset-frontend/plugins/legacy-plugin-chart-parallel-coordinates/tsconfig.json index 7e74154150e..e7088b6c760 100644 --- a/superset-frontend/plugins/legacy-plugin-chart-parallel-coordinates/tsconfig.json +++ b/superset-frontend/plugins/legacy-plugin-chart-parallel-coordinates/tsconfig.json @@ -1,26 +1,20 @@ { + "extends": "../../tsconfig.base.json", "compilerOptions": { - "declarationDir": "lib", - "outDir": "lib", + "composite": true, "rootDir": "src", - "allowJs": false - }, - "exclude": [ - "lib", - "test" - ], - "extends": "../../tsconfig.json", - "include": [ - "src/**/*", - "types/**/*", - "../../types/**/*" - ], - "references": [ - { - "path": "../../packages/superset-ui-chart-controls" - }, - { - "path": "../../packages/superset-ui-core" + "outDir": "lib", + "baseUrl": ".", + "paths": { + "d3v3": ["./types/d3v3"] } + + + }, + "include": ["src/**/*", "types/**/*"], + "exclude": ["lib", "test"], + "references": [ + { "path": "../../packages/superset-ui-core" }, + { "path": "../../packages/superset-ui-chart-controls" } ] } diff --git a/superset-frontend/plugins/legacy-plugin-chart-parallel-coordinates/types/d3-parcoords.d.ts b/superset-frontend/plugins/legacy-plugin-chart-parallel-coordinates/types/d3-parcoords.d.ts new file mode 100644 index 00000000000..e8026f2e2ac --- /dev/null +++ b/superset-frontend/plugins/legacy-plugin-chart-parallel-coordinates/types/d3-parcoords.d.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. + */ +declare module 'src/vendor/parcoords/d3.parcoords' { + const parcoords: any; + export default parcoords; +} diff --git a/superset-frontend/plugins/legacy-plugin-chart-parallel-coordinates/types/d3.d.ts b/superset-frontend/plugins/legacy-plugin-chart-parallel-coordinates/types/d3.d.ts new file mode 100644 index 00000000000..34a150e873e --- /dev/null +++ b/superset-frontend/plugins/legacy-plugin-chart-parallel-coordinates/types/d3.d.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. + */ +declare module 'd3' { + const d3: any; + export = d3; +} diff --git a/superset-frontend/plugins/legacy-plugin-chart-partition/src/OptionDescription.tsx b/superset-frontend/plugins/legacy-plugin-chart-partition/src/OptionDescription.tsx index e349e61132a..4b5a68c3028 100644 --- a/superset-frontend/plugins/legacy-plugin-chart-partition/src/OptionDescription.tsx +++ b/superset-frontend/plugins/legacy-plugin-chart-partition/src/OptionDescription.tsx @@ -19,10 +19,8 @@ import PropTypes from 'prop-types'; -import { - ColumnMeta, - InfoTooltipWithTrigger, -} from '@superset-ui/chart-controls'; +import { ColumnMeta } from '@superset-ui/chart-controls'; +import { InfoTooltip } from '@superset-ui/core/components'; const propTypes = { option: PropTypes.object.isRequired, @@ -38,7 +36,7 @@ export default function OptionDescription({ option }: { option: ColumnMeta }) { {option.label} {option.description && ( - { ); }); - it('renders an InfoTooltipWithTrigger', () => { + it('renders an InfoTooltip', () => { const tooltipTrigger = screen.getByLabelText('Show info tooltip'); expect(tooltipTrigger).toBeInTheDocument(); diff --git a/superset-frontend/plugins/legacy-plugin-chart-partition/tsconfig.json b/superset-frontend/plugins/legacy-plugin-chart-partition/tsconfig.json index b6bfaa2d984..b5b28fc6189 100644 --- a/superset-frontend/plugins/legacy-plugin-chart-partition/tsconfig.json +++ b/superset-frontend/plugins/legacy-plugin-chart-partition/tsconfig.json @@ -1,25 +1,18 @@ { + "extends": "../../tsconfig.base.json", "compilerOptions": { - "declarationDir": "lib", + "composite": true, + "rootDir": "src", "outDir": "lib", - "rootDir": "src" - }, - "exclude": [ - "lib", - "test" - ], - "extends": "../../tsconfig.json", - "include": [ - "src/**/*", - "types/**/*", - "../../types/**/*" - ], - "references": [ - { - "path": "../../packages/superset-ui-chart-controls" - }, - { - "path": "../../packages/superset-ui-core" + "baseUrl": ".", + "paths": { + "@superset-ui/core/components": ["../../packages/superset-ui-core/src/components"] } + }, + "include": ["src/**/*", "types/**/*"], + "exclude": ["lib", "test"], + "references": [ + { "path": "../../packages/superset-ui-core" }, + { "path": "../../packages/superset-ui-chart-controls" } ] } diff --git a/superset-frontend/plugins/legacy-plugin-chart-rose/tsconfig.json b/superset-frontend/plugins/legacy-plugin-chart-rose/tsconfig.json index b6bfaa2d984..b3af9a1d193 100644 --- a/superset-frontend/plugins/legacy-plugin-chart-rose/tsconfig.json +++ b/superset-frontend/plugins/legacy-plugin-chart-rose/tsconfig.json @@ -1,25 +1,15 @@ { + "extends": "../../tsconfig.base.json", "compilerOptions": { - "declarationDir": "lib", + "composite": true, + "rootDir": "src", "outDir": "lib", - "rootDir": "src" + "baseUrl": "." }, - "exclude": [ - "lib", - "test" - ], - "extends": "../../tsconfig.json", - "include": [ - "src/**/*", - "types/**/*", - "../../types/**/*" - ], + "include": ["src/**/*", "types/**/*"], + "exclude": ["lib", "test"], "references": [ - { - "path": "../../packages/superset-ui-chart-controls" - }, - { - "path": "../../packages/superset-ui-core" - } + { "path": "../../packages/superset-ui-core" }, + { "path": "../../packages/superset-ui-chart-controls" } ] } diff --git a/superset-frontend/plugins/legacy-plugin-chart-world-map/tsconfig.json b/superset-frontend/plugins/legacy-plugin-chart-world-map/tsconfig.json index b6bfaa2d984..b3af9a1d193 100644 --- a/superset-frontend/plugins/legacy-plugin-chart-world-map/tsconfig.json +++ b/superset-frontend/plugins/legacy-plugin-chart-world-map/tsconfig.json @@ -1,25 +1,15 @@ { + "extends": "../../tsconfig.base.json", "compilerOptions": { - "declarationDir": "lib", + "composite": true, + "rootDir": "src", "outDir": "lib", - "rootDir": "src" + "baseUrl": "." }, - "exclude": [ - "lib", - "test" - ], - "extends": "../../tsconfig.json", - "include": [ - "src/**/*", - "types/**/*", - "../../types/**/*" - ], + "include": ["src/**/*", "types/**/*"], + "exclude": ["lib", "test"], "references": [ - { - "path": "../../packages/superset-ui-chart-controls" - }, - { - "path": "../../packages/superset-ui-core" - } + { "path": "../../packages/superset-ui-core" }, + { "path": "../../packages/superset-ui-chart-controls" } ] } diff --git a/superset-frontend/plugins/legacy-preset-chart-deckgl/tsconfig.json b/superset-frontend/plugins/legacy-preset-chart-deckgl/tsconfig.json index 3e1b196c648..b3af9a1d193 100644 --- a/superset-frontend/plugins/legacy-preset-chart-deckgl/tsconfig.json +++ b/superset-frontend/plugins/legacy-preset-chart-deckgl/tsconfig.json @@ -1,26 +1,15 @@ { + "extends": "../../tsconfig.base.json", "compilerOptions": { - "declarationDir": "lib", + "composite": true, + "rootDir": "src", "outDir": "lib", - "rootDir": "src" + "baseUrl": "." }, - "exclude": [ - "lib", - "test" - ], - "extends": "../../tsconfig.json", - "include": [ - "src/**/*", - "types/**/*", - "test/**/*", - "../../types/**/*" - ], + "include": ["src/**/*", "types/**/*"], + "exclude": ["lib", "test"], "references": [ - { - "path": "../../packages/superset-ui-chart-controls" - }, - { - "path": "../../packages/superset-ui-core" - } + { "path": "../../packages/superset-ui-core" }, + { "path": "../../packages/superset-ui-chart-controls" } ] } diff --git a/superset-frontend/plugins/legacy-preset-chart-nvd3/tsconfig.json b/superset-frontend/plugins/legacy-preset-chart-nvd3/tsconfig.json index b6bfaa2d984..b3af9a1d193 100644 --- a/superset-frontend/plugins/legacy-preset-chart-nvd3/tsconfig.json +++ b/superset-frontend/plugins/legacy-preset-chart-nvd3/tsconfig.json @@ -1,25 +1,15 @@ { + "extends": "../../tsconfig.base.json", "compilerOptions": { - "declarationDir": "lib", + "composite": true, + "rootDir": "src", "outDir": "lib", - "rootDir": "src" + "baseUrl": "." }, - "exclude": [ - "lib", - "test" - ], - "extends": "../../tsconfig.json", - "include": [ - "src/**/*", - "types/**/*", - "../../types/**/*" - ], + "include": ["src/**/*", "types/**/*"], + "exclude": ["lib", "test"], "references": [ - { - "path": "../../packages/superset-ui-chart-controls" - }, - { - "path": "../../packages/superset-ui-core" - } + { "path": "../../packages/superset-ui-core" }, + { "path": "../../packages/superset-ui-chart-controls" } ] } diff --git a/superset-frontend/plugins/plugin-chart-cartodiagram/tsconfig.json b/superset-frontend/plugins/plugin-chart-cartodiagram/tsconfig.json index 019b367ef9e..b3af9a1d193 100644 --- a/superset-frontend/plugins/plugin-chart-cartodiagram/tsconfig.json +++ b/superset-frontend/plugins/plugin-chart-cartodiagram/tsconfig.json @@ -1,25 +1,15 @@ { + "extends": "../../tsconfig.base.json", "compilerOptions": { - "declarationDir": "lib", + "composite": true, + "rootDir": "src", "outDir": "lib", - "rootDir": "src" + "baseUrl": "." }, - "exclude": [ - "lib", - "test" - ], - "extends": "../../tsconfig.json", - "include": [ - "src/**/*", - "types/**/*", - "../../types/**/*" - ], + "include": ["src/**/*", "types/**/*"], + "exclude": ["lib", "test"], "references": [ - { - "path": "../../packages/superset-ui-chart-controls" - }, - { - "path": "../../packages/superset-ui-core" - }, + { "path": "../../packages/superset-ui-core" }, + { "path": "../../packages/superset-ui-chart-controls" } ] } diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Step/index.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Step/index.ts index fcdbc52468b..99d2c57101a 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Step/index.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Step/index.ts @@ -17,10 +17,7 @@ * under the License. */ import { AnnotationType, Behavior, t } from '@superset-ui/core'; -import { - EchartsTimeseriesChartProps, - EchartsTimeseriesFormData, -} from '@superset-ui/plugin-chart-echarts'; +import { EchartsTimeseriesChartProps, EchartsTimeseriesFormData } from '../..'; import buildQuery from '../buildQuery'; import controlPanel from './controlPanel'; import transformProps from '../transformProps'; diff --git a/superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/transformProps.test.ts b/superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/transformProps.test.ts index c3a476bce0d..9a24c990c9a 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/transformProps.test.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/transformProps.test.ts @@ -21,7 +21,7 @@ import { LegendOrientation, LegendType, EchartsTimeseriesSeriesType, -} from '@superset-ui/plugin-chart-echarts'; +} from '../../src'; import transformProps from '../../src/MixedTimeseries/transformProps'; import { EchartsMixedTimeseriesFormData, diff --git a/superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformers.test.ts b/superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformers.test.ts index d138ed0c5dc..a0b3d5ad7d2 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformers.test.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformers.test.ts @@ -17,7 +17,7 @@ * under the License. */ import { CategoricalColorScale } from '@superset-ui/core'; -import { EchartsTimeseriesSeriesType } from '@superset-ui/plugin-chart-echarts'; +import { EchartsTimeseriesSeriesType } from '../../src'; import { transformSeries } from '../../src/Timeseries/transformers'; // Mock the colorScale function diff --git a/superset-frontend/plugins/plugin-chart-echarts/test/utils/transformers.test.ts b/superset-frontend/plugins/plugin-chart-echarts/test/utils/transformers.test.ts index 113b416f9c5..277911e3b83 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/test/utils/transformers.test.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/test/utils/transformers.test.ts @@ -31,7 +31,7 @@ import { TimeseriesAnnotationLayer, TimeseriesDataRecord, } from '@superset-ui/core'; -import { OrientationType } from '@superset-ui/plugin-chart-echarts'; +import { OrientationType } from '../../src'; import { transformEventAnnotation, transformFormulaAnnotation, diff --git a/superset-frontend/plugins/plugin-chart-echarts/tsconfig.json b/superset-frontend/plugins/plugin-chart-echarts/tsconfig.json index b6bfaa2d984..b3af9a1d193 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/tsconfig.json +++ b/superset-frontend/plugins/plugin-chart-echarts/tsconfig.json @@ -1,25 +1,15 @@ { + "extends": "../../tsconfig.base.json", "compilerOptions": { - "declarationDir": "lib", + "composite": true, + "rootDir": "src", "outDir": "lib", - "rootDir": "src" + "baseUrl": "." }, - "exclude": [ - "lib", - "test" - ], - "extends": "../../tsconfig.json", - "include": [ - "src/**/*", - "types/**/*", - "../../types/**/*" - ], + "include": ["src/**/*", "types/**/*"], + "exclude": ["lib", "test"], "references": [ - { - "path": "../../packages/superset-ui-chart-controls" - }, - { - "path": "../../packages/superset-ui-core" - } + { "path": "../../packages/superset-ui-core" }, + { "path": "../../packages/superset-ui-chart-controls" } ] } diff --git a/superset-frontend/plugins/plugin-chart-handlebars/src/components/Handlebars/HandlebarsViewer.tsx b/superset-frontend/plugins/plugin-chart-handlebars/src/components/Handlebars/HandlebarsViewer.tsx index 8e1a1aab9d4..701d8949b67 100644 --- a/superset-frontend/plugins/plugin-chart-handlebars/src/components/Handlebars/HandlebarsViewer.tsx +++ b/superset-frontend/plugins/plugin-chart-handlebars/src/components/Handlebars/HandlebarsViewer.tsx @@ -16,7 +16,8 @@ * specific language governing permissions and limitations * under the License. */ -import { SafeMarkdown, styled, t } from '@superset-ui/core'; +import { styled, t } from '@superset-ui/core'; +import { SafeMarkdown } from '@superset-ui/core/components'; import Handlebars from 'handlebars'; import dayjs from 'dayjs'; import { useMemo, useState } from 'react'; diff --git a/superset-frontend/plugins/plugin-chart-handlebars/src/consts.ts b/superset-frontend/plugins/plugin-chart-handlebars/src/consts.ts index e566fd66b27..f474eb67b34 100644 --- a/superset-frontend/plugins/plugin-chart-handlebars/src/consts.ts +++ b/superset-frontend/plugins/plugin-chart-handlebars/src/consts.ts @@ -18,7 +18,8 @@ */ import { debounce } from 'lodash'; import { formatSelectOptions } from '@superset-ui/chart-controls'; -import { SLOW_DEBOUNCE, t } from '@superset-ui/core'; +import { Constants } from '@superset-ui/core/components'; +import { t } from '@superset-ui/core'; export const PAGE_SIZE_OPTIONS = formatSelectOptions([ [0, t('page_size.all')], @@ -36,5 +37,5 @@ export const PAGE_SIZE_OPTIONS = formatSelectOptions([ export const debounceFunc = debounce( (func: (val: string) => void, source: string) => func(source), - SLOW_DEBOUNCE, + Constants.SLOW_DEBOUNCE, ); diff --git a/superset-frontend/plugins/plugin-chart-handlebars/src/plugin/controls/handlebarTemplate.tsx b/superset-frontend/plugins/plugin-chart-handlebars/src/plugin/controls/handlebarTemplate.tsx index a15b8936231..e09f7f5aba9 100644 --- a/superset-frontend/plugins/plugin-chart-handlebars/src/plugin/controls/handlebarTemplate.tsx +++ b/superset-frontend/plugins/plugin-chart-handlebars/src/plugin/controls/handlebarTemplate.tsx @@ -20,9 +20,9 @@ import { ControlSetItem, CustomControlConfig, sharedControls, - InfoTooltipWithTrigger, } from '@superset-ui/chart-controls'; -import { t, validateNonEmpty, useTheme, SafeMarkdown } from '@superset-ui/core'; +import { t, validateNonEmpty, useTheme } from '@superset-ui/core'; +import { InfoTooltip, SafeMarkdown } from '@superset-ui/core/components'; import { CodeEditor } from '../../components/CodeEditor/CodeEditor'; import { ControlHeader } from '../../components/ControlHeader/controlHeader'; import { debounceFunc } from '../../consts'; @@ -70,7 +70,7 @@ ${helperDescriptions
{props.label} - } /> diff --git a/superset-frontend/plugins/plugin-chart-handlebars/src/plugin/controls/style.tsx b/superset-frontend/plugins/plugin-chart-handlebars/src/plugin/controls/style.tsx index 09aee379db5..b69b2ea0424 100644 --- a/superset-frontend/plugins/plugin-chart-handlebars/src/plugin/controls/style.tsx +++ b/superset-frontend/plugins/plugin-chart-handlebars/src/plugin/controls/style.tsx @@ -20,9 +20,9 @@ import { ControlSetItem, CustomControlConfig, sharedControls, - InfoTooltipWithTrigger, } from '@superset-ui/chart-controls'; import { t, useTheme } from '@superset-ui/core'; +import { InfoTooltip } from '@superset-ui/core/components'; import { CodeEditor } from '../../components/CodeEditor/CodeEditor'; import { ControlHeader } from '../../components/ControlHeader/controlHeader'; import { debounceFunc } from '../../consts'; @@ -47,7 +47,7 @@ const StyleControl = (props: CustomControlConfig) => {
{props.label} - diff --git a/superset-frontend/plugins/plugin-chart-handlebars/tsconfig.json b/superset-frontend/plugins/plugin-chart-handlebars/tsconfig.json index b6bfaa2d984..b5b28fc6189 100644 --- a/superset-frontend/plugins/plugin-chart-handlebars/tsconfig.json +++ b/superset-frontend/plugins/plugin-chart-handlebars/tsconfig.json @@ -1,25 +1,18 @@ { + "extends": "../../tsconfig.base.json", "compilerOptions": { - "declarationDir": "lib", + "composite": true, + "rootDir": "src", "outDir": "lib", - "rootDir": "src" - }, - "exclude": [ - "lib", - "test" - ], - "extends": "../../tsconfig.json", - "include": [ - "src/**/*", - "types/**/*", - "../../types/**/*" - ], - "references": [ - { - "path": "../../packages/superset-ui-chart-controls" - }, - { - "path": "../../packages/superset-ui-core" + "baseUrl": ".", + "paths": { + "@superset-ui/core/components": ["../../packages/superset-ui-core/src/components"] } + }, + "include": ["src/**/*", "types/**/*"], + "exclude": ["lib", "test"], + "references": [ + { "path": "../../packages/superset-ui-core" }, + { "path": "../../packages/superset-ui-chart-controls" } ] } diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/tsconfig.json b/superset-frontend/plugins/plugin-chart-pivot-table/tsconfig.json index b6bfaa2d984..b3af9a1d193 100644 --- a/superset-frontend/plugins/plugin-chart-pivot-table/tsconfig.json +++ b/superset-frontend/plugins/plugin-chart-pivot-table/tsconfig.json @@ -1,25 +1,15 @@ { + "extends": "../../tsconfig.base.json", "compilerOptions": { - "declarationDir": "lib", + "composite": true, + "rootDir": "src", "outDir": "lib", - "rootDir": "src" + "baseUrl": "." }, - "exclude": [ - "lib", - "test" - ], - "extends": "../../tsconfig.json", - "include": [ - "src/**/*", - "types/**/*", - "../../types/**/*" - ], + "include": ["src/**/*", "types/**/*"], + "exclude": ["lib", "test"], "references": [ - { - "path": "../../packages/superset-ui-chart-controls" - }, - { - "path": "../../packages/superset-ui-core" - } + { "path": "../../packages/superset-ui-core" }, + { "path": "../../packages/superset-ui-chart-controls" } ] } diff --git a/superset-frontend/plugins/plugin-chart-table/package.json b/superset-frontend/plugins/plugin-chart-table/package.json index fac61d3205c..4abf7dacfe7 100644 --- a/superset-frontend/plugins/plugin-chart-table/package.json +++ b/superset-frontend/plugins/plugin-chart-table/package.json @@ -37,7 +37,6 @@ }, "peerDependencies": { "@ant-design/icons": "^5.2.6", - "antd": "^5.24.6", "@superset-ui/chart-controls": "*", "@superset-ui/core": "*", "@testing-library/dom": "^8.20.1", diff --git a/superset-frontend/plugins/plugin-chart-table/src/DataTable/DataTable.tsx b/superset-frontend/plugins/plugin-chart-table/src/DataTable/DataTable.tsx index d03bba53124..ee7b07174c0 100644 --- a/superset-frontend/plugins/plugin-chart-table/src/DataTable/DataTable.tsx +++ b/superset-frontend/plugins/plugin-chart-table/src/DataTable/DataTable.tsx @@ -42,7 +42,7 @@ import { } from 'react-table'; import { matchSorter, rankings } from 'match-sorter'; import { isEqual } from 'lodash'; -import { Space } from 'antd'; +import { Space } from '@superset-ui/core/components'; import GlobalFilter, { GlobalFilterProps } from './components/GlobalFilter'; import SelectPageSize, { SelectPageSizeProps, diff --git a/superset-frontend/plugins/plugin-chart-table/src/DataTable/components/GlobalFilter.tsx b/superset-frontend/plugins/plugin-chart-table/src/DataTable/components/GlobalFilter.tsx index b1ff46eee73..ef9b8fc8bd8 100644 --- a/superset-frontend/plugins/plugin-chart-table/src/DataTable/components/GlobalFilter.tsx +++ b/superset-frontend/plugins/plugin-chart-table/src/DataTable/components/GlobalFilter.tsx @@ -25,7 +25,7 @@ import { Ref, } from 'react'; import { Row, FilterValue } from 'react-table'; -import { Input, type InputRef, Space } from 'antd'; +import { Input, type InputRef, Space } from '@superset-ui/core/components'; import useAsyncState from '../utils/useAsyncState'; export interface SearchInputProps { diff --git a/superset-frontend/plugins/plugin-chart-table/src/DataTable/components/SearchSelectDropdown.tsx b/superset-frontend/plugins/plugin-chart-table/src/DataTable/components/SearchSelectDropdown.tsx index 5a1cc6b6e16..d4cc33e6181 100644 --- a/superset-frontend/plugins/plugin-chart-table/src/DataTable/components/SearchSelectDropdown.tsx +++ b/superset-frontend/plugins/plugin-chart-table/src/DataTable/components/SearchSelectDropdown.tsx @@ -18,10 +18,10 @@ */ /* eslint-disable import/no-extraneous-dependencies */ import { styled } from '@superset-ui/core'; -import { Select } from 'antd'; +import { RawAntdSelect } from '@superset-ui/core/components'; import { SearchOption } from '../../types'; -const StyledSelect = styled(Select)` +const StyledSelect = styled(RawAntdSelect)` width: 120px; margin-right: 8px; `; diff --git a/superset-frontend/plugins/plugin-chart-table/src/DataTable/components/SelectPageSize.tsx b/superset-frontend/plugins/plugin-chart-table/src/DataTable/components/SelectPageSize.tsx index f62caefae68..a3323c2e205 100644 --- a/superset-frontend/plugins/plugin-chart-table/src/DataTable/components/SelectPageSize.tsx +++ b/superset-frontend/plugins/plugin-chart-table/src/DataTable/components/SelectPageSize.tsx @@ -19,7 +19,7 @@ import { memo } from 'react'; import { css, t } from '@superset-ui/core'; import { formatSelectOptions } from '@superset-ui/chart-controls'; -import { Select } from 'antd'; +import { RawAntdSelect } from '@superset-ui/core/components'; export type SizeOption = [number, string]; @@ -34,12 +34,12 @@ function DefaultSelectRenderer({ options, onChange, }: SelectPageSizeRendererProps) { - const { Option } = Select; + const { Option } = RawAntdSelect; return ( {t('Show')}{' '} - + value={current} onChange={value => onChange(value)} size="small" @@ -62,7 +62,7 @@ function DefaultSelectRenderer({ ); })} - {' '} + {' '} {t('entries')} ); diff --git a/superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx b/superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx index b06d51d7e0f..76b331c93c6 100644 --- a/superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx +++ b/superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx @@ -54,7 +54,14 @@ import { useTheme, SupersetTheme, } from '@superset-ui/core'; -import { Dropdown, Menu, Tooltip } from '@superset-ui/chart-controls'; +import { + Input, + Space, + RawAntdSelect as Select, + Dropdown, + Menu, + Tooltip, +} from '@superset-ui/core/components'; import { CheckOutlined, InfoCircleOutlined, @@ -64,7 +71,6 @@ import { TableOutlined, } from '@ant-design/icons'; import { isEmpty, debounce, isEqual } from 'lodash'; -import { Input, Space, Select } from 'antd'; import { ColorSchemeEnum, DataColumnMeta, diff --git a/superset-frontend/plugins/plugin-chart-table/src/buildQuery.ts b/superset-frontend/plugins/plugin-chart-table/src/buildQuery.ts index 439df369f5a..0e892567f42 100644 --- a/superset-frontend/plugins/plugin-chart-table/src/buildQuery.ts +++ b/superset-frontend/plugins/plugin-chart-table/src/buildQuery.ts @@ -18,17 +18,18 @@ */ import { AdhocColumn, + BuildQuery, + PostProcessingRule, + QueryFormOrderBy, + QueryMode, + QueryObject, buildQueryContext, ensureIsArray, getMetricLabel, isPhysicalColumn, - QueryFormOrderBy, - QueryMode, - QueryObject, removeDuplicates, } from '@superset-ui/core'; -import { PostProcessingRule } from '@superset-ui/core/src/query/types/PostProcessing'; -import { BuildQuery } from '@superset-ui/core/src/chart/registries/ChartBuildQueryRegistrySingleton'; + import { isTimeComparison, timeCompareOperator, diff --git a/superset-frontend/plugins/plugin-chart-table/test/TableChart.test.tsx b/superset-frontend/plugins/plugin-chart-table/test/TableChart.test.tsx index 6cc791aff40..bfb3ca4df90 100644 --- a/superset-frontend/plugins/plugin-chart-table/test/TableChart.test.tsx +++ b/superset-frontend/plugins/plugin-chart-table/test/TableChart.test.tsx @@ -17,7 +17,7 @@ * under the License. */ import '@testing-library/jest-dom'; -import { render, screen } from '@testing-library/react'; +import { render, screen } from '@superset-ui/core/spec'; import { ThemeProvider, supersetTheme } from '@superset-ui/core'; import TableChart from '../src/TableChart'; import transformProps from '../src/transformProps'; diff --git a/superset-frontend/plugins/plugin-chart-table/tsconfig.json b/superset-frontend/plugins/plugin-chart-table/tsconfig.json index f60297e2489..b5b28fc6189 100644 --- a/superset-frontend/plugins/plugin-chart-table/tsconfig.json +++ b/superset-frontend/plugins/plugin-chart-table/tsconfig.json @@ -1,18 +1,18 @@ { + "extends": "../../tsconfig.base.json", "compilerOptions": { - "declarationDir": "lib", + "composite": true, + "rootDir": "src", "outDir": "lib", - "rootDir": "src" - }, - "exclude": ["lib", "test"], - "extends": "../../tsconfig.json", - "include": ["src/**/*", "types/**/*", "../../types/**/*"], - "references": [ - { - "path": "../../packages/superset-ui-chart-controls" - }, - { - "path": "../../packages/superset-ui-core" + "baseUrl": ".", + "paths": { + "@superset-ui/core/components": ["../../packages/superset-ui-core/src/components"] } + }, + "include": ["src/**/*", "types/**/*"], + "exclude": ["lib", "test"], + "references": [ + { "path": "../../packages/superset-ui-core" }, + { "path": "../../packages/superset-ui-chart-controls" } ] } diff --git a/superset-frontend/plugins/plugin-chart-word-cloud/src/chart/WordCloud.tsx b/superset-frontend/plugins/plugin-chart-word-cloud/src/chart/WordCloud.tsx index 7dc5d4604b0..d634e06a594 100644 --- a/superset-frontend/plugins/plugin-chart-word-cloud/src/chart/WordCloud.tsx +++ b/superset-frontend/plugins/plugin-chart-word-cloud/src/chart/WordCloud.tsx @@ -16,9 +16,8 @@ * specific language governing permissions and limitations * under the License. */ - import { PureComponent } from 'react'; -import cloudLayout, { Word } from 'd3-cloud'; +import cloudLayout from 'd3-cloud'; import { PlainObject, createEncoderFactory, @@ -34,9 +33,20 @@ import { import { isEqual } from 'lodash'; const seedRandom = seed('superset-ui'); + +// Polyfill Word type since it's not exported from 'd3-cloud' +export type Word = { + text: string; + size: number; + x?: number; + y?: number; + rotate?: number; + font?: string; + weight?: string | number; +}; + export const ROTATION = { flat: () => 0, - // this calculates a random rotation between -90 and 90 degrees. random: () => Math.floor(seedRandom() * 6 - 3) * 30, square: () => Math.floor(seedRandom() * 2) * 90, }; @@ -53,9 +63,6 @@ type WordCloudEncodingConfig = { text: ['Text', string]; }; -/** - * These props should be stored when saving the chart. - */ export interface WordCloudVisualProps { encoding?: Partial; rotation?: RotationType; @@ -84,15 +91,10 @@ type FullWordCloudProps = WordCloudProps & const SCALE_FACTOR_STEP = 0.5; const MAX_SCALE_FACTOR = 3; -// Percentage of top results that will always be displayed. -// Needed to avoid clutter when shrinking a chart with many records. const TOP_RESULTS_PERCENTAGE = 0.1; - class WordCloud extends PureComponent { static defaultProps = defaultProps; - // Cannot name it isMounted because of conflict - // with React's component function name isComponentMounted = false; wordCloudEncoderFactory = createEncoderFactory({ @@ -112,11 +114,15 @@ class WordCloud extends PureComponent { }, }); - createEncoder = (encoding?: Partial) => { - const selector = this.wordCloudEncoderFactory.createSelector(); + createEncoder = ( + encoding?: Partial, + ): Encoder => { + const selector: ( + e: Partial, + ) => Encoder = + this.wordCloudEncoderFactory.createSelector(); - // @ts-ignore - return selector(encoding as any); + return selector(encoding ?? {}); }; constructor(props: FullWordCloudProps) { @@ -135,7 +141,6 @@ class WordCloud extends PureComponent { componentDidUpdate(prevProps: WordCloudProps) { const { data, encoding, width, height, rotation } = this.props; - if ( !isEqual(prevProps.data, data) || !isEqual(prevProps.encoding, encoding) || @@ -160,8 +165,7 @@ class WordCloud extends PureComponent { update() { const { data, encoding } = this.props; - const encoder: Encoder = - this.createEncoder(encoding); + const encoder = this.createEncoder(encoding); encoder.setDomainFromDataset(data); const sortedData = [...data].sort( @@ -175,7 +179,6 @@ class WordCloud extends PureComponent { ); const topResults = sortedData.slice(0, topResultsCount); - // Ensure top results are always included in the final word cloud by scaling chart down if needed this.generateCloud(encoder, 1, (words: Word[]) => topResults.every((d: PlainObject) => words.find( @@ -194,7 +197,6 @@ class WordCloud extends PureComponent { cloudLayout() .size([width * scaleFactor, height * scaleFactor]) - // clone the data because cloudLayout mutates input .words(data.map((d: Word) => ({ ...d }))) .padding(5) .rotate(ROTATION[rotation] || ROTATION.flat) @@ -208,9 +210,7 @@ class WordCloud extends PureComponent { .fontSize((d: PlainObject) => encoder.channels.fontSize.encodeDatum(d, 0)) .on('end', (words: Word[]) => { if (isValid(words) || scaleFactor > MAX_SCALE_FACTOR) { - if (this.isComponentMounted) { - this.setState({ words, scaleFactor }); - } + this.setWords(words); } else { this.generateCloud(encoder, scaleFactor + SCALE_FACTOR_STEP, isValid); } @@ -219,17 +219,13 @@ class WordCloud extends PureComponent { } render() { - const { scaleFactor } = this.state; + const { scaleFactor, words } = this.state; const { width, height, encoding, sliceId, colorScheme } = this.props; - const { words } = this.state; - // @ts-ignore const encoder = this.createEncoder(encoding); encoder.channels.color.setDomainFromDataset(words); - const { getValueFromDatum } = encoder.channels.color; const colorFn = CategoricalColorNamespace.getScale(colorScheme); - const viewBoxWidth = width * scaleFactor; const viewBoxHeight = height * scaleFactor; @@ -237,9 +233,7 @@ class WordCloud extends PureComponent { {words.map(w => ( @@ -248,7 +242,10 @@ class WordCloud extends PureComponent { fontSize={`${w.size}px`} fontWeight={w.weight} fontFamily={w.font} - fill={colorFn(getValueFromDatum(w) as string, sliceId)} + fill={colorFn( + encoder.channels.color.getValueFromDatum(w) as string, + sliceId, + )} textAnchor="middle" transform={`translate(${w.x}, ${w.y}) rotate(${w.rotate})`} > diff --git a/superset-frontend/plugins/plugin-chart-word-cloud/tsconfig.json b/superset-frontend/plugins/plugin-chart-word-cloud/tsconfig.json index b6bfaa2d984..b3af9a1d193 100644 --- a/superset-frontend/plugins/plugin-chart-word-cloud/tsconfig.json +++ b/superset-frontend/plugins/plugin-chart-word-cloud/tsconfig.json @@ -1,25 +1,15 @@ { + "extends": "../../tsconfig.base.json", "compilerOptions": { - "declarationDir": "lib", + "composite": true, + "rootDir": "src", "outDir": "lib", - "rootDir": "src" + "baseUrl": "." }, - "exclude": [ - "lib", - "test" - ], - "extends": "../../tsconfig.json", - "include": [ - "src/**/*", - "types/**/*", - "../../types/**/*" - ], + "include": ["src/**/*", "types/**/*"], + "exclude": ["lib", "test"], "references": [ - { - "path": "../../packages/superset-ui-chart-controls" - }, - { - "path": "../../packages/superset-ui-core" - } + { "path": "../../packages/superset-ui-core" }, + { "path": "../../packages/superset-ui-chart-controls" } ] } diff --git a/superset-frontend/spec/helpers/shim.tsx b/superset-frontend/spec/helpers/shim.tsx index af5ea846815..5de51ec841a 100644 --- a/superset-frontend/spec/helpers/shim.tsx +++ b/superset-frontend/spec/helpers/shim.tsx @@ -92,7 +92,7 @@ jest.mock('rehype-raw', () => () => jest.fn()); // Mocks the Icon component due to its async nature // Tests should override this when needed -jest.mock('src/components/Icons/AsyncIcon', () => ({ +jest.mock('@superset-ui/core/components/Icons/AsyncIcon', () => ({ __esModule: true, default: ({ fileName, diff --git a/superset-frontend/src/SqlLab/actions/sqlLab.js b/superset-frontend/src/SqlLab/actions/sqlLab.js index 8b54319a568..70269c37ec7 100644 --- a/superset-frontend/src/SqlLab/actions/sqlLab.js +++ b/superset-frontend/src/SqlLab/actions/sqlLab.js @@ -28,7 +28,7 @@ import { } from '@superset-ui/core'; import { invert, mapKeys } from 'lodash'; -import { now } from 'src/utils/dates'; +import { now } from '@superset-ui/core/utils/dates'; import { addDangerToast as addDangerToastAction, addInfoToast as addInfoToastAction, diff --git a/superset-frontend/src/SqlLab/components/AceEditorWrapper/AceEditorWrapper.test.tsx b/superset-frontend/src/SqlLab/components/AceEditorWrapper/AceEditorWrapper.test.tsx index c2f2ac083a8..a46f60c5d4e 100644 --- a/superset-frontend/src/SqlLab/components/AceEditorWrapper/AceEditorWrapper.test.tsx +++ b/superset-frontend/src/SqlLab/components/AceEditorWrapper/AceEditorWrapper.test.tsx @@ -22,7 +22,10 @@ import { QueryEditor } from 'src/SqlLab/types'; import { Store } from 'redux'; import { initialState, defaultQueryEditor } from 'src/SqlLab/fixtures'; import AceEditorWrapper from 'src/SqlLab/components/AceEditorWrapper'; -import { FullSQLEditor, type AsyncAceEditorProps } from 'src/components'; +import { + FullSQLEditor, + type AsyncAceEditorProps, +} from '@superset-ui/core/components'; import { queryEditorSetCursorPosition, queryEditorSetDb, @@ -33,14 +36,14 @@ fetchMock.get('glob:*/api/v1/database/*/function_names/', { function_names: [], }); -jest.mock('src/components/Select/Select', () => () => ( +jest.mock('@superset-ui/core/components/Select/Select', () => () => (
)); -jest.mock('src/components/Select/AsyncSelect', () => () => ( +jest.mock('@superset-ui/core/components/Select/AsyncSelect', () => () => (
)); -jest.mock('src/components/AsyncAceEditor', () => ({ +jest.mock('@superset-ui/core/components/AsyncAceEditor', () => ({ FullSQLEditor: jest .fn() .mockImplementation((props: AsyncAceEditorProps) => ( diff --git a/superset-frontend/src/SqlLab/components/AceEditorWrapper/index.tsx b/superset-frontend/src/SqlLab/components/AceEditorWrapper/index.tsx index 799e42a94f5..bfa615765b6 100644 --- a/superset-frontend/src/SqlLab/components/AceEditorWrapper/index.tsx +++ b/superset-frontend/src/SqlLab/components/AceEditorWrapper/index.tsx @@ -24,7 +24,7 @@ import { Global } from '@emotion/react'; import { SQL_EDITOR_LEFTBAR_WIDTH } from 'src/SqlLab/constants'; import { queryEditorSetSelectedText } from 'src/SqlLab/actions/sqlLab'; -import { FullSQLEditor as AceEditor } from 'src/components'; +import { FullSQLEditor as AceEditor } from '@superset-ui/core/components'; import type { KeyboardShortcut } from 'src/SqlLab/components/KeyboardShortcutButton'; import useQueryEditor from 'src/SqlLab/hooks/useQueryEditor'; import { SqlLabRootState, type CursorPosition } from 'src/SqlLab/types'; diff --git a/superset-frontend/src/SqlLab/components/AceEditorWrapper/useKeywords.ts b/superset-frontend/src/SqlLab/components/AceEditorWrapper/useKeywords.ts index d17884dd7da..99e99125133 100644 --- a/superset-frontend/src/SqlLab/components/AceEditorWrapper/useKeywords.ts +++ b/superset-frontend/src/SqlLab/components/AceEditorWrapper/useKeywords.ts @@ -20,7 +20,7 @@ import { useEffect, useMemo, useRef } from 'react'; import { useSelector, useDispatch, shallowEqual, useStore } from 'react-redux'; import { getExtensionsRegistry, t } from '@superset-ui/core'; -import type { Editor } from 'src/components'; +import type { Editor } from '@superset-ui/core/components'; import sqlKeywords from 'src/SqlLab/utils/sqlKeywords'; import { addTable, addDangerToast } from 'src/SqlLab/actions/sqlLab'; import { diff --git a/superset-frontend/src/SqlLab/components/ColumnElement/index.tsx b/superset-frontend/src/SqlLab/components/ColumnElement/index.tsx index d2555b25dda..6150c6e3a79 100644 --- a/superset-frontend/src/SqlLab/components/ColumnElement/index.tsx +++ b/superset-frontend/src/SqlLab/components/ColumnElement/index.tsx @@ -19,7 +19,7 @@ import { ReactNode } from 'react'; import { ClassNames } from '@emotion/react'; import { styled, useTheme, t } from '@superset-ui/core'; -import { Flex, Tooltip } from 'src/components'; +import { Flex, Tooltip } from '@superset-ui/core/components'; const StyledTooltip = (props: any) => { const theme = useTheme(); diff --git a/superset-frontend/src/SqlLab/components/EstimateQueryCostButton/EstimateQueryCostButton.test.tsx b/superset-frontend/src/SqlLab/components/EstimateQueryCostButton/EstimateQueryCostButton.test.tsx index 7668020cd35..a989d02f702 100644 --- a/superset-frontend/src/SqlLab/components/EstimateQueryCostButton/EstimateQueryCostButton.test.tsx +++ b/superset-frontend/src/SqlLab/components/EstimateQueryCostButton/EstimateQueryCostButton.test.tsx @@ -33,10 +33,10 @@ import EstimateQueryCostButton, { const middlewares = [thunk]; const mockStore = configureStore(middlewares); -jest.mock('src/components/Select/Select', () => () => ( +jest.mock('@superset-ui/core/components/Select/Select', () => () => (
)); -jest.mock('src/components/Select/AsyncSelect', () => () => ( +jest.mock('@superset-ui/core/components/Select/AsyncSelect', () => () => (
)); diff --git a/superset-frontend/src/SqlLab/components/EstimateQueryCostButton/index.tsx b/superset-frontend/src/SqlLab/components/EstimateQueryCostButton/index.tsx index 6dd2fd2374c..88fca28e97a 100644 --- a/superset-frontend/src/SqlLab/components/EstimateQueryCostButton/index.tsx +++ b/superset-frontend/src/SqlLab/components/EstimateQueryCostButton/index.tsx @@ -20,10 +20,14 @@ import { useMemo } from 'react'; import { useSelector } from 'react-redux'; import { css, styled, t } from '@superset-ui/core'; -import { Alert, Button, Loading } from 'src/components'; -import TableView from 'src/components/TableView'; -import ModalTrigger from 'src/components/ModalTrigger'; -import { EmptyWrapperType } from 'src/components/TableView/TableView'; +import { + Alert, + Button, + Loading, + ModalTrigger, + TableView, + EmptyWrapperType, +} from '@superset-ui/core/components'; import useQueryEditor from 'src/SqlLab/hooks/useQueryEditor'; import { SqlLabRootState, QueryCostEstimate } from 'src/SqlLab/types'; diff --git a/superset-frontend/src/SqlLab/components/ExploreCtasResultsButton/index.tsx b/superset-frontend/src/SqlLab/components/ExploreCtasResultsButton/index.tsx index 62a9e6b0d5a..8d8bc7b1cb4 100644 --- a/superset-frontend/src/SqlLab/components/ExploreCtasResultsButton/index.tsx +++ b/superset-frontend/src/SqlLab/components/ExploreCtasResultsButton/index.tsx @@ -23,8 +23,8 @@ import { addInfoToast, addDangerToast, } from 'src/SqlLab/actions/sqlLab'; -import { Button, IconTooltip } from 'src/components'; -import { Icons } from 'src/components/Icons'; +import { Button, IconTooltip } from '@superset-ui/core/components'; +import { Icons } from '@superset-ui/core/components/Icons'; import { exploreChart } from 'src/explore/exploreUtils'; import { SqlLabRootState } from 'src/SqlLab/types'; diff --git a/superset-frontend/src/SqlLab/components/ExploreResultsButton/ExploreResultsButton.test.tsx b/superset-frontend/src/SqlLab/components/ExploreResultsButton/ExploreResultsButton.test.tsx index 79a26966ac2..0b119946138 100644 --- a/superset-frontend/src/SqlLab/components/ExploreResultsButton/ExploreResultsButton.test.tsx +++ b/superset-frontend/src/SqlLab/components/ExploreResultsButton/ExploreResultsButton.test.tsx @@ -21,7 +21,7 @@ import { render, screen } from 'spec/helpers/testing-library'; import ExploreResultsButton, { ExploreResultsButtonProps, } from 'src/SqlLab/components/ExploreResultsButton'; -import type { OnClickHandler } from 'src/components'; +import type { OnClickHandler } from '@superset-ui/core/components'; const setup = ( onClickFn: OnClickHandler, diff --git a/superset-frontend/src/SqlLab/components/ExploreResultsButton/index.tsx b/superset-frontend/src/SqlLab/components/ExploreResultsButton/index.tsx index 1bdba6783ac..53f9cdc2b0f 100644 --- a/superset-frontend/src/SqlLab/components/ExploreResultsButton/index.tsx +++ b/superset-frontend/src/SqlLab/components/ExploreResultsButton/index.tsx @@ -17,7 +17,11 @@ * under the License. */ import { t } from '@superset-ui/core'; -import { Button, type OnClickHandler, Icons } from 'src/components'; +import { + Button, + type OnClickHandler, + Icons, +} from '@superset-ui/core/components'; export interface ExploreResultsButtonProps { database?: { diff --git a/superset-frontend/src/SqlLab/components/HighlightedSql/index.tsx b/superset-frontend/src/SqlLab/components/HighlightedSql/index.tsx index f3cf8dc8578..2733b4ae81e 100644 --- a/superset-frontend/src/SqlLab/components/HighlightedSql/index.tsx +++ b/superset-frontend/src/SqlLab/components/HighlightedSql/index.tsx @@ -21,7 +21,7 @@ import sql from 'react-syntax-highlighter/dist/cjs/languages/hljs/sql'; import github from 'react-syntax-highlighter/dist/cjs/styles/hljs/github'; import atomOneDark from 'react-syntax-highlighter/dist/cjs/styles/hljs/atom-one-dark'; import { t, themeObject } from '@superset-ui/core'; -import ModalTrigger from 'src/components/ModalTrigger'; +import { ModalTrigger } from '@superset-ui/core/components'; SyntaxHighlighterBase.registerLanguage('sql', sql); diff --git a/superset-frontend/src/SqlLab/components/KeyboardShortcutButton/index.tsx b/superset-frontend/src/SqlLab/components/KeyboardShortcutButton/index.tsx index bc043589a4c..e9749a56187 100644 --- a/superset-frontend/src/SqlLab/components/KeyboardShortcutButton/index.tsx +++ b/superset-frontend/src/SqlLab/components/KeyboardShortcutButton/index.tsx @@ -18,7 +18,7 @@ */ import { FC } from 'react'; import { styled, t, css } from '@superset-ui/core'; -import ModalTrigger from 'src/components/ModalTrigger'; +import { ModalTrigger } from '@superset-ui/core/components'; import { detectOS } from 'src/utils/common'; const userOS = detectOS(); diff --git a/superset-frontend/src/SqlLab/components/QueryAutoRefresh/QueryAutoRefresh.test.tsx b/superset-frontend/src/SqlLab/components/QueryAutoRefresh/QueryAutoRefresh.test.tsx index 7a35adccc40..2e26087296e 100644 --- a/superset-frontend/src/SqlLab/components/QueryAutoRefresh/QueryAutoRefresh.test.tsx +++ b/superset-frontend/src/SqlLab/components/QueryAutoRefresh/QueryAutoRefresh.test.tsx @@ -16,11 +16,13 @@ * specific language governing permissions and limitations * under the License. */ +import { act } from 'react-dom/test-utils'; import { QueryState } from '@superset-ui/core'; import fetchMock from 'fetch-mock'; import configureStore from 'redux-mock-store'; import thunk from 'redux-thunk'; import { render, waitFor } from 'spec/helpers/testing-library'; +import { cleanup } from '@testing-library/react'; import { LOG_ACTIONS_SQLLAB_FETCH_FAILED_QUERY } from 'src/logger/LogUtils'; import { CLEAR_INACTIVE_QUERIES, @@ -41,46 +43,42 @@ const mockState = { databases: mockDatabases, }; -// NOTE: The uses of @ts-ignore in this file is to enable testing of bad inputs to verify the -// function / component handles bad data elegantly describe('QueryAutoRefresh', () => { - const runningQueries: QueryDictionary = {}; - runningQueries[runningQuery.id] = runningQuery; - - const successfulQueries: QueryDictionary = {}; - successfulQueries[successfulQuery.id] = successfulQuery; - + const runningQueries: QueryDictionary = { [runningQuery.id]: runningQuery }; + const successfulQueries: QueryDictionary = { + [successfulQuery.id]: successfulQuery, + }; const queriesLastUpdate = Date.now(); - const refreshApi = 'glob:*/api/v1/query/updated_since?*'; + beforeEach(() => { + jest.useFakeTimers(); + }); + afterEach(() => { fetchMock.reset(); + cleanup(); + jest.runOnlyPendingTimers(); + jest.useRealTimers(); }); it('isQueryRunning returns true for valid running query', () => { - const running = isQueryRunning(runningQuery); - expect(running).toBe(true); + expect(isQueryRunning(runningQuery)).toBe(true); }); it('isQueryRunning returns false for valid not-running query', () => { - const running = isQueryRunning(successfulQuery); - expect(running).toBe(false); + expect(isQueryRunning(successfulQuery)).toBe(false); }); it('isQueryRunning returns false for invalid query', () => { // @ts-ignore - let running = isQueryRunning(null); - expect(running).toBe(false); + expect(isQueryRunning(null)).toBe(false); // @ts-ignore - running = isQueryRunning(undefined); - expect(running).toBe(false); + expect(isQueryRunning(undefined)).toBe(false); // @ts-ignore - running = isQueryRunning('I Should Be An Object'); - expect(running).toBe(false); + expect(isQueryRunning('I Should Be An Object')).toBe(false); // @ts-ignore - running = isQueryRunning({ state: { badFormat: true } }); - expect(running).toBe(false); + expect(isQueryRunning({ state: { badFormat: true } })).toBe(false); }); it('shouldCheckForQueries is true for valid running query', () => { @@ -112,16 +110,10 @@ describe('QueryAutoRefresh', () => { }); it('Attempts to refresh when given pending query', async () => { - const store = mockStore({ - sqlLab: { ...mockState }, - }); + const store = mockStore({ sqlLab: { ...mockState } }); + fetchMock.get(refreshApi, { - result: [ - { - id: runningQuery.id, - status: 'success', - }, - ], + result: [{ id: runningQuery.id, status: 'success' }], }); render( @@ -131,22 +123,22 @@ describe('QueryAutoRefresh', () => { />, { useRedux: true, store }, ); - await waitFor( - () => - expect(store.getActions()).toContainEqual( - expect.objectContaining({ - type: REFRESH_QUERIES, - }), - ), - { timeout: QUERY_UPDATE_FREQ + 100 }, + + await act(async () => { + jest.advanceTimersByTime(QUERY_UPDATE_FREQ + 100); + }); + + await waitFor(() => + expect(store.getActions()).toContainEqual( + expect.objectContaining({ type: REFRESH_QUERIES }), + ), ); }); it('Attempts to clear inactive queries when updated queries are empty', async () => { const store = mockStore({ sqlLab: { ...mockState } }); - fetchMock.get(refreshApi, { - result: [], - }); + + fetchMock.get(refreshApi, { result: [] }); render( { />, { useRedux: true, store }, ); - await waitFor( - () => - expect(store.getActions()).toContainEqual( - expect.objectContaining({ - type: CLEAR_INACTIVE_QUERIES, - }), - ), - { timeout: QUERY_UPDATE_FREQ + 100 }, + + await act(async () => { + jest.advanceTimersByTime(QUERY_UPDATE_FREQ + 100); + }); + + await waitFor(() => + expect(store.getActions()).toContainEqual( + expect.objectContaining({ type: CLEAR_INACTIVE_QUERIES }), + ), ); + expect( store.getActions().filter(({ type }) => type === REFRESH_QUERIES), ).toHaveLength(0); expect(fetchMock.calls(refreshApi)).toHaveLength(1); }); - it('Does not fail and attempts to refresh when given pending query and invalid query', async () => { + it('Does not fail and attempts to refresh with mixed valid/invalid queries', async () => { const store = mockStore({ sqlLab: { ...mockState } }); + fetchMock.get(refreshApi, { - result: [ - { - id: runningQuery.id, - status: 'success', - }, - ], + result: [{ id: runningQuery.id, status: 'success' }], }); render( @@ -189,27 +179,25 @@ describe('QueryAutoRefresh', () => { />, { useRedux: true, store }, ); - await waitFor( - () => - expect(store.getActions()).toContainEqual( - expect.objectContaining({ - type: REFRESH_QUERIES, - }), - ), - { timeout: QUERY_UPDATE_FREQ + 100 }, + + await act(async () => { + jest.advanceTimersByTime(QUERY_UPDATE_FREQ + 100); + }); + + await waitFor(() => + expect(store.getActions()).toContainEqual( + expect.objectContaining({ type: REFRESH_QUERIES }), + ), ); }); it('Does NOT Attempt to refresh when given only completed queries', async () => { const store = mockStore({ sqlLab: { ...mockState } }); + fetchMock.get(refreshApi, { - result: [ - { - id: runningQuery.id, - status: 'success', - }, - ], + result: [{ id: runningQuery.id, status: 'success' }], }); + render( { />, { useRedux: true, store }, ); - await waitFor( - () => - expect(store.getActions()).toContainEqual( - expect.objectContaining({ - type: CLEAR_INACTIVE_QUERIES, - }), - ), - { timeout: QUERY_UPDATE_FREQ + 100 }, + + await act(async () => { + jest.advanceTimersByTime(QUERY_UPDATE_FREQ + 100); + }); + + await waitFor(() => + expect(store.getActions()).toContainEqual( + expect.objectContaining({ type: CLEAR_INACTIVE_QUERIES }), + ), ); + expect(fetchMock.calls(refreshApi)).toHaveLength(0); }); it('logs the failed error for async queries', async () => { const store = mockStore({ sqlLab: { ...mockState } }); + fetchMock.get(refreshApi, { result: [ { @@ -257,6 +248,7 @@ describe('QueryAutoRefresh', () => { }, ], }); + render( { />, { useRedux: true, store }, ); - await waitFor( - () => - expect(store.getActions()).toContainEqual( - expect.objectContaining({ - payload: expect.objectContaining({ - eventName: LOG_ACTIONS_SQLLAB_FETCH_FAILED_QUERY, - eventData: expect.objectContaining({ - error_type: 'TEST_ERROR', - error_details: 'Syntax invalid', - issue_codes: [102], - }), + + await act(async () => { + jest.advanceTimersByTime(QUERY_UPDATE_FREQ + 100); + }); + + await waitFor(() => + expect(store.getActions()).toContainEqual( + expect.objectContaining({ + payload: expect.objectContaining({ + eventName: LOG_ACTIONS_SQLLAB_FETCH_FAILED_QUERY, + eventData: expect.objectContaining({ + error_type: 'TEST_ERROR', + error_details: 'Syntax invalid', + issue_codes: [102], }), }), - ), - { timeout: QUERY_UPDATE_FREQ + 100 }, + }), + ), ); }); }); diff --git a/superset-frontend/src/SqlLab/components/QueryHistory/index.tsx b/superset-frontend/src/SqlLab/components/QueryHistory/index.tsx index 4f578df507d..85cf33ade30 100644 --- a/superset-frontend/src/SqlLab/components/QueryHistory/index.tsx +++ b/superset-frontend/src/SqlLab/components/QueryHistory/index.tsx @@ -20,7 +20,7 @@ import { useEffect, useMemo, useState } from 'react'; import { shallowEqual, useSelector } from 'react-redux'; import { useInView } from 'react-intersection-observer'; import { omit } from 'lodash'; -import { EmptyState, Skeleton } from 'src/components'; +import { EmptyState, Skeleton } from '@superset-ui/core/components'; import { t, styled, diff --git a/superset-frontend/src/SqlLab/components/QueryLimitSelect/QueryLimitSelect.test.tsx b/superset-frontend/src/SqlLab/components/QueryLimitSelect/QueryLimitSelect.test.tsx index 8d421f92c92..bbaa76720b0 100644 --- a/superset-frontend/src/SqlLab/components/QueryLimitSelect/QueryLimitSelect.test.tsx +++ b/superset-frontend/src/SqlLab/components/QueryLimitSelect/QueryLimitSelect.test.tsx @@ -35,10 +35,10 @@ import QueryLimitSelect, { const middlewares = [thunk]; const mockStore = configureStore(middlewares); -jest.mock('src/components/Select/Select', () => () => ( +jest.mock('@superset-ui/core/components/Select/Select', () => () => (
)); -jest.mock('src/components/Select/AsyncSelect', () => () => ( +jest.mock('@superset-ui/core/components/Select/AsyncSelect', () => () => (
)); diff --git a/superset-frontend/src/SqlLab/components/QueryLimitSelect/index.tsx b/superset-frontend/src/SqlLab/components/QueryLimitSelect/index.tsx index 665141f8392..bb6e45b405f 100644 --- a/superset-frontend/src/SqlLab/components/QueryLimitSelect/index.tsx +++ b/superset-frontend/src/SqlLab/components/QueryLimitSelect/index.tsx @@ -18,9 +18,9 @@ */ import { useDispatch } from 'react-redux'; import { t } from '@superset-ui/core'; -import { Dropdown, Button } from 'src/components'; -import { Menu } from 'src/components/Menu'; -import { Icons } from 'src/components/Icons'; +import { Dropdown, Button } from '@superset-ui/core/components'; +import { Menu } from '@superset-ui/core/components/Menu'; +import { Icons } from '@superset-ui/core/components/Icons'; import { queryEditorSetQueryLimit } from 'src/SqlLab/actions/sqlLab'; import useQueryEditor from 'src/SqlLab/hooks/useQueryEditor'; diff --git a/superset-frontend/src/SqlLab/components/QueryStateLabel/QueryStateLabel.test.tsx b/superset-frontend/src/SqlLab/components/QueryStateLabel/QueryStateLabel.test.tsx index 55ddd71c478..d02428bf2d0 100644 --- a/superset-frontend/src/SqlLab/components/QueryStateLabel/QueryStateLabel.test.tsx +++ b/superset-frontend/src/SqlLab/components/QueryStateLabel/QueryStateLabel.test.tsx @@ -21,7 +21,7 @@ import type { QueryState } from '@superset-ui/core'; import { render } from 'spec/helpers/testing-library'; import QueryStateLabel from '.'; -jest.mock('src/components/Label', () => ({ +jest.mock('@superset-ui/core/components/Label', () => ({ __esModule: true, Label: () =>
, })); diff --git a/superset-frontend/src/SqlLab/components/QueryStateLabel/index.tsx b/superset-frontend/src/SqlLab/components/QueryStateLabel/index.tsx index 2b234c341f8..5d2625dbc78 100644 --- a/superset-frontend/src/SqlLab/components/QueryStateLabel/index.tsx +++ b/superset-frontend/src/SqlLab/components/QueryStateLabel/index.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { Label } from 'src/components'; +import { Label } from '@superset-ui/core/components'; import { STATE_TYPE_MAP, STATE_TYPE_MAP_LOCALIZED } from 'src/SqlLab/constants'; import { styled, Query } from '@superset-ui/core'; diff --git a/superset-frontend/src/SqlLab/components/QueryTable/index.tsx b/superset-frontend/src/SqlLab/components/QueryTable/index.tsx index 3b675664660..f892913ca43 100644 --- a/superset-frontend/src/SqlLab/components/QueryTable/index.tsx +++ b/superset-frontend/src/SqlLab/components/QueryTable/index.tsx @@ -17,8 +17,16 @@ * under the License. */ import { useMemo, ReactNode } from 'react'; -import { Card, Button, Tooltip, Label } from 'src/components'; -import ProgressBar from 'src/components/ProgressBar'; +import { + Card, + Button, + Tooltip, + Label, + Icons, + ModalTrigger, + TableView, +} from '@superset-ui/core/components'; +import ProgressBar from '@superset-ui/core/components/ProgressBar'; import { t, useTheme, QueryResponse } from '@superset-ui/core'; import { useDispatch, useSelector } from 'react-redux'; @@ -29,11 +37,8 @@ import { clearQueryResults, removeQuery, } from 'src/SqlLab/actions/sqlLab'; -import TableView from 'src/components/TableView'; -import { fDuration, extendedDayjs } from 'src/utils/dates'; -import { Icons } from 'src/components/Icons'; +import { fDuration, extendedDayjs } from '@superset-ui/core/utils/dates'; import { SqlLabRootState } from 'src/SqlLab/types'; -import ModalTrigger from 'src/components/ModalTrigger'; import { UserWithPermissionsAndRoles as User } from 'src/types/bootstrapTypes'; import ResultSet from '../ResultSet'; import HighlightedSql from '../HighlightedSql'; diff --git a/superset-frontend/src/SqlLab/components/QueryTable/styles.ts b/superset-frontend/src/SqlLab/components/QueryTable/styles.ts index 838911994e1..03f0eb3e679 100644 --- a/superset-frontend/src/SqlLab/components/QueryTable/styles.ts +++ b/superset-frontend/src/SqlLab/components/QueryTable/styles.ts @@ -17,7 +17,7 @@ * under the License. */ import { styled, css } from '@superset-ui/core'; -import { IconTooltip } from 'src/components'; +import { IconTooltip } from '@superset-ui/core/components'; export const StaticPosition = css` position: static; diff --git a/superset-frontend/src/SqlLab/components/ResultSet/index.tsx b/superset-frontend/src/SqlLab/components/ResultSet/index.tsx index ae289f57acb..60edbd141a5 100644 --- a/superset-frontend/src/SqlLab/components/ResultSet/index.tsx +++ b/superset-frontend/src/SqlLab/components/ResultSet/index.tsx @@ -34,13 +34,15 @@ import { ButtonGroup, Tooltip, Card, - CopyToClipboard, - ErrorMessageWithStackTrace, Modal, - FilterableTable, Input, Label, Loading, +} from '@superset-ui/core/components'; +import { + CopyToClipboard, + FilterableTable, + ErrorMessageWithStackTrace, } from 'src/components'; import { nanoid } from 'nanoid'; import { @@ -63,7 +65,7 @@ import { import { EXPLORE_CHART_DEFAULT, SqlLabRootState } from 'src/SqlLab/types'; import { mountExploreUrl } from 'src/explore/exploreUtils'; import { postFormData } from 'src/explore/exploreUtils/formData'; -import ProgressBar from 'src/components/ProgressBar'; +import ProgressBar from '@superset-ui/core/components/ProgressBar'; import { addDangerToast } from 'src/components/MessageToasts/actions'; import { prepareCopyToClipboardTabularData } from 'src/utils/common'; import { getItem, LocalStorageKeys } from 'src/utils/localStorageHelpers'; @@ -82,7 +84,7 @@ import { LOG_ACTIONS_SQLLAB_CREATE_CHART, LOG_ACTIONS_SQLLAB_DOWNLOAD_CSV, } from 'src/logger/LogUtils'; -import { Icons } from 'src/components/Icons'; +import { Icons } from '@superset-ui/core/components/Icons'; import { findPermission } from 'src/utils/findPermission'; import ExploreCtasResultsButton from '../ExploreCtasResultsButton'; import ExploreResultsButton from '../ExploreResultsButton'; diff --git a/superset-frontend/src/SqlLab/components/RunQueryActionButton/RunQueryActionButton.test.tsx b/superset-frontend/src/SqlLab/components/RunQueryActionButton/RunQueryActionButton.test.tsx index 40df87b68e4..798a98b3ff3 100644 --- a/superset-frontend/src/SqlLab/components/RunQueryActionButton/RunQueryActionButton.test.tsx +++ b/superset-frontend/src/SqlLab/components/RunQueryActionButton/RunQueryActionButton.test.tsx @@ -29,10 +29,10 @@ import RunQueryActionButton, { const middlewares = [thunk]; const mockStore = configureStore(middlewares); -jest.mock('src/components/Select/Select', () => () => ( +jest.mock('@superset-ui/core/components/Select/Select', () => () => (
)); -jest.mock('src/components/Select/AsyncSelect', () => () => ( +jest.mock('@superset-ui/core/components/Select/AsyncSelect', () => () => (
)); diff --git a/superset-frontend/src/SqlLab/components/RunQueryActionButton/index.tsx b/superset-frontend/src/SqlLab/components/RunQueryActionButton/index.tsx index 052ffed4001..79d6f962600 100644 --- a/superset-frontend/src/SqlLab/components/RunQueryActionButton/index.tsx +++ b/superset-frontend/src/SqlLab/components/RunQueryActionButton/index.tsx @@ -20,8 +20,8 @@ import { useMemo, FC, ReactElement } from 'react'; import { t, styled, useTheme, SupersetTheme } from '@superset-ui/core'; -import { Button, DropdownButton } from 'src/components'; -import { Icons } from 'src/components/Icons'; +import { Button, DropdownButton } from '@superset-ui/core/components'; +import { Icons } from '@superset-ui/core/components/Icons'; import { detectOS } from 'src/utils/common'; import { QueryButtonProps } from 'src/SqlLab/types'; import useQueryEditor from 'src/SqlLab/hooks/useQueryEditor'; diff --git a/superset-frontend/src/SqlLab/components/SaveDatasetActionButton/SaveDatasetActionButton.test.tsx b/superset-frontend/src/SqlLab/components/SaveDatasetActionButton/SaveDatasetActionButton.test.tsx index f5283dfd1e3..0ab7237a037 100644 --- a/superset-frontend/src/SqlLab/components/SaveDatasetActionButton/SaveDatasetActionButton.test.tsx +++ b/superset-frontend/src/SqlLab/components/SaveDatasetActionButton/SaveDatasetActionButton.test.tsx @@ -17,7 +17,7 @@ * under the License. */ import { render, screen, userEvent } from 'spec/helpers/testing-library'; -import { Menu } from 'src/components/Menu'; +import { Menu } from '@superset-ui/core/components/Menu'; import SaveDatasetActionButton from 'src/SqlLab/components/SaveDatasetActionButton'; const overlayMenu = ( diff --git a/superset-frontend/src/SqlLab/components/SaveDatasetActionButton/index.tsx b/superset-frontend/src/SqlLab/components/SaveDatasetActionButton/index.tsx index 4c9464a04c6..bcdc8370357 100644 --- a/superset-frontend/src/SqlLab/components/SaveDatasetActionButton/index.tsx +++ b/superset-frontend/src/SqlLab/components/SaveDatasetActionButton/index.tsx @@ -17,8 +17,8 @@ * under the License. */ import { t, useTheme } from '@superset-ui/core'; -import { Icons } from 'src/components/Icons'; -import { Button, DropdownButton } from 'src/components'; +import { Icons } from '@superset-ui/core/components/Icons'; +import { Button, DropdownButton } from '@superset-ui/core/components'; interface SaveDatasetActionButtonProps { setShowSave: (arg0: boolean) => void; diff --git a/superset-frontend/src/SqlLab/components/SaveDatasetModal/index.tsx b/superset-frontend/src/SqlLab/components/SaveDatasetModal/index.tsx index f6dff994e8f..22df5b4c6c7 100644 --- a/superset-frontend/src/SqlLab/components/SaveDatasetModal/index.tsx +++ b/superset-frontend/src/SqlLab/components/SaveDatasetModal/index.tsx @@ -19,14 +19,14 @@ import { useCallback, useState, FormEvent } from 'react'; -import { Radio, RadioChangeEvent } from 'src/components/Radio'; +import { Radio, RadioChangeEvent } from '@superset-ui/core/components/Radio'; import { AsyncSelect, Button, Modal, Input, type SelectValue, -} from 'src/components'; +} from '@superset-ui/core/components'; import { styled, t, diff --git a/superset-frontend/src/SqlLab/components/SaveQuery/index.tsx b/superset-frontend/src/SqlLab/components/SaveQuery/index.tsx index e6e94ca71e3..5a5fa55b3fb 100644 --- a/superset-frontend/src/SqlLab/components/SaveQuery/index.tsx +++ b/superset-frontend/src/SqlLab/components/SaveQuery/index.tsx @@ -20,8 +20,16 @@ import { useState, useEffect, useMemo, ChangeEvent } from 'react'; import type { DatabaseObject } from 'src/features/databases/types'; import { t, styled } from '@superset-ui/core'; -import { Input, Button, Form, FormItem, Modal, Row, Col } from 'src/components'; -import { Menu } from 'src/components/Menu'; +import { + Input, + Button, + Form, + FormItem, + Modal, + Row, + Col, +} from '@superset-ui/core/components'; +import { Menu } from '@superset-ui/core/components/Menu'; import SaveDatasetActionButton from 'src/SqlLab/components/SaveDatasetActionButton'; import { SaveDatasetModal, diff --git a/superset-frontend/src/SqlLab/components/ScheduleQueryButton/index.tsx b/superset-frontend/src/SqlLab/components/ScheduleQueryButton/index.tsx index af42121ce0d..7c68662cf60 100644 --- a/superset-frontend/src/SqlLab/components/ScheduleQueryButton/index.tsx +++ b/superset-frontend/src/SqlLab/components/ScheduleQueryButton/index.tsx @@ -23,8 +23,18 @@ import { FormValidation } from '@rjsf/utils'; import validator from '@rjsf/validator-ajv8'; import { t, styled } from '@superset-ui/core'; import { parseDate } from 'chrono-node'; -import ModalTrigger, { ModalTriggerRef } from 'src/components/ModalTrigger'; -import { Input, Button, Form, FormItem, Row, Col } from 'src/components'; +import { + ModalTrigger, + ModalTriggerRef, +} from '@superset-ui/core/components/ModalTrigger'; +import { + Input, + Button, + Form, + FormItem, + Row, + Col, +} from '@superset-ui/core/components'; import getBootstrapData from 'src/utils/getBootstrapData'; const bootstrapData = getBootstrapData(); diff --git a/superset-frontend/src/SqlLab/components/ShareSqlLabQuery/index.tsx b/superset-frontend/src/SqlLab/components/ShareSqlLabQuery/index.tsx index f57d8d338ff..7249d5909fb 100644 --- a/superset-frontend/src/SqlLab/components/ShareSqlLabQuery/index.tsx +++ b/superset-frontend/src/SqlLab/components/ShareSqlLabQuery/index.tsx @@ -22,8 +22,9 @@ import { SupersetClient, css, } from '@superset-ui/core'; -import { Button, CopyToClipboard } from 'src/components'; -import { Icons } from 'src/components/Icons'; +import { Button } from '@superset-ui/core/components'; +import { CopyToClipboard } from 'src/components'; +import { Icons } from '@superset-ui/core/components/Icons'; import withToasts from 'src/components/MessageToasts/withToasts'; import useQueryEditor from 'src/SqlLab/hooks/useQueryEditor'; import { LOG_ACTIONS_SQLLAB_COPY_LINK } from 'src/logger/LogUtils'; diff --git a/superset-frontend/src/SqlLab/components/ShowSQL/index.tsx b/superset-frontend/src/SqlLab/components/ShowSQL/index.tsx index e0b27265094..a9739faacee 100644 --- a/superset-frontend/src/SqlLab/components/ShowSQL/index.tsx +++ b/superset-frontend/src/SqlLab/components/ShowSQL/index.tsx @@ -19,9 +19,8 @@ import SyntaxHighlighter from 'react-syntax-highlighter/dist/cjs/light'; import sql from 'react-syntax-highlighter/dist/cjs/languages/hljs/sql'; import github from 'react-syntax-highlighter/dist/cjs/styles/hljs/github'; -import { IconTooltip } from 'src/components/IconTooltip'; -import ModalTrigger from 'src/components/ModalTrigger'; -import { Icons } from 'src/components/Icons'; +import { IconTooltip, ModalTrigger } from '@superset-ui/core/components'; +import { Icons } from '@superset-ui/core/components/Icons'; SyntaxHighlighter.registerLanguage('sql', sql); diff --git a/superset-frontend/src/SqlLab/components/SouthPane/Results.tsx b/superset-frontend/src/SqlLab/components/SouthPane/Results.tsx index 7ba0d9b4f39..06b7033c254 100644 --- a/superset-frontend/src/SqlLab/components/SouthPane/Results.tsx +++ b/superset-frontend/src/SqlLab/components/SouthPane/Results.tsx @@ -18,7 +18,7 @@ */ import { FC } from 'react'; import { shallowEqual, useSelector } from 'react-redux'; -import { Alert, EmptyState } from 'src/components'; +import { Alert, EmptyState } from '@superset-ui/core/components'; import { FeatureFlag, styled, t, isFeatureEnabled } from '@superset-ui/core'; import { SqlLabRootState } from 'src/SqlLab/types'; diff --git a/superset-frontend/src/SqlLab/components/SouthPane/index.tsx b/superset-frontend/src/SqlLab/components/SouthPane/index.tsx index ed0128c23d6..7096f4d6328 100644 --- a/superset-frontend/src/SqlLab/components/SouthPane/index.tsx +++ b/superset-frontend/src/SqlLab/components/SouthPane/index.tsx @@ -19,13 +19,13 @@ import { createRef, useCallback, useMemo } from 'react'; import { shallowEqual, useDispatch, useSelector } from 'react-redux'; import { nanoid } from 'nanoid'; -import Tabs from 'src/components/Tabs'; +import Tabs from '@superset-ui/core/components/Tabs'; import { css, styled, t, useTheme } from '@superset-ui/core'; import { removeTables, setActiveSouthPaneTab } from 'src/SqlLab/actions/sqlLab'; -import { Label } from 'src/components'; -import { Icons } from 'src/components/Icons'; +import { Label } from '@superset-ui/core/components'; +import { Icons } from '@superset-ui/core/components/Icons'; import { SqlLabRootState } from 'src/SqlLab/types'; import QueryHistory from '../QueryHistory'; import { diff --git a/superset-frontend/src/SqlLab/components/SqlEditor/SqlEditor.test.tsx b/superset-frontend/src/SqlLab/components/SqlEditor/SqlEditor.test.tsx index f5d0277a894..119021f722b 100644 --- a/superset-frontend/src/SqlLab/components/SqlEditor/SqlEditor.test.tsx +++ b/superset-frontend/src/SqlLab/components/SqlEditor/SqlEditor.test.tsx @@ -45,8 +45,8 @@ import setupExtensions from 'src/setup/setupExtensions'; import type { Action, Middleware, Store } from 'redux'; import SqlEditor, { Props } from '.'; -jest.mock('src/components/AsyncAceEditor', () => ({ - ...jest.requireActual('src/components/AsyncAceEditor'), +jest.mock('@superset-ui/core/components/AsyncAceEditor', () => ({ + ...jest.requireActual('@superset-ui/core/components/AsyncAceEditor'), FullSQLEditor: ({ onChange, onBlur, diff --git a/superset-frontend/src/SqlLab/components/SqlEditor/index.tsx b/superset-frontend/src/SqlLab/components/SqlEditor/index.tsx index 85673b3073d..93f6e831a2c 100644 --- a/superset-frontend/src/SqlLab/components/SqlEditor/index.tsx +++ b/superset-frontend/src/SqlLab/components/SqlEditor/index.tsx @@ -53,19 +53,19 @@ import type { DatabaseObject } from 'src/features/databases/types'; import { debounce, throttle, isEmpty } from 'lodash'; import Mousetrap from 'mousetrap'; import { - Input, - Button, Alert, + Button, Dropdown, EmptyState, + Input, Modal, -} from 'src/components'; -import Timer from 'src/components/Timer'; + Timer, +} from '@superset-ui/core/components'; import ResizableSidebar from 'src/components/ResizableSidebar'; -import { Skeleton } from 'src/components/Skeleton'; -import { Switch } from 'src/components/Switch'; -import { Menu } from 'src/components/Menu'; -import { Icons } from 'src/components/Icons'; +import { Skeleton } from '@superset-ui/core/components/Skeleton'; +import { Switch } from '@superset-ui/core/components/Switch'; +import { Menu } from '@superset-ui/core/components/Menu'; +import { Icons } from '@superset-ui/core/components/Icons'; import { detectOS } from 'src/utils/common'; import { addNewQueryEditor, diff --git a/superset-frontend/src/SqlLab/components/SqlEditorLeftBar/index.tsx b/superset-frontend/src/SqlLab/components/SqlEditorLeftBar/index.tsx index 5991040389c..2b1656125b3 100644 --- a/superset-frontend/src/SqlLab/components/SqlEditorLeftBar/index.tsx +++ b/superset-frontend/src/SqlLab/components/SqlEditorLeftBar/index.tsx @@ -33,7 +33,8 @@ import { addDangerToast, resetState, } from 'src/SqlLab/actions/sqlLab'; -import { Button, EmptyState, Icons, type DatabaseObject } from 'src/components'; +import { Button, EmptyState, Icons } from '@superset-ui/core/components'; +import { type DatabaseObject } from 'src/components'; import { t, styled, css } from '@superset-ui/core'; import { TableSelectorMultiple } from 'src/components/TableSelector'; import useQueryEditor from 'src/SqlLab/hooks/useQueryEditor'; diff --git a/superset-frontend/src/SqlLab/components/SqlEditorTabHeader/SqlEditorTabHeader.test.tsx b/superset-frontend/src/SqlLab/components/SqlEditorTabHeader/SqlEditorTabHeader.test.tsx index 3e10def3757..ae79d42ecb4 100644 --- a/superset-frontend/src/SqlLab/components/SqlEditorTabHeader/SqlEditorTabHeader.test.tsx +++ b/superset-frontend/src/SqlLab/components/SqlEditorTabHeader/SqlEditorTabHeader.test.tsx @@ -41,10 +41,10 @@ import { } from 'src/SqlLab/actions/sqlLab'; import SqlEditorTabHeader from 'src/SqlLab/components/SqlEditorTabHeader'; -jest.mock('src/components/Select/Select', () => () => ( +jest.mock('@superset-ui/core/components/Select/Select', () => () => (
)); -jest.mock('src/components/Select/AsyncSelect', () => () => ( +jest.mock('@superset-ui/core/components/Select/AsyncSelect', () => () => (
)); diff --git a/superset-frontend/src/SqlLab/components/SqlEditorTabHeader/index.tsx b/superset-frontend/src/SqlLab/components/SqlEditorTabHeader/index.tsx index 0f19e341e57..d99c2d95762 100644 --- a/superset-frontend/src/SqlLab/components/SqlEditorTabHeader/index.tsx +++ b/superset-frontend/src/SqlLab/components/SqlEditorTabHeader/index.tsx @@ -20,8 +20,8 @@ import { useMemo, FC } from 'react'; import { bindActionCreators } from 'redux'; import { useSelector, useDispatch, shallowEqual } from 'react-redux'; -import { MenuDotsDropdown } from 'src/components'; -import { Menu } from 'src/components/Menu'; +import { MenuDotsDropdown } from '@superset-ui/core/components'; +import { Menu } from '@superset-ui/core/components/Menu'; import { styled, css, @@ -38,8 +38,8 @@ import { toggleLeftBar, } from 'src/SqlLab/actions/sqlLab'; import { QueryEditor, SqlLabRootState } from 'src/SqlLab/types'; -import { Icons } from 'src/components/Icons'; -import type { IconType } from 'src/components/Icons/types'; +import { Icons } from '@superset-ui/core/components/Icons'; +import type { IconType } from '@superset-ui/core/components/Icons/types'; const TabTitleWrapper = styled.div` display: flex; diff --git a/superset-frontend/src/SqlLab/components/TabbedSqlEditors/index.tsx b/superset-frontend/src/SqlLab/components/TabbedSqlEditors/index.tsx index 9cb78f7e0b2..414cff18645 100644 --- a/superset-frontend/src/SqlLab/components/TabbedSqlEditors/index.tsx +++ b/superset-frontend/src/SqlLab/components/TabbedSqlEditors/index.tsx @@ -18,7 +18,7 @@ */ import { PureComponent } from 'react'; import { pick } from 'lodash'; -import { EditableTabs } from 'src/components/Tabs'; +import { EditableTabs } from '@superset-ui/core/components/Tabs'; import { connect } from 'react-redux'; import URI from 'urijs'; import type { QueryEditor, SqlLabRootState } from 'src/SqlLab/types'; @@ -30,13 +30,13 @@ import { css, } from '@superset-ui/core'; import { Logger } from 'src/logger/LogUtils'; -import { EmptyState, Tooltip } from 'src/components'; +import { EmptyState, Tooltip } from '@superset-ui/core/components'; import { detectOS } from 'src/utils/common'; import * as Actions from 'src/SqlLab/actions/sqlLab'; import getBootstrapData from 'src/utils/getBootstrapData'; import { locationContext } from 'src/pages/SqlLab/LocationContext'; import { navigateWithState } from 'src/utils/navigationUtils'; -import { Icons } from 'src/components/Icons'; +import { Icons } from '@superset-ui/core/components/Icons'; import SqlEditor from '../SqlEditor'; import SqlEditorTabHeader from '../SqlEditorTabHeader'; diff --git a/superset-frontend/src/SqlLab/components/TableElement/TableElement.test.tsx b/superset-frontend/src/SqlLab/components/TableElement/TableElement.test.tsx index 1e34738cf67..96f68b6666a 100644 --- a/superset-frontend/src/SqlLab/components/TableElement/TableElement.test.tsx +++ b/superset-frontend/src/SqlLab/components/TableElement/TableElement.test.tsx @@ -30,10 +30,10 @@ jest.mock('@superset-ui/core', () => ({ const mockedIsFeatureEnabled = isFeatureEnabled as jest.Mock; -jest.mock('src/components/Loading', () => ({ +jest.mock('@superset-ui/core/components/Loading', () => ({ Loading: () =>
, })); -jest.mock('src/components/IconTooltip', () => ({ +jest.mock('@superset-ui/core/components/IconTooltip', () => ({ IconTooltip: ({ onClick, tooltip, diff --git a/superset-frontend/src/SqlLab/components/TableElement/index.tsx b/superset-frontend/src/SqlLab/components/TableElement/index.tsx index 0deda9875bf..e15f4ccacad 100644 --- a/superset-frontend/src/SqlLab/components/TableElement/index.tsx +++ b/superset-frontend/src/SqlLab/components/TableElement/index.tsx @@ -26,12 +26,13 @@ import { Card, Collapse, Tooltip, - CopyToClipboard, Flex, IconTooltip, Loading, + ModalTrigger, type CollapseProps, -} from 'src/components'; +} from '@superset-ui/core/components'; +import { CopyToClipboard } from 'src/components'; import { t, styled, useTheme } from '@superset-ui/core'; import { debounce } from 'lodash'; @@ -46,11 +47,10 @@ import { useTableExtendedMetadataQuery, useTableMetadataQuery, } from 'src/hooks/apiResources'; -import ModalTrigger from 'src/components/ModalTrigger'; import useEffectEvent from 'src/hooks/useEffectEvent'; import { ActionType } from 'src/types/Action'; -import { Icons } from 'src/components/Icons'; -import { Space } from 'src/components/Space'; +import { Icons } from '@superset-ui/core/components/Icons'; +import { Space } from '@superset-ui/core/components/Space'; import ColumnElement, { ColumnKeyTypeType } from '../ColumnElement'; import ShowSQL from '../ShowSQL'; diff --git a/superset-frontend/src/SqlLab/components/TablePreview/TablePreview.test.tsx b/superset-frontend/src/SqlLab/components/TablePreview/TablePreview.test.tsx index 5c92308d36f..5f3a7f23c3c 100644 --- a/superset-frontend/src/SqlLab/components/TablePreview/TablePreview.test.tsx +++ b/superset-frontend/src/SqlLab/components/TablePreview/TablePreview.test.tsx @@ -45,7 +45,7 @@ jest.mock( ({ children }: { children: (params: { height: number }) => ReactChild }) => children({ height: 500 }), ); -jest.mock('src/components/IconTooltip', () => ({ +jest.mock('@superset-ui/core/components/IconTooltip', () => ({ IconTooltip: ({ onClick, tooltip, diff --git a/superset-frontend/src/SqlLab/components/TablePreview/index.tsx b/superset-frontend/src/SqlLab/components/TablePreview/index.tsx index d0364fcde52..2b409a8fcf3 100644 --- a/superset-frontend/src/SqlLab/components/TablePreview/index.tsx +++ b/superset-frontend/src/SqlLab/components/TablePreview/index.tsx @@ -25,24 +25,23 @@ import { ClientErrorObject, css, getExtensionsRegistry, - SafeMarkdown, styled, t, } from '@superset-ui/core'; -import AutoSizer from 'react-virtualized-auto-sizer'; -import { Icons } from 'src/components/Icons'; -import type { SqlLabRootState } from 'src/SqlLab/types'; import { + SafeMarkdown, Alert, Breadcrumb, Button, Card, - CopyToClipboard, Dropdown, - FilterableTable, Skeleton, -} from 'src/components'; -import Tabs from 'src/components/Tabs'; +} from '@superset-ui/core/components'; +import AutoSizer from 'react-virtualized-auto-sizer'; +import { Icons } from '@superset-ui/core/components/Icons'; +import type { SqlLabRootState } from 'src/SqlLab/types'; +import { CopyToClipboard, FilterableTable } from 'src/components'; +import Tabs from '@superset-ui/core/components/Tabs'; import { tableApiUtil, TableMetaData, @@ -50,7 +49,7 @@ import { useTableMetadataQuery, } from 'src/hooks/apiResources'; import { runTablePreviewQuery } from 'src/SqlLab/actions/sqlLab'; -import { Menu } from 'src/components/Menu'; +import { Menu } from '@superset-ui/core/components/Menu'; import ResultSet from '../ResultSet'; import ShowSQL from '../ShowSQL'; diff --git a/superset-frontend/src/SqlLab/components/TemplateParamsEditor/TemplateParamsEditor.test.tsx b/superset-frontend/src/SqlLab/components/TemplateParamsEditor/TemplateParamsEditor.test.tsx index cdafc5ba177..acada8b861c 100644 --- a/superset-frontend/src/SqlLab/components/TemplateParamsEditor/TemplateParamsEditor.test.tsx +++ b/superset-frontend/src/SqlLab/components/TemplateParamsEditor/TemplateParamsEditor.test.tsx @@ -32,13 +32,13 @@ import TemplateParamsEditor, { TemplateParamsEditorProps, } from 'src/SqlLab/components/TemplateParamsEditor'; -jest.mock('src/components/Select/Select', () => () => ( +jest.mock('@superset-ui/core/components/Select/Select', () => () => (
)); -jest.mock('src/components/Select/AsyncSelect', () => () => ( +jest.mock('@superset-ui/core/components/Select/AsyncSelect', () => () => (
)); -jest.mock('src/components/AsyncAceEditor', () => ({ +jest.mock('@superset-ui/core/components/AsyncAceEditor', () => ({ ConfigEditor: ({ value }: { value: string }) => (
{value}
), diff --git a/superset-frontend/src/SqlLab/components/TemplateParamsEditor/index.tsx b/superset-frontend/src/SqlLab/components/TemplateParamsEditor/index.tsx index 2f8019f4d17..e10e0c78e40 100644 --- a/superset-frontend/src/SqlLab/components/TemplateParamsEditor/index.tsx +++ b/superset-frontend/src/SqlLab/components/TemplateParamsEditor/index.tsx @@ -18,11 +18,15 @@ */ import { useState, useEffect } from 'react'; import { t, styled } from '@superset-ui/core'; -import { InfoTooltipWithTrigger } from '@superset-ui/chart-controls'; import { debounce } from 'lodash'; -import { Badge, ConfigEditor, Tooltip } from 'src/components'; -import ModalTrigger from 'src/components/ModalTrigger'; -import { FAST_DEBOUNCE } from 'src/constants'; +import { + Badge, + ConfigEditor, + InfoTooltip, + ModalTrigger, + Tooltip, + Constants, +} from '@superset-ui/core/components'; import useQueryEditor from 'src/SqlLab/hooks/useQueryEditor'; const StyledConfigEditor = styled(ConfigEditor)` @@ -80,7 +84,7 @@ const TemplateParamsEditor = ({ mode={language} minLines={25} maxLines={50} - onChange={debounce(onChange, FAST_DEBOUNCE)} + onChange={debounce(onChange, Constants.FAST_DEBOUNCE)} width="100%" editorProps={{ $blockScrolling: true }} enableLiveAutocompletion @@ -105,7 +109,7 @@ const TemplateParamsEditor = ({ {t('Parameters ')} {!isValid && ( - = { offline: 'error', diff --git a/superset-frontend/src/SqlLab/reducers/sqlLab.js b/superset-frontend/src/SqlLab/reducers/sqlLab.js index e0bc4307dcc..c77f708653f 100644 --- a/superset-frontend/src/SqlLab/reducers/sqlLab.js +++ b/superset-frontend/src/SqlLab/reducers/sqlLab.js @@ -19,8 +19,8 @@ import { normalizeTimestamp, QueryState, t } from '@superset-ui/core'; import { isEqual, omit } from 'lodash'; import { shallowEqual } from 'react-redux'; +import { now } from '@superset-ui/core/utils/dates'; import * as actions from '../actions/sqlLab'; -import { now } from '../../utils/dates'; import { addToObject, alterInObject, diff --git a/superset-frontend/src/SqlLab/types.ts b/superset-frontend/src/SqlLab/types.ts index 6438db4e562..cc5a4469bea 100644 --- a/superset-frontend/src/SqlLab/types.ts +++ b/superset-frontend/src/SqlLab/types.ts @@ -22,7 +22,10 @@ import { UserWithPermissionsAndRoles, } from 'src/types/bootstrapTypes'; import { ToastType } from 'src/components/MessageToasts/types'; -import type { ButtonProps, DropdownButtonProps } from 'src/components'; +import type { + ButtonProps, + DropdownButtonProps, +} from '@superset-ui/core/components'; import type { TableMetaData } from 'src/hooks/apiResources'; export type QueryButtonProps = DropdownButtonProps | ButtonProps; diff --git a/superset-frontend/src/assets/branding/.!4592!superset-logo-horiz-apache-dark.png b/superset-frontend/src/assets/branding/.!4592!superset-logo-horiz-apache-dark.png new file mode 100644 index 00000000000..e69de29bb2d diff --git a/superset-frontend/src/assets/branding/.!4862!superset-logo-horiz-apache-dark.png b/superset-frontend/src/assets/branding/.!4862!superset-logo-horiz-apache-dark.png new file mode 100644 index 00000000000..e69de29bb2d diff --git a/superset-frontend/src/assets/branding/.!4993!superset-logo-horiz-apache-dark.png b/superset-frontend/src/assets/branding/.!4993!superset-logo-horiz-apache-dark.png new file mode 100644 index 00000000000..e69de29bb2d diff --git a/superset-frontend/src/components/AlteredSliceTag/index.tsx b/superset-frontend/src/components/AlteredSliceTag/index.tsx index be63b84eddb..43fd0d7a4f9 100644 --- a/superset-frontend/src/components/AlteredSliceTag/index.tsx +++ b/superset-frontend/src/components/AlteredSliceTag/index.tsx @@ -23,11 +23,13 @@ import { t } from '@superset-ui/core'; import { sanitizeFormData } from 'src/explore/exploreUtils/formData'; import getControlsForVizType from 'src/utils/getControlsForVizType'; import { safeStringify } from 'src/utils/safeStringify'; -import { Icons } from 'src/components/Icons'; -import { Label } from '../Label'; -import { Tooltip } from '../Tooltip'; -import ModalTrigger from '../ModalTrigger'; -import TableView from '../TableView'; +import { + Label, + Icons, + Tooltip, + ModalTrigger, + TableView, +} from '@superset-ui/core/components'; import type { AlteredSliceTagProps, ControlMap, diff --git a/superset-frontend/src/components/AuditInfo/ModifiedInfo.test.tsx b/superset-frontend/src/components/AuditInfo/ModifiedInfo.test.tsx index 11f9e95ca2e..177772b4df6 100644 --- a/superset-frontend/src/components/AuditInfo/ModifiedInfo.test.tsx +++ b/superset-frontend/src/components/AuditInfo/ModifiedInfo.test.tsx @@ -39,7 +39,7 @@ test('should render a tooltip when user is provided', async () => { expect(dateElement).toBeInTheDocument(); expect(screen.getByText(TEST_DATE)).toBeInTheDocument(); expect(screen.queryByText('Modified by: Foo Bar')).not.toBeInTheDocument(); - userEvent.hover(dateElement); + await userEvent.hover(dateElement); const tooltip = await screen.findByRole('tooltip'); expect(tooltip).toBeInTheDocument(); expect(screen.getByText('Modified by: Foo Bar')).toBeInTheDocument(); @@ -51,7 +51,7 @@ test('should render only the date if username is not provided', async () => { const dateElement = screen.getByTestId('audit-info-date'); expect(dateElement).toBeInTheDocument(); expect(screen.getByText(TEST_DATE)).toBeInTheDocument(); - userEvent.hover(dateElement); + await userEvent.hover(dateElement); await waitFor( () => { const tooltip = screen.queryByRole('tooltip'); diff --git a/superset-frontend/src/components/AuditInfo/index.tsx b/superset-frontend/src/components/AuditInfo/index.tsx index 75aaa5d3936..2bb34906e23 100644 --- a/superset-frontend/src/components/AuditInfo/index.tsx +++ b/superset-frontend/src/components/AuditInfo/index.tsx @@ -18,7 +18,7 @@ */ import getOwnerName from 'src/utils/getOwnerName'; import { t } from '@superset-ui/core'; -import { Tooltip } from '../Tooltip'; +import { Tooltip } from '@superset-ui/core/components'; import type { ModifiedInfoProps } from './types'; export const ModifiedInfo = ({ user, date }: ModifiedInfoProps) => { diff --git a/superset-frontend/src/components/Chart/Chart.tsx b/superset-frontend/src/components/Chart/Chart.tsx index c7264a449f5..c4d89b5eb13 100644 --- a/superset-frontend/src/components/Chart/Chart.tsx +++ b/superset-frontend/src/components/Chart/Chart.tsx @@ -30,7 +30,8 @@ import { ChartDataResponse, } from '@superset-ui/core'; import { PLACEHOLDER_DATASOURCE } from 'src/dashboard/constants'; -import { EmptyState, ErrorBoundary, Loading } from 'src/components'; +import { EmptyState, Loading } from '@superset-ui/core/components'; +import { ErrorBoundary } 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 a1e08b3af17..5095da6c9c1 100644 --- a/superset-frontend/src/components/Chart/ChartContextMenu/ChartContextMenu.tsx +++ b/superset-frontend/src/components/Chart/ChartContextMenu/ChartContextMenu.tsx @@ -41,9 +41,9 @@ import { useTheme, } from '@superset-ui/core'; import { RootState } from 'src/dashboard/types'; -import { Menu } from 'src/components/Menu'; +import { Menu } from '@superset-ui/core/components/Menu'; import { usePermissions } from 'src/hooks/usePermissions'; -import { Dropdown } from 'src/components'; +import { Dropdown } from '@superset-ui/core/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 98c099d3266..40ce7a86527 100644 --- a/superset-frontend/src/components/Chart/ChartErrorMessage.test.tsx +++ b/superset-frontend/src/components/Chart/ChartErrorMessage.test.tsx @@ -23,7 +23,7 @@ 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 { getErrorMessageComponentRegistry } from 'src/components/ErrorMessage'; import { ChartErrorMessage } from './ChartErrorMessage'; // Mock the useChartOwnerNames hook diff --git a/superset-frontend/src/components/Chart/ChartRenderer.jsx b/superset-frontend/src/components/Chart/ChartRenderer.jsx index 9ac9029c9cf..4100e9b9aca 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'; +import { EmptyState } from '@superset-ui/core/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 fdaa296f4df..b74ccb7e172 100644 --- a/superset-frontend/src/components/Chart/DisabledMenuItemTooltip.tsx +++ b/superset-frontend/src/components/Chart/DisabledMenuItemTooltip.tsx @@ -19,8 +19,8 @@ import { ReactNode } from 'react'; import { css, SupersetTheme } from '@superset-ui/core'; -import { Icons } from 'src/components/Icons'; -import { Tooltip } from 'src/components'; +import { Icons } from '@superset-ui/core/components/Icons'; +import { Tooltip } from '@superset-ui/core/components'; export const MenuItemTooltip = ({ title, diff --git a/superset-frontend/src/components/Chart/DrillBy/DrillByMenuItems.test.tsx b/superset-frontend/src/components/Chart/DrillBy/DrillByMenuItems.test.tsx index ad3da909b2f..fd838f0108c 100644 --- a/superset-frontend/src/components/Chart/DrillBy/DrillByMenuItems.test.tsx +++ b/superset-frontend/src/components/Chart/DrillBy/DrillByMenuItems.test.tsx @@ -30,7 +30,7 @@ import { waitFor, } from 'spec/helpers/testing-library'; import chartQueries, { sliceId } from 'spec/fixtures/mockChartQueries'; -import { Menu } from 'src/components/Menu'; +import { Menu } from '@superset-ui/core/components/Menu'; import { supersetGetCache } from 'src/utils/cachedSupersetGet'; import { DrillByMenuItems, DrillByMenuItemsProps } from './DrillByMenuItems'; diff --git a/superset-frontend/src/components/Chart/DrillBy/DrillByMenuItems.tsx b/superset-frontend/src/components/Chart/DrillBy/DrillByMenuItems.tsx index f2bf2128435..c0ffc795e26 100644 --- a/superset-frontend/src/components/Chart/DrillBy/DrillByMenuItems.tsx +++ b/superset-frontend/src/components/Chart/DrillBy/DrillByMenuItems.tsx @@ -26,13 +26,12 @@ import { useRef, useState, } from 'react'; -import { Menu } from 'src/components/Menu'; +import { Menu } from '@superset-ui/core/components/Menu'; import { BaseFormData, Behavior, Column, ContextMenuFilters, - FAST_DEBOUNCE, JsonResponse, css, ensureIsArray, @@ -42,12 +41,12 @@ import { t, useTheme, } from '@superset-ui/core'; +import { Constants, Input, Loading } from '@superset-ui/core/components'; import rison from 'rison'; import { debounce } from 'lodash'; import { FixedSizeList as List } from 'react-window'; -import { Icons } from 'src/components/Icons'; +import { Icons } from '@superset-ui/core/components/Icons'; import { useToasts } from 'src/components/MessageToasts/withToasts'; -import { Input, Loading } from 'src/components'; import { cachedSupersetGet, supersetGetCache, @@ -203,7 +202,7 @@ export const DrillByMenuItems = ({ () => debounce((value: string) => { setDebouncedSearchInput(value); - }, FAST_DEBOUNCE), + }, Constants.FAST_DEBOUNCE), [], ); diff --git a/superset-frontend/src/components/Chart/DrillBy/DrillByModal.tsx b/superset-frontend/src/components/Chart/DrillBy/DrillByModal.tsx index 305e8a0b710..f990ec3529b 100644 --- a/superset-frontend/src/components/Chart/DrillBy/DrillByModal.tsx +++ b/superset-frontend/src/components/Chart/DrillBy/DrillByModal.tsx @@ -40,7 +40,7 @@ import { Loading, Breadcrumb, Flex, -} from 'src/components'; +} from '@superset-ui/core/components'; import { RootState } from 'src/dashboard/types'; import { DashboardPageIdContext } from 'src/dashboard/containers/DashboardPage'; import { postFormData } from 'src/explore/exploreUtils/formData'; diff --git a/superset-frontend/src/components/Chart/DrillBy/useDisplayModeToggle.tsx b/superset-frontend/src/components/Chart/DrillBy/useDisplayModeToggle.tsx index addd4fd1c58..e8fb13e0163 100644 --- a/superset-frontend/src/components/Chart/DrillBy/useDisplayModeToggle.tsx +++ b/superset-frontend/src/components/Chart/DrillBy/useDisplayModeToggle.tsx @@ -19,7 +19,7 @@ import { useMemo, useState } from 'react'; import { css, SupersetTheme, t } from '@superset-ui/core'; -import { Radio } from 'src/components/Radio'; +import { Radio } from '@superset-ui/core/components/Radio'; import { DrillByType } from '../types'; export const useDisplayModeToggle = () => { diff --git a/superset-frontend/src/components/Chart/DrillBy/useResultsTableView.tsx b/superset-frontend/src/components/Chart/DrillBy/useResultsTableView.tsx index 8635c8981b1..bda96d35aa8 100644 --- a/superset-frontend/src/components/Chart/DrillBy/useResultsTableView.tsx +++ b/superset-frontend/src/components/Chart/DrillBy/useResultsTableView.tsx @@ -18,7 +18,7 @@ */ import { css, styled, isDefined, QueryData, t } from '@superset-ui/core'; import { SingleQueryResultPane } from 'src/explore/components/DataTablesPane/components/SingleQueryResultPane'; -import Tabs from 'src/components/Tabs'; +import Tabs from '@superset-ui/core/components/Tabs'; const DATA_SIZE = 15; diff --git a/superset-frontend/src/components/Chart/DrillDetail/DrillDetailMenuItems.test.tsx b/superset-frontend/src/components/Chart/DrillDetail/DrillDetailMenuItems.test.tsx index 31f8f14803e..db5cd63b986 100644 --- a/superset-frontend/src/components/Chart/DrillDetail/DrillDetailMenuItems.test.tsx +++ b/superset-frontend/src/components/Chart/DrillDetail/DrillDetailMenuItems.test.tsx @@ -28,7 +28,7 @@ import setupPlugins from 'src/setup/setupPlugins'; import { getMockStoreWithNativeFilters } from 'spec/fixtures/mockStore'; import chartQueries, { sliceId } from 'spec/fixtures/mockChartQueries'; import { BinaryQueryObjectFilterClause, VizType } from '@superset-ui/core'; -import { Menu } from 'src/components/Menu'; +import { Menu } from '@superset-ui/core/components/Menu'; import DrillDetailMenuItems, { DrillDetailMenuItemsProps, } from './DrillDetailMenuItems'; diff --git a/superset-frontend/src/components/Chart/DrillDetail/DrillDetailMenuItems.tsx b/superset-frontend/src/components/Chart/DrillDetail/DrillDetailMenuItems.tsx index 1059fc89517..6fef045ceaa 100644 --- a/superset-frontend/src/components/Chart/DrillDetail/DrillDetailMenuItems.tsx +++ b/superset-frontend/src/components/Chart/DrillDetail/DrillDetailMenuItems.tsx @@ -37,7 +37,7 @@ import { t, } from '@superset-ui/core'; import { useSelector } from 'react-redux'; -import { Menu } from 'src/components/Menu'; +import { Menu } from '@superset-ui/core/components/Menu'; import { RootState } from 'src/dashboard/types'; import { getSubmenuYOffset } from '../utils'; import { MenuItemTooltip } from '../DisabledMenuItemTooltip'; diff --git a/superset-frontend/src/components/Chart/DrillDetail/DrillDetailModal.tsx b/superset-frontend/src/components/Chart/DrillDetail/DrillDetailModal.tsx index a826216ac06..915e968609c 100644 --- a/superset-frontend/src/components/Chart/DrillDetail/DrillDetailModal.tsx +++ b/superset-frontend/src/components/Chart/DrillDetail/DrillDetailModal.tsx @@ -26,7 +26,7 @@ import { t, useTheme, } from '@superset-ui/core'; -import { Button, Modal } from 'src/components'; +import { Button, Modal } from '@superset-ui/core/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 191423f805f..62b82f03e27 100644 --- a/superset-frontend/src/components/Chart/DrillDetail/DrillDetailPane.tsx +++ b/superset-frontend/src/components/Chart/DrillDetail/DrillDetailPane.tsx @@ -37,13 +37,16 @@ import { useTheme, } from '@superset-ui/core'; import { useResizeDetector } from 'react-resize-detector'; -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, Loading } from 'src/components'; +import BooleanCell from '@superset-ui/core/components/Table/cell-renderers/BooleanCell'; +import NullCell from '@superset-ui/core/components/Table/cell-renderers/NullCell'; +import TimeCell from '@superset-ui/core/components/Table/cell-renderers/TimeCell'; +import { EmptyState, Loading } from '@superset-ui/core/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'; +import Table, { + ColumnsType, + TableSize, +} from '@superset-ui/core/components/Table'; +import HeaderWithRadioGroup from '@superset-ui/core/components/Table/header-renderers/HeaderWithRadioGroup'; import { ResourceStatus } from 'src/hooks/apiResources/apiResources'; import { useDatasetMetadataBar } from 'src/features/datasets/metadataBar/useDatasetMetadataBar'; import TableControls from './DrillDetailTableControls'; diff --git a/superset-frontend/src/components/Chart/DrillDetail/DrillDetailTableControls.tsx b/superset-frontend/src/components/Chart/DrillDetail/DrillDetailTableControls.tsx index eecf312e14f..27f3fee8e01 100644 --- a/superset-frontend/src/components/Chart/DrillDetail/DrillDetailTableControls.tsx +++ b/superset-frontend/src/components/Chart/DrillDetail/DrillDetailTableControls.tsx @@ -27,7 +27,7 @@ import { useTheme, } from '@superset-ui/core'; import RowCountLabel from 'src/explore/components/RowCountLabel'; -import { Icons } from 'src/components/Icons'; +import { Icons } from '@superset-ui/core/components/Icons'; export type TableControlsProps = { filters: BinaryQueryObjectFilterClause[]; diff --git a/superset-frontend/src/components/Chart/MenuItemWithTruncation.tsx b/superset-frontend/src/components/Chart/MenuItemWithTruncation.tsx index 29102cbe050..89e246ed1b5 100644 --- a/superset-frontend/src/components/Chart/MenuItemWithTruncation.tsx +++ b/superset-frontend/src/components/Chart/MenuItemWithTruncation.tsx @@ -19,8 +19,8 @@ import { ReactNode, CSSProperties } from 'react'; import { css, truncationCSS, useCSSTextTruncation } from '@superset-ui/core'; -import { Menu } from 'src/components/Menu'; -import { Tooltip } from 'src/components'; +import { Menu } from '@superset-ui/core/components/Menu'; +import { Tooltip } from '@superset-ui/core/components'; import { MenuItemProps } from 'antd'; export type MenuItemWithTruncationProps = { diff --git a/superset-frontend/src/components/Chart/chartAction.js b/superset-frontend/src/components/Chart/chartAction.js index a12ae44e2b1..575402b525f 100644 --- a/superset-frontend/src/components/Chart/chartAction.js +++ b/superset-frontend/src/components/Chart/chartAction.js @@ -43,7 +43,7 @@ import { updateDataMask } from 'src/dataMask/actions'; import { waitForAsyncData } from 'src/middleware/asyncEvent'; import { ensureAppRoot } from 'src/utils/pathUtils'; import { safeStringify } from 'src/utils/safeStringify'; -import { extendedDayjs } from 'src/utils/dates'; +import { extendedDayjs } from '@superset-ui/core/utils/dates'; export const CHART_UPDATE_STARTED = 'CHART_UPDATE_STARTED'; export function chartUpdateStarted(queryController, latestQueryFormData, key) { diff --git a/superset-frontend/src/components/Chart/chartReducer.ts b/superset-frontend/src/components/Chart/chartReducer.ts index 997c5bf7b7c..081bd415472 100644 --- a/superset-frontend/src/components/Chart/chartReducer.ts +++ b/superset-frontend/src/components/Chart/chartReducer.ts @@ -24,7 +24,7 @@ import { DatasourcesAction } from 'src/dashboard/actions/datasources'; import { ChartState } from 'src/explore/types'; import { getFormDataFromControls } from 'src/explore/controlUtils'; import { HYDRATE_EXPLORE } from 'src/explore/actions/hydrateExplore'; -import { now } from 'src/utils/dates'; +import { now } from '@superset-ui/core/utils/dates'; import * as actions from './chartAction'; export const chart: ChartState = { diff --git a/superset-frontend/src/components/CopyToClipboard/CopyToClipboard.stories.tsx b/superset-frontend/src/components/CopyToClipboard/CopyToClipboard.stories.tsx index c725ce032df..64ea320157a 100644 --- a/superset-frontend/src/components/CopyToClipboard/CopyToClipboard.stories.tsx +++ b/superset-frontend/src/components/CopyToClipboard/CopyToClipboard.stories.tsx @@ -16,9 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -import { Icons } from 'src/components/Icons'; +import { Icons } from '@superset-ui/core/components/Icons'; import ToastContainer from 'src/components/MessageToasts/ToastContainer'; -import { Button } from '../Button'; +import { Button } from '@superset-ui/core/components'; import { CopyToClipboard } from '.'; export default { diff --git a/superset-frontend/src/components/CopyToClipboard/index.tsx b/superset-frontend/src/components/CopyToClipboard/index.tsx index 019bdc3b0b6..92263d261f7 100644 --- a/superset-frontend/src/components/CopyToClipboard/index.tsx +++ b/superset-frontend/src/components/CopyToClipboard/index.tsx @@ -19,8 +19,8 @@ import { Component, cloneElement, ReactElement } from 'react'; import { t } from '@superset-ui/core'; import copyTextToClipboard from 'src/utils/copy'; +import { Tooltip } from '@superset-ui/core/components'; import withToasts from '../MessageToasts/withToasts'; -import { Tooltip } from '../Tooltip'; import type { CopyToClipboardProps } from './types'; const defaultProps: Partial = { diff --git a/superset-frontend/src/components/DatabaseSelector/DatabaseSelector.test.tsx b/superset-frontend/src/components/DatabaseSelector/DatabaseSelector.test.tsx index 957d5c33f32..a409f3a4576 100644 --- a/superset-frontend/src/components/DatabaseSelector/DatabaseSelector.test.tsx +++ b/superset-frontend/src/components/DatabaseSelector/DatabaseSelector.test.tsx @@ -27,7 +27,7 @@ import { waitFor, } from 'spec/helpers/testing-library'; import { api } from 'src/hooks/apiResources/queryApi'; -import { EmptyState } from '../EmptyState'; +import { EmptyState } from '@superset-ui/core/components'; import { DatabaseSelector } from '.'; import type { DatabaseSelectorProps } from './types'; @@ -215,7 +215,7 @@ test('Refresh should work', async () => { name: 'Select schema or type to search schemas', }); - userEvent.click(select); + await userEvent.click(select); await waitFor(() => { expect(fetchMock.calls(databaseApiRoute).length).toBe(1); @@ -226,7 +226,7 @@ test('Refresh should work', async () => { }); // click schema reload - userEvent.click(screen.getByRole('button', { name: 'sync' })); + await userEvent.click(screen.getByRole('button', { name: 'sync' })); await waitFor(() => { expect(fetchMock.calls(databaseApiRoute).length).toBe(1); @@ -244,7 +244,7 @@ test('Should database select display options', async () => { name: 'Select database or type to search databases', }); expect(select).toBeInTheDocument(); - userEvent.click(select); + await userEvent.click(select); expect(await screen.findByText('test-mysql')).toBeInTheDocument(); }); @@ -261,7 +261,7 @@ test('should display options in order of the api response', async () => { name: 'Select database or type to search databases', }); expect(select).toBeInTheDocument(); - userEvent.click(select); + await userEvent.click(select); const options = await screen.findAllByRole('option'); expect(options[0]).toHaveTextContent( @@ -291,7 +291,7 @@ test('Should fetch the search keyword when total count exceeds initial options', expect(fetchMock.calls(databaseApiRoute)).toHaveLength(1), ); expect(select).toBeInTheDocument(); - userEvent.type(select, 'keywordtest'); + await userEvent.type(select, 'keywordtest'); await waitFor(() => expect(fetchMock.calls(databaseApiRoute)).toHaveLength(2), ); @@ -315,7 +315,7 @@ test('should show empty state if there are no options', async () => { const select = screen.getByRole('combobox', { name: 'Select database or type to search databases', }); - userEvent.click(select); + await userEvent.click(select); const emptystate = await screen.findByText('empty'); expect(emptystate).toBeInTheDocument(); expect(screen.queryByText('test-mysql')).not.toBeInTheDocument(); @@ -328,7 +328,7 @@ test('Should schema select display options', async () => { name: 'Select schema or type to search schemas', }); expect(select).toBeInTheDocument(); - userEvent.click(select); + await userEvent.click(select); await waitFor(() => { expect(screen.queryByText('Loading...')).not.toBeInTheDocument(); }); @@ -348,8 +348,8 @@ test('Sends the correct db when changing the database', async () => { name: 'Select database or type to search databases', }); expect(select).toBeInTheDocument(); - userEvent.click(select); - userEvent.click(await screen.findByText('test-mysql')); + await userEvent.click(select); + await userEvent.click(await screen.findByText('test-mysql')); await waitFor(() => expect(props.onDbChange).toHaveBeenCalledWith( expect.objectContaining({ @@ -374,9 +374,9 @@ test('Sends the correct schema when changing the schema', async () => { name: 'Select schema or type to search schemas', }); expect(select).toBeInTheDocument(); - userEvent.click(select); + await userEvent.click(select); const schemaOption = await screen.findByText('information_schema'); - userEvent.click(schemaOption); + await userEvent.click(schemaOption); await waitFor(() => expect(props.onSchemaChange).toHaveBeenCalledWith('information_schema'), ); diff --git a/superset-frontend/src/components/DatabaseSelector/index.tsx b/superset-frontend/src/components/DatabaseSelector/index.tsx index 1399b8e91a1..7f7eb792bdb 100644 --- a/superset-frontend/src/components/DatabaseSelector/index.tsx +++ b/superset-frontend/src/components/DatabaseSelector/index.tsx @@ -26,7 +26,7 @@ import { } from 'react'; import { styled, SupersetClient, SupersetError, t } from '@superset-ui/core'; import rison from 'rison'; -import RefreshLabel from 'src/components/RefreshLabel'; +import RefreshLabel from '@superset-ui/core/components/RefreshLabel'; import { useToasts } from 'src/components/MessageToasts/withToasts'; import { useCatalogs, @@ -34,12 +34,15 @@ 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 { + Select, + AsyncSelect, + Label, + FormLabel, + LabeledValue as AntdLabeledValue, +} from '@superset-ui/core/components'; -import type { LabeledValue as AntdLabeledValue } from '../Select'; +import { ErrorMessageWithStackTrace } from 'src/components'; import type { DatabaseSelectorProps, DatabaseValue, diff --git a/superset-frontend/src/components/Datasource/ChangeDatasourceModal.tsx b/superset-frontend/src/components/Datasource/ChangeDatasourceModal.tsx index 8331ede7feb..e0cafe52e80 100644 --- a/superset-frontend/src/components/Datasource/ChangeDatasourceModal.tsx +++ b/superset-frontend/src/components/Datasource/ChangeDatasourceModal.tsx @@ -31,24 +31,30 @@ import { styled, getClientErrorObject, } from '@superset-ui/core'; -import TableView, { EmptyWrapperType } from 'src/components/TableView'; -import { ServerPagination, SortByType } from 'src/components/TableView/types'; +import { + Alert, + Button, + Constants, + EmptyWrapperType, + Input, + Loading, + Modal, + TableView, +} from '@superset-ui/core/components'; +import { + ServerPagination, + SortByType, +} from '@superset-ui/core/components/TableView/types'; +import { FacePile } from 'src/components'; 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 { 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'; -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( @@ -135,7 +141,7 @@ const ChangeDatasourceModal: FunctionComponent = ({ }), }); }, - SLOW_DEBOUNCE, + Constants.SLOW_DEBOUNCE, [filter, pageIndex, sortBy], ); diff --git a/superset-frontend/src/components/Datasource/CollectionTable.tsx b/superset-frontend/src/components/Datasource/CollectionTable.tsx index 63bfb2ebf9d..adb135a0ab7 100644 --- a/superset-frontend/src/components/Datasource/CollectionTable.tsx +++ b/superset-frontend/src/components/Datasource/CollectionTable.tsx @@ -20,12 +20,17 @@ import { PureComponent, ReactNode } from 'react'; import { nanoid } from 'nanoid'; -import { InfoTooltipWithTrigger } from '@superset-ui/chart-controls'; import { t, styled, css } from '@superset-ui/core'; -import { Icons } from 'src/components/Icons'; +import { Icons, Button, InfoTooltip } from '@superset-ui/core/components'; import { FilterValue } from 'react-table'; -import { Button } from '../Button'; +import Table, { + type ColumnsType, + type SortOrder, + type SorterResult, + type TablePaginationConfig, + TableSize, +} from '@superset-ui/core/components/Table'; import Fieldset from './Fieldset'; import { recurseReactClone } from './utils'; import { @@ -33,13 +38,6 @@ import { type CRUDCollectionState, type Sort, } from './types'; -import Table, { - type ColumnsType, - type SortOrder, - type SorterResult, - type TablePaginationConfig, - TableSize, -} from '../Table'; const CrudButtonWrapper = styled.div` text-align: right; @@ -324,7 +322,7 @@ export default class CRUDCollection extends PureComponent< {tooltip && ( <> {' '} - ({ ...jest.requireActual('@superset-ui/core'), isFeatureEnabled: jest.fn(), @@ -64,7 +67,7 @@ describe('DatasourceEditor', () => { afterEach(() => { fetchMock.restore(); - jest.clearAllMocks(); + // jest.clearAllMocks(); }); it('renders Tabs', () => { @@ -73,7 +76,7 @@ describe('DatasourceEditor', () => { it('can sync columns from source', async () => { const columnsTab = screen.getByTestId('collection-tab-Columns'); - userEvent.click(columnsTab); + await userEvent.click(columnsTab); const syncButton = screen.getByText(/sync columns from source/i); expect(syncButton).toBeInTheDocument(); @@ -90,7 +93,7 @@ describe('DatasourceEditor', () => { ); }); - userEvent.click(syncButton); + await userEvent.click(syncButton); // Wait for the fetch to be called const url = await fetchPromise; @@ -100,12 +103,12 @@ describe('DatasourceEditor', () => { // to add, remove and modify columns accordingly it('can modify columns', async () => { const columnsTab = screen.getByTestId('collection-tab-Columns'); - userEvent.click(columnsTab); + await userEvent.click(columnsTab); const getToggles = screen.getAllByRole('button', { name: /expand row/i, }); - userEvent.click(getToggles[0]); + await userEvent.click(getToggles[0]); const getTextboxes = await screen.findAllByRole('textbox'); expect(getTextboxes.length).toBeGreaterThanOrEqual(5); @@ -118,22 +121,22 @@ describe('DatasourceEditor', () => { 'Certification details', ); - userEvent.type(inputLabel, 'test_label'); - userEvent.type(inputDescription, 'test'); - userEvent.type(inputDtmFormat, 'test'); - userEvent.type(inputCertifiedBy, 'test'); - userEvent.type(inputCertDetails, 'test'); + await userEvent.type(inputLabel, 'test_label'); + await userEvent.type(inputDescription, 'test'); + await userEvent.type(inputDtmFormat, 'test'); + await userEvent.type(inputCertifiedBy, 'test'); + await userEvent.type(inputCertDetails, 'test'); }); it('can delete columns', async () => { const columnsTab = screen.getByTestId('collection-tab-Columns'); - userEvent.click(columnsTab); + await userEvent.click(columnsTab); const getToggles = screen.getAllByRole('button', { name: /expand row/i, }); - userEvent.click(getToggles[0]); + await userEvent.click(getToggles[0]); const deleteButtons = await screen.findAllByRole('button', { name: /delete item/i, @@ -141,7 +144,7 @@ describe('DatasourceEditor', () => { const initialCount = deleteButtons.length; expect(initialCount).toBeGreaterThan(0); - userEvent.click(deleteButtons[0]); + await userEvent.click(deleteButtons[0]); await waitFor(() => { const countRows = screen.getAllByRole('button', { name: /delete item/i }); @@ -151,14 +154,14 @@ describe('DatasourceEditor', () => { it('can add new columns', async () => { const calcColsTab = screen.getByTestId('collection-tab-Calculated columns'); - userEvent.click(calcColsTab); + await userEvent.click(calcColsTab); const addBtn = screen.getByRole('button', { name: /add item/i, }); expect(addBtn).toBeInTheDocument(); - userEvent.click(addBtn); + await userEvent.click(addBtn); // newColumn (Column name) is the first textbox in the tab await waitFor(() => { @@ -167,11 +170,11 @@ describe('DatasourceEditor', () => { }); }); - it('renders isSqla fields', () => { + it('renders isSqla fields', async () => { const columnsTab = screen.getByRole('tab', { name: /settings/i, }); - userEvent.click(columnsTab); + await userEvent.click(columnsTab); const extraField = screen.getAllByText(/extra/i); expect(extraField.length).toBeGreaterThan(0); @@ -203,9 +206,9 @@ describe('DatasourceEditor Source Tab', () => { isFeatureEnabled.mockRestore(); }); - it('Source Tab: edit mode', () => { + it('Source Tab: edit mode', async () => { const getLockBtn = screen.getByRole('img', { name: /lock/i }); - userEvent.click(getLockBtn); + await userEvent.click(getLockBtn); const physicalRadioBtn = screen.getByRole('radio', { name: /physical \(table or view\)/i, diff --git a/superset-frontend/src/components/Datasource/DatasourceEditorCurrency.test.jsx b/superset-frontend/src/components/Datasource/DatasourceEditorCurrency.test.jsx index 6ccf06c17a6..9fdff4fb3c0 100644 --- a/superset-frontend/src/components/Datasource/DatasourceEditorCurrency.test.jsx +++ b/superset-frontend/src/components/Datasource/DatasourceEditorCurrency.test.jsx @@ -19,7 +19,7 @@ import fetchMock from 'fetch-mock'; import { render, screen, waitFor } from 'spec/helpers/testing-library'; import userEvent from '@testing-library/user-event'; -import DatasourceEditor from 'src/components/Datasource/DatasourceEditor'; +import DatasourceEditor from './DatasourceEditor'; import { props, DATASOURCE_ENDPOINT } from './DatasourceEditor.test'; // Optimized render function that doesn't use waitFor initially diff --git a/superset-frontend/src/components/Datasource/DatasourceEditorRTL.test.jsx b/superset-frontend/src/components/Datasource/DatasourceEditorRTL.test.jsx index 41f46110a7b..5a4b869e7a7 100644 --- a/superset-frontend/src/components/Datasource/DatasourceEditorRTL.test.jsx +++ b/superset-frontend/src/components/Datasource/DatasourceEditorRTL.test.jsx @@ -17,8 +17,7 @@ * under the License. */ import fetchMock from 'fetch-mock'; -import { screen, waitFor } from 'spec/helpers/testing-library'; -import userEvent from '@testing-library/user-event'; +import { screen, userEvent, waitFor } from 'spec/helpers/testing-library'; import { props, asyncRender, @@ -39,10 +38,10 @@ describe('DatasourceEditor RTL Metrics Tests', () => { await asyncRender(props); const metricButton = screen.getByTestId('collection-tab-Metrics'); - userEvent.click(metricButton); + await userEvent.click(metricButton); const expandToggle = await screen.findAllByLabelText(/expand row/i); - userEvent.click(expandToggle[0]); + await userEvent.click(expandToggle[0]); const certificationDetails = await screen.findByPlaceholderText( /certification details/i, @@ -57,15 +56,15 @@ describe('DatasourceEditor RTL Metrics Tests', () => { await asyncRender(props); const metricButton = screen.getByTestId('collection-tab-Metrics'); - userEvent.click(metricButton); + await userEvent.click(metricButton); const expandToggle = await screen.findAllByLabelText(/expand row/i); - userEvent.click(expandToggle[1]); + await userEvent.click(expandToggle[1]); const certifiedBy = await screen.findByPlaceholderText(/certified by/i); // Use userEvent.clear and userEvent.type instead of directly setting value - userEvent.clear(certifiedBy); - userEvent.type(certifiedBy, 'I am typing a new name'); + await userEvent.clear(certifiedBy); + await userEvent.type(certifiedBy, 'I am typing a new name'); const certificationDetails = await screen.findByPlaceholderText( /certification details/i, @@ -74,8 +73,8 @@ describe('DatasourceEditor RTL Metrics Tests', () => { expect(certifiedBy.value).toEqual('I am typing a new name'); }); - userEvent.clear(certificationDetails); - userEvent.type(certificationDetails, 'I am typing something new'); + await userEvent.clear(certificationDetails); + await userEvent.type(certificationDetails, 'I am typing something new'); await waitFor(() => { expect(certificationDetails.value).toEqual('I am typing something new'); @@ -97,7 +96,7 @@ describe('DatasourceEditor RTL Columns Tests', () => { await asyncRender(props); const columnsButton = screen.getByTestId('collection-tab-Columns'); - userEvent.click(columnsButton); + await userEvent.click(columnsButton); const dsDefaultDatetimeRadio = screen.getByTestId('radio-default-dttm-ds'); expect(dsDefaultDatetimeRadio).toBeChecked(); @@ -112,7 +111,7 @@ describe('DatasourceEditor RTL Columns Tests', () => { await asyncRender(props); const columnsButton = screen.getByTestId('collection-tab-Columns'); - userEvent.click(columnsButton); + await userEvent.click(columnsButton); const dsDefaultDatetimeRadio = screen.getByTestId('radio-default-dttm-ds'); expect(dsDefaultDatetimeRadio).toBeEnabled(); diff --git a/superset-frontend/src/components/Datasource/DatasourceModal.tsx b/superset-frontend/src/components/Datasource/DatasourceModal.tsx index 02ec1fbc49d..b5db44b8b16 100644 --- a/superset-frontend/src/components/Datasource/DatasourceModal.tsx +++ b/superset-frontend/src/components/Datasource/DatasourceModal.tsx @@ -29,8 +29,15 @@ import { css, } from '@superset-ui/core'; -import { Icons } from 'src/components/Icons'; +import { + Icons, + Alert, + Button, + Modal, + AsyncEsmComponent, +} from '@superset-ui/core/components'; import withToasts from 'src/components/MessageToasts/withToasts'; +import { ErrorMessageWithStackTrace } from 'src/components'; import { startMetaDataLoading, stopMetaDataLoading, @@ -41,11 +48,6 @@ import { updateColumns, } from 'src/components/Datasource/utils'; 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')); diff --git a/superset-frontend/src/components/Datasource/Field.test.tsx b/superset-frontend/src/components/Datasource/Field.test.tsx index f04af96c231..3f2d3ee8c98 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 '../Input'; +import { Input } from '@superset-ui/core/components'; import Field from './Field'; diff --git a/superset-frontend/src/components/Datasource/Field.tsx b/superset-frontend/src/components/Datasource/Field.tsx index a392dadd7c6..e228f378479 100644 --- a/superset-frontend/src/components/Datasource/Field.tsx +++ b/superset-frontend/src/components/Datasource/Field.tsx @@ -19,9 +19,12 @@ import { useCallback, ReactNode, ReactElement, cloneElement } from 'react'; import { css, SupersetTheme, useTheme } from '@superset-ui/core'; -import { Icons } from 'src/components/Icons'; -import { FormItem, FormLabel } from '../Form'; -import { Tooltip } from '../Tooltip'; +import { + Icons, + Tooltip, + FormItem, + FormLabel, +} from '@superset-ui/core/components'; const formItemInlineCss = css` .ant-form-item-control-input-content { diff --git a/superset-frontend/src/components/Datasource/Fieldset.tsx b/superset-frontend/src/components/Datasource/Fieldset.tsx index 4ca185b1354..cf1efd4434d 100644 --- a/superset-frontend/src/components/Datasource/Fieldset.tsx +++ b/superset-frontend/src/components/Datasource/Fieldset.tsx @@ -17,11 +17,9 @@ * under the License. */ import { ReactNode, useCallback } from 'react'; -import { Divider } from '../Divider'; -import { Typography } from '../Typography'; +import { Divider, Form, Typography } from '@superset-ui/core/components'; import { recurseReactClone } from './utils'; import Field from './Field'; -import { Form } from '../Form'; interface FieldsetProps { children: ReactNode; diff --git a/superset-frontend/src/components/DropdownContainer/DropdownContainer.test.tsx b/superset-frontend/src/components/DropdownContainer/DropdownContainer.test.tsx deleted file mode 100644 index 69dcba0f340..00000000000 --- a/superset-frontend/src/components/DropdownContainer/DropdownContainer.test.tsx +++ /dev/null @@ -1,157 +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 { screen, render, userEvent } from 'spec/helpers/testing-library'; -import { Icons } from 'src/components/Icons'; -import { Button } from '../Button'; -import { DropdownContainer } from '.'; - -const generateItems = (n: number) => - Array.from({ length: n }).map((_, i) => ({ - id: `el-${i + 1}`, - element: , - })); - -const ITEMS = generateItems(10); - -const mockOverflowingIndex = async ( - overflowingIndex: number, - func: Function, -) => { - const spy = jest.spyOn(global.React, 'useState'); - spy.mockImplementation(() => [overflowingIndex, jest.fn()]); - await func(); - spy.mockRestore(); -}; - -test('renders children', () => { - render(); - expect(screen.getByText('Element 1')).toBeInTheDocument(); - expect(screen.getByText('Element 2')).toBeInTheDocument(); - expect(screen.getByText('Element 3')).toBeInTheDocument(); -}); - -test('renders children with custom horizontal spacing', () => { - render(); - expect(screen.getByTestId('container')).toHaveStyle('gap: 20px'); -}); - -test('renders a dropdown trigger when overflowing', async () => { - await mockOverflowingIndex(3, () => { - render(); - expect(screen.getByText('More')).toBeInTheDocument(); - }); -}); - -test('renders a dropdown trigger with custom icon', async () => { - await mockOverflowingIndex(3, async () => { - render( - } - />, - ); - expect( - await screen.findByRole('img', { name: 'link' }), - ).toBeInTheDocument(); - }); -}); - -test('renders a dropdown trigger with custom text', async () => { - await mockOverflowingIndex(3, () => { - const customText = 'Custom text'; - render( - , - ); - expect(screen.getByText(customText)).toBeInTheDocument(); - }); -}); - -test('renders a dropdown trigger with custom count', async () => { - await mockOverflowingIndex(3, () => { - const customCount = 99; - render( - , - ); - expect(screen.getByTitle(customCount)).toBeInTheDocument(); - }); -}); - -test('does not render a dropdown button when not overflowing', () => { - render(); - expect(screen.queryByText('More')).not.toBeInTheDocument(); -}); - -test('renders a dropdown when overflowing', async () => { - await mockOverflowingIndex(3, () => { - render(); - userEvent.click(screen.getByText('More')); - expect(screen.getByTestId('dropdown-content')).toBeInTheDocument(); - }); -}); - -test('renders children with custom vertical spacing', async () => { - await mockOverflowingIndex(3, () => { - render(); - userEvent.click(screen.getByText('More')); - expect(screen.getByTestId('dropdown-content')).toHaveStyle('gap: 20px'); - }); -}); - -test('fires event when overflowing state changes', async () => { - await mockOverflowingIndex(3, () => { - const onOverflowingStateChange = jest.fn(); - render( - , - ); - expect(onOverflowingStateChange).toHaveBeenCalledWith({ - notOverflowed: ['el-1', 'el-2', 'el-3'], - overflowed: ['el-4', 'el-5'], - }); - }); -}); - -test('renders a dropdown with custom content', async () => { - await mockOverflowingIndex(3, () => { - const customDropdownContent =
Custom content
; - render( - customDropdownContent} - />, - ); - userEvent.click(screen.getByText('More')); - expect(screen.getByText('Custom content')).toBeInTheDocument(); - }); -}); - -test('Shows tooltip on dropdown trigger hover', async () => { - await mockOverflowingIndex(3, async () => { - render( - , - ); - userEvent.hover(screen.getByText('More')); - expect(await screen.findByText('Test tooltip')).toBeInTheDocument(); - }); -}); diff --git a/superset-frontend/src/components/ErrorMessage/BasicErrorAlert.test.tsx b/superset-frontend/src/components/ErrorMessage/BasicErrorAlert.test.tsx index 3b9f1a70490..17048e1e53a 100644 --- a/superset-frontend/src/components/ErrorMessage/BasicErrorAlert.test.tsx +++ b/superset-frontend/src/components/ErrorMessage/BasicErrorAlert.test.tsx @@ -22,7 +22,7 @@ import { ErrorLevel, supersetTheme } from '@superset-ui/core'; import { BasicErrorAlert } from './BasicErrorAlert'; jest.mock( - 'src/components/Icons/AsyncIcon', + '@superset-ui/core/components/Icons/AsyncIcon', () => ({ fileName }: { fileName: string }) => ( diff --git a/superset-frontend/src/components/ErrorMessage/BasicErrorAlert.tsx b/superset-frontend/src/components/ErrorMessage/BasicErrorAlert.tsx index 27a90054b61..218fbfd43df 100644 --- a/superset-frontend/src/components/ErrorMessage/BasicErrorAlert.tsx +++ b/superset-frontend/src/components/ErrorMessage/BasicErrorAlert.tsx @@ -17,7 +17,7 @@ * under the License. */ import { ErrorLevel, styled, themeObject, useTheme } from '@superset-ui/core'; -import { Icons } from 'src/components/Icons'; +import { Icons } from '@superset-ui/core/components'; const StyledContent = styled.div` display: flex; diff --git a/superset-frontend/src/components/ErrorMessage/DatabaseErrorMessage.test.tsx b/superset-frontend/src/components/ErrorMessage/DatabaseErrorMessage.test.tsx index fd8ddee9e0c..41367081224 100644 --- a/superset-frontend/src/components/ErrorMessage/DatabaseErrorMessage.test.tsx +++ b/superset-frontend/src/components/ErrorMessage/DatabaseErrorMessage.test.tsx @@ -22,7 +22,7 @@ import { render, screen, userEvent } from 'spec/helpers/testing-library'; import { DatabaseErrorMessage } from './DatabaseErrorMessage'; jest.mock( - 'src/components/Icons/AsyncIcon', + '@superset-ui/core/components/Icons/AsyncIcon', () => ({ fileName }: { fileName: string }) => ( diff --git a/superset-frontend/src/components/ErrorMessage/DatasetNotFoundErrorMessage.test.tsx b/superset-frontend/src/components/ErrorMessage/DatasetNotFoundErrorMessage.test.tsx index 76d5eefa416..cfe1b61a606 100644 --- a/superset-frontend/src/components/ErrorMessage/DatasetNotFoundErrorMessage.test.tsx +++ b/superset-frontend/src/components/ErrorMessage/DatasetNotFoundErrorMessage.test.tsx @@ -22,7 +22,7 @@ import { render, screen } from 'spec/helpers/testing-library'; import { DatasetNotFoundErrorMessage } from './DatasetNotFoundErrorMessage'; jest.mock( - 'src/components/Icons/AsyncIcon', + '@superset-ui/core/components/Icons/AsyncIcon', () => ({ fileName }: { fileName: string }) => ( diff --git a/superset-frontend/src/components/ErrorMessage/ErrorAlert.stories.tsx b/superset-frontend/src/components/ErrorMessage/ErrorAlert.stories.tsx index e746afd747b..5ae44b2f738 100644 --- a/superset-frontend/src/components/ErrorMessage/ErrorAlert.stories.tsx +++ b/superset-frontend/src/components/ErrorMessage/ErrorAlert.stories.tsx @@ -17,9 +17,7 @@ * under the License. */ import { Meta, StoryFn } from '@storybook/react'; -import { Layout } from '../Layout'; -import { Card } from '../Card'; -import { Row, Col } from '../Grid'; +import { Card, Col, Layout, Row } from '@superset-ui/core/components'; 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 b6f819f409d..2538b1e8008 100644 --- a/superset-frontend/src/components/ErrorMessage/ErrorAlert.test.tsx +++ b/superset-frontend/src/components/ErrorMessage/ErrorAlert.test.tsx @@ -17,8 +17,7 @@ * under the License. */ -import { screen, fireEvent } from '@testing-library/react'; -import { render } from 'spec/helpers/testing-library'; +import { screen, fireEvent, render } from 'spec/helpers/testing-library'; import { ErrorAlert } from './ErrorAlert'; describe('ErrorAlert', () => { diff --git a/superset-frontend/src/components/ErrorMessage/ErrorAlert.tsx b/superset-frontend/src/components/ErrorMessage/ErrorAlert.tsx index 1bb843fbc90..1c503de955c 100644 --- a/superset-frontend/src/components/ErrorMessage/ErrorAlert.tsx +++ b/superset-frontend/src/components/ErrorMessage/ErrorAlert.tsx @@ -17,13 +17,15 @@ * under the License. */ import { useState } from 'react'; -import { Icons } from 'src/components/Icons'; import { t, useTheme } from '@superset-ui/core'; -import { Tooltip } from '../Tooltip'; -import { Alert } from '../Alert'; -import { Modal } from '../Modal'; +import { + Alert, + Icons, + Modal, + Tooltip, + Typography, +} from '@superset-ui/core/components'; import type { ErrorAlertProps } from './types'; -import { Typography } from '../Typography'; export const ErrorAlert: React.FC = ({ errorType = t('Error'), diff --git a/superset-frontend/src/components/ErrorMessage/ErrorMessageWithStackTrace.test.tsx b/superset-frontend/src/components/ErrorMessage/ErrorMessageWithStackTrace.test.tsx index b9003b5bfec..b27ff32d00a 100644 --- a/superset-frontend/src/components/ErrorMessage/ErrorMessageWithStackTrace.test.tsx +++ b/superset-frontend/src/components/ErrorMessage/ErrorMessageWithStackTrace.test.tsx @@ -23,7 +23,7 @@ import { ErrorMessageWithStackTrace } from './ErrorMessageWithStackTrace'; import { BasicErrorAlert } from './BasicErrorAlert'; jest.mock( - 'src/components/Icons/AsyncIcon', + '@superset-ui/core/components/Icons/AsyncIcon', () => ({ fileName }: { fileName: string }) => ( diff --git a/superset-frontend/src/components/ErrorMessage/ErrorMessageWithStackTrace.tsx b/superset-frontend/src/components/ErrorMessage/ErrorMessageWithStackTrace.tsx index fe9b840e553..c28e5b11366 100644 --- a/superset-frontend/src/components/ErrorMessage/ErrorMessageWithStackTrace.tsx +++ b/superset-frontend/src/components/ErrorMessage/ErrorMessageWithStackTrace.tsx @@ -18,7 +18,7 @@ */ import { ReactNode } from 'react'; import { ErrorSource, t, SupersetError } from '@superset-ui/core'; -import { Typography } from 'src/components/Typography'; +import { Typography } from '@superset-ui/core/components'; import { getErrorMessageComponentRegistry } from './getErrorMessageComponentRegistry'; import { ErrorAlert } from './ErrorAlert'; diff --git a/superset-frontend/src/components/ErrorMessage/FrontendNetworkErrorMessage.test.tsx b/superset-frontend/src/components/ErrorMessage/FrontendNetworkErrorMessage.test.tsx index 32026052eed..c7a1175efa9 100644 --- a/superset-frontend/src/components/ErrorMessage/FrontendNetworkErrorMessage.test.tsx +++ b/superset-frontend/src/components/ErrorMessage/FrontendNetworkErrorMessage.test.tsx @@ -22,7 +22,7 @@ import { render, screen, userEvent } from 'spec/helpers/testing-library'; import { FrontendNetworkErrorMessage } from './FrontendNetworkErrorMessage'; jest.mock( - 'src/components/Icons/AsyncIcon', + '@superset-ui/core/components/Icons/AsyncIcon', () => ({ fileName }: { fileName: string }) => ( diff --git a/superset-frontend/src/components/ErrorMessage/IssueCode.tsx b/superset-frontend/src/components/ErrorMessage/IssueCode.tsx index e0aacdbaab0..62e71c572bb 100644 --- a/superset-frontend/src/components/ErrorMessage/IssueCode.tsx +++ b/superset-frontend/src/components/ErrorMessage/IssueCode.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { Icons } from 'src/components/Icons'; +import { Icons } from '@superset-ui/core/components'; import { useTheme } from '@superset-ui/core'; interface IssueCodeProps { diff --git a/superset-frontend/src/components/ErrorMessage/MarshmallowErrorMessage.tsx b/superset-frontend/src/components/ErrorMessage/MarshmallowErrorMessage.tsx index 2dbaa6f55ea..6612abd5be0 100644 --- a/superset-frontend/src/components/ErrorMessage/MarshmallowErrorMessage.tsx +++ b/superset-frontend/src/components/ErrorMessage/MarshmallowErrorMessage.tsx @@ -19,10 +19,8 @@ import { JSONTree } from 'react-json-tree'; import { t } from '@superset-ui/core'; import { useJsonTreeTheme } from 'src/hooks/useJsonTreeTheme'; -import { Collapse } from '../Collapse'; +import { Collapse, List, Typography } from '@superset-ui/core/components'; import type { ErrorMessageComponentProps } from './types'; -import { List } from '../List'; -import { Typography } from '../Typography'; interface MarshmallowErrorExtra { messages: object; diff --git a/superset-frontend/src/components/ErrorMessage/ParameterErrorMessage.test.tsx b/superset-frontend/src/components/ErrorMessage/ParameterErrorMessage.test.tsx index 1ad69a21d0a..80a0f7e5500 100644 --- a/superset-frontend/src/components/ErrorMessage/ParameterErrorMessage.test.tsx +++ b/superset-frontend/src/components/ErrorMessage/ParameterErrorMessage.test.tsx @@ -22,7 +22,7 @@ import { render, screen, userEvent } from 'spec/helpers/testing-library'; import { ParameterErrorMessage } from './ParameterErrorMessage'; jest.mock( - 'src/components/Icons/AsyncIcon', + '@superset-ui/core/components/Icons/AsyncIcon', () => ({ fileName }: { fileName: string }) => ( diff --git a/superset-frontend/src/components/ErrorMessage/ParameterErrorMessage.tsx b/superset-frontend/src/components/ErrorMessage/ParameterErrorMessage.tsx index f1f8990b93e..9a9047fedac 100644 --- a/superset-frontend/src/components/ErrorMessage/ParameterErrorMessage.tsx +++ b/superset-frontend/src/components/ErrorMessage/ParameterErrorMessage.tsx @@ -20,10 +20,10 @@ import { ReactNode } from 'react'; import { t, tn } from '@superset-ui/core'; import levenshtein from 'js-levenshtein'; +import { List } from '@superset-ui/core/components'; import { ErrorMessageComponentProps } from './types'; import { IssueCode } from './IssueCode'; import { ErrorAlert } from './ErrorAlert'; -import { List } from '../List'; interface ParameterErrorExtra { undefined_parameters?: string[]; diff --git a/superset-frontend/src/components/ErrorMessage/TimeoutErrorMessage.test.tsx b/superset-frontend/src/components/ErrorMessage/TimeoutErrorMessage.test.tsx index fa10f0a474c..7ceb0062c42 100644 --- a/superset-frontend/src/components/ErrorMessage/TimeoutErrorMessage.test.tsx +++ b/superset-frontend/src/components/ErrorMessage/TimeoutErrorMessage.test.tsx @@ -22,7 +22,7 @@ import { render, screen, userEvent } from 'spec/helpers/testing-library'; import { TimeoutErrorMessage } from './TimeoutErrorMessage'; jest.mock( - 'src/components/Icons/AsyncIcon', + '@superset-ui/core/components/Icons/AsyncIcon', () => ({ fileName }: { fileName: string }) => ( diff --git a/superset-frontend/src/components/FacePile/index.tsx b/superset-frontend/src/components/FacePile/index.tsx index 8f59e9d6cb5..220209afc2d 100644 --- a/superset-frontend/src/components/FacePile/index.tsx +++ b/superset-frontend/src/components/FacePile/index.tsx @@ -23,7 +23,7 @@ import { FeatureFlag, } from '@superset-ui/core'; import getOwnerName from 'src/utils/getOwnerName'; -import { Avatar, AvatarGroup, Tooltip } from 'src/components'; +import { Avatar, AvatarGroup, Tooltip } from '@superset-ui/core/components'; import { ensureAppRoot } from 'src/utils/pathUtils'; import { getRandomColor } from './utils'; import type { FacePileProps } from './types'; diff --git a/superset-frontend/src/components/FilterableTable/index.tsx b/superset-frontend/src/components/FilterableTable/index.tsx index 989aad50315..e414bc7d80c 100644 --- a/superset-frontend/src/components/FilterableTable/index.tsx +++ b/superset-frontend/src/components/FilterableTable/index.tsx @@ -18,9 +18,9 @@ */ 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 { GridSize } from 'src/components/GridTable/constants'; +import { GridTable } from 'src/components/GridTable'; +import { type ColDef } from 'src/components/GridTable/types'; import { useCellContentParser } from './useCellContentParser'; import { renderResultCell } from './utils'; diff --git a/superset-frontend/src/components/GridTable/Header.test.tsx b/superset-frontend/src/components/GridTable/Header.test.tsx index cbd3a677126..9976df6c814 100644 --- a/superset-frontend/src/components/GridTable/Header.test.tsx +++ b/superset-frontend/src/components/GridTable/Header.test.tsx @@ -21,12 +21,12 @@ import { act, fireEvent, render } from 'spec/helpers/testing-library'; import { Header } from './Header'; import { PIVOT_COL_ID } from './constants'; -jest.mock('src/components/Dropdown', () => ({ +jest.mock('@superset-ui/core/components/Dropdown', () => ({ Dropdown: () =>
, })); -jest.mock('src/components/Icons', () => { - const actualIcons = jest.requireActual('src/components/Icons'); +jest.mock('@superset-ui/core/components/Icons', () => { + const actualIcons = jest.requireActual('@superset-ui/core/components/Icons'); return { __esModule: true, Icons: { diff --git a/superset-frontend/src/components/GridTable/Header.tsx b/superset-frontend/src/components/GridTable/Header.tsx index eb2acb919bc..467918d5ec6 100644 --- a/superset-frontend/src/components/GridTable/Header.tsx +++ b/superset-frontend/src/components/GridTable/Header.tsx @@ -20,7 +20,7 @@ import { useCallback, useEffect, useRef, useState } from 'react'; import { styled, useTheme, t } from '@superset-ui/core'; import type { Column, GridApi } from 'ag-grid-community'; -import { Icons } from 'src/components/Icons'; +import { Icons } from '@superset-ui/core/components/Icons'; import { PIVOT_COL_ID } from './constants'; import { HeaderMenu } from './HeaderMenu'; diff --git a/superset-frontend/src/components/GridTable/HeaderMenu.test.tsx b/superset-frontend/src/components/GridTable/HeaderMenu.test.tsx index 525383425ee..72a5948d592 100644 --- a/superset-frontend/src/components/GridTable/HeaderMenu.test.tsx +++ b/superset-frontend/src/components/GridTable/HeaderMenu.test.tsx @@ -25,7 +25,7 @@ import { } from 'spec/helpers/testing-library'; import { HeaderMenu } from './HeaderMenu'; -jest.mock('src/components/Menu', () => { +jest.mock('@superset-ui/core/components/Menu', () => { const Menu = ({ children }: { children: React.ReactChild }) => (
{children}
); @@ -58,7 +58,7 @@ jest.mock('src/components/Menu', () => { return { Menu }; }); -jest.mock('src/components/Dropdown', () => ({ +jest.mock('@superset-ui/core/components/Dropdown', () => ({ MenuDotsDropdown: ({ overlay }: { overlay: React.ReactChild }) => (
{overlay}
), @@ -181,7 +181,7 @@ test('renders unhide when invisible column exists', async () => { }); describe('for main menu', () => { - test('renders Copy to Clipboard', async () => { + it('renders Copy to Clipboard', async () => { const { getByText } = render(); fireEvent.click(getByText('Copy the current data')); await waitFor(() => @@ -194,7 +194,7 @@ describe('for main menu', () => { }); }); - test('renders Download to CSV', async () => { + it('renders Download to CSV', async () => { const { getByText } = render(); fireEvent.click(getByText('Download to CSV')); await waitFor(() => @@ -205,7 +205,7 @@ describe('for main menu', () => { }); }); - test('renders autosize column', async () => { + it('renders autosize column', async () => { const { getByText } = render(); fireEvent.click(getByText('Autosize all columns')); await waitFor(() => @@ -213,7 +213,7 @@ describe('for main menu', () => { ); }); - test('renders all unhide all hidden columns when multiple invisible columns exist', async () => { + it('renders all unhide all hidden columns when multiple invisible columns exist', async () => { render( { ); }); - test('reset columns configuration', async () => { + it('reset columns configuration', async () => { const { getByText } = render( ({ ); return ( - + <> css` #grid-table.ag-theme-quartz { @@ -216,7 +215,7 @@ export function GridTable({ onCellKeyDown={onKeyDown} />
- + ); } diff --git a/superset-frontend/src/components/ImportModal/ErrorAlert.tsx b/superset-frontend/src/components/ImportModal/ErrorAlert.tsx index f2c14867a12..0d81b818e94 100644 --- a/superset-frontend/src/components/ImportModal/ErrorAlert.tsx +++ b/superset-frontend/src/components/ImportModal/ErrorAlert.tsx @@ -21,7 +21,7 @@ import { FunctionComponent } from 'react'; import { t, SupersetTheme } from '@superset-ui/core'; import { getDatabaseDocumentationLinks } from 'src/views/CRUD/hooks'; -import { Alert } from '../Alert'; +import { Alert } from '@superset-ui/core/components'; import { antdWarningAlertStyles } from './styles'; const supersetTextDocs = getDatabaseDocumentationLinks(); diff --git a/superset-frontend/src/components/ImportModal/ImportErrorAlert.tsx b/superset-frontend/src/components/ImportModal/ImportErrorAlert.tsx index 7579f941514..f835f6d9733 100644 --- a/superset-frontend/src/components/ImportModal/ImportErrorAlert.tsx +++ b/superset-frontend/src/components/ImportModal/ImportErrorAlert.tsx @@ -21,7 +21,7 @@ import { FunctionComponent } from 'react'; import { t } from '@superset-ui/core'; import { getDatabaseDocumentationLinks } from 'src/views/CRUD/hooks'; -import { ErrorAlert } from '../ErrorMessage'; +import { ErrorAlert } from 'src/components'; const supersetTextDocs = getDatabaseDocumentationLinks(); export const DOCUMENTATION_LINK = supersetTextDocs diff --git a/superset-frontend/src/components/ImportModal/index.tsx b/superset-frontend/src/components/ImportModal/index.tsx index 1a39c91a107..7cbc2de069a 100644 --- a/superset-frontend/src/components/ImportModal/index.tsx +++ b/superset-frontend/src/components/ImportModal/index.tsx @@ -19,10 +19,12 @@ import { FunctionComponent, useEffect, useState, ChangeEvent } from 'react'; import { styled, t, css } from '@superset-ui/core'; import { useImportResource } from 'src/views/CRUD/hooks'; -import { Upload, type UploadChangeParam, type UploadFile } from '../Upload'; -import { Button } from '../Button'; -import { Input } from '../Input'; -import { Modal } from '../Modal'; +import { + Upload, + type UploadChangeParam, + type UploadFile, +} from '@superset-ui/core/components/Upload'; +import { Button, Input, Modal } from '@superset-ui/core/components'; import { ImportErrorAlert } from './ImportErrorAlert'; import type { ImportModelsModalProps } from './types'; diff --git a/superset-frontend/src/components/InfoTooltip/index.tsx b/superset-frontend/src/components/InfoTooltip/index.tsx deleted file mode 100644 index 668b956e7bd..00000000000 --- a/superset-frontend/src/components/InfoTooltip/index.tsx +++ /dev/null @@ -1,86 +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 { styled, useTheme, css } from '@superset-ui/core'; -import { Icons } from 'src/components/Icons'; -import { Tooltip } from '../Tooltip'; -import type { InfoTooltipProps } from './types'; - -const StyledTooltip = styled(Tooltip)` - cursor: pointer; -`; - -const StyledTooltipTitle = styled.span` - display: -webkit-box; - -webkit-line-clamp: 20; - -webkit-box-orient: vertical; - overflow: hidden; - text-overflow: ellipsis; -`; - -const defaultOverlayStyle = { - fontSize: '12px', - lineHeight: '16px', -}; -const InfoIconContainer = styled.div` - ${({ theme }) => css` - display: flex; - flex-direction: row; - justify-content: center; - align-items: center; - margin-left: ${theme.sizeUnit}px; - `} -`; - -export function InfoTooltip({ - tooltip, - iconStyle = {}, - placement = 'right', - trigger = 'hover', - overlayStyle = defaultOverlayStyle, - bgColor, - viewBox = '0 -1 24 24', -}: InfoTooltipProps) { - const theme = useTheme(); - const alteredIconStyle = { - ...iconStyle, - color: iconStyle.color || theme.colorIcon, - }; - return ( - {tooltip}} - placement={placement} - trigger={trigger} - overlayStyle={overlayStyle} - color={bgColor} - > - - - - - ); -} - -export type { InfoTooltipProps }; diff --git a/superset-frontend/src/components/JsonModal/index.tsx b/superset-frontend/src/components/JsonModal/index.tsx index 57052d31f7d..f108c3dc19b 100644 --- a/superset-frontend/src/components/JsonModal/index.tsx +++ b/superset-frontend/src/components/JsonModal/index.tsx @@ -38,9 +38,8 @@ import { FC, useMemo } from 'react'; import { JSONTree } from 'react-json-tree'; import { useJsonTreeTheme } from 'src/hooks/useJsonTreeTheme'; -import { Button } from '../Button'; +import { Button, ModalTrigger } from '@superset-ui/core/components'; import { CopyToClipboard } from '../CopyToClipboard'; -import ModalTrigger from '../ModalTrigger'; import { convertBigIntStrToNumber } from './utils'; import type { JsonModalProps } from './types'; diff --git a/superset-frontend/src/components/ListView/ActionsBar.tsx b/superset-frontend/src/components/ListView/ActionsBar.tsx index 321ff2bbb60..e802005de74 100644 --- a/superset-frontend/src/components/ListView/ActionsBar.tsx +++ b/superset-frontend/src/components/ListView/ActionsBar.tsx @@ -37,9 +37,12 @@ */ import { ReactElement } from 'react'; import { styled } from '@superset-ui/core'; -import { Icons, IconNameType } from 'src/components/Icons'; -import { Tooltip } from '../Tooltip'; -import { TooltipPlacement } from '../Tooltip/types'; +import { + Icons, + IconNameType, + Tooltip, + type TooltipPlacement, +} from '@superset-ui/core/components'; export type ActionProps = { label: string; diff --git a/superset-frontend/src/components/ListView/CardSortSelect.tsx b/superset-frontend/src/components/ListView/CardSortSelect.tsx index 3a8ec86e7ac..9be9b7cc1bb 100644 --- a/superset-frontend/src/components/ListView/CardSortSelect.tsx +++ b/superset-frontend/src/components/ListView/CardSortSelect.tsx @@ -18,8 +18,7 @@ */ import { useState, useMemo } from 'react'; import { styled, t } from '@superset-ui/core'; -import { FormLabel } from '../Form'; -import { Select } from '../Select'; +import { FormLabel, Select } from '@superset-ui/core/components'; import { SELECT_WIDTH } from './utils'; import { CardSortSelectOption, SortColumn } from './types'; diff --git a/superset-frontend/src/components/ListView/CrossLinksTooltip.test.tsx b/superset-frontend/src/components/ListView/CrossLinksTooltip.test.tsx index b17b417269f..08a863c9875 100644 --- a/superset-frontend/src/components/ListView/CrossLinksTooltip.test.tsx +++ b/superset-frontend/src/components/ListView/CrossLinksTooltip.test.tsx @@ -65,7 +65,7 @@ test('should render', () => { test('should render multiple links', async () => { setup(); - userEvent.hover(screen.getByText('Hover me')); + await userEvent.hover(screen.getByText('Hover me')); await waitFor(() => { expect(screen.getByText('Test dashboard')).toBeInTheDocument(); @@ -76,9 +76,9 @@ test('should render multiple links', async () => { }); }); -test('should not render the "+ {x} more"', () => { +test('should not render the "+ {x} more"', async () => { setup(); - userEvent.hover(screen.getByText('Hover me')); + await userEvent.hover(screen.getByText('Hover me')); expect(screen.queryByTestId('plus-more')).not.toBeInTheDocument(); }); @@ -86,7 +86,7 @@ test('should render the "+ {x} more"', async () => { setup({ moreItems: 3, }); - userEvent.hover(screen.getByText('Hover me')); + await userEvent.hover(screen.getByText('Hover me')); expect(await screen.findByTestId('plus-more')).toBeInTheDocument(); expect(await screen.findByText('+ 3 more')).toBeInTheDocument(); }); diff --git a/superset-frontend/src/components/ListView/CrossLinksTooltip.tsx b/superset-frontend/src/components/ListView/CrossLinksTooltip.tsx index 723cfd7d6e7..52517869ab7 100644 --- a/superset-frontend/src/components/ListView/CrossLinksTooltip.tsx +++ b/superset-frontend/src/components/ListView/CrossLinksTooltip.tsx @@ -19,7 +19,7 @@ import { ReactNode } from 'react'; import { styled, t } from '@superset-ui/core'; import { Link } from 'react-router-dom'; -import { Tooltip } from '../Tooltip'; +import { Tooltip } from '@superset-ui/core/components'; export type CrossLinksTooltipProps = { children: ReactNode; diff --git a/superset-frontend/src/components/ListView/Filters/DateRange.tsx b/superset-frontend/src/components/ListView/Filters/DateRange.tsx index 326374e59f5..619880a5775 100644 --- a/superset-frontend/src/components/ListView/Filters/DateRange.tsx +++ b/superset-frontend/src/components/ListView/Filters/DateRange.tsx @@ -25,13 +25,15 @@ import { } from 'react'; import { styled, t } from '@superset-ui/core'; -import { extendedDayjs } from 'src/utils/dates'; import { Dayjs } from 'dayjs'; import { useLocale } from 'src/hooks/useLocale'; -import { Loading } from '../../Loading'; -import { AntdThemeProvider } from '../../AntdThemeProvider'; -import { FormLabel } from '../../Form'; -import { RangePicker } from '../../DatePicker'; +import { extendedDayjs } from '@superset-ui/core/utils/dates'; +import { + AntdThemeProvider, + Loading, + FormLabel, + RangePicker, +} from '@superset-ui/core/components'; import { BaseFilter, FilterHandler } from './Base'; interface DateRangeFilterProps extends BaseFilter { diff --git a/superset-frontend/src/components/ListView/Filters/NumericalRange.tsx b/superset-frontend/src/components/ListView/Filters/NumericalRange.tsx index 0283015fecb..53c94b79c93 100644 --- a/superset-frontend/src/components/ListView/Filters/NumericalRange.tsx +++ b/superset-frontend/src/components/ListView/Filters/NumericalRange.tsx @@ -18,8 +18,8 @@ */ import { useState, forwardRef, useImperativeHandle, RefObject } from 'react'; import { styled, t } from '@superset-ui/core'; -import { InputNumber } from 'src/components/Input'; -import { FormLabel } from 'src/components/Form'; +import { InputNumber } from '@superset-ui/core/components/Input'; +import { FormLabel } from '@superset-ui/core/components/Form'; import { BaseFilter, FilterHandler } from './Base'; const RangeFilterContainer = styled.div` diff --git a/superset-frontend/src/components/ListView/Filters/Search.tsx b/superset-frontend/src/components/ListView/Filters/Search.tsx index c1a163b53ae..0ca61d72c8b 100644 --- a/superset-frontend/src/components/ListView/Filters/Search.tsx +++ b/superset-frontend/src/components/ListView/Filters/Search.tsx @@ -25,10 +25,12 @@ import { } from 'react'; import { t, styled, useTheme, css } from '@superset-ui/core'; -import { Icons } from 'src/components/Icons'; -import { FormLabel } from '../../Form'; -import { Input } from '../../Input'; -import { InfoTooltip } from '../../InfoTooltip'; +import { + Input, + InfoTooltip, + FormLabel, + Icons, +} from '@superset-ui/core/components'; import { BaseFilter, FilterHandler, FilterContainer } from './Base'; interface SearchHeaderProps extends BaseFilter { @@ -81,9 +83,7 @@ function SearchFilter( `} > {Header} - {toolTipDescription && ( - - )} + {toolTipDescription && }
{ const tableSelect = screen.getByRole('combobox', { name: 'Select table or type to search tables', }); - userEvent.click(tableSelect); + await userEvent.click(tableSelect); expect(await screen.findByText('table_a')).toBeInTheDocument(); expect( screen.queryByRole('option', { name: /Select All/i }), @@ -138,7 +138,7 @@ test('renders table options without Select All option', async () => { }); await act(async () => { - userEvent.click(tableSelect); + await userEvent.click(tableSelect); }); await waitFor( @@ -171,7 +171,7 @@ test('table select retain value if not in SQL Lab mode', async () => { expect(getSelectItemContainer(tableSelect)).toHaveLength(0); await act(async () => { - userEvent.click(tableSelect); + await userEvent.click(tableSelect); }); await waitFor( @@ -182,7 +182,7 @@ test('table select retain value if not in SQL Lab mode', async () => { ); await act(async () => { - userEvent.click(screen.getByText('table_a')); + await userEvent.click(screen.getByText('table_a')); }); await waitFor( @@ -242,16 +242,16 @@ test('table multi select retain all the values selected', async () => { expect(screen.queryByText('table_a')).not.toBeInTheDocument(); expect(getSelectItemContainer(tableSelect)).toHaveLength(0); - userEvent.click(tableSelect); + await userEvent.click(tableSelect); await waitFor(async () => { const item = await screen.findAllByText('table_b'); - userEvent.click(item[item.length - 1]); + await userEvent.click(item[item.length - 1]); }); await waitFor(async () => { const item = await screen.findAllByText('table_c'); - userEvent.click(item[item.length - 1]); + await userEvent.click(item[item.length - 1]); }); const selections = await screen.findAllByRole('option', { selected: true }); diff --git a/superset-frontend/src/components/TableSelector/index.tsx b/superset-frontend/src/components/TableSelector/index.tsx index 7fa1b53a4f4..a557a7c0339 100644 --- a/superset-frontend/src/components/TableSelector/index.tsx +++ b/superset-frontend/src/components/TableSelector/index.tsx @@ -23,7 +23,7 @@ import { useMemo, useEffect, } from 'react'; -import type { SelectValue } from 'src/components'; +import type { SelectValue } from '@superset-ui/core/components'; import { styled, @@ -34,13 +34,13 @@ import { import { FormLabel, CertifiedBadge, - DatabaseSelector, Select, -} from 'src/components'; -import { Icons } from 'src/components/Icons'; +} from '@superset-ui/core/components'; +import { DatabaseSelector } from 'src/components'; +import { Icons } from '@superset-ui/core/components/Icons'; import type { DatabaseObject } from 'src/components/DatabaseSelector/types'; -import RefreshLabel from 'src/components/RefreshLabel'; -import WarningIconWithTooltip from 'src/components/WarningIconWithTooltip'; +import RefreshLabel from '@superset-ui/core/components/RefreshLabel'; +import WarningIconWithTooltip from '@superset-ui/core/components/WarningIconWithTooltip'; import { useToasts } from 'src/components/MessageToasts/withToasts'; import { useTables, Table } from 'src/hooks/apiResources'; diff --git a/superset-frontend/src/components/InfoTooltip/types.ts b/superset-frontend/src/components/Tag/TagType.ts similarity index 57% rename from superset-frontend/src/components/InfoTooltip/types.ts rename to superset-frontend/src/components/Tag/TagType.ts index 1c5e9c44fb0..e7165234a38 100644 --- a/superset-frontend/src/components/InfoTooltip/types.ts +++ b/superset-frontend/src/components/Tag/TagType.ts @@ -16,27 +16,26 @@ * specific language governing permissions and limitations * under the License. */ -import { ActionType } from 'src/types/Action'; +import { CSSProperties, MouseEventHandler, ReactNode } from 'react'; +import { SerializedStyles } from '@emotion/react'; -export interface InfoTooltipProps { - iconStyle?: React.CSSProperties; - tooltip: string; - placement?: - | 'bottom' - | 'left' - | 'right' - | 'top' - | 'topLeft' - | 'topRight' - | 'bottomLeft' - | 'bottomRight' - | 'leftTop' - | 'leftBottom' - | 'rightTop' - | 'rightBottom' - | undefined; - trigger?: ActionType | ActionType[]; - overlayStyle?: any; - bgColor?: string; - viewBox?: string; +export interface TagType { + id?: number; + className?: string; + type?: string | number; + editable?: boolean; + onDelete?: (index: number) => void; + onClick?: MouseEventHandler; + onMouseDown?: MouseEventHandler; + onClose?: () => void; + color?: string; + name?: string; + index?: number; + toolTipTitle?: string; + children?: ReactNode; + role?: string; + style?: CSSProperties; + icon?: ReactNode; + css?: SerializedStyles; + closable?: boolean; } diff --git a/superset-frontend/src/components/Tag/index.tsx b/superset-frontend/src/components/Tag/index.tsx index b9065686136..503bc9fef1d 100644 --- a/superset-frontend/src/components/Tag/index.tsx +++ b/superset-frontend/src/components/Tag/index.tsx @@ -20,11 +20,10 @@ import { styled } from '@superset-ui/core'; import { Link } from 'react-router-dom'; import TagType from 'src/types/TagType'; -import { Tag as AntdTag } from 'antd'; +import { Tag as AntdTag, Tooltip } from '@superset-ui/core/components'; import type { TagProps } from 'antd/es'; import type { CheckableTagProps } from 'antd/es/tag'; import { useMemo } from 'react'; -import { Tooltip } from '../Tooltip'; const StyledTag = styled(AntdTag)` ${({ theme }) => ` @@ -103,4 +102,4 @@ const SupersetTag = ({ export const Tag = Object.assign(SupersetTag, { CheckableTag: AntdTag.CheckableTag, }); -export type { TagProps, CheckableTagProps }; +export type { TagProps, CheckableTagProps, TagType }; diff --git a/superset-frontend/src/components/TagsList/TagsList.stories.tsx b/superset-frontend/src/components/TagsList/TagsList.stories.tsx index e2eb2e77757..75c1a5fcd22 100644 --- a/superset-frontend/src/components/TagsList/TagsList.stories.tsx +++ b/superset-frontend/src/components/TagsList/TagsList.stories.tsx @@ -17,7 +17,7 @@ * under the License. */ import { Meta, StoryObj } from '@storybook/react'; -import TagsList, { type TagsListProps } from 'src/components/TagsList'; +import { TagsList, type TagsListProps } from 'src/components/TagsList'; export default { title: 'Components/TagsList', diff --git a/superset-frontend/src/components/TagsList/TagsList.test.tsx b/superset-frontend/src/components/TagsList/TagsList.test.tsx index 6d4eb048b64..d8001bb6e65 100644 --- a/superset-frontend/src/components/TagsList/TagsList.test.tsx +++ b/superset-frontend/src/components/TagsList/TagsList.test.tsx @@ -17,7 +17,7 @@ * under the License. */ import { render, waitFor } from 'spec/helpers/testing-library'; -import TagsList, { TagsListProps } from '.'; +import { TagsList, TagsListProps } from '.'; const testTags = [ { diff --git a/superset-frontend/src/components/TagsList/index.tsx b/superset-frontend/src/components/TagsList/index.tsx index d63d73f0743..61086bf28ea 100644 --- a/superset-frontend/src/components/TagsList/index.tsx +++ b/superset-frontend/src/components/TagsList/index.tsx @@ -41,7 +41,7 @@ const TagsDiv = styled.div` flex-wrap: wrap; `; -const TagsList = ({ +export const TagsList = ({ tags, editable = false, onDelete, @@ -112,5 +112,3 @@ const TagsList = ({ ); }; - -export default TagsList; diff --git a/superset-frontend/src/components/index.ts b/superset-frontend/src/components/index.ts index 7cef78f5a60..09d50bb315a 100644 --- a/superset-frontend/src/components/index.ts +++ b/superset-frontend/src/components/index.ts @@ -16,154 +16,9 @@ * specific language governing permissions and limitations * under the License. */ - -/* - * Re-exporting of components in src/components to facilitate - * their imports by other components. - * E.g. import { Select } from 'src/components', probably in the future from '@superset-ui/components' - */ -export { AntdThemeProvider } from './AntdThemeProvider'; -export { Alert, type AlertProps } from './Alert'; -export { Icons } from './Icons'; -export { - AsyncEsmComponent, - type PlaceholderProps as AsyncEsmPlaceholderProps, -} from './AsyncEsmComponent'; -export { - AsyncAceEditor, - CssEditor, - JsonEditor, - SQLEditor, - FullSQLEditor, - MarkdownEditor, - TextAreaEditor, - ConfigEditor, - type AsyncAceEditorProps, - type Editor, -} from './AsyncAceEditor'; -export { AlteredSliceTag, type AlteredSliceTagProps } from './AlteredSliceTag'; -export { ModifiedInfo, type ModifiedInfoProps } from './AuditInfo'; -export { AutoComplete, type AutoCompleteProps } from './AutoComplete'; -export { - Avatar, - AvatarGroup, - type AvatarProps, - type AvatarGroupProps, -} from './Avatar'; -export { Badge, type BadgeProps } from './Badge'; -export { Tooltip, type TooltipProps } from './Tooltip'; -export { Button, type ButtonProps, type OnClickHandler } from './Button'; -export { ButtonGroup, type ButtonGroupProps } from './ButtonGroup'; -export { Breadcrumb, type BreadcrumbProps } from './Breadcrumb'; -export { CachedLabel, type CacheLabelProps } from './CachedLabel'; -export { Card } from './Card'; -export { CertifiedBadge } from './CertifiedBadge'; -export { - Checkbox, - type CheckboxProps, - type CheckboxChangeEvent, -} from './Checkbox'; -export { - Collapse, - type CollapseProps, - CollapseLabelInModal, - type CollapseLabelInModalProps, -} from './Collapse'; -export { - ConfirmStatusChange, - type ConfirmStatusChangeProps, -} from './ConfirmStatusChange'; -export { CopyToClipboard, type CopyToClipboardProps } from './CopyToClipboard'; -export { CronPicker, type CronError } from './CronPicker'; -export { DatabaseSelector, type DatabaseObject } from './DatabaseSelector'; -export { - DatasourceModal, - ChangeDatasourceModal, - type DatasourceModalProps, - type ChangeDatasourceModalProps, -} from './Datasource'; -export { - DatePicker, - RangePicker, - type DatePickerProps, - type RangePickerProps, -} from './DatePicker'; -export { DeleteModal, type DeleteModalProps } from './DeleteModal'; -export { Divider, type DividerProps } from './Divider'; -export { - Dropdown, - MenuDotsDropdown, - NoAnimationDropdown, - type DropdownProps, - type NoAnimationDropdownProps, - type MenuDotsDropdownProps, -} from './Dropdown'; -export { DropdownButton, type DropdownButtonProps } from './DropdownButton'; -export { - DropdownContainer, - type DropdownItem, - type DropdownRef, -} from './DropdownContainer'; -export { - DynamicEditableTitle, - type DynamicEditableTitleProps, -} from './DynamicEditableTitle'; -export { - DynamicPluginProvider, - PluginContext, - usePluginContext, - type PluginContextType, -} from './DynamicPlugins'; -export { EditableTitle, type EditableTitleProps } from './EditableTitle'; -export { EmptyState, type EmptyStateProps } from './EmptyState'; -export { Empty, type EmptyProps } from './EmptyState/Empty'; -export { ErrorBoundary, type ErrorBoundaryProps } from './ErrorBoundary'; -export * from './ErrorMessage'; -export { FacePile, type FacePileProps } from './FacePile'; -export { FaveStar, type FaveStarProps } from './FaveStar'; -export { - Modal, - FormModal, - StyledModal, - type ModalProps, - type FormModalProps, -} from './Modal'; -export { FilterableTable, type FilterableTableProps } from './FilterableTable'; -export { FlashProvider, type FlashMessage } from './FlashProvider'; -export { Flex, type FlexProps } from './Flex'; -export { - Form, - FormItem, - FormLabel, - LabeledErrorBoundInput, - type FormInstance, - type FormProps, - type FormItemProps, -} from './Form'; -export { GenericLink } from './GenericLink'; -export { Grid, Row, Col, type RowProps, type ColProps } from './Grid'; -export { GridTable, type TableProps } from './GridTable'; -export { IconButton, type IconButtonProps } from './IconButton'; -export { IconTooltip, type IconTooltipProps } from './IconTooltip'; -export { ImportModal, type ImportModelsModalProps } from './ImportModal'; -export { InfoTooltip, type InfoTooltipProps } from './InfoTooltip'; -export { - Input, - InputNumber, - type InputProps, - type TextAreaProps, - type InputNumberProps, -} from './Input'; -export { JsonModal, type JsonModalProps } from './JsonModal'; -export { - Label, - DatasetTypeLabel, - PublishedLabel, - type LabelType, -} from './Label'; -export { LastUpdated, type LastUpdatedProps } from './LastUpdated'; -export { Layout, type LayoutProps, type SiderProps } from './Layout'; -export { List, type ListProps, type ListItemProps } from './List'; +export * from './CopyToClipboard'; +export * from './FilterableTable'; +export * from './AlteredSliceTag'; export { ListView, ListViewActionsBar, @@ -177,40 +32,21 @@ export { type ListViewFetchDataConfig, type ListViewFilterValue, } from './ListView'; +export { DatabaseSelector, type DatabaseObject } from './DatabaseSelector'; +export * from './Datasource'; +export * from './ErrorMessage'; +export { ImportModal, type ImportModelsModalProps } from './ImportModal'; +export { ErrorBoundary, type ErrorBoundaryProps } from './ErrorBoundary'; +export * from './GenericLink'; +export { FlashProvider, type FlashMessage } from './FlashProvider'; +export { GridTable, type TableProps } from './GridTable'; +export * from './Tag'; +export * from './TagsList'; +export { ModifiedInfo, type ModifiedInfoProps } from './AuditInfo'; export { - ListViewCard, - ImageLoader, - type ListViewCardProps, -} from './ListViewCard'; -export { Loading, type LoadingProps } from './Loading'; - -export { - Select, - AsyncSelect, - type SelectProps, - type SelectValue, - type SelectOptionsType, - type LabeledValue, - type RefSelectProps, -} from './Select'; - -export { Steps, type StepsProps } from './Steps'; - -export { Space, type SpaceProps } from './Space'; - -export { Skeleton, type SkeletonProps } from './Skeleton'; - -export { Switch, type SwitchProps } from './Switch'; - -export { Tag } from './Tag'; - -export { TreeSelect, type TreeSelectProps } from './TreeSelect'; - -export { - Typography, - type TypographyProps, - type ParagraphProps, -} from './Typography'; - -export { Image, type ImageProps } from './Image'; -export { Upload, type UploadFile, type UploadChangeParam } from './Upload'; + DynamicPluginProvider, + PluginContext, + usePluginContext, + type PluginContextType, +} from './DynamicPlugins'; +export * from './FacePile'; diff --git a/superset-frontend/src/constants.ts b/superset-frontend/src/constants.ts index 98abb6c2b12..4dc734651d5 100644 --- a/superset-frontend/src/constants.ts +++ b/superset-frontend/src/constants.ts @@ -16,20 +16,13 @@ * specific language governing permissions and limitations * under the License. */ -import { - t, - DEFAULT_D3_FORMAT, - DEFAULT_D3_TIME_FORMAT, -} from '@superset-ui/core'; +import { DEFAULT_D3_FORMAT, DEFAULT_D3_TIME_FORMAT } from '@superset-ui/core'; import { BootstrapData, CommonBootstrapData } from './types/bootstrapTypes'; export const DATETIME_WITH_TIME_ZONE = 'YYYY-MM-DD HH:mm:ssZ'; export const TIME_WITH_MS = 'HH:mm:ss.SSS'; -export const BOOL_TRUE_DISPLAY = 'True'; -export const BOOL_FALSE_DISPLAY = 'False'; - export const URL_PARAMS = { standalone: { name: 'standalone', @@ -127,21 +120,6 @@ export const RESERVED_DASHBOARD_URL_PARAMS: string[] = [ URL_PARAMS.preselectFilters.name, ]; -/** - * Faster debounce delay for inputs without expensive operation. - */ -export const FAST_DEBOUNCE = 250; - -/** - * Slower debounce delay for inputs with expensive API calls. - */ -export const SLOW_DEBOUNCE = 500; - -/** - * Display null as `N/A` - */ -export const NULL_DISPLAY = t('N/A'); - export const DEFAULT_COMMON_BOOTSTRAP_DATA: CommonBootstrapData = { application_root: '/', static_assets_prefix: '', diff --git a/superset-frontend/src/dashboard/components/AddSliceCard/AddSliceCard.tsx b/superset-frontend/src/dashboard/components/AddSliceCard/AddSliceCard.tsx index b93e9f4b726..d684456a98c 100644 --- a/superset-frontend/src/dashboard/components/AddSliceCard/AddSliceCard.tsx +++ b/superset-frontend/src/dashboard/components/AddSliceCard/AddSliceCard.tsx @@ -30,12 +30,8 @@ import { } from 'react'; import { t, isFeatureEnabled, FeatureFlag, css } from '@superset-ui/core'; -import { - GenericLink, - Tooltip, - usePluginContext, - ImageLoader, -} from 'src/components'; +import { Tooltip, ImageLoader } from '@superset-ui/core/components'; +import { GenericLink, usePluginContext } from 'src/components'; import { assetUrl } from 'src/utils/assetUrl'; import { Theme } from '@emotion/react'; diff --git a/superset-frontend/src/dashboard/components/BuilderComponentPane/index.tsx b/superset-frontend/src/dashboard/components/BuilderComponentPane/index.tsx index 0aaa6d886b7..e279d3e35a4 100644 --- a/superset-frontend/src/dashboard/components/BuilderComponentPane/index.tsx +++ b/superset-frontend/src/dashboard/components/BuilderComponentPane/index.tsx @@ -18,7 +18,7 @@ */ /* eslint-env browser */ import { rgba } from 'emotion-rgba'; -import Tabs from 'src/components/Tabs'; +import Tabs from '@superset-ui/core/components/Tabs'; import { t, css, SupersetTheme } from '@superset-ui/core'; import SliceAdder from 'src/dashboard/containers/SliceAdder'; import dashboardComponents from 'src/visualizations/presets/dashboardComponents'; diff --git a/superset-frontend/src/dashboard/components/CssEditor/CssEditor.test.tsx b/superset-frontend/src/dashboard/components/CssEditor/CssEditor.test.tsx index fbaadf89128..63bdea50792 100644 --- a/superset-frontend/src/dashboard/components/CssEditor/CssEditor.test.tsx +++ b/superset-frontend/src/dashboard/components/CssEditor/CssEditor.test.tsx @@ -22,12 +22,12 @@ import { userEvent, waitFor, } from 'spec/helpers/testing-library'; -import { CssEditor as AceCssEditor } from 'src/components/AsyncAceEditor'; +import { CssEditor as AceCssEditor } from '@superset-ui/core/components/AsyncAceEditor'; import { IAceEditorProps } from 'react-ace'; import fetchMock from 'fetch-mock'; import CssEditor from '.'; -jest.mock('src/components/AsyncAceEditor', () => ({ +jest.mock('@superset-ui/core/components/AsyncAceEditor', () => ({ CssEditor: ({ value, onChange }: IAceEditorProps) => (