Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cz-github-issues as an issue source for cz-component-dash in animations-ave.json #77

Merged
merged 12 commits into from
Oct 19, 2016
34 changes: 22 additions & 12 deletions client/cz-component-dash.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
is: "cz-component-dash",

properties: {
users: {
userConfigs: {
Copy link
Collaborator Author

@alancutter alancutter Oct 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can anticipate disapproval for this rename, it has a weaker line of reasoning than searchQuery.query.

type: 'Object',
value: function() { return []; },
},
Expand All @@ -112,25 +112,33 @@
type: 'Object',
value: function() { return null; },
},
usernames: {
type: 'Object',
value: function() { return new Set(); },
},
component: {
type: 'Object',
value: function() { return {}; }
}
},
},

observers: [
'updateComponent(issueList)',
'updateUsernames(userConfigs, issueList)',
'updateComponent(usernames, issueList)',
],

attached: function() {
registerSource('cz-config', 'users', users => {
this.set('users', users.map(userData => userData['email']));
registerSource('cz-config', 'users', userConfigs => {
this.set('userConfigs', userConfigs);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.userConfigs = userConfigs

});
registerSource('cz-config', 'updateSLO', updateSLO => {
this.set('updateSLO', updateSLO);
});
registerSource('cz-config', 'issue-sources', issueSources => {
this.updateIssueSource(issueSources[this.key]);
var issueSource = issueSources[this.key];
registerSource(issueSource.tag, issueSource.query, issueList => {
this.set('issueList', issueList);
});
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, thought I reverted the updateIssueSource() split in the previous patch.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.issueList = issueList :P

});
},

Expand All @@ -141,21 +149,23 @@
return issueList.summary(updateSLO);
},

updateIssueSource: function({tag, query}) {
registerSource(tag, query, issueList => {
this.set('issueList', issueList);
});
updateUsernames: function(userConfigs, issueList) {
if (!issueList) {
return;
}
var usernames = userConfigs.map(userConfig => issueList.getUsername(userConfig));
this.set('usernames', new Set(usernames));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.usernames = ...

},

updateComponent: function(issueList) {
updateComponent: function(usernames, issueList) {
var team = new IssueList();
var others = new IssueList();
var unowned = new IssueList();
if (issueList) {
for (var issue of issueList) {
if (issue.owner == null) {
unowned.push(issue);
} else if (this.users.indexOf(issue.owner) === -1) {
} else if (!usernames.has(issue.owner)) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, you can use .includes on a list directly now, so you don't need to Set-ify usernames (I don't think there's any other reason to do that here as it isn't edited anywhere).

others.push(issue);
} else {
team.push(issue);
Expand Down
6 changes: 5 additions & 1 deletion client/cz-crbug-issues.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@
return Crbug.queryURL(query);
}

return new IssueList(issues, getQueryURL);
function getUsername(userConfig) {
return userConfig.email;
}

return new IssueList(issues, getQueryURL, getUsername);
},

registerQuery: function(query, callback) {
Expand Down
52 changes: 52 additions & 0 deletions client/cz-github-issues.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="../bower_components/iron-ajax/iron-ajax.html">
<script src="chromez-behaviors.js"></script>
<script src="issues-lib.js"></script>

<dom-module id="cz-github-issues">

<template>
<template is="dom-repeat" items="{{searchQueries}}">
<iron-ajax
auto
handle-as="json"
url="https://api.github.com/repos/[[item.params.repo]]/issues"
on-response="handleResponse"></iron-ajax>
</template>
</template>

<script>
Polymer({
is: 'cz-github-issues',

behaviors: [ChromeZBehaviors.AJAXBehavior],

onResponse: function(items, query) {
var issues = items.map(item => {
return new Issue({
id: item.id,
owner: item.assignee ? item.assignee.login : null,
summary: item.title,
lastUpdatedString: item.updated_at,
labels: item.labels.map(label => label.name),
});
});

function getQueryUrl(subQuery) {
return 'https://www.github.com/' + query.repo + '/issues';
}

function getUsername(userConfig) {
return /(.+)@/.exec(userConfig.email)[1];
}

return new IssueList(issues, getQueryUrl, getUsername);
},

registerQuery: function(query, callback) {
var params = {repo: query.repo};
this.addCallbackToQuery(query, callback, params);
},
});
</script>
</dom-module>
19 changes: 15 additions & 4 deletions client/issues-lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ var _reviewLevelMetadata = {
'none (P3)': {
query: {label: 'Pri-3', '-has': 'Update'},
},
'none': {
query: {'-has': 'Update'},
},
};
var _defaultReviewLevel = 'none';
var _inSLOColor = '#4CAF50'; // Green 500
Expand All @@ -53,7 +56,7 @@ class Issue {
summary,
lastUpdatedString,
labels,
priority: undefined,
priority: null,
_lastUpdatedMS: Date.parse(lastUpdatedString),
_reviewLevel: _defaultReviewLevel,
});
Expand Down Expand Up @@ -86,28 +89,36 @@ class Issue {

reviewLevelWithBackoff() {
var result = this._reviewLevel;
if (result == _defaultReviewLevel) {
if (result == _defaultReviewLevel && this.priority != null) {
result += ' (P' + this.priority + ')';
}
return result;
}
}

class IssueList {
constructor(issues = [], getQueryURL = null) {
constructor(issues = [], getQueryURL = null, getUsername = null) {
for (var issue of issues) {
console.assert(issue instanceof Issue);
}
this._issues = issues;
this._getQueryURL = getQueryURL;
this._getUsername = getUsername;
}

getQueryURL(subQuery) {
return this._getQueryURL(subQuery);
}

getUsername(userConfig) {
return this._getUsername(userConfig);
}

clone() {
return new IssueList(this._issues.map(issue => issue.clone()), this._getQueryURL);
return new IssueList(
this._issues.map(issue => issue.clone()),
this._getQueryURL,
this._getUsername);
}

push(issue) {
Expand Down
5 changes: 5 additions & 0 deletions configs/animations-ave.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"cz-clock-dash",
"cz-component-dash(Blink Animations)",
"cz-issue-priority-dash",
"cz-component-dash(Web Animations Polyfill)",
"cz-regression-dash",
"cz-review-latency-dash(false)",
"cz-review-load-dash",
Expand Down Expand Up @@ -47,6 +48,10 @@
"Blink Animations": {
"tag": "cz-crbug-issues",
"query": {"component": "Blink>Animation"}
},
"Web Animations Polyfill": {
"tag": "cz-github-issues",
"query": {"repo": "web-animations/web-animations-js"}
}
}
}