mirror of
https://github.com/apache/superset.git
synced 2026-06-01 21:59:26 +00:00
feat(explore): each control can define its own canDrop for dnd (#16090)
* feat(explore): each control can define its own canDrop for dnd * Make canDropValue optional * Add onDropValue
This commit is contained in:
committed by
GitHub
parent
a70248736f
commit
6e1d16d956
@@ -40,9 +40,11 @@ export default function DndSelectLabel<T, O>({
|
||||
|
||||
drop: (item: DatasourcePanelDndItem) => {
|
||||
props.onDrop(item);
|
||||
props.onDropValue?.(item.value);
|
||||
},
|
||||
|
||||
canDrop: (item: DatasourcePanelDndItem) => props.canDrop(item),
|
||||
canDrop: (item: DatasourcePanelDndItem) =>
|
||||
props.canDrop(item) && (props.canDropValue?.(item.value) ?? true),
|
||||
|
||||
collect: monitor => ({
|
||||
isOver: monitor.isOver(),
|
||||
|
||||
@@ -19,7 +19,10 @@
|
||||
import { ReactNode } from 'react';
|
||||
import { Metric } from '@superset-ui/core';
|
||||
import { ColumnMeta } from '@superset-ui/chart-controls';
|
||||
import { DatasourcePanelDndItem } from '../../DatasourcePanel/types';
|
||||
import {
|
||||
DatasourcePanelDndItem,
|
||||
DndItemValue,
|
||||
} from '../../DatasourcePanel/types';
|
||||
import { DndItemType } from '../../DndItemType';
|
||||
|
||||
export interface OptionProps {
|
||||
@@ -53,6 +56,8 @@ export interface DndColumnSelectProps<
|
||||
> extends LabelProps<T> {
|
||||
onDrop: (item: DatasourcePanelDndItem) => void;
|
||||
canDrop: (item: DatasourcePanelDndItem) => boolean;
|
||||
canDropValue?: (value: DndItemValue) => boolean;
|
||||
onDropValue?: (value: DndItemValue) => void;
|
||||
valuesRenderer: () => ReactNode;
|
||||
accept: DndItemType | DndItemType[];
|
||||
ghostButtonText?: string;
|
||||
|
||||
Reference in New Issue
Block a user