-
Notifications
You must be signed in to change notification settings - Fork 3.9k
/
Copy pathindex.tsx
86 lines (75 loc) · 2.51 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import Long from "long";
import { Link } from "react-router";
import React from "react";
import { connect } from "react-redux";
import { RouterState } from "react-router";
import * as protos from "src/js/protos";
import { refreshCommandQueue } from "src/redux/apiReducers";
import { AdminUIState } from "src/redux/state";
import { rangeIDAttr } from "src/util/constants";
import { LongToMoment } from "src/util/convert";
import CommandQueueViz from "src/views/reports/containers/commandQueue/commandQueueViz";
interface CommandQueueOwnProps {
commandQueue: protos.cockroach.server.serverpb.CommandQueueResponse;
refreshCommandQueue: typeof refreshCommandQueue;
}
type CommandQueueProps = CommandQueueOwnProps & RouterState;
/**
* Renders the Command Queue Report page.
*/
class CommandQueue extends React.Component<CommandQueueProps, {}> {
refresh(props = this.props) {
props.refreshCommandQueue(new protos.cockroach.server.serverpb.CommandQueueRequest({
range_id: Long.fromString(props.params[rangeIDAttr]),
}));
}
componentWillMount() {
this.refresh();
}
render() {
const rangeID = this.props.params[rangeIDAttr];
return (
<div className="section command-queue">
<h1>
<Link
to={`/reports/range/${rangeID.toString()}`}
className="debug-link">
r{rangeID.toString()}
</Link>
{" "}>{" "}
Command queue
</h1>
<div className="command-queue__timestamp">
{this.props.commandQueue
? <span>
Snapshot taken at
{" "}{LongToMoment(this.props.commandQueue.queues.timestamp).toISOString()}
</span>
: <span>Loading...</span>}
</div>
<div className="command-queue__key">
Key:
<div className="command-queue__key__read">Read</div>
<div className="command-queue__key__write">Write</div>
</div>
<h2>Local Scope</h2>
{this.props.commandQueue
? <CommandQueueViz queue={this.props.commandQueue.queues.localScope} />
: <p>Loading...</p>}
<h2>Global Scope</h2>
{this.props.commandQueue
? <CommandQueueViz queue={this.props.commandQueue.queues.globalScope} />
: <p>Loading...</p>}
</div>
);
}
}
function mapStateToProps(state: AdminUIState) {
return {
commandQueue: state.cachedData.commandQueue.data,
};
}
const actions = {
refreshCommandQueue,
};
export default connect(mapStateToProps, actions)(CommandQueue);