diff --git a/desktop/app/src/ui/components/data-inspector/DataDescription.tsx b/desktop/app/src/ui/components/data-inspector/DataDescription.tsx index e0a5da658..ac9ef5c8b 100644 --- a/desktop/app/src/ui/components/data-inspector/DataDescription.tsx +++ b/desktop/app/src/ui/components/data-inspector/DataDescription.tsx @@ -19,6 +19,7 @@ import React, {KeyboardEvent} from 'react'; import Glyph from '../Glyph'; import {HighlightContext} from '../Highlight'; import Select from '../Select'; +import TimelineDataDescription from './TimelineDataDescription'; const NullValue = styled.span({ color: 'rgb(128, 128, 128)', @@ -567,6 +568,24 @@ class DataDescriptionContainer extends PureComponent<{ const highlighter = this.context; switch (type) { + case 'timeline': { + return ( + <> + { + this.props.commit({ + value: id, + keep: true, + clear: false, + set: true, + }); + }} + /> + + ); + } + case 'number': return {+val}; diff --git a/desktop/app/src/ui/components/data-inspector/TimelineDataDescription.tsx b/desktop/app/src/ui/components/data-inspector/TimelineDataDescription.tsx new file mode 100644 index 000000000..f07811ccb --- /dev/null +++ b/desktop/app/src/ui/components/data-inspector/TimelineDataDescription.tsx @@ -0,0 +1,85 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + */ + +import ManagedDataInspector from './ManagedDataInspector'; +import {Component, ReactNode} from 'react'; +import {colors} from '../colors'; +import React from 'react'; +import MarkerTimeline from '../MarkerTimeline'; +import Button from '../Button'; + +type TimePoint = { + moment: number; + display: string; + color: string; + key: string; + properties: {[key: string]: string}; +}; + +type Timeline = { + time: TimePoint[]; + current: string; +}; + +type Props = { + timeline: Timeline; + onClick: (selected: string) => void; +}; + +type State = { + selected: string; +}; + +export default class TimelineDataDescription extends Component { + constructor(props: Props) { + super(props); + this.state = {selected: props.timeline.current}; + } + + render(): ReactNode { + const moments = Object.values(this.props.timeline.time); + const firstMoment = moments[0].moment; + const points = moments.map((value) => ({ + label: value.display, + time: value.moment - firstMoment, + color: + Object.entries(colors).find(([k, _]) => k === value.color)?.[1] ?? + value.color, + key: value.key, + })); + return ( + <> +
+ +
+
+ this.setState({selected: ids[0]})} + maxGap={50} + selected={this.state.selected} + /> +
+
+ value.key === this.state.selected, + )?.properties ?? {} + } + /> +
+ + ); + } +}