-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbug-triage.html
226 lines (211 loc) · 5.68 KB
/
bug-triage.html
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<!DOCTYPE html>
<title>Bug Triage List</title>
<!-- TODO: Use server-side transforms -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/react.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/JSXTransformer.js"></script>
<body>
<script type="text/jsx">
'use strict';
const maxResultsPerPage = 100;
const statusUnconfirmed = 'unconfirmed';
const statusUntriaged = 'untriaged';
function formatIssuesUrl(opts, page, status, resultsPerPage) {
if (!/\d\d\d\d\/\d?\d\/\d?\d/.test(opts.openedAfter)) {
throw 'opts.openedAfter should match YYYY/mm/dd but is \"' +
opts.openedAfter + '"';
}
return 'https://code.google.com/feeds/issues/p/chromium/issues/full' +
'?alt=json&start-index=' + (page * resultsPerPage + 1) +
'&max-results=' + resultsPerPage +
'&q=status:' + status + '+opened-after:' + opts.openedAfter +
'+cr=' + opts.label;
}
function issueId(issue) {
return Number(issue.issues$id.$t);
}
function fetchIssues(opts) {
var optsCopy = {
label: opts.label,
openedAfter: opts.openedAfter
};
var page = 0;
var issues = [];
function fetchPage(status) {
try {
var url = formatIssuesUrl(optsCopy, page, status, maxResultsPerPage);
} catch (e) {
return Promise.reject(e);
}
return fetch(url)
.then(function(response) {
return response.json();
})
.then(function(json) {
if (!json.feed.entry) {
return;
}
issues.push.apply(issues, json.feed.entry);
page++;
return fetchPage();
});
}
return Promise.all([
fetchPage(statusUntriaged),
fetchPage(statusUnconfirmed)
])
.then(() => {
issues.sort((a, b) => { issueId(a) - issueId(b) });
return issues;
});
}
var Issue = React.createClass({
render: function() {
return (
<tr>
<td>
<a href={this.props.href} target="_blank">{this.props.number}</a>
</td>
<td>{this.props.title}</td>
</tr>
);
}
});
var IssueList = React.createClass({
getInitialState: function() {
return {issues: [], loading: false}
},
componentDidMount: function() {
this.propsChanging(this.props);
},
componentWillReceiveProps: function(nextProps) {
console.log(nextProps);
if (this.sameProps(nextProps)) {
console.log('bail out');
return;
}
this.propsChanging(nextProps);
},
sameProps: function(otherProps) {
return otherProps.label == this.props.label &&
otherProps.openedAfter == this.props.openedAfter;
},
propsChanging: function(nextProps) {
if (!nextProps.label) {
this.setState({issues: [], loading: false});
return;
}
this.setState({issues: this.state.issues, loading: true});
fetchIssues({label: nextProps.label, openedAfter: nextProps.openedAfter})
.then(function(issues) {
console.log('got data');
if (!this.sameProps(nextProps)) {
console.log('bail out');
return; // This must be the response to a stale request.
}
this.setState({issues: issues, loading: false});
}.bind(this));
},
render: function() {
if (this.state.loading) {
return (
<span>
⌛ Please wait...
</span>
);
}
if (!this.state.issues.length) {
return (
<span>
🎈 No issues! 🎈
</span>
);
}
var issueNodes = this.state.issues.map(function(issue) {
var id = issueId(issue);
var url;
issue.link.some(function(link) {
if (link.rel == 'alternate' && link.type == 'text/html') {
url = link.href;
return true;
}
});
return (
<Issue
key={id}
number={id}
title={issue.title.$t}
href={url}
/>
);
});
return (
<table className="issueList">
{issueNodes}
</table>
);
}
});
var LabelSwitcher = React.createClass({
render: function() {
var labels = this.props.labels.map(function(label) {
return (
<div key={label}>
<a href="javascript:"
label={label}
onClick={this.select.bind(this, label)}
>
{this.props.selected == label ? '*' : ''}
{label}
</a>
</div>
);
}, this);
return (
<div>{labels}</div>
);
},
select: function(label) {
this.props.delegate.select(label);
}
});
var App = React.createClass({
getInitialState: function() {
var oneWeekAgo = new Date();
oneWeekAgo.setDate(oneWeekAgo.getDate() - 7);
return {date: oneWeekAgo};
},
render: function() {
return (
<div>
Since:
<input
type="date"
defaultValue={this.dateStringForInput()}
onChange={this.dateChanged}/>
<LabelSwitcher
labels={['Blink-DOM', 'Blink-HTML', 'Blink-XML', 'Blink',
'Blink-Editing', 'Blink-Focus', 'Blink-Forms',
'Blink-TextSelection', 'Blink-WebComponents']}
delegate={this}
selected={this.state.selected}/>
{this.state.selected
? <IssueList
label={this.state.selected}
openedAfter={this.dateStringForIssues()} />
: <div/>}
</div>
);
},
select: function(label) { this.setState({selected: label}); },
dateStringForInput: function() {
return this.state.date.toISOString().split('T')[0];
},
dateStringForIssues: function() {
return this.dateStringForInput().replace(/-/g, '/');
},
dateChanged: function(event) {
this.setState({date: new Date(event.target.value)});
}
});
React.render(<App />, document.body);
</script>