feat: navigation to new explorer from old page are updated (#3093)

This commit is contained in:
Palash Gupta 2023-07-11 10:54:33 +05:30 committed by GitHub
parent ed200e50c8
commit 652bd52ea7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 100 additions and 5 deletions

View File

@ -0,0 +1,27 @@
import { Card, Space, Typography } from 'antd';
import TextToolTip from 'components/TextToolTip';
function ExplorerCard({ children }: Props): JSX.Element {
return (
<Card
size="small"
title={
<Space>
<Typography>Query Builder</Typography>
<TextToolTip
url="https://signoz.io/docs/userguide/query-builder/?utm_source=product&utm_medium=new-query-builder"
text="More details on how to use query builder"
/>
</Space>
}
>
{children}
</Card>
);
}
interface Props {
children: React.ReactNode;
}
export default ExplorerCard;

View File

@ -1 +1 @@
export const style = { fontSize: '1.3125rem' };
export const style = { fontSize: '1rem' };

View File

@ -0,0 +1,3 @@
export const RIBBON_STYLES = {
top: '-0.75rem',
};

View File

@ -0,0 +1,50 @@
import { CompassOutlined } from '@ant-design/icons';
import { Badge, Button } from 'antd';
import ROUTES from 'constants/routes';
import history from 'lib/history';
import { useMemo } from 'react';
import { useLocation } from 'react-router-dom';
import { RIBBON_STYLES } from './config';
function NewExplorerCTA(): JSX.Element | null {
const location = useLocation();
const isTraceOrLogsExplorerPage = useMemo(
() => location.pathname === ROUTES.LOGS || location.pathname === ROUTES.TRACE,
[location.pathname],
);
const onClickHandler = (): void => {
if (location.pathname === ROUTES.LOGS) {
history.push(ROUTES.LOGS_EXPLORER);
} else if (location.pathname === ROUTES.TRACE) {
history.push(ROUTES.TRACES_EXPLORER);
}
};
const buttonText = useMemo(
() =>
`Try new ${ROUTES.LOGS === location.pathname ? 'Logs' : 'Traces'} Explorer`,
[location.pathname],
);
if (!isTraceOrLogsExplorerPage) {
return null;
}
return (
<Badge.Ribbon style={RIBBON_STYLES} text="New">
<Button
icon={<CompassOutlined />}
onClick={onClickHandler}
danger
type="primary"
>
{buttonText}
</Button>
</Badge.Ribbon>
);
}
export default NewExplorerCTA;

View File

@ -1,4 +1,4 @@
import { Col } from 'antd';
import { Col, Row, Space } from 'antd';
import ROUTES from 'constants/routes';
import { useMemo } from 'react';
import { matchPath, useHistory } from 'react-router-dom';
@ -6,6 +6,7 @@ import { matchPath, useHistory } from 'react-router-dom';
import ShowBreadcrumbs from './Breadcrumbs';
import DateTimeSelector from './DateTimeSelection';
import { routesToSkip } from './DateTimeSelection/config';
import NewExplorerCTA from './NewExplorerCTA';
import { Container } from './styles';
function TopNav(): JSX.Element | null {
@ -36,7 +37,15 @@ function TopNav(): JSX.Element | null {
{!isRouteToSkip && (
<Col span={8}>
<Row justify="end">
<Space align="start" size={60} direction="horizontal">
<NewExplorerCTA />
<div>
<DateTimeSelector />
</div>
</Space>
</Row>
</Col>
)}
</Container>

View File

@ -1,4 +1,5 @@
import { Col, Row } from 'antd';
import ExplorerCard from 'components/ExplorerCard';
import LogExplorerQuerySection from 'container/LogExplorerQuerySection';
import LogsExplorerViews from 'container/LogsExplorerViews';
@ -10,7 +11,9 @@ function LogsExplorer(): JSX.Element {
<WrapperStyled>
<Row gutter={[0, 16]}>
<Col xs={24}>
<ExplorerCard>
<LogExplorerQuerySection />
</ExplorerCard>
</Col>
<Col xs={24}>
<LogsExplorerViews />

View File

@ -1,5 +1,6 @@
import { Tabs } from 'antd';
import axios from 'axios';
import ExplorerCard from 'components/ExplorerCard';
import { QueryParams } from 'constants/query';
import { initialQueriesMap, PANEL_TYPES } from 'constants/queryBuilder';
import { queryParamNamesMap } from 'constants/queryBuilderQueryNames';
@ -177,7 +178,9 @@ function TracesExplorer(): JSX.Element {
return (
<>
<ExplorerCard>
<QuerySection />
</ExplorerCard>
<Container>
<ActionsWrapper>