Skip to content

Commit

Permalink
fix(datasets): Replace left panel layout by TableSelector (#24599)
Browse files Browse the repository at this point in the history
Co-authored-by: Justin Park <justinpark@apache.org>
  • Loading branch information
justinpark and Justin Park authored Jul 20, 2023
1 parent df106aa commit b2831b4
Show file tree
Hide file tree
Showing 7 changed files with 216 additions and 352 deletions.
8 changes: 7 additions & 1 deletion superset-frontend/src/components/TableSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ interface TableSelectorProps {
tableValue?: string | string[];
onTableSelectChange?: (value?: string | string[], schema?: string) => void;
tableSelectMode?: 'single' | 'multiple';
customTableOptionLabelRenderer?: (table: Table) => JSX.Element;
}

export interface TableOption {
Expand Down Expand Up @@ -132,6 +133,7 @@ export const TableOption = ({ table }: { table: Table }) => {
<WarningIconWithTooltip
warningMarkdown={extra.warning_markdown}
size="l"
marginRight={4}
/>
)}
{value}
Expand Down Expand Up @@ -164,6 +166,7 @@ const TableSelector: FunctionComponent<TableSelectorProps> = ({
tableSelectMode = 'single',
tableValue = undefined,
onTableSelectChange,
customTableOptionLabelRenderer,
}) => {
const { addSuccessToast } = useToasts();
const [currentSchema, setCurrentSchema] = useState<string | undefined>(
Expand Down Expand Up @@ -203,9 +206,12 @@ const TableSelector: FunctionComponent<TableSelectorProps> = ({
value: table.value,
label: <TableOption table={table} />,
text: table.value,
...(customTableOptionLabelRenderer && {
customLabel: customTableOptionLabelRenderer(table),
}),
}))
: [],
[data],
[data, customTableOptionLabelRenderer],
);

useEffect(() => {
Expand Down
3 changes: 3 additions & 0 deletions superset-frontend/src/components/Tooltip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ export const Tooltip = (props: TooltipProps) => {
display: block;
}
}
.ant-tooltip-inner > p {
margin: 0;
}
`}
/>
<AntdTooltip
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ import { Tooltip } from 'src/components/Tooltip';
export interface WarningIconWithTooltipProps {
warningMarkdown: string;
size?: IconType['iconSize'];
marginRight?: number;
}

function WarningIconWithTooltip({
warningMarkdown,
size,
marginRight,
}: WarningIconWithTooltipProps) {
const theme = useTheme();
return (
Expand All @@ -39,7 +41,7 @@ function WarningIconWithTooltip({
<Icons.AlertSolid
iconColor={theme.colors.alert.base}
iconSize={size}
css={{ marginRight: theme.gridUnit * 2 }}
css={{ marginRight: marginRight ?? theme.gridUnit * 2 }}
/>
</Tooltip>
);
Expand Down
Loading

0 comments on commit b2831b4

Please sign in to comment.