Immutable timeline

Summary:
Removes the "Set current" button if the timeline isn't editable

Note that the styling does weird stuff to colors when a field is set as not editable

Differential Revision: D24419006

fbshipit-source-id: 84dcee2e04d5ed7ebb3dc0255e99d1756f195284
This commit is contained in:
Paco Estevez Garcia
2020-10-20 10:48:18 -07:00
committed by Facebook GitHub Bot
parent 38ef16aeeb
commit d733f8131f
2 changed files with 11 additions and 7 deletions

View File

@@ -572,6 +572,7 @@ class DataDescriptionContainer extends PureComponent<{
return ( return (
<> <>
<TimelineDataDescription <TimelineDataDescription
canSetCurrent={editable}
timeline={JSON.parse(val)} timeline={JSON.parse(val)}
onClick={(id) => { onClick={(id) => {
this.props.commit({ this.props.commit({

View File

@@ -28,6 +28,7 @@ type Timeline = {
}; };
type Props = { type Props = {
canSetCurrent?: boolean;
timeline: Timeline; timeline: Timeline;
onClick: (selected: string) => void; onClick: (selected: string) => void;
}; };
@@ -55,13 +56,15 @@ export default class TimelineDataDescription extends Component<Props, State> {
})); }));
return ( return (
<> <>
<div> {this.props.canSetCurrent && (
<Button <div>
onClick={() => this.props.onClick(this.state.selected)} <Button
disabled={this.state.selected === this.props.timeline.current}> onClick={() => this.props.onClick(this.state.selected)}
Set as current disabled={this.state.selected === this.props.timeline.current}>
</Button> Set as current
</div> </Button>
</div>
)}
<div> <div>
<MarkerTimeline <MarkerTimeline
points={points} points={points}