-
Notifications
You must be signed in to change notification settings - Fork 528
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
- Loading branch information
1 parent
7580270
commit 5bddd3d
Showing
13 changed files
with
311 additions
and
116 deletions.
There are no files selected for viewing
117 changes: 117 additions & 0 deletions
117
packages/jaeger-ui/src/components/TracePage/TraceTimelineViewer/MultiParentIcon.tsx
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,117 @@ | ||
// Copyright (c) 2019 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, Dropdown, Menu, Tooltip } from 'antd'; | ||
import { bindActionCreators } from 'redux'; | ||
import { connect, Dispatch } from 'react-redux'; | ||
import { History as RouterHistory, Location } from 'history'; | ||
import { withRouter } from 'react-router-dom'; | ||
|
||
import { FetchedTrace, ReduxState, TNil } from '../../../types'; | ||
import { actions as timelineActions } from './duck'; | ||
import { extractUiFindFromState } from '../../common/UiFindInput'; | ||
import { SpanReference, Trace } from '../../../types/trace'; | ||
import updateUiFind from '../../../utils/update-ui-find'; | ||
|
||
type TDispatchProps = { | ||
focusUiFindMatches: (trace: Trace, uiFind: string | TNil) => void; | ||
}; | ||
|
||
type TReduxProps = { | ||
uiFind: string | TNil; | ||
trace: FetchedTrace | TNil; | ||
}; | ||
|
||
type TOwnProps = { | ||
references: SpanReference[]; | ||
traceID: string; | ||
history: RouterHistory; | ||
location: Location; | ||
match: any; | ||
}; | ||
|
||
type MultiParentIconProps = TDispatchProps & TReduxProps & TOwnProps; | ||
|
||
const linkValueList = (links: SpanReference[], focusUiFindMatches: (spanID: string) => void) => ( | ||
<Menu> | ||
{links.map(({ spanID, span }, index) => { | ||
let text = spanID; | ||
if (span) { | ||
text = `${span.operationName} (${spanID})`; | ||
} | ||
return ( | ||
// `index` is necessary in the key because url can repeat | ||
// eslint-disable-next-line react/no-array-index-key | ||
<Menu.Item key={`${spanID}-${index}`}> | ||
<a role="button" onClick={() => focusUiFindMatches(spanID)}> | ||
{' '} | ||
{text}{' '} | ||
</a> | ||
</Menu.Item> | ||
); | ||
})} | ||
</Menu> | ||
); | ||
|
||
class MultiParentIconImpl extends React.PureComponent<MultiParentIconProps> { | ||
focusUiFindMatches = (uiFind: string) => { | ||
const { trace, focusUiFindMatches, location, history } = this.props; | ||
if (trace && trace.data) { | ||
updateUiFind({ | ||
location, | ||
history, | ||
uiFind, | ||
}); | ||
focusUiFindMatches(trace.data, uiFind); | ||
} | ||
}; | ||
|
||
render() { | ||
const { references } = this.props; | ||
return ( | ||
<Tooltip arrowPointAtCenter mouseLeaveDelay={0.5} placement="left" title="Contains multiple references"> | ||
<Dropdown | ||
overlay={linkValueList(references, this.focusUiFindMatches)} | ||
placement="bottomRight" | ||
trigger={['click']} | ||
> | ||
<Button className="MultiParentIcon" htmlType="button" icon="fork" /> | ||
</Dropdown> | ||
</Tooltip> | ||
); | ||
} | ||
} | ||
|
||
export function mapDispatchToProps(dispatch: Dispatch<ReduxState>): TDispatchProps { | ||
const { focusUiFindMatches } = bindActionCreators(timelineActions, dispatch); | ||
return { focusUiFindMatches }; | ||
} | ||
|
||
// export for tests | ||
export function mapStateToProps(state: ReduxState, ownProps: TOwnProps): TReduxProps { | ||
const { traces } = state.trace; | ||
const trace = ownProps.traceID ? traces[ownProps.traceID] : null; | ||
return { | ||
trace, | ||
...extractUiFindFromState(state), | ||
}; | ||
} | ||
|
||
export default withRouter( | ||
connect( | ||
mapStateToProps, | ||
mapDispatchToProps | ||
)(MultiParentIconImpl) | ||
); |
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
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.