Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Revert "Replace reactable with DataTable from superset-ui in QueryTab… #11125

Merged
merged 1 commit into from
Oct 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 9 additions & 15 deletions superset-frontend/spec/javascripts/sqllab/QueryTable_spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,27 @@
*/
import React from 'react';
import { shallow } from 'enzyme';
import DataTable from '@superset-ui/plugin-chart-table/lib/DataTable';
import * as useMountedMemo from '@superset-ui/plugin-chart-table/lib/DataTable/utils/useMountedMemo';
import { Table } from 'reactable-arc';
import QueryTable from 'src/SqlLab/components/QueryTable';

import { dataTableProps } from 'spec/javascripts/sqllab/fixtures';
import { queries } from './fixtures';

describe('QueryTable', () => {
// hack for mocking hook that implements sticky behaviour of DataTable
jest
.spyOn(useMountedMemo, 'default')
.mockImplementation(() => ({ width: 100, height: 100 }));
const mockedProps = {
...dataTableProps,
displayLimit: 10000,
queries,
};
it('is valid', () => {
expect(React.isValidElement(<QueryTable {...mockedProps} />)).toBe(true);
expect(React.isValidElement(<QueryTable />)).toBe(true);
});
it('is valid with props', () => {
expect(React.isValidElement(<QueryTable {...mockedProps} />)).toBe(true);
});
it('renders a proper table', () => {
const wrapper = shallow(<QueryTable {...mockedProps} />);
expect(wrapper.find(DataTable)).toExist();
expect(wrapper.find(DataTable).shallow().find('table')).toExist();
expect(
wrapper.find(DataTable).shallow().find('tbody').find('tr'),
).toHaveLength(2);
expect(wrapper.find(Table)).toExist();
expect(wrapper.find(Table).shallow().find('table')).toExist();
expect(wrapper.find(Table).shallow().find('table').find('Tr')).toHaveLength(
2,
);
});
});
5 changes: 0 additions & 5 deletions superset-frontend/spec/javascripts/sqllab/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,3 @@ export const query = {
ctas: false,
cached: false,
};

export const dataTableProps = {
columns: ['dbId', 'sql'],
queries,
};
26 changes: 10 additions & 16 deletions superset-frontend/src/SqlLab/components/QueryTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@
import React from 'react';
import PropTypes from 'prop-types';
import moment from 'moment';
import { Table } from 'reactable-arc';
import { ProgressBar, Well } from 'react-bootstrap';
import Label from 'src/components/Label';
import { t } from '@superset-ui/core';
import DataTable from '@superset-ui/plugin-chart-table/lib/DataTable';

import Button from 'src/components/Button';
import { fDuration } from 'src/modules/dates';
import Link from '../../components/Link';
import ResultSet from './ResultSet';
import ModalTrigger from '../../components/ModalTrigger';
import HighlightedSql from './HighlightedSql';
import { fDuration } from '../../modules/dates';
import QueryStateLabel from './QueryStateLabel';

const propTypes = {
Expand Down Expand Up @@ -213,20 +213,14 @@ class QueryTable extends React.PureComponent {
})
.reverse();
return (
<DataTable
tableClassName="table table-condensed"
columns={this.props.columns.map(column => ({
accessor: column,
Header: () => <th>{column}</th>,
Cell: ({ value }) => <td>{value}</td>,
}))}
data={data}
pageSize={10}
maxPageItemCount={9}
searchInput={false}
height="100%"
sticky
/>
<div className="QueryTable">
<Table
columns={this.props.columns}
className="table table-condensed"
data={data}
itemsPerPage={50}
/>
</div>
);
}
}
Expand Down