-
Notifications
You must be signed in to change notification settings - Fork 483
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
Span Search - Add result count, navigation and clear buttons #234
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
755b1d4
Add result count, navigation and clear buttons
df6f51b
Correct imports
407f1f7
Move and delete files
af12460
Review fixes
5168c6e
Fix TracePageHeader test
c46d954
Lighten buttons when disabled
02dc925
Review fixes
fe9df64
Fix tests
cc48630
Add shortcuts
7bdc815
Fix merge changes
98ca290
Fix TracePageHeader and TracePageSearchBar tests
e23f6a1
Delay TracePageHeader testing until release of Enzyme v3.5.0
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
packages/jaeger-ui/src/components/TracePage/TracePageSearchBar.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
Copyright (c) 2018 Uber Technologies, Inc. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
.TracePageSearchBar { | ||
max-width: 20rem; | ||
} | ||
|
||
.TracePageSearchBar--bar { | ||
display: flex; | ||
max-width: 20rem; | ||
} | ||
|
||
.TracePageSearchBar--count { | ||
opacity: 0.6; | ||
} | ||
|
||
.TracePageSearchBar--btn { | ||
transition: 0.2s; | ||
} | ||
|
||
.TracePageSearchBar--btn.is-disabled { | ||
opacity: 0.5; | ||
} |
82 changes: 82 additions & 0 deletions
82
packages/jaeger-ui/src/components/TracePage/TracePageSearchBar.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// @flow | ||
|
||
// Copyright (c) 2018 Uber Technologies, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import * as React from 'react'; | ||
import { Button, Input } from 'antd'; | ||
|
||
import * as markers from './TracePageSearchBar.markers'; | ||
|
||
import './TracePageSearchBar.css'; | ||
|
||
type TracePageSearchBarProps = { | ||
updateTextFilter: string => void, | ||
textFilter: string, | ||
prevResult: () => void, | ||
nextResult: () => void, | ||
clearSearch: () => void, | ||
resultCount: number, | ||
forwardedRef: { current: Input | null }, | ||
}; | ||
|
||
export function TracePageSearchBarFn(props: TracePageSearchBarProps) { | ||
const { | ||
prevResult, | ||
nextResult, | ||
clearSearch, | ||
resultCount, | ||
updateTextFilter, | ||
textFilter, | ||
forwardedRef, | ||
} = props; | ||
|
||
const count = textFilter ? <span className="TracePageSearchBar--count">{resultCount}</span> : null; | ||
|
||
const updateFilter = event => updateTextFilter(event.target.value); | ||
const onKeyDown = e => { | ||
if (e.keyCode === 27) clearSearch(); | ||
}; | ||
|
||
const btnClass = `TracePageSearchBar--btn${textFilter ? '' : ' is-disabled'}`; | ||
|
||
return ( | ||
<div className="ub-flex-auto ub-mr2 TracePageSearchBar"> | ||
{/* style inline because compact overwrites the display */} | ||
<Input.Group compact style={{ display: 'flex' }}> | ||
<Input | ||
name="search" | ||
className="TracePageSearchBar--bar ub-flex-auto" | ||
placeholder="Search..." | ||
onChange={updateFilter} | ||
value={textFilter} | ||
data-test={markers.IN_TRACE_SEARCH} | ||
suffix={count} | ||
ref={forwardedRef} | ||
onKeyDown={onKeyDown} | ||
onPressEnter={nextResult} | ||
/> | ||
<Button className={btnClass} disabled={!textFilter} icon="up" onClick={prevResult} /> | ||
<Button className={btnClass} disabled={!textFilter} icon="down" onClick={nextResult} /> | ||
<Button className={btnClass} disabled={!textFilter} icon="close" onClick={clearSearch} /> | ||
</Input.Group> | ||
</div> | ||
); | ||
} | ||
|
||
// ghetto fabulous cast because the 16.3 API is not in flow yet | ||
// https://github.com/facebook/flow/issues/6103 | ||
export default (React: any).forwardRef((props, ref) => ( | ||
<TracePageSearchBarFn {...props} forwardedRef={ref} /> | ||
)); |
File renamed without changes.
55 changes: 55 additions & 0 deletions
55
packages/jaeger-ui/src/components/TracePage/TracePageSearchBar.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright (c) 2017 Uber Technologies, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
|
||
import * as markers from './TracePageSearchBar.markers'; | ||
import { TracePageSearchBarFn as TracePageSearchBar } from './TracePageSearchBar'; | ||
|
||
describe('<TracePageSearchBar>', () => { | ||
const defaultProps = { | ||
updateTextFilter: () => {}, | ||
textFilter: 'something', | ||
prevResult: () => {}, | ||
nextResult: () => {}, | ||
resultCount: 0, | ||
}; | ||
|
||
let wrapper; | ||
|
||
beforeEach(() => { | ||
wrapper = shallow(<TracePageSearchBar {...defaultProps} />); | ||
}); | ||
|
||
it('calls updateTextFilter() function for onChange of the input', () => { | ||
const updateTextFilter = jest.fn(); | ||
const props = { ...defaultProps, updateTextFilter }; | ||
wrapper = shallow(<TracePageSearchBar {...props} />); | ||
const event = { target: { value: 'my new value' } }; | ||
wrapper | ||
.find(`[data-test="${markers.IN_TRACE_SEARCH}"]`) | ||
.first() | ||
.simulate('change', event); | ||
expect(updateTextFilter.mock.calls.length).toBe(1); | ||
}); | ||
|
||
it('renders the search bar', () => { | ||
expect(wrapper.find('Input').length).toBe(1); | ||
}); | ||
|
||
it('renders the buttons', () => { | ||
expect(wrapper.find('Button').length).toBe(3); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was the
u-tx-muted
CSS utility class too dark?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nvm