mirror of
https://github.com/datahub-project/datahub.git
synced 2025-12-25 08:58:26 +00:00
feat(queries): Adding Tooltips to Queries Tab (#7421)
This commit is contained in:
parent
285177b2b2
commit
5e77e68352
@ -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}
|
||||
|
||||
@ -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}
|
||||
|
||||
@ -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>
|
||||
|
||||
@ -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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user