kgabryje commented on a change in pull request #13210:
URL: https://github.com/apache/superset/pull/13210#discussion_r581012403



##########
File path: 
superset-frontend/src/explore/components/controls/DndColumnSelectControl/DndColumnSelectLabel.tsx
##########
@@ -0,0 +1,118 @@
+/**
+ * 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, { useState } from 'react';
+import { useDrop } from 'react-dnd';
+import { isEmpty } from 'lodash';
+import { t, withTheme, SupersetTheme } from '@superset-ui/core';
+import { BaseControlConfig, ColumnMeta } from '@superset-ui/chart-controls';
+import ControlHeader from 'src/explore/components/ControlHeader';
+import {
+  AddControlLabel,
+  HeaderContainer,
+  LabelsContainer,
+} from 'src/explore/components/OptionControls';
+import {
+  DatasourcePanelDndType,
+  DatasourcePanelDndItem,
+} from 'src/explore/components/DatasourcePanel/types';
+import Icon from 'src/components/Icon';
+import OptionWrapper from './components/OptionWrapper';
+import { OptionSelector } from './utils';
+
+interface LabelProps extends BaseControlConfig {
+  name: string;
+  value: string[] | string | null;
+  onChange: (value: string[] | string | null) => void;
+  options: { string: ColumnMeta };
+  theme: SupersetTheme;
+}
+
+function DndColumnSelectLabel(props: LabelProps) {
+  const { value, options } = props;
+  const optionSelector = new OptionSelector(options, value);
+  const [groupByOptions, setGroupByOptions] = useState<ColumnMeta[]>(
+    optionSelector.groupByOptions,
+  );
+
+  const [, datasourcePanelDrop] = useDrop({
+    accept: DatasourcePanelDndType.COLUMN,
+
+    drop: (item: DatasourcePanelDndItem) => {
+      optionSelector.add(item.metricOrColumnName);
+      setGroupByOptions(optionSelector.groupByOptions);
+      props.onChange(optionSelector.getValues());
+    },
+
+    canDrop: (item: DatasourcePanelDndItem) =>
+      !optionSelector.has(item.metricOrColumnName),
+
+    collect: monitor => ({
+      isOver: monitor.isOver(),
+      canDrop: monitor.canDrop(),
+    }),
+  });
+
+  function onClickClose(index: number) {
+    optionSelector.del(index);
+    setGroupByOptions(optionSelector.groupByOptions);
+    props.onChange(optionSelector.getValues());
+  }
+
+  function onShiftOptions(dragIndex: number, hoverIndex: number) {
+    optionSelector.swap(dragIndex, hoverIndex);
+    setGroupByOptions(optionSelector.groupByOptions);
+    props.onChange(optionSelector.getValues());
+  }
+
+  function placeHolderRenderer() {
+    return (
+      <AddControlLabel cancelHover>

Review comment:
       Hmm, I suppose it's a product decision and we can wait for Junlin's 
input, but I'd go for allowing users to choose the way they want to interact 
with our control panel. Removing normal select in favour of dnd feels like a 
step back to me




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to