Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add uiFind icons, scroll to first match #367

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Clarify focusUiFind function name, fix existing
tests, add TraceTimelineViewer/duck.tsx tests

Signed-off-by: Everett Ross <reverett@uber.com>
  • Loading branch information
everett980 committed Apr 11, 2019
commit 37f9a20e40cea0930fd917e652b616f1dc80790d
11 changes: 2 additions & 9 deletions packages/jaeger-ui/src/components/TracePage/ScrollManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import _get from 'lodash/get';
import _findIndex from 'lodash/findIndex';
import _isUndefined from 'lodash/isUndefined';

import { TNil } from '../../types';
import { Span, SpanReference, Trace } from '../../types/trace';

Expand Down Expand Up @@ -135,11 +131,8 @@ export default class ScrollManager {
}
const { duration, spans, startTime: traceStartTime } = this._trace;
const isUp = direction < 0;
const boundaryRow = _isUndefined(startRow)
? isUp ? xrs.getTopRowIndexVisible() : xrs.getBottomRowIndexVisible()
: startRow;
console.log(boundaryRow);
const spanIndex = xrs.mapRowIndexToSpanIndex(boundaryRow);
const boundaryRow = isUp ? xrs.getTopRowIndexVisible() : xrs.getBottomRowIndexVisible();
const spanIndex = xrs.mapRowIndexToSpanIndex(startRow != null ? startRow : boundaryRow);
everett980 marked this conversation as resolved.
Show resolved Hide resolved
if ((spanIndex === 0 && isUp) || (spanIndex === spans.length - 1 && !isUp)) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import './TracePageHeader.css';
type TracePageHeaderEmbedProps = {
canCollapse: boolean;
clearSearch: () => void;
focusUiFind: () => void;
focusUiFindMatches: () => void;
hideMap: boolean;
hideSummary: boolean;
linkToStandalone: string;
Expand Down Expand Up @@ -96,7 +96,7 @@ export function TracePageHeaderFn(props: TracePageHeaderEmbedProps & { forwarded
const {
canCollapse,
clearSearch,
focusUiFind,
focusUiFindMatches,
forwardedRef,
hideMap,
hideSummary,
Expand Down Expand Up @@ -166,7 +166,7 @@ export function TracePageHeaderFn(props: TracePageHeaderEmbedProps & { forwarded
{showShortcutsHelp && <KeyboardShortcutsHelp className="ub-mr2" />}
<TracePageSearchBar
clearSearch={clearSearch}
focusUiFind={focusUiFind}
focusUiFindMatches={focusUiFindMatches}
nextResult={nextResult}
prevResult={prevResult}
ref={forwardedRef}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('<TracePageSearchBar>', () => {

it('renders buttons', () => {
const buttons = wrapper.find('Button');
expect(buttons.length).toBe(3);
expect(buttons.length).toBe(4);
buttons.forEach(button => {
expect(button.hasClass('TracePageSearchBar--btn')).toBe(true);
expect(button.hasClass('is-disabled')).toBe(false);
Expand All @@ -66,15 +66,11 @@ describe('<TracePageSearchBar>', () => {
expect(wrapper.find('Button[icon="close"]').prop('onClick')).toBe(defaultProps.clearSearch);
});

it('disables navigation buttons when not navigable', () => {
it('hides navigation buttons when not navigable', () => {
wrapper.setProps({ navigable: false });
const buttons = wrapper.find('Button');
expect(buttons.length).toBe(3);
buttons.forEach((button, i) => {
expect(button.hasClass('TracePageSearchBar--btn')).toBe(true);
expect(button.hasClass('is-disabled')).toBe(i !== 2);
expect(button.prop('disabled')).toBe(i !== 2);
});
const button = wrapper.find('Button');
expect(button.length).toBe(1);
expect(button.prop('icon')).toBe('close');
});
});

Expand All @@ -89,7 +85,7 @@ describe('<TracePageSearchBar>', () => {

it('renders buttons', () => {
const buttons = wrapper.find('Button');
expect(buttons.length).toBe(3);
expect(buttons.length).toBe(4);
buttons.forEach(button => {
expect(button.hasClass('TracePageSearchBar--btn')).toBe(true);
expect(button.hasClass('is-disabled')).toBe(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ type TracePageSearchBarProps = {
prevResult: () => void;
nextResult: () => void;
clearSearch: () => void;
focusUiFind: () => void;
focusUiFindMatches: () => void;
resultCount: number;
navigable: boolean;
};

export function TracePageSearchBarFn(props: TracePageSearchBarProps & { forwardedRef: React.Ref<Input> }) {
const {
clearSearch,
focusUiFind,
focusUiFindMatches,
forwardedRef,
navigable,
nextResult,
Expand All @@ -47,8 +47,7 @@ export function TracePageSearchBarFn(props: TracePageSearchBarProps & { forwarde

const count = textFilter ? <span className="TracePageSearchBar--count">{resultCount}</span> : null;

const navigationBtnDisabled = !navigable || !textFilter;
const navigationBtnClass = cx('TracePageSearchBar--btn', { 'is-disabled': navigationBtnDisabled });
const navigationBtnClass = cx('TracePageSearchBar--btn', { 'is-disabled': !textFilter });
const btnClass = cx('TracePageSearchBar--btn', { 'is-disabled': !textFilter });
const uiFindInputInputProps = {
'data-test': markers.IN_TRACE_SEARCH,
Expand All @@ -66,27 +65,31 @@ export function TracePageSearchBarFn(props: TracePageSearchBarProps & { forwarde
forwardedRef={forwardedRef}
trackFindFunction={trackFilter}
/>
<Button
className={navigationBtnClass}
disabled={navigationBtnDisabled}
htmlType="button"
icon="up"
onClick={prevResult}
/>
<Button
className={navigationBtnClass}
disabled={navigationBtnDisabled}
htmlType="button"
icon="down"
onClick={nextResult}
/>
<Button
className={navigationBtnClass}
disabled={navigationBtnDisabled}
htmlType="button"
icon="search"
onClick={focusUiFind}
/>
{navigable && (
<>
<Button
className={navigationBtnClass}
disabled={!textFilter}
htmlType="button"
icon="up"
onClick={prevResult}
/>
<Button
className={navigationBtnClass}
disabled={!textFilter}
htmlType="button"
icon="down"
onClick={nextResult}
/>
<Button
className={navigationBtnClass}
disabled={!textFilter}
htmlType="button"
icon="search"
onClick={focusUiFindMatches}
/>
</>
)}
<Button
className={btnClass}
disabled={!textFilter}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
jest.mock('../utils');

import React from 'react';
import { Button } from 'antd';
import { shallow } from 'enzyme';

import AccordianKeyValues from './AccordianKeyValues';
Expand Down Expand Up @@ -122,7 +123,7 @@ describe('<SpanDetail>', () => {
});

it('calls addToUiFind when the spanID is clicked', () => {
const spanIDButton = wrapper.find('button');
const spanIDButton = wrapper.find(Button);
spanIDButton.simulate('click');
expect(props.addToUiFind).toHaveBeenCalledWith(props.span.spanID);
});
Expand Down
Loading