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