-
Notifications
You must be signed in to change notification settings - Fork 487
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
Timeline Expand and Collapse Features #221
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
b4d1f23
Add expansion and collapsing features
1969f44
Use Icon component
0d3996a
Use spans upstream
04bcb26
Improve css
1d00d88
Rotate collapse buttons
dd98ace
Remove debug logging
31ebe58
Remove spans from TimelineHeaderRow
e75c5de
Add unit test for TimelineCollapser
6152402
Use popover
1f23496
Add TimelineCollapser test
40db4b2
Revert "Use popover"
5bd0006
Add tests for duck.js
85b638d
Add more tests for duck.js
ece37e9
Add more tests for index.js
a7cc97e
Add keyboard shortcuts
d0a009b
Update changelog
495328a
Make review changes
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
30 changes: 30 additions & 0 deletions
30
...r-ui/src/components/TracePage/TraceTimelineViewer/TimelineHeaderRow/TimelineCollapser.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,30 @@ | ||
/* | ||
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. | ||
*/ | ||
|
||
.TimelineCollapser { | ||
float: right; | ||
margin: 0 0.8rem 0 0; | ||
display: inline-block; | ||
} | ||
|
||
.TimelineCollapser--btn, | ||
.TimelineCollapser--btn-expand { | ||
margin-right: 0.3rem; | ||
} | ||
|
||
.TimelineCollapser--btn-expand { | ||
transform: rotate(90deg); | ||
} |
48 changes: 48 additions & 0 deletions
48
...er-ui/src/components/TracePage/TraceTimelineViewer/TimelineHeaderRow/TimelineCollapser.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,48 @@ | ||
// @flow | ||
|
||
// 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 { Tooltip, Icon } from 'antd'; | ||
|
||
import './TimelineCollapser.css'; | ||
|
||
type CollapserProps = { | ||
onCollapseAll: () => void, | ||
onCollapseOne: () => void, | ||
onExpandOne: () => void, | ||
onExpandAll: () => void, | ||
}; | ||
|
||
export default function TimelineCollapser(props: CollapserProps) { | ||
const { onExpandAll, onExpandOne, onCollapseAll, onCollapseOne } = props; | ||
return ( | ||
<span className="TimelineCollapser"> | ||
<Tooltip title="Expand +1"> | ||
<Icon type="right" onClick={onExpandOne} className="TimelineCollapser--btn-expand" /> | ||
</Tooltip> | ||
<Tooltip title="Collapse +1"> | ||
<Icon type="right" onClick={onCollapseOne} className="TimelineCollapser--btn" /> | ||
</Tooltip> | ||
<Tooltip title="Expand All"> | ||
<Icon type="double-right" onClick={onExpandAll} className="TimelineCollapser--btn-expand" /> | ||
</Tooltip> | ||
<Tooltip title="Collapse All"> | ||
<Icon type="double-right" onClick={onCollapseAll} className="TimelineCollapser--btn" /> | ||
</Tooltip> | ||
</span> | ||
); | ||
} |
32 changes: 32 additions & 0 deletions
32
.../src/components/TracePage/TraceTimelineViewer/TimelineHeaderRow/TimelineCollapser.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,32 @@ | ||
// 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 TimelineCollapser from './TimelineCollapser'; | ||
|
||
describe('<TimelineCollapser>', () => { | ||
it('renders without exploding', () => { | ||
const props = { | ||
onCollapseAll: () => {}, | ||
onCollapseOne: () => {}, | ||
onExpandAll: () => {}, | ||
onExpandOne: () => {}, | ||
}; | ||
const wrapper = shallow(<TimelineCollapser {...props} />); | ||
expect(wrapper).toBeDefined(); | ||
expect(wrapper.find('.TimelineCollapser').length).toBe(1); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,10 @@ export const actionTypes = generateActionTypes('@jaeger-ui/trace-timeline-viewer | |
'SET_TRACE', | ||
'SET_SPAN_NAME_COLUMN_WIDTH', | ||
'CHILDREN_TOGGLE', | ||
'EXPAND_ALL', | ||
'COLLAPSE_ALL', | ||
'EXPAND_ONE', | ||
'COLLAPSE_ONE', | ||
'DETAIL_TOGGLE', | ||
'DETAIL_TAGS_TOGGLE', | ||
'DETAIL_PROCESS_TOGGLE', | ||
|
@@ -61,6 +65,10 @@ const fullActions = createActions({ | |
[actionTypes.SET_TRACE]: traceID => ({ traceID }), | ||
[actionTypes.SET_SPAN_NAME_COLUMN_WIDTH]: width => ({ width }), | ||
[actionTypes.CHILDREN_TOGGLE]: spanID => ({ spanID }), | ||
[actionTypes.EXPAND_ALL]: () => ({}), | ||
[actionTypes.EXPAND_ONE]: spans => ({ spans }), | ||
[actionTypes.COLLAPSE_ALL]: spans => ({ spans }), | ||
[actionTypes.COLLAPSE_ONE]: spans => ({ spans }), | ||
[actionTypes.DETAIL_TOGGLE]: spanID => ({ spanID }), | ||
[actionTypes.DETAIL_TAGS_TOGGLE]: spanID => ({ spanID }), | ||
[actionTypes.DETAIL_PROCESS_TOGGLE]: spanID => ({ spanID }), | ||
|
@@ -97,6 +105,70 @@ function childrenToggle(state, { payload }) { | |
return { ...state, childrenHiddenIDs }; | ||
} | ||
|
||
function shouldDisableCollapse(allSpans, hiddenSpansIds) { | ||
const allParentSpans = allSpans.filter(s => s.hasChildren); | ||
return allParentSpans.length === hiddenSpansIds.size; | ||
} | ||
|
||
export function expandAll(state) { | ||
const childrenHiddenIDs = new Set(); | ||
return { ...state, childrenHiddenIDs }; | ||
} | ||
|
||
export function collapseAll(state, { payload }) { | ||
const { spans } = payload; | ||
if (shouldDisableCollapse(spans, state.childrenHiddenIDs)) { | ||
return state; | ||
} | ||
const childrenHiddenIDs = spans.reduce((res, s) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just curious, why prefer
Applies generally to these reducers. |
||
if (s.hasChildren) { | ||
res.add(s.spanID); | ||
} | ||
return res; | ||
}, new Set()); | ||
return { ...state, childrenHiddenIDs }; | ||
} | ||
|
||
export function collapseOne(state, { payload }) { | ||
const { spans } = payload; | ||
if (shouldDisableCollapse(spans, state.childrenHiddenIDs)) { | ||
return state; | ||
} | ||
let nearestCollapsedAncestor; | ||
const childrenHiddenIDs = spans.reduce((res, curSpan) => { | ||
if (nearestCollapsedAncestor && curSpan.depth <= nearestCollapsedAncestor.depth) { | ||
res.add(nearestCollapsedAncestor.spanID); | ||
nearestCollapsedAncestor = curSpan; | ||
} else if (curSpan.hasChildren && !res.has(curSpan.spanID)) { | ||
nearestCollapsedAncestor = curSpan; | ||
} | ||
return res; | ||
}, new Set(state.childrenHiddenIDs)); | ||
childrenHiddenIDs.add(nearestCollapsedAncestor.spanID); | ||
return { ...state, childrenHiddenIDs }; | ||
} | ||
|
||
export function expandOne(state, { payload }) { | ||
const { spans } = payload; | ||
if (state.childrenHiddenIDs.size === 0) { | ||
return state; | ||
} | ||
let prevExpandedDepth = -1; | ||
let expandNextHiddenSpan = true; | ||
const childrenHiddenIDs = spans.reduce((res, s) => { | ||
if (s.depth <= prevExpandedDepth) { | ||
expandNextHiddenSpan = true; | ||
} | ||
if (expandNextHiddenSpan && res.has(s.spanID)) { | ||
res.delete(s.spanID); | ||
expandNextHiddenSpan = false; | ||
prevExpandedDepth = s.depth; | ||
} | ||
return res; | ||
}, new Set(state.childrenHiddenIDs)); | ||
return { ...state, childrenHiddenIDs }; | ||
} | ||
|
||
function detailToggle(state, { payload }) { | ||
const { spanID } = payload; | ||
const detailStates = new Map(state.detailStates); | ||
|
@@ -149,6 +221,10 @@ export default handleActions( | |
[actionTypes.SET_TRACE]: setTrace, | ||
[actionTypes.SET_SPAN_NAME_COLUMN_WIDTH]: setColumnWidth, | ||
[actionTypes.CHILDREN_TOGGLE]: childrenToggle, | ||
[actionTypes.EXPAND_ALL]: expandAll, | ||
[actionTypes.EXPAND_ONE]: expandOne, | ||
[actionTypes.COLLAPSE_ALL]: collapseAll, | ||
[actionTypes.COLLAPSE_ONE]: collapseOne, | ||
[actionTypes.DETAIL_TOGGLE]: detailToggle, | ||
[actionTypes.DETAIL_TAGS_TOGGLE]: detailTagsToggle, | ||
[actionTypes.DETAIL_PROCESS_TOGGLE]: detailProcessToggle, | ||
|
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.
This is float right?