Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export const IconTooltip = ({
placement = 'top',
style = {},
tooltip = null,
mouseEnterDelay = 0.3,
mouseLeaveDelay = 0.15,
}: IconTooltipProps) => {
const iconTooltip = (
<Button
Expand All @@ -47,8 +49,8 @@ export const IconTooltip = ({
id="tooltip"
title={tooltip}
placement={placement}
mouseEnterDelay={0.3}
mouseLeaveDelay={0.15}
Comment on lines -50 to -51
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not need these delays anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @msyavuz! If we want this to behave the same as the other tooltips, we don’t need those delays. If we prefer to keep two different behaviors, we can leave it as is.

Looping in @kasiazjc and @yousoph to hear their thoughts

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @msyavuz, I went a step further, I added support for configuring those delays when needed, while keeping the same default values if nothing is passed. This way, the problem should be solved without changing the existing behavior. Please take a look at my latest commit --> 6281e5f

mouseEnterDelay={mouseEnterDelay}
mouseLeaveDelay={mouseLeaveDelay}
>
{iconTooltip}
</Tooltip>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ export interface IconTooltipProps {
| 'rightBottom';
style?: object;
tooltip?: string | null;
mouseEnterDelay?: number;
mouseLeaveDelay?: number;
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ export default styled(NVD3)`
text.nv-axislabel {
font-size: ${({ theme }) => theme.fontSize} !important;
}
g.nv-axis text {
fill: ${({ theme }) => theme.colorText};
}
g.nv-series text {
fill: ${({ theme }) => theme.colorText};
}
g.solid path,
line.solid {
stroke-dasharray: unset;
Expand Down
11 changes: 8 additions & 3 deletions superset-frontend/src/explore/components/ControlHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const ControlHeader: FC<ControlHeaderProps> = ({
<span
css={() => css`
position: absolute;
top: 60%;
top: 50%;
right: 0;
padding-left: ${theme.sizeUnit}px;
transform: translate(100%, -50%);
Expand Down Expand Up @@ -156,13 +156,18 @@ const ControlHeader: FC<ControlHeaderProps> = ({
</span>
)}
{validationErrors?.length > 0 && (
<span data-test="error-tooltip">
<span
data-test="error-tooltip"
css={css`
cursor: pointer;
`}
>
<Tooltip
id="error-tooltip"
placement="top"
title={validationErrors?.join(' ')}
>
<Icons.CloseCircleOutlined iconColor={theme.colorErrorText} />
<Icons.InfoCircleOutlined iconColor={theme.colorErrorText} />
</Tooltip>{' '}
</span>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
* under the License.
*/
import { useSelector } from 'react-redux';
import { render, screen, userEvent } from 'spec/helpers/testing-library';
import {
render,
screen,
userEvent,
waitFor,
} from 'spec/helpers/testing-library';
import {
DatasourceType,
getChartControlPanelRegistry,
Expand All @@ -40,50 +45,54 @@ const FormDataMock = () => {
};

describe('ControlPanelsContainer', () => {
beforeAll(() => {
getChartControlPanelRegistry().registerValue('table', {
controlPanelSections: [
{
label: t('GROUP BY'),
description: t(
'Use this section if you want a query that aggregates',
),
expanded: true,
controlSetRows: [
['groupby'],
['metrics'],
['percent_metrics'],
['timeseries_limit_metric', 'row_limit'],
['include_time', 'order_desc'],
],
},
{
label: t('NOT GROUPED BY'),
description: t('Use this section if you want to query atomic rows'),
expanded: true,
controlSetRows: [
['all_columns'],
['order_by_cols'],
['row_limit', null],
],
},
{
label: t('Query'),
expanded: true,
controlSetRows: [['adhoc_filters']],
},
{
label: t('Options'),
expanded: true,
controlSetRows: [
['table_timestamp_format'],
['page_length', null],
['include_search', 'table_filter'],
['align_pn', 'color_pn'],
],
},
],
});
const defaultTableConfig = {
controlPanelSections: [
{
label: t('GROUP BY'),
description: t('Use this section if you want a query that aggregates'),
expanded: true,
controlSetRows: [
['groupby'],
['metrics'],
['percent_metrics'],
['timeseries_limit_metric', 'row_limit'],
['include_time', 'order_desc'],
],
},
{
label: t('NOT GROUPED BY'),
description: t('Use this section if you want to query atomic rows'),
expanded: true,
controlSetRows: [
['all_columns'],
['order_by_cols'],
['row_limit', null],
],
},
{
label: t('Query'),
expanded: true,
controlSetRows: [['adhoc_filters']],
},
{
label: t('Options'),
expanded: true,
controlSetRows: [
['table_timestamp_format'],
['page_length', null],
['include_search', 'table_filter'],
['align_pn', 'color_pn'],
],
},
],
};

beforeEach(() => {
getChartControlPanelRegistry().registerValue('table', defaultTableConfig);
});

afterEach(() => {
getChartControlPanelRegistry().remove('table');
});

afterAll(() => {
Expand All @@ -110,17 +119,22 @@ describe('ControlPanelsContainer', () => {
render(<ControlPanelsContainer {...getDefaultProps()} />, {
useRedux: true,
});
expect(
await screen.findAllByTestId('collapsible-control-panel-header'),
).toHaveLength(4);
await waitFor(() => {
expect(
screen.getAllByTestId('collapsible-control-panel-header'),
).toHaveLength(4);
});
expect(screen.getByRole('tab', { name: /customize/i })).toBeInTheDocument();
userEvent.click(screen.getByRole('tab', { name: /customize/i }));
expect(
await screen.findAllByTestId('collapsible-control-panel-header'),
).toHaveLength(5);
await waitFor(() => {
expect(
screen.getAllByTestId('collapsible-control-panel-header'),
).toHaveLength(5);
});
});

test('renders ControlPanelSections no Customize Tab', async () => {
getChartControlPanelRegistry().remove('table');
getChartControlPanelRegistry().registerValue('table', {
controlPanelSections: [
{
Expand Down Expand Up @@ -148,12 +162,15 @@ describe('ControlPanelsContainer', () => {
useRedux: true,
});
expect(screen.queryByText(/customize/i)).not.toBeInTheDocument();
expect(
await screen.findAllByTestId('collapsible-control-panel-header'),
).toHaveLength(2);
await waitFor(() => {
expect(
screen.getAllByTestId('collapsible-control-panel-header'),
).toHaveLength(2);
});
});

test('visibility of panels is correctly applied', async () => {
getChartControlPanelRegistry().remove('table');
getChartControlPanelRegistry().registerValue('table', {
controlPanelSections: [
{
Expand Down Expand Up @@ -204,6 +221,7 @@ describe('ControlPanelsContainer', () => {
});

test('hidden state of controls is correctly applied', async () => {
getChartControlPanelRegistry().remove('table');
getChartControlPanelRegistry().registerValue('table', {
controlPanelSections: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ export const ControlPanelsContainer = (props: ControlPanelsContainerProps) => {
id={`${kebabCase('validation-errors')}-tooltip`}
title={t('This section contains validation errors')}
>
<Icons.CloseCircleOutlined iconColor={theme.colorErrorText} />
<Icons.InfoCircleOutlined iconColor={theme.colorErrorText} />
</Tooltip>
)}
</span>
Expand Down Expand Up @@ -723,7 +723,7 @@ export const ControlPanelsContainer = (props: ControlPanelsContainerProps) => {
placement="right"
title={props.errorMessage}
>
<Icons.CloseCircleOutlined
<Icons.InfoCircleOutlined
data-test="query-error-tooltip-trigger"
iconColor={theme.colorErrorText}
iconSize="s"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,12 @@ test('Should have remove button', async () => {
const props = createProps();
render(<CollectionControl {...props} />);

expect(
await screen.findByRole('button', { name: 'Show info tooltip' }),
).toBeInTheDocument();
const removeButton = await screen.findByRole('img', { name: 'close' });
expect(removeButton).toBeInTheDocument();
expect(props.onChange).toHaveBeenCalledTimes(0);
userEvent.click(screen.getByRole('button', { name: 'Show info tooltip' }));
const buttonElement = removeButton.closest('button');
expect(buttonElement).not.toBeNull();
userEvent.click(buttonElement!);
expect(props.onChange).toHaveBeenCalledWith([]);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
import { Component } from 'react';
import PropTypes from 'prop-types';
import { InfoTooltip, List } from '@superset-ui/core/components';
import { IconTooltip, List } from '@superset-ui/core/components';
import { nanoid } from 'nanoid';
import { t, withTheme } from '@superset-ui/core';
import {
Expand Down Expand Up @@ -118,9 +118,10 @@ class CollectionControl extends Component {
<SortableListItem
className="clearfix"
css={theme => ({
alignItems: 'center',
justifyContent: 'flex-start',
display: '-webkit-flex',
paddingInline: theme.sizeUnit * 3,
display: 'flex',
paddingInline: theme.sizeUnit * 6,
})}
key={this.props.keyAccessor(o)}
index={i}
Expand All @@ -139,14 +140,30 @@ class CollectionControl extends Component {
onChange={this.onChange.bind(this, i)}
/>
</div>
<InfoTooltip
icon="times"
role="button"
label="remove-item"
tooltip={t('Remove item')}
bsStyle="primary"
<IconTooltip
className="pointer"
placement="right"
onClick={this.removeItem.bind(this, i)}
/>
tooltip={t('Remove item')}
mouseEnterDelay={0}
mouseLeaveDelay={0}
css={theme => ({
padding: 0,
minWidth: 'auto',
height: 'auto',
lineHeight: 1,
cursor: 'pointer',
'& svg path': {
fill: theme.colorIcon,
transition: `fill ${theme.motionDurationMid} ease-out`,
},
'&:hover svg path': {
fill: theme.colorError,
},
})}
>
<Icons.CloseOutlined iconSize="s" />
</IconTooltip>
</SortableListItem>
);
})}
Expand All @@ -160,7 +177,10 @@ class CollectionControl extends Component {
<HeaderContainer>
<ControlHeader {...this.props} />
<AddIconButton onClick={this.onAdd}>
<Icons.PlusOutlined iconSize="s" />
<Icons.PlusOutlined
iconSize="s"
iconColor={this.props.theme.colorTextLightSolid}
/>
</AddIconButton>
</HeaderContainer>
{this.renderList()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ export const AddIconButton = styled.button`
background-color: ${({ theme }) => theme.colorPrimaryText};
border: none;
border-radius: 2px;
cursor: pointer;

:disabled {
cursor: not-allowed;
Expand Down
Loading
Loading