-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
f208dfd
Upgrade react-split
kgabryje 705af79
Implement split on ExploreChartPanel
kgabryje cd698ac
Implement tabs with collapse
kgabryje 505b1bd
Fix run query button
kgabryje 40f53b1
Fix copy to clipboard button
kgabryje 1be6df7
Move table controls to separate file
kgabryje 85b7c77
Make component more generic to handle samples
kgabryje 677830b
Remove samples from DisplayQueryButton
kgabryje a3cc158
Move data tables to separate file
kgabryje e63cc63
Make split dynamically controlled
kgabryje 0826a58
Fix unit test
kgabryje c51ef6a
Fix arrow not centered
kgabryje 976197e
fixup! Fix arrow not centered
kgabryje f9fdaa6
Change copy button paddings
kgabryje f733f4f
Use translations
kgabryje 62931da
Fix grammar in a comment
kgabryje 1c1dd2c
Fix imports
kgabryje 879f973
Use grid units
kgabryje 694099d
Convert new files to typescript
kgabryje 227135d
Fix after rebase
kgabryje e20d4f9
Remove forceRender
kgabryje 9a9517a
Fix big_number test
kgabryje 03c0c34
Delay making request until panel is opened
kgabryje 127b259
White background in south panel
kgabryje c897e74
fixup! White background in south panel
kgabryje 2869377
Lint fix
kgabryje 7ad3415
Lint fix
kgabryje f7e76f3
Remove redundant prop types
kgabryje 689c16a
Remove console log
kgabryje 15851b4
Delay loading samples until user switches tab
kgabryje 4e4da81
Add debounce to filter input
kgabryje 62bd8f4
Use gridUnit for gutter sizes
kgabryje 585844f
Change types object to Record<string, any>
kgabryje File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
superset-frontend/src/explore/components/DataTableControl.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) : ''} | ||
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], | ||
); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
todata?: Record<string, any>