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 styles = getStyles(); const { onExpandAll, onExpandOne, onCollapseAll, onCollapseOne } = props;
return <span className={styles.tooltipTitle}>{value}</span>;
}
export default class TimelineCollapser extends React.PureComponent<CollapserProps> {
containerRef: React.RefObject<HTMLDivElement>;
constructor(props: CollapserProps) {
super(props);
this.containerRef = React.createRef();
}
// TODO: Something less hacky than createElement to help TypeScript / AntD
getContainer = () => this.containerRef.current || document.createElement('div');
render() {
const { onExpandAll, onExpandOne, onCollapseAll, onCollapseOne } = this.props;
const styles = getStyles(); const styles = getStyles();
return ( return (
<div className={styles.TimelineCollapser} ref={this.containerRef} data-test-id="TimelineCollapser"> <div className={styles.TimelineCollapser} data-test-id="TimelineCollapser">
<UITooltip title={getTitle('Expand +1')} getPopupContainer={this.getContainer}> <IconButton tooltip="Expand +1" size="xl" tooltipPlacement="top" name="angle-down" onClick={onExpandOne} />
<UIIcon type="right" onClick={onExpandOne} className={cx(styles.btn, styles.btnExpanded)} /> <IconButton tooltip="Collapse +1" size="xl" tooltipPlacement="top" name="angle-right" onClick={onCollapseOne} />
</UITooltip> <IconButton
<UITooltip title={getTitle('Collapse +1')} getPopupContainer={this.getContainer}> tooltip="Expand All"
<UIIcon type="right" onClick={onCollapseOne} className={styles.btn} /> size="xl"
</UITooltip> tooltipPlacement="top"
<UITooltip title={getTitle('Expand All')} getPopupContainer={this.getContainer}> name="angle-double-down"
<UIIcon type="double-right" onClick={onExpandAll} className={cx(styles.btn, styles.btnExpanded)} /> onClick={onExpandAll}
</UITooltip> />
<UITooltip title={getTitle('Collapse All')} getPopupContainer={this.getContainer}> <IconButton
<UIIcon type="double-right" onClick={onCollapseAll} className={styles.btn} /> tooltip="Collapse All"
</UITooltip> size="xl"
tooltipPlacement="top"
name="angle-double-right"
onClick={onCollapseAll}
/>
</div> </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