fix empty <ProblemTimeline /> rendering

This commit is contained in:
Alexander Zobnin
2018-12-16 17:23:37 +03:00
parent c8b4c138ee
commit a945d57760
3 changed files with 17 additions and 10 deletions

View File

@@ -31,7 +31,9 @@ export default class ProblemTimeline extends PureComponent<ProblemTimelineProps,
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
width: 0 width: 0,
highlightedEvent: null,
showEventInfo: false,
}; };
} }
@@ -115,7 +117,7 @@ export default class ProblemTimeline extends PureComponent<ProblemTimelineProps,
event={this.state.highlightedEvent} event={this.state.highlightedEvent}
show={this.state.showEventInfo} show={this.state.showEventInfo}
/> />
<svg className="event-timeline-canvas" viewBox={`0 0 ${width + 20} 40`}> <svg className="event-timeline-canvas" viewBox={`0 0 ${width} 40`}>
<defs> <defs>
<filter id="dropShadow" x="-50%" y="-50%" width="200%" height="200%"> <filter id="dropShadow" x="-50%" y="-50%" width="200%" height="200%">
<feGaussianBlur in="SourceAlpha" stdDeviation="2" /> <feGaussianBlur in="SourceAlpha" stdDeviation="2" />

View File

@@ -377,15 +377,19 @@ class ProblemDetails extends PureComponent<any, ProblemDetailsState> {
} }
componentDidMount() { componentDidMount() {
this.fetchProblemEvents();
requestAnimationFrame(() => {
this.setState({ show: true });
});
}
fetchProblemEvents() {
const problem = this.props.original; const problem = this.props.original;
this.props.getProblemEvents(problem) this.props.getProblemEvents(problem)
.then(events => { .then(events => {
console.log(events, this.props.timeRange); console.log(events, this.props.timeRange);
this.setState({ events }); this.setState({ events });
}); });
requestAnimationFrame(() => {
this.setState({ show: true });
});
} }
ackProblem = (data: AckProblemData) => { ackProblem = (data: AckProblemData) => {
@@ -434,14 +438,16 @@ class ProblemDetails extends PureComponent<any, ProblemDetailsState> {
<span>{problem.comments}</span> <span>{problem.comments}</span>
</div> </div>
} }
{problem.tags && problem.tags.length && {problem.tags && problem.tags.length > 0 &&
<div className="problem-tags"> <div className="problem-tags">
{problem.tags && problem.tags.map(tag => {problem.tags && problem.tags.map(tag =>
<EventTag key={tag.tag + tag.value} tag={tag} highlight={tag.tag === problem.correlation_tag} />) <EventTag key={tag.tag + tag.value} tag={tag} highlight={tag.tag === problem.correlation_tag} />)
} }
</div> </div>
} }
<ProblemTimeline events={this.state.events} timeRange={this.props.timeRange} /> {this.state.events.length > 0 &&
<ProblemTimeline events={this.state.events} timeRange={this.props.timeRange} />
}
{problem.acknowledges && !wideLayout && {problem.acknowledges && !wideLayout &&
<div className="problem-ack-container"> <div className="problem-ack-container">
<h6><FAIcon icon="reply-all" /> Acknowledges</h6> <h6><FAIcon icon="reply-all" /> Acknowledges</h6>

View File

@@ -340,8 +340,8 @@
.event-timeline { .event-timeline {
display: flex; display: flex;
position: relative; position: relative;
margin-bottom: 1.6rem; margin-bottom: 0.6rem;
padding-top: 0.4rem; padding-top: 1.6rem;
// margin-top: auto; // margin-top: auto;
.timeline-info-container { .timeline-info-container {
@@ -360,7 +360,6 @@
svg.event-timeline-canvas { svg.event-timeline-canvas {
height: 40px; height: 40px;
margin-top: 1.6rem;
g.event-timeline-group { g.event-timeline-group {
height: 40px; height: 40px;