mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
fix: copy to Clipboard order (#16299)
* copy to Clipboard order * centralized copyToClipboard * fixed table order * fixed tests * added colnames to all viz types * added colnames to all viz types * added colnames to all viz types
This commit is contained in:
@@ -55,11 +55,15 @@ const CopyNode = (
|
||||
|
||||
export const CopyToClipboardButton = ({
|
||||
data,
|
||||
columns,
|
||||
}: {
|
||||
data?: Record<string, any>;
|
||||
columns?: string[];
|
||||
}) => (
|
||||
<CopyToClipboard
|
||||
text={data ? prepareCopyToClipboardTabularData(data) : ''}
|
||||
text={
|
||||
data && columns ? prepareCopyToClipboardTabularData(data, columns) : ''
|
||||
}
|
||||
wrapped={false}
|
||||
copyNode={CopyNode}
|
||||
/>
|
||||
@@ -113,29 +117,32 @@ export const useFilteredTableData = (
|
||||
}, [data, filterText]);
|
||||
|
||||
export const useTableColumns = (
|
||||
colnames?: string[],
|
||||
data?: Record<string, any>[],
|
||||
moreConfigs?: { [key: string]: Partial<Column> },
|
||||
) =>
|
||||
useMemo(
|
||||
() =>
|
||||
data?.length
|
||||
? Object.keys(data[0]).map(
|
||||
key =>
|
||||
({
|
||||
accessor: row => row[key],
|
||||
Header: key,
|
||||
Cell: ({ value }) => {
|
||||
if (value === true) {
|
||||
return BOOL_TRUE_DISPLAY;
|
||||
}
|
||||
if (value === false) {
|
||||
return BOOL_FALSE_DISPLAY;
|
||||
}
|
||||
return String(value);
|
||||
},
|
||||
...moreConfigs?.[key],
|
||||
} as Column),
|
||||
)
|
||||
colnames && data?.length
|
||||
? colnames
|
||||
.filter((column: string) => Object.keys(data[0]).includes(column))
|
||||
.map(
|
||||
key =>
|
||||
({
|
||||
accessor: row => row[key],
|
||||
Header: key,
|
||||
Cell: ({ value }) => {
|
||||
if (value === true) {
|
||||
return BOOL_TRUE_DISPLAY;
|
||||
}
|
||||
if (value === false) {
|
||||
return BOOL_FALSE_DISPLAY;
|
||||
}
|
||||
return String(value);
|
||||
},
|
||||
...moreConfigs?.[key],
|
||||
} as Column),
|
||||
)
|
||||
: [],
|
||||
[data, moreConfigs],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user