From 816a2c3e1e9fb1cc82923f8c0948267697c1d234 Mon Sep 17 00:00:00 2001
From: "Michael S. Molina" <70410625+michael-s-molina@users.noreply.github.com>
Date: Tue, 29 Mar 2022 10:15:07 -0300
Subject: [PATCH] chore: Removes direct theme imports (#19368)
---
superset-frontend/.eslintrc.js | 2 +-
.../src/SqlLab/components/App/index.jsx | 14 ++++++--------
.../RunQueryActionButton.test.jsx | 9 ++++++---
.../components/RunQueryActionButton/index.tsx | 8 +++++---
.../src/components/CertifiedBadge/index.tsx | 9 ++++-----
superset-frontend/src/components/Icons/Icon.tsx | 2 +-
.../FilterBar/FilterSets/FilterSetUnit.tsx | 8 ++++----
.../DatasourceControl/DatasourceControl.test.jsx | 13 ++++++++-----
.../DatasourceControl/DatasourceControl.test.tsx | 1 +
.../controls/DatasourceControl/index.jsx | 8 ++++----
.../CRUD/alert/components/AlertStatusIcon.tsx | 4 ++--
11 files changed, 42 insertions(+), 36 deletions(-)
diff --git a/superset-frontend/.eslintrc.js b/superset-frontend/.eslintrc.js
index 1ba0436c28..8decc32ee7 100644
--- a/superset-frontend/.eslintrc.js
+++ b/superset-frontend/.eslintrc.js
@@ -181,7 +181,6 @@ module.exports = {
],
'no-only-tests/no-only-tests': 'error',
'max-classes-per-file': 0,
- 'theme-colors/no-literal-colors': 0,
},
},
{
@@ -198,6 +197,7 @@ module.exports = {
],
rules: {
'theme-colors/no-literal-colors': 0,
+ 'no-restricted-imports': 0,
},
},
],
diff --git a/superset-frontend/src/SqlLab/components/App/index.jsx b/superset-frontend/src/SqlLab/components/App/index.jsx
index c98ff12e87..8a0ade9509 100644
--- a/superset-frontend/src/SqlLab/components/App/index.jsx
+++ b/superset-frontend/src/SqlLab/components/App/index.jsx
@@ -20,7 +20,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
-import { t, supersetTheme, ThemeProvider } from '@superset-ui/core';
+import { t } from '@superset-ui/core';
import throttle from 'lodash/throttle';
import ToastContainer from 'src/components/MessageToasts/ToastContainer';
import {
@@ -98,13 +98,11 @@ class App extends React.PureComponent {
return window.location.replace('/superset/sqllab/history/');
}
return (
-
-
-
-
-
-
-
+
+
+
+
+
);
}
}
diff --git a/superset-frontend/src/SqlLab/components/RunQueryActionButton/RunQueryActionButton.test.jsx b/superset-frontend/src/SqlLab/components/RunQueryActionButton/RunQueryActionButton.test.jsx
index 198759c69e..823f10741a 100644
--- a/superset-frontend/src/SqlLab/components/RunQueryActionButton/RunQueryActionButton.test.jsx
+++ b/superset-frontend/src/SqlLab/components/RunQueryActionButton/RunQueryActionButton.test.jsx
@@ -17,8 +17,8 @@
* under the License.
*/
import React from 'react';
-import { shallow } from 'enzyme';
-
+import { mount } from 'enzyme';
+import { supersetTheme, ThemeProvider } from '@superset-ui/core';
import RunQueryActionButton from 'src/SqlLab/components/RunQueryActionButton';
import Button from 'src/components/Button';
@@ -35,7 +35,10 @@ describe('RunQueryActionButton', () => {
};
beforeEach(() => {
- wrapper = shallow();
+ wrapper = mount(, {
+ wrappingComponent: ThemeProvider,
+ wrappingComponentProps: { theme: supersetTheme },
+ });
});
it('is a valid react element', () => {
diff --git a/superset-frontend/src/SqlLab/components/RunQueryActionButton/index.tsx b/superset-frontend/src/SqlLab/components/RunQueryActionButton/index.tsx
index 398ec30110..2a9e0fbaf8 100644
--- a/superset-frontend/src/SqlLab/components/RunQueryActionButton/index.tsx
+++ b/superset-frontend/src/SqlLab/components/RunQueryActionButton/index.tsx
@@ -17,7 +17,7 @@
* under the License.
*/
import React from 'react';
-import { t, styled, supersetTheme } from '@superset-ui/core';
+import { t, styled, useTheme } from '@superset-ui/core';
import { Menu } from 'src/components/Menu';
import Button, { ButtonProps } from 'src/components/Button';
@@ -93,6 +93,8 @@ const RunQueryActionButton = ({
runQuery,
stopQuery,
}: Props) => {
+ const theme = useTheme();
+
const shouldShowStopBtn =
!!queryState && ['running', 'pending'].indexOf(queryState) > -1;
@@ -123,8 +125,8 @@ const RunQueryActionButton = ({
diff --git a/superset-frontend/src/components/CertifiedBadge/index.tsx b/superset-frontend/src/components/CertifiedBadge/index.tsx
index 6ad82fb1c8..80581e6320 100644
--- a/superset-frontend/src/components/CertifiedBadge/index.tsx
+++ b/superset-frontend/src/components/CertifiedBadge/index.tsx
@@ -17,7 +17,7 @@
* under the License.
*/
import React from 'react';
-import { t, supersetTheme } from '@superset-ui/core';
+import { t, useTheme } from '@superset-ui/core';
import Icons, { IconType } from 'src/components/Icons';
import { Tooltip } from 'src/components/Tooltip';
@@ -32,6 +32,8 @@ function CertifiedBadge({
details,
size = 'l',
}: CertifiedBadgeProps) {
+ const theme = useTheme();
+
return (
}
>
-
+
);
}
diff --git a/superset-frontend/src/components/Icons/Icon.tsx b/superset-frontend/src/components/Icons/Icon.tsx
index d45943502d..7d698d0d54 100644
--- a/superset-frontend/src/components/Icons/Icon.tsx
+++ b/superset-frontend/src/components/Icons/Icon.tsx
@@ -42,7 +42,7 @@ export const StyledIcon = styled(AntdIconComponent)`
: '24px'};
`;
-interface IconProps extends IconType {
+export interface IconProps extends IconType {
fileName: string;
}
diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterSets/FilterSetUnit.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterSets/FilterSetUnit.tsx
index 2c21dc6afe..53ea1c94c5 100644
--- a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterSets/FilterSetUnit.tsx
+++ b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterSets/FilterSetUnit.tsx
@@ -24,7 +24,7 @@ import {
FilterSet,
HandlerFunction,
styled,
- supersetTheme,
+ useTheme,
t,
} from '@superset-ui/core';
import { CheckOutlined, EllipsisOutlined } from '@ant-design/icons';
@@ -76,6 +76,8 @@ const FilterSetUnit: FC = ({
isApplied,
onRebuild,
}) => {
+ const theme = useTheme();
+
const menu = (