villebro commented on a change in pull request #17379:
URL: https://github.com/apache/superset/pull/17379#discussion_r748465429
##########
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:
Yeah, this is definitely one of the more extreme cases of nested
ternaries. We've discussed this one before, maybe we should put this on the
TODO of things to clarify in an upcoming follow-up
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]