Skip to content

Commit

Permalink
fix(frontend): add no matches message in trace search (#2690)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgeepc committed Jun 9, 2023
1 parent aad17b9 commit cd7ed6e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
11 changes: 11 additions & 0 deletions web/src/components/RunDetailTrace/RunDetailTrace.styled.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {CloseCircleFilled} from '@ant-design/icons';
import {Typography} from 'antd';
import styled from 'styled-components';

export const Container = styled.div`
Expand Down Expand Up @@ -52,3 +53,13 @@ export const ClearSearchIcon = styled(CloseCircleFilled)`
color: ${({theme}) => theme.color.textLight};
cursor: pointer;
`;

export const NoMatchesContainer = styled.div`
color: ${({theme}) => theme.color.textSecondary};
margin-top: 8px;
margin-left: 8px;
`;

export const NoMatchesText = styled(Typography.Text)`
color: ${({theme}) => theme.color.textSecondary};
`;
28 changes: 21 additions & 7 deletions web/src/components/RunDetailTrace/Search.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import {Col, Row} from 'antd';
import {CloseCircleOutlined} from '@ant-design/icons';
import {Col, Row, Space} from 'antd';
import {debounce} from 'lodash';
import {useTestRun} from 'providers/TestRun/TestRun.provider';
import {useCallback, useMemo, useState} from 'react';

import Editor from 'components/Editor';
import {SupportedEditors} from 'constants/Editor.constants';
import {useTestRun} from 'providers/TestRun/TestRun.provider';
import {useLazyGetSelectedSpansQuery} from 'redux/apis/TraceTest.api';
import {useAppDispatch} from 'redux/hooks';
import {useAppDispatch, useAppSelector} from 'redux/hooks';
import {matchSpans, selectSpan, setSearchText} from 'redux/slices/Trace.slice';
import TraceSelectors from 'selectors/Trace.selectors';
import SpanService from 'services/Span.service';
import Editor from 'components/Editor';
import {SupportedEditors} from 'constants/Editor.constants';
import EditorService from 'services/Editor.service';
import * as S from './RunDetailTrace.styled';

Expand All @@ -19,6 +22,7 @@ interface IProps {
const Search = ({runId, testId}: IProps) => {
const [search, setSearch] = useState('');
const dispatch = useAppDispatch();
const matchedSpans = useAppSelector(TraceSelectors.selectMatchedSpans);
const {
run: {trace: {spans = []} = {}},
} = useTestRun();
Expand All @@ -43,7 +47,9 @@ const Search = ({runId, testId}: IProps) => {
}

dispatch(matchSpans({spanIds}));
dispatch(selectSpan({spanId: spanIds[0]}));
if (spanIds.length) {
dispatch(selectSpan({spanId: spanIds[0]}));
}
},
[dispatch, getSelectedSpans, runId, spans, testId]
);
Expand All @@ -66,7 +72,15 @@ const Search = ({runId, testId}: IProps) => {
}}
value={search}
/>
{Boolean(search) && <S.ClearSearchIcon onClick={onClear} />}
{!!search && <S.ClearSearchIcon onClick={onClear} />}
{!!search && !matchedSpans.length && (
<S.NoMatchesContainer>
<Space>
<CloseCircleOutlined />
<S.NoMatchesText>No matches found</S.NoMatchesText>
</Space>
</S.NoMatchesContainer>
)}
</Col>
</Row>
);
Expand Down

0 comments on commit cd7ed6e

Please sign in to comment.