You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/11/12 17:20:18 UTC

[GitHub] [superset] geido commented on a change in pull request #17379: feat(explore): adhoc column expressions [ID-3]

geido commented on a change in pull request #17379:
URL: https://github.com/apache/superset/pull/17379#discussion_r748425157



##########
File path: superset-frontend/src/explore/components/controls/DndColumnSelectControl/ColumnSelectPopover.tsx
##########
@@ -41,29 +53,48 @@ const StyledSelect = styled(Select)`
 
 interface ColumnSelectPopoverProps {
   columns: ColumnMeta[];
-  editedColumn?: ColumnMeta;
-  onChange: (column: ColumnMeta) => void;
+  editedColumn?: ColumnMeta | AdhocColumn;
+  onChange: (column: ColumnMeta | AdhocColumn) => void;
   onClose: () => void;
+  setLabel: (title: string) => void;
+  getCurrentTab: (tab: string) => void;
+  label: string;
+  isAdhocColumnsEnabled: boolean;
 }
 
 const ColumnSelectPopover = ({
   columns,
   editedColumn,
   onChange,
   onClose,
+  setLabel,
+  getCurrentTab,
+  label,
+  isAdhocColumnsEnabled,
 }: ColumnSelectPopoverProps) => {
-  const [
-    initialCalculatedColumn,
-    initialSimpleColumn,
-  ] = editedColumn?.expression
-    ? [editedColumn, undefined]
-    : [undefined, editedColumn];
-  const [selectedCalculatedColumn, setSelectedCalculatedColumn] = useState(
-    initialCalculatedColumn,
-  );
-  const [selectedSimpleColumn, setSelectedSimpleColumn] = useState(
-    initialSimpleColumn,
+  const [initialLabel] = useState(label);
+  const [initialAdhocColumn, initialCalculatedColumn, initialSimpleColumn]: [
+    AdhocColumn?,
+    ColumnMeta?,
+    ColumnMeta?,
+  ] = !editedColumn
+    ? [undefined, undefined, undefined]

Review comment:
       I appreciate the brevity but this is probably one of those instances where brevity goes against readability. I would prefer to see all these logics below unpacked but that's a personal preference and not a blocker.




-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org