-
Notifications
You must be signed in to change notification settings - Fork 16.6k
feat(explore): ColumnSelectControl with drag-and-drop #13210
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
Changes from all commits
215124b
e142b6a
3ee03ed
f073c1e
f797e55
6563283
ad28813
8b699d7
f59bf84
c985c25
507ca47
d4e2a58
d97ed8d
6b6327b
7296a54
671eaed
49989ea
64f8d4d
41126f6
44d2bec
1854cd7
3510e15
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /** | ||
| * 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, { ReactNode } from 'react'; | ||
| import { useDrag } from 'react-dnd'; | ||
| import { styled } from '@superset-ui/core'; | ||
| import { DatasourcePanelDndItem } from './types'; | ||
|
|
||
| const DatasourceItemContainer = styled.div` | ||
| display: flex; | ||
| align-items: center; | ||
| width: 100%; | ||
| height: ${({ theme }) => theme.gridUnit * 6}px; | ||
| cursor: pointer; | ||
|
|
||
| :hover { | ||
| background-color: ${({ theme }) => theme.colors.grayscale.light2}; | ||
| } | ||
| `; | ||
|
|
||
| interface DatasourcePanelDragWrapperProps extends DatasourcePanelDndItem { | ||
| children?: ReactNode; | ||
| } | ||
|
|
||
| export default function DatasourcePanelDragWrapper( | ||
| props: DatasourcePanelDragWrapperProps, | ||
| ) { | ||
| const [, drag] = useDrag({ | ||
| item: { | ||
| metricOrColumnName: props.metricOrColumnName, | ||
| type: props.type, | ||
| }, | ||
| }); | ||
|
|
||
| return ( | ||
| <DatasourceItemContainer ref={drag}> | ||
| {props.children} | ||
| </DatasourceItemContainer> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,30 @@ | ||||||||||
| /** | ||||||||||
| * 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. | ||||||||||
| */ | ||||||||||
| export enum DatasourcePanelDndType { | ||||||||||
| // todo: The new `metric` conflicts with the existing metric type | ||||||||||
| METRIC = 'datasource-panel-metric', | ||||||||||
| COLUMN = 'column', | ||||||||||
| } | ||||||||||
|
|
||||||||||
| export interface DatasourcePanelDndItem { | ||||||||||
| metricOrColumnName: string; | ||||||||||
| type: | ||||||||||
| | typeof DatasourcePanelDndType.METRIC | ||||||||||
| | typeof DatasourcePanelDndType.COLUMN; | ||||||||||
|
||||||||||
| type: | |
| | typeof DatasourcePanelDndType.METRIC | |
| | typeof DatasourcePanelDndType.COLUMN; | |
| type: DatasourcePanelDndType; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,14 +27,14 @@ import { Tooltip } from 'src/common/components/Tooltip'; | |
| import Icon from 'src/components/Icon'; | ||
| import { savedMetricType } from 'src/explore/components/controls/MetricControl/types'; | ||
|
|
||
| const DragContainer = styled.div` | ||
| export const DragContainer = styled.div` | ||
| margin-bottom: ${({ theme }) => theme.gridUnit}px; | ||
| :last-child { | ||
| margin-bottom: 0; | ||
| } | ||
| `; | ||
|
|
||
| const OptionControlContainer = styled.div<{ | ||
| export const OptionControlContainer = styled.div<{ | ||
| isAdhoc?: boolean; | ||
| }>` | ||
| display: flex; | ||
|
|
@@ -47,7 +47,7 @@ const OptionControlContainer = styled.div<{ | |
| cursor: ${({ isAdhoc }) => (isAdhoc ? 'pointer' : 'default')}; | ||
| `; | ||
|
|
||
| const Label = styled.div` | ||
| export const Label = styled.div` | ||
| display: flex; | ||
| max-width: 100%; | ||
| overflow: hidden; | ||
|
|
@@ -63,13 +63,13 @@ const Label = styled.div` | |
| } | ||
| `; | ||
|
|
||
| const CaretContainer = styled.div` | ||
| export const CaretContainer = styled.div` | ||
| height: 100%; | ||
| border-left: solid 1px ${({ theme }) => theme.colors.grayscale.dark2}0C; | ||
| margin-left: auto; | ||
| `; | ||
|
|
||
| const CloseContainer = styled.div` | ||
| export const CloseContainer = styled.div` | ||
| height: 100%; | ||
| width: ${({ theme }) => theme.gridUnit * 6}px; | ||
| border-right: solid 1px ${({ theme }) => theme.colors.grayscale.dark2}0C; | ||
|
|
@@ -92,7 +92,26 @@ export const LabelsContainer = styled.div` | |
| border-radius: ${({ theme }) => theme.gridUnit}px; | ||
| `; | ||
|
|
||
| export const AddControlLabel = styled.div` | ||
| export const DndLabelsContainer = styled.div<{ | ||
| canDrop?: boolean; | ||
| isOver?: boolean; | ||
| }>` | ||
| padding: ${({ theme }) => theme.gridUnit}px; | ||
| border: ${({ canDrop, isOver, theme }) => { | ||
| if (isOver && canDrop) { | ||
| return `dashed 1px ${theme.colors.info.dark1}`; | ||
| } | ||
| if (isOver && !canDrop) { | ||
| return `dashed 1px ${theme.colors.error.dark1}`; | ||
| } | ||
|
||
| return `solid 1px ${theme.colors.grayscale.light2}`; | ||
| }}; | ||
| border-radius: ${({ theme }) => theme.gridUnit}px; | ||
| `; | ||
|
|
||
| export const AddControlLabel = styled.div<{ | ||
| cancelHover?: boolean; | ||
| }>` | ||
| display: flex; | ||
| align-items: center; | ||
| width: 100%; | ||
|
|
@@ -102,14 +121,16 @@ export const AddControlLabel = styled.div` | |
| color: ${({ theme }) => theme.colors.grayscale.light1}; | ||
| border: dashed 1px ${({ theme }) => theme.colors.grayscale.light2}; | ||
| border-radius: ${({ theme }) => theme.gridUnit}px; | ||
| cursor: pointer; | ||
| cursor: ${({ cancelHover }) => (cancelHover ? 'inherit' : 'pointer')}; | ||
|
|
||
| :hover { | ||
| background-color: ${({ theme }) => theme.colors.grayscale.light4}; | ||
| background-color: ${({ cancelHover, theme }) => | ||
| cancelHover ? 'inherit' : theme.colors.grayscale.light4}; | ||
| } | ||
|
|
||
| :active { | ||
| background-color: ${({ theme }) => theme.colors.grayscale.light3}; | ||
| background-color: ${({ cancelHover, theme }) => | ||
| cancelHover ? 'inherit' : theme.colors.grayscale.light3}; | ||
| } | ||
| `; | ||
|
|
||
|
|
||
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.
What do you think about using a
cursor: moveinstead of default here?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.
sorry, what is
cursor: moveon this?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.
I mean that here we could use

cursor: moveto indicate that the label is draggableThere 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.
All right, I will add indicator style on this component and drop component.
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.
The style
pointer: moveon the datasource panel looks strange. the UI behavior we can ask @mihir174move.mp4