Skip to content

Commit

Permalink
Add tooltipPlacement prop to MetadataBar instead of hardcoding "bottom"
Browse files Browse the repository at this point in the history
  • Loading branch information
kgabryje committed Oct 27, 2022
1 parent d91dd9e commit 71c6322
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,9 @@ export default function DrillDetailPane({
margin-bottom: ${theme.gridUnit * 4}px;
`}
>
{status === 'complete' && <MetadataBar items={items} />}
{status === 'complete' && (
<MetadataBar items={items} tooltipPlacement="bottom" />
)}
{status === 'error' && (
<Alert
type="error"
Expand Down
14 changes: 11 additions & 3 deletions superset-frontend/src/components/MetadataBar/MetadataBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import React, { useCallback, useEffect, useRef, useState } from 'react';
import { useResizeDetector } from 'react-resize-detector';
import { uniqWith } from 'lodash';
import { styled } from '@superset-ui/core';
import { Tooltip } from 'src/components/Tooltip';
import { Tooltip, TooltipPlacement } from 'src/components/Tooltip';
import { ContentType } from './ContentType';
import { config } from './ContentConfig';

Expand Down Expand Up @@ -116,11 +116,13 @@ const Item = ({
contentType,
collapsed,
last = false,
tooltipPlacement,
}: {
barWidth: number | undefined;
contentType: ContentType;
collapsed: boolean;
last?: boolean;
tooltipPlacement: TooltipPlacement;
}) => {
const { icon, title, tooltip = title } = config(contentType);
const [isTruncated, setIsTruncated] = useState(false);
Expand Down Expand Up @@ -150,7 +152,7 @@ const Item = ({
);
return isTruncated || collapsed || (tooltip && tooltip !== title) ? (
<Tooltip
placement="bottom"
placement={tooltipPlacement}
title={<TootipContent>{tooltip}</TootipContent>}
>
{content}
Expand All @@ -166,6 +168,11 @@ export interface MetadataBarProps {
* for each content type, check {@link ContentType}
*/
items: ContentType[];
/**
* Antd tooltip placement. To see available values, check {@link TooltipPlacement}.
* Defaults to "top".
*/
tooltipPlacement?: TooltipPlacement;
}

/**
Expand All @@ -176,7 +183,7 @@ export interface MetadataBarProps {
* To extend the list of content types, a developer needs to request the inclusion of the new type in the design system.
* This process is important to make sure the new type is reviewed by the design team, improving Superset consistency.
*/
const MetadataBar = ({ items }: MetadataBarProps) => {
const MetadataBar = ({ items, tooltipPlacement = 'top' }: MetadataBarProps) => {
const [width, setWidth] = useState<number>();
const [collapsed, setCollapsed] = useState(false);
const uniqueItems = uniqWith(items, (a, b) => a.type === b.type);
Expand Down Expand Up @@ -214,6 +221,7 @@ const MetadataBar = ({ items }: MetadataBarProps) => {
contentType={item}
collapsed={collapsed}
last={index === count - 1}
tooltipPlacement={tooltipPlacement}
/>
))}
</Bar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export const ExploreChartHeader = ({
value: slice?.description,
});
}
return <MetadataBar items={items} />;
return <MetadataBar items={items} tooltipPlacement="bottom" />;
}, [metadata, slice?.description]);

const oldSliceName = slice?.slice_name;
Expand Down

0 comments on commit 71c6322

Please sign in to comment.