Commit e93bd233 by Zoltán Bedi Committed by GitHub

Jaeger: timeline collapser to show icons (#28284)

* Fix: timeline collapser to show icons

* Use IconButton

* Export named component instead of default
parent 9141efa3
...@@ -12,6 +12,8 @@ export type IconName = ...@@ -12,6 +12,8 @@ export type IconName =
| 'filter' | 'filter'
| 'angle-left' | 'angle-left'
| 'angle-right' | 'angle-right'
| 'angle-double-right'
| 'angle-double-down'
| 'pen' | 'pen'
| 'envelope' | 'envelope'
| 'percentage' | 'percentage'
...@@ -128,6 +130,8 @@ export const getAvailableIcons = (): IconName[] => [ ...@@ -128,6 +130,8 @@ export const getAvailableIcons = (): IconName[] => [
'filter', 'filter',
'angle-left', 'angle-left',
'angle-right', 'angle-right',
'angle-double-right',
'angle-double-down',
'pen', 'pen',
'envelope', 'envelope',
'percentage', 'percentage',
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
import React from 'react'; import React from 'react';
import { shallow } from 'enzyme'; import { shallow } from 'enzyme';
import TimelineCollapser from './TimelineCollapser'; import { TimelineCollapser } from './TimelineCollapser';
describe('<TimelineCollapser>', () => { describe('<TimelineCollapser>', () => {
it('renders without exploding', () => { it('renders without exploding', () => {
......
...@@ -12,18 +12,13 @@ ...@@ -12,18 +12,13 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import React from 'react'; import { IconButton } from '@grafana/ui';
import { css } from 'emotion'; import { css } from 'emotion';
import cx from 'classnames'; import React from 'react';
import { UITooltip, UIIcon } from '../../uiElementsContext';
import { createStyle } from '../../Theme'; import { createStyle } from '../../Theme';
const getStyles = createStyle(() => { const getStyles = createStyle(() => {
return { return {
TraceTimelineViewer: css`
border-bottom: 1px solid #bbb;
`,
TimelineCollapser: css` TimelineCollapser: css`
align-items: center; align-items: center;
display: flex; display: flex;
...@@ -31,21 +26,6 @@ const getStyles = createStyle(() => { ...@@ -31,21 +26,6 @@ const getStyles = createStyle(() => {
justify-content: center; justify-content: center;
margin-right: 0.5rem; margin-right: 0.5rem;
`, `,
tooltipTitle: css`
white-space: pre;
`,
btn: css`
color: rgba(0, 0, 0, 0.5);
cursor: pointer;
margin-right: 0.3rem;
padding: 0.1rem;
&:hover {
color: rgba(0, 0, 0, 0.85);
}
`,
btnExpanded: css`
transform: rotate(90deg);
`,
}; };
}); });
...@@ -56,40 +36,27 @@ type CollapserProps = { ...@@ -56,40 +36,27 @@ type CollapserProps = {
onExpandAll: () => void; onExpandAll: () => void;
}; };
function getTitle(value: string) { export function TimelineCollapser(props: CollapserProps) {
const { onExpandAll, onExpandOne, onCollapseAll, onCollapseOne } = props;
const styles = getStyles(); const styles = getStyles();
return <span className={styles.tooltipTitle}>{value}</span>; return (
} <div className={styles.TimelineCollapser} data-test-id="TimelineCollapser">
<IconButton tooltip="Expand +1" size="xl" tooltipPlacement="top" name="angle-down" onClick={onExpandOne} />
export default class TimelineCollapser extends React.PureComponent<CollapserProps> { <IconButton tooltip="Collapse +1" size="xl" tooltipPlacement="top" name="angle-right" onClick={onCollapseOne} />
containerRef: React.RefObject<HTMLDivElement>; <IconButton
tooltip="Expand All"
constructor(props: CollapserProps) { size="xl"
super(props); tooltipPlacement="top"
this.containerRef = React.createRef(); name="angle-double-down"
} onClick={onExpandAll}
/>
// TODO: Something less hacky than createElement to help TypeScript / AntD <IconButton
getContainer = () => this.containerRef.current || document.createElement('div'); tooltip="Collapse All"
size="xl"
render() { tooltipPlacement="top"
const { onExpandAll, onExpandOne, onCollapseAll, onCollapseOne } = this.props; name="angle-double-right"
const styles = getStyles(); onClick={onCollapseAll}
return ( />
<div className={styles.TimelineCollapser} ref={this.containerRef} data-test-id="TimelineCollapser"> </div>
<UITooltip title={getTitle('Expand +1')} getPopupContainer={this.getContainer}> );
<UIIcon type="right" onClick={onExpandOne} className={cx(styles.btn, styles.btnExpanded)} />
</UITooltip>
<UITooltip title={getTitle('Collapse +1')} getPopupContainer={this.getContainer}>
<UIIcon type="right" onClick={onCollapseOne} className={styles.btn} />
</UITooltip>
<UITooltip title={getTitle('Expand All')} getPopupContainer={this.getContainer}>
<UIIcon type="double-right" onClick={onExpandAll} className={cx(styles.btn, styles.btnExpanded)} />
</UITooltip>
<UITooltip title={getTitle('Collapse All')} getPopupContainer={this.getContainer}>
<UIIcon type="double-right" onClick={onCollapseAll} className={styles.btn} />
</UITooltip>
</div>
);
}
} }
...@@ -19,7 +19,7 @@ import TimelineHeaderRow from './TimelineHeaderRow'; ...@@ -19,7 +19,7 @@ import TimelineHeaderRow from './TimelineHeaderRow';
import TimelineColumnResizer from './TimelineColumnResizer'; import TimelineColumnResizer from './TimelineColumnResizer';
import TimelineViewingLayer from './TimelineViewingLayer'; import TimelineViewingLayer from './TimelineViewingLayer';
import Ticks from '../Ticks'; import Ticks from '../Ticks';
import TimelineCollapser from './TimelineCollapser'; import { TimelineCollapser } from './TimelineCollapser';
describe('<TimelineHeaderRow>', () => { describe('<TimelineHeaderRow>', () => {
let wrapper; let wrapper;
......
...@@ -16,7 +16,7 @@ import * as React from 'react'; ...@@ -16,7 +16,7 @@ import * as React from 'react';
import { css } from 'emotion'; import { css } from 'emotion';
import cx from 'classnames'; import cx from 'classnames';
import TimelineCollapser from './TimelineCollapser'; import { TimelineCollapser } from './TimelineCollapser';
import TimelineColumnResizer from './TimelineColumnResizer'; import TimelineColumnResizer from './TimelineColumnResizer';
import TimelineViewingLayer from './TimelineViewingLayer'; import TimelineViewingLayer from './TimelineViewingLayer';
import Ticks from '../Ticks'; import Ticks from '../Ticks';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment