feat(queries): Adding Tooltips to Queries Tab (#7421)

This commit is contained in:
John Joyce 2023-02-24 16:04:23 -08:00 committed by GitHub
parent 285177b2b2
commit 5e77e68352
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 12 deletions

View File

@ -1,14 +1,22 @@
import React, { useEffect, useRef, useState } from 'react';
import { Pagination, Typography } from 'antd';
import { Pagination, Tooltip, Typography } from 'antd';
import { InfoCircleOutlined } from '@ant-design/icons';
import styled from 'styled-components';
import QueriesList from './QueriesList';
import { Query } from './types';
import { DEFAULT_PAGE_SIZE } from './utils/constants';
import { getQueriesForPage } from './utils/getCurrentPage';
import { ANTD_GRAY } from '../../../constants';
const QueriesTitleSection = styled.div`
display: flex;
align-items: center;
margin-bottom: 20px;
`;
const QueriesTitle = styled(Typography.Title)`
&& {
margin-bottom: 20px;
margin: 0px;
}
`;
@ -20,9 +28,16 @@ const StyledPagination = styled(Pagination)`
justify-content: center;
`;
const StyledInfoOutlined = styled(InfoCircleOutlined)`
margin-left: 8px;
font-size: 12px;
color: ${ANTD_GRAY[7]};
`;
type Props = {
title: string;
queries: Query[];
tooltip?: string;
initialPage?: number;
initialPageSize?: number;
showDetails?: boolean;
@ -34,6 +49,7 @@ type Props = {
export default function QueriesListSection({
title,
tooltip,
queries,
initialPage = 1,
initialPageSize = DEFAULT_PAGE_SIZE,
@ -55,18 +71,27 @@ export default function QueriesListSection({
*/
const headerRef = useRef(null);
useEffect(() => {
(headerRef?.current as any)?.scrollIntoView({
behavior: 'smooth',
block: 'start',
inline: 'nearest',
});
if (page !== 1) {
(headerRef?.current as any)?.scrollIntoView({
behavior: 'smooth',
block: 'start',
inline: 'nearest',
});
}
}, [page]);
return (
<>
<QueriesTitle ref={headerRef} level={4}>
{title}
</QueriesTitle>
<QueriesTitleSection>
<QueriesTitle ref={headerRef} level={4}>
{title}
</QueriesTitle>
{tooltip && (
<Tooltip title={tooltip}>
<StyledInfoOutlined />
</Tooltip>
)}
</QueriesTitleSection>
<QueriesList
queries={paginatedQueries}
showDelete={showDelete}

View File

@ -106,6 +106,7 @@ export default function QueriesTab() {
{highlightedQueries.length > 0 && (
<QueriesListSection
title="Highlighted Queries"
tooltip="Shared queries relevant to this dataset"
queries={highlightedQueries}
showEdit
showDelete
@ -116,6 +117,7 @@ export default function QueriesTab() {
{recentQueries.length > 0 && (
<QueriesListSection
title="Recent Queries"
tooltip="Queries that have been recently run against this dataset"
queries={recentQueries}
showDetails={false}
showDelete={false}

View File

@ -19,7 +19,10 @@ type Props = {
export default function QueriesTabToolbar({ addQueryDisabled, onAddQuery, onChangeSearch }: Props) {
return (
<TabToolbar>
<Tooltip title={(addQueryDisabled && ADD_UNAUTHORIZED_MESSAGE) || undefined}>
<Tooltip
placement="right"
title={(addQueryDisabled && ADD_UNAUTHORIZED_MESSAGE) || 'Add a highlighted query'}
>
<Button disabled={addQueryDisabled} type="text" onClick={onAddQuery} data-testid="add-query-button">
<PlusOutlined /> Add Query
</Button>

View File

@ -5,7 +5,7 @@ import { ANTD_GRAY } from '../../../constants';
const Statement = styled.div<{ fullHeight?: boolean }>`
background-color: ${ANTD_GRAY[2]};
height: ${(props) => (props.fullHeight && '380px') || '240px'};
height: ${(props) => (props.fullHeight && '378px') || '240px'};
margin: 0px 0px 4px 0px;
border-radius: 8px;
:hover {