mirror of
https://github.com/apache/superset.git
synced 2026-04-20 08:34:37 +00:00
feat: Adds drill to detail context menu to Table (#21168)
* feat: Adds drill to detail context menu to Table * Improves context menu positioning * Fixes Pivot Table typying
This commit is contained in:
committed by
GitHub
parent
982210ad83
commit
68fa4d2665
@@ -39,6 +39,7 @@ import {
|
||||
ensureIsArray,
|
||||
GenericDataType,
|
||||
getTimeFormatterForGranularity,
|
||||
QueryObjectFilterClause,
|
||||
styled,
|
||||
t,
|
||||
tn,
|
||||
@@ -205,6 +206,7 @@ export default function TableChart<D extends DataRecord = DataRecord>(
|
||||
sticky = true, // whether to use sticky header
|
||||
columnColorFormatters,
|
||||
allowRearrangeColumns = false,
|
||||
onContextMenu,
|
||||
} = props;
|
||||
const timestampFormatter = useCallback(
|
||||
value => getTimeFormatterForGranularity(timeGrain)(value),
|
||||
@@ -576,6 +578,24 @@ export default function TableChart<D extends DataRecord = DataRecord>(
|
||||
|
||||
const { width: widthFromState, height: heightFromState } = tableSize;
|
||||
|
||||
const handleContextMenu =
|
||||
onContextMenu && !isRawRecords
|
||||
? (value: D, clientX: number, clientY: number) => {
|
||||
const filters: QueryObjectFilterClause[] = [];
|
||||
columnsMeta.forEach(col => {
|
||||
if (!col.isMetric) {
|
||||
filters.push({
|
||||
col: col.key,
|
||||
op: '==',
|
||||
val: value[col.key] as string | number | boolean,
|
||||
formattedVal: String(value[col.key]),
|
||||
});
|
||||
}
|
||||
});
|
||||
onContextMenu(filters, clientX, clientY);
|
||||
}
|
||||
: undefined;
|
||||
|
||||
return (
|
||||
<Styles>
|
||||
<DataTable<D>
|
||||
@@ -598,6 +618,7 @@ export default function TableChart<D extends DataRecord = DataRecord>(
|
||||
selectPageSize={pageSize !== null && SelectPageSize}
|
||||
// not in use in Superset, but needed for unit tests
|
||||
sticky={sticky}
|
||||
onContextMenu={handleContextMenu}
|
||||
/>
|
||||
</Styles>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user