mirror of
https://github.com/apache/superset.git
synced 2024-09-12 00:29:39 -04:00
This reverts commit e93d92e8ac
.
This commit is contained in:
parent
50d80405a9
commit
7a72082d31
@ -18,33 +18,27 @@
|
|||||||
*/
|
*/
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { shallow } from 'enzyme';
|
import { shallow } from 'enzyme';
|
||||||
import DataTable from '@superset-ui/plugin-chart-table/lib/DataTable';
|
import { Table } from 'reactable-arc';
|
||||||
import * as useMountedMemo from '@superset-ui/plugin-chart-table/lib/DataTable/utils/useMountedMemo';
|
|
||||||
import QueryTable from 'src/SqlLab/components/QueryTable';
|
import QueryTable from 'src/SqlLab/components/QueryTable';
|
||||||
|
|
||||||
import { dataTableProps } from 'spec/javascripts/sqllab/fixtures';
|
import { queries } from './fixtures';
|
||||||
|
|
||||||
describe('QueryTable', () => {
|
describe('QueryTable', () => {
|
||||||
// hack for mocking hook that implements sticky behaviour of DataTable
|
|
||||||
jest
|
|
||||||
.spyOn(useMountedMemo, 'default')
|
|
||||||
.mockImplementation(() => ({ width: 100, height: 100 }));
|
|
||||||
const mockedProps = {
|
const mockedProps = {
|
||||||
...dataTableProps,
|
queries,
|
||||||
displayLimit: 10000,
|
|
||||||
};
|
};
|
||||||
it('is valid', () => {
|
it('is valid', () => {
|
||||||
expect(React.isValidElement(<QueryTable {...mockedProps} />)).toBe(true);
|
expect(React.isValidElement(<QueryTable />)).toBe(true);
|
||||||
});
|
});
|
||||||
it('is valid with props', () => {
|
it('is valid with props', () => {
|
||||||
expect(React.isValidElement(<QueryTable {...mockedProps} />)).toBe(true);
|
expect(React.isValidElement(<QueryTable {...mockedProps} />)).toBe(true);
|
||||||
});
|
});
|
||||||
it('renders a proper table', () => {
|
it('renders a proper table', () => {
|
||||||
const wrapper = shallow(<QueryTable {...mockedProps} />);
|
const wrapper = shallow(<QueryTable {...mockedProps} />);
|
||||||
expect(wrapper.find(DataTable)).toExist();
|
expect(wrapper.find(Table)).toExist();
|
||||||
expect(wrapper.find(DataTable).shallow().find('table')).toExist();
|
expect(wrapper.find(Table).shallow().find('table')).toExist();
|
||||||
expect(
|
expect(wrapper.find(Table).shallow().find('table').find('Tr')).toHaveLength(
|
||||||
wrapper.find(DataTable).shallow().find('tbody').find('tr'),
|
2,
|
||||||
).toHaveLength(2);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -493,8 +493,3 @@ export const query = {
|
|||||||
ctas: false,
|
ctas: false,
|
||||||
cached: false,
|
cached: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const dataTableProps = {
|
|
||||||
columns: ['dbId', 'sql'],
|
|
||||||
queries,
|
|
||||||
};
|
|
||||||
|
@ -19,17 +19,17 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
import { Table } from 'reactable-arc';
|
||||||
import { ProgressBar, Well } from 'react-bootstrap';
|
import { ProgressBar, Well } from 'react-bootstrap';
|
||||||
import Label from 'src/components/Label';
|
import Label from 'src/components/Label';
|
||||||
import { t } from '@superset-ui/core';
|
import { t } from '@superset-ui/core';
|
||||||
import DataTable from '@superset-ui/plugin-chart-table/lib/DataTable';
|
|
||||||
|
|
||||||
import Button from 'src/components/Button';
|
import Button from 'src/components/Button';
|
||||||
import { fDuration } from 'src/modules/dates';
|
|
||||||
import Link from '../../components/Link';
|
import Link from '../../components/Link';
|
||||||
import ResultSet from './ResultSet';
|
import ResultSet from './ResultSet';
|
||||||
import ModalTrigger from '../../components/ModalTrigger';
|
import ModalTrigger from '../../components/ModalTrigger';
|
||||||
import HighlightedSql from './HighlightedSql';
|
import HighlightedSql from './HighlightedSql';
|
||||||
|
import { fDuration } from '../../modules/dates';
|
||||||
import QueryStateLabel from './QueryStateLabel';
|
import QueryStateLabel from './QueryStateLabel';
|
||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
@ -213,20 +213,14 @@ class QueryTable extends React.PureComponent {
|
|||||||
})
|
})
|
||||||
.reverse();
|
.reverse();
|
||||||
return (
|
return (
|
||||||
<DataTable
|
<div className="QueryTable">
|
||||||
tableClassName="table table-condensed"
|
<Table
|
||||||
columns={this.props.columns.map(column => ({
|
columns={this.props.columns}
|
||||||
accessor: column,
|
className="table table-condensed"
|
||||||
Header: () => <th>{column}</th>,
|
|
||||||
Cell: ({ value }) => <td>{value}</td>,
|
|
||||||
}))}
|
|
||||||
data={data}
|
data={data}
|
||||||
pageSize={10}
|
itemsPerPage={50}
|
||||||
maxPageItemCount={9}
|
|
||||||
searchInput={false}
|
|
||||||
height="100%"
|
|
||||||
sticky
|
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user