-
Notifications
You must be signed in to change notification settings - Fork 18
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
Changes from 11 commits
c6b5f25
dbaeae9
5edd350
c8191d6
44f27d8
97f40a5
0d33ec5
f4480d6
b7d89a7
510174b
5fcfa2f
f425b21
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,7 +100,7 @@ | |
is: "cz-component-dash", | ||
|
||
properties: { | ||
users: { | ||
userConfigs: { | ||
type: 'Object', | ||
value: function() { return []; }, | ||
}, | ||
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops, thought I reverted the updateIssueSource() split in the previous patch. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this.issueList = issueList :P |
||
}); | ||
}, | ||
|
||
|
@@ -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)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
|
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> |
There was a problem hiding this comment.
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
.