mirror of https://github.com/apache/superset.git
Eslint error cleanup (#10657)
* moving two console errors to logger errors * nixing unused map index * nixing unused param * linting * changing an alert to a toast * fixing tests * lint fix * one letter change, just to see if iti gets CI to pass this test.
This commit is contained in:
parent
9461f9c1e0
commit
fdfb7cdfd2
|
@ -90,7 +90,7 @@ describe('Test explore links', () => {
|
|||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@postJson' });
|
||||
cy.url().then(url => {
|
||||
cy.url().then(() => {
|
||||
cy.get('button[data-target="#save_modal"]').click();
|
||||
cy.get('.modal-content').within(() => {
|
||||
cy.get('#saveas-radio').check();
|
||||
|
|
|
@ -20,12 +20,17 @@ import React from 'react';
|
|||
import { shallow, mount } from 'enzyme';
|
||||
import { OverlayTrigger } from 'react-bootstrap';
|
||||
import sinon from 'sinon';
|
||||
import { Provider } from 'react-redux';
|
||||
import configureStore from 'redux-mock-store';
|
||||
|
||||
import EmbedCodeButton from 'src/explore/components/EmbedCodeButton';
|
||||
import * as exploreUtils from 'src/explore/exploreUtils';
|
||||
import * as common from 'src/utils/common';
|
||||
|
||||
describe('EmbedCodeButton', () => {
|
||||
const mockStore = configureStore([]);
|
||||
const store = mockStore({});
|
||||
|
||||
const defaultProps = {
|
||||
latestQueryFormData: { datasource: '107__table' },
|
||||
};
|
||||
|
@ -41,11 +46,16 @@ describe('EmbedCodeButton', () => {
|
|||
expect(wrapper.find(OverlayTrigger)).toExist();
|
||||
});
|
||||
|
||||
it('should create shorten, standalone, explore url', () => {
|
||||
it('should create a short, standalone, explore url', () => {
|
||||
const spy1 = sinon.spy(exploreUtils, 'getExploreLongUrl');
|
||||
const spy2 = sinon.spy(common, 'getShortUrl');
|
||||
|
||||
const wrapper = mount(<EmbedCodeButton {...defaultProps} />);
|
||||
const wrapper = mount(<EmbedCodeButton {...defaultProps} />, {
|
||||
wrappingComponent: Provider,
|
||||
wrappingComponentProps: {
|
||||
store,
|
||||
},
|
||||
});
|
||||
wrapper.setState({
|
||||
height: '1000',
|
||||
width: '2000',
|
||||
|
|
|
@ -18,13 +18,18 @@
|
|||
*/
|
||||
import React from 'react';
|
||||
import { mount, shallow } from 'enzyme';
|
||||
import { Provider } from 'react-redux';
|
||||
import configureStore from 'redux-mock-store';
|
||||
|
||||
import Link from 'src/components/Link';
|
||||
import TableElement from 'src/SqlLab/components/TableElement';
|
||||
import ColumnElement from 'src/SqlLab/components/ColumnElement';
|
||||
|
||||
import { mockedActions, table } from './fixtures';
|
||||
|
||||
describe('TableElement', () => {
|
||||
const mockStore = configureStore([]);
|
||||
const store = mockStore({});
|
||||
const mockedProps = {
|
||||
actions: mockedActions,
|
||||
table,
|
||||
|
@ -45,7 +50,11 @@ describe('TableElement', () => {
|
|||
expect(wrapper.find(ColumnElement)).toHaveLength(14);
|
||||
});
|
||||
it('mounts', () => {
|
||||
mount(<TableElement {...mockedProps} />);
|
||||
mount(
|
||||
<Provider store={store}>
|
||||
<TableElement {...mockedProps} />
|
||||
</Provider>,
|
||||
);
|
||||
});
|
||||
it('sorts columns', () => {
|
||||
const wrapper = shallow(<TableElement {...mockedProps} />);
|
||||
|
@ -58,7 +67,11 @@ describe('TableElement', () => {
|
|||
);
|
||||
});
|
||||
it('calls the collapseTable action', () => {
|
||||
const wrapper = mount(<TableElement {...mockedProps} />);
|
||||
const wrapper = mount(
|
||||
<Provider store={store}>
|
||||
<TableElement {...mockedProps} />
|
||||
</Provider>,
|
||||
);
|
||||
expect(mockedActions.collapseTable.called).toBe(false);
|
||||
wrapper.find('.table-name').simulate('click');
|
||||
expect(mockedActions.collapseTable.called).toBe(true);
|
||||
|
|
|
@ -114,14 +114,12 @@ export default function Button(props: ButtonProps) {
|
|||
{props.children}
|
||||
</SupersetButton>
|
||||
<ul className="dropdown-menu">
|
||||
{dropdownItems.map(
|
||||
(dropdownItem: DropdownItemProps, index1: number) => (
|
||||
<MenuItem key={`${dropdownItem.label}`} href={dropdownItem.url}>
|
||||
<i className={`fa ${dropdownItem.icon}`} />
|
||||
{dropdownItem.label}
|
||||
</MenuItem>
|
||||
),
|
||||
)}
|
||||
{dropdownItems.map((dropdownItem: DropdownItemProps) => (
|
||||
<MenuItem key={`${dropdownItem.label}`} href={dropdownItem.url}>
|
||||
<i className={`fa ${dropdownItem.icon}`} />
|
||||
{dropdownItem.label}
|
||||
</MenuItem>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -20,6 +20,7 @@ import React from 'react';
|
|||
import PropTypes from 'prop-types';
|
||||
import { Tooltip, OverlayTrigger, MenuItem } from 'react-bootstrap';
|
||||
import { t } from '@superset-ui/translation';
|
||||
import withToasts from 'src/messageToasts/enhancers/withToasts';
|
||||
|
||||
const propTypes = {
|
||||
copyNode: PropTypes.node,
|
||||
|
@ -30,6 +31,7 @@ const propTypes = {
|
|||
inMenu: PropTypes.bool,
|
||||
wrapped: PropTypes.bool,
|
||||
tooltipText: PropTypes.string,
|
||||
addDangerToast: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
const defaultProps = {
|
||||
|
@ -41,7 +43,7 @@ const defaultProps = {
|
|||
tooltipText: t('Copy to clipboard'),
|
||||
};
|
||||
|
||||
export default class CopyToClipboard extends React.Component {
|
||||
class CopyToClipboard extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
|
@ -95,9 +97,9 @@ export default class CopyToClipboard extends React.Component {
|
|||
throw new Error(t('Not successful'));
|
||||
}
|
||||
} catch (err) {
|
||||
window.alert(
|
||||
this.props.addDangerToast(
|
||||
t('Sorry, your browser does not support copying. Use Ctrl / Cmd + C!'),
|
||||
); // eslint-disable-line
|
||||
);
|
||||
}
|
||||
|
||||
document.body.removeChild(span);
|
||||
|
@ -194,5 +196,7 @@ export default class CopyToClipboard extends React.Component {
|
|||
}
|
||||
}
|
||||
|
||||
export default withToasts(CopyToClipboard);
|
||||
|
||||
CopyToClipboard.propTypes = propTypes;
|
||||
CopyToClipboard.defaultProps = defaultProps;
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
import React, { useEffect } from 'react';
|
||||
import { logging } from '@superset-ui/core';
|
||||
|
||||
interface ImageLoaderProps
|
||||
extends React.DetailedHTMLProps<
|
||||
|
@ -48,7 +49,7 @@ export default function ImageLoader({
|
|||
}
|
||||
})
|
||||
.catch(e => {
|
||||
console.error(e); // eslint-disable-line no-console
|
||||
logging.error(e);
|
||||
setImgSrc(fallback);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import {
|
|||
import { t } from '@superset-ui/translation';
|
||||
import rison from 'rison';
|
||||
import getClientErrorObject from 'src/utils/getClientErrorObject';
|
||||
import { logging } from '@superset-ui/core';
|
||||
|
||||
export const createFetchRelated = (
|
||||
resource: string,
|
||||
|
@ -56,7 +57,7 @@ export const createFetchRelated = (
|
|||
export function createErrorHandler(handleErrorFunc: (errMsg?: string) => void) {
|
||||
return async (e: SupersetClientResponse | string) => {
|
||||
const parsedError = await getClientErrorObject(e);
|
||||
console.error(e);
|
||||
logging.error(e);
|
||||
handleErrorFunc(parsedError.message);
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue