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

feat: Results table on Explore view #11854

Merged
merged 33 commits into from
Dec 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
f208dfd
Upgrade react-split
kgabryje Nov 30, 2020
705af79
Implement split on ExploreChartPanel
kgabryje Nov 30, 2020
cd698ac
Implement tabs with collapse
kgabryje Nov 30, 2020
505b1bd
Fix run query button
kgabryje Dec 2, 2020
40f53b1
Fix copy to clipboard button
kgabryje Dec 2, 2020
1be6df7
Move table controls to separate file
kgabryje Dec 2, 2020
85b7c77
Make component more generic to handle samples
kgabryje Dec 2, 2020
677830b
Remove samples from DisplayQueryButton
kgabryje Dec 2, 2020
a3cc158
Move data tables to separate file
kgabryje Dec 2, 2020
e63cc63
Make split dynamically controlled
kgabryje Dec 2, 2020
0826a58
Fix unit test
kgabryje Dec 2, 2020
c51ef6a
Fix arrow not centered
kgabryje Dec 3, 2020
976197e
fixup! Fix arrow not centered
kgabryje Dec 3, 2020
f9fdaa6
Change copy button paddings
kgabryje Dec 3, 2020
f733f4f
Use translations
kgabryje Dec 3, 2020
62931da
Fix grammar in a comment
kgabryje Dec 3, 2020
1c1dd2c
Fix imports
kgabryje Dec 3, 2020
879f973
Use grid units
kgabryje Dec 3, 2020
694099d
Convert new files to typescript
kgabryje Dec 3, 2020
227135d
Fix after rebase
kgabryje Dec 3, 2020
e20d4f9
Remove forceRender
kgabryje Dec 3, 2020
9a9517a
Fix big_number test
kgabryje Dec 3, 2020
03c0c34
Delay making request until panel is opened
kgabryje Dec 3, 2020
127b259
White background in south panel
kgabryje Dec 3, 2020
c897e74
fixup! White background in south panel
kgabryje Dec 3, 2020
2869377
Lint fix
kgabryje Dec 3, 2020
7ad3415
Lint fix
kgabryje Dec 3, 2020
f7e76f3
Remove redundant prop types
kgabryje Dec 4, 2020
689c16a
Remove console log
kgabryje Dec 4, 2020
15851b4
Delay loading samples until user switches tab
kgabryje Dec 4, 2020
4e4da81
Add debounce to filter input
kgabryje Dec 4, 2020
62bd8f4
Use gridUnit for gutter sizes
kgabryje Dec 4, 2020
585844f
Change types object to Record<string, any>
kgabryje Dec 4, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ describe('Visualization > Big Number with Trendline', () => {
...BIG_NUMBER_FORM_DATA,
show_trend_line: false,
});
cy.get('.chart-container .header-line');
cy.get('.chart-container .subheader-line');
cy.get('.chart-container svg').should('not.exist');
cy.get('[data-test="chart-container"] .header-line');
cy.get('[data-test="chart-container"] .subheader-line');
cy.get('[data-test="chart-container"] svg').should('not.exist');
});
});
8 changes: 4 additions & 4 deletions superset-frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion superset-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
"react-select": "^3.1.0",
"react-select-async-paginate": "^0.4.1",
"react-sortable-hoc": "^1.11.0",
"react-split": "^2.0.4",
"react-split": "^2.0.9",
"react-sticky": "^6.0.3",
"react-syntax-highlighter": "^15.3.0",
"react-table": "^7.2.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('DisplayQueryButton', () => {
theme: supersetTheme,
},
});
expect(wrapper.find(ModalTrigger)).toHaveLength(3);
expect(wrapper.find(Menu.Item)).toHaveLength(5);
expect(wrapper.find(ModalTrigger)).toHaveLength(1);
expect(wrapper.find(Menu.Item)).toHaveLength(3);
});
});
2 changes: 2 additions & 0 deletions superset-frontend/src/chart/Chart.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ const defaultProps = {
};

const Styles = styled.div`
position: relative;
height: 100%;
.chart-tooltip {
opacity: 0.75;
font-size: ${({ theme }) => theme.typography.sizes.s}px;
Expand Down
105 changes: 105 additions & 0 deletions superset-frontend/src/explore/components/DataTableControl.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import React, { useMemo } from 'react';
import { styled, t } from '@superset-ui/core';
import { FormControl } from 'react-bootstrap';
import debounce from 'lodash/debounce';
import Button from 'src/components/Button';
import {
applyFormattingToTabularData,
prepareCopyToClipboardTabularData,
} from 'src/utils/common';
import CopyToClipboard from 'src/components/CopyToClipboard';
import RowCountLabel from './RowCountLabel';

export const CopyButton = styled(Button)`
font-size: ${({ theme }) => theme.typography.sizes.s}px;

// needed to override button's first-of-type margin: 0
&& {
margin: 0 ${({ theme }) => theme.gridUnit * 2}px;
}

i {
padding: 0 ${({ theme }) => theme.gridUnit}px;
}
`;

export const CopyToClipboardButton = ({
data,
}: {
data?: Record<string, any>;
}) => (
<CopyToClipboard
text={data ? prepareCopyToClipboardTabularData(data) : ''}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if data is always an object, then this check shouldn't be needed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It actually can be undefined, I changed data: object to data?: Record<string, any>

wrapped={false}
copyNode={
<CopyButton buttonSize="xs">
<i className="fa fa-clipboard" />
</CopyButton>
}
/>
);

export const FilterInput = ({
onChangeHandler,
}: {
onChangeHandler(filterText: string): void;
}) => {
const debouncedChangeHandler = debounce(onChangeHandler, 500);
return (
<FormControl
placeholder={t('Search')}
bsSize="sm"
onChange={(event: any) => {
const filterText = event.target.value;
debouncedChangeHandler(filterText);
}}
/>
);
};

export const RowCount = ({ data }: { data?: Record<string, any>[] }) => (
<RowCountLabel rowcount={data?.length ?? 0} suffix={t('rows retrieved')} />
);

export const useFilteredTableData = (
filterText: string,
data?: Record<string, any>[],
) =>
useMemo(() => {
if (!data?.length) {
return [];
}
const formattedData = applyFormattingToTabularData(data);
return formattedData.filter((row: Record<string, any>) =>
Object.values(row).some(value =>
value.toString().toLowerCase().includes(filterText.toLowerCase()),
),
);
}, [data, filterText]);

export const useTableColumns = (data?: Record<string, any>[]) =>
useMemo(
() =>
data?.length
? Object.keys(data[0]).map(key => ({ accessor: key, Header: key }))
: [],
[data],
);
Loading