Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
setupController: function(controller, model) {
this._super(controller, model);
controller.set('currentRepository', card.data.repositoryName);
},
currentUserChanged: function(user) {
var route = this;
var applicationController = route.controllerFor('application');
var repositoryName = card.data.repositoryName;
var githubLogin = user && user.github_login;
if (!user) {
applicationController.set('myIssues', []);
return;
}
Issue.
findEverything(repositoryName, githubLogin).
then(updateTheApplicationController).
then(null, Conductor.error);
function updateTheApplicationController(hash) {
applicationController.set('myIssues', hash.userIssues || []);
applicationController.set('model', hash.allIssues);
model: function(){
var route = this;
var user = card.data.user;
var githubLogin = user && user.github_login;
var applicationController = this.controllerFor('application');
var repositoryName = card.data.repositoryName;
applicationController.set('repositoryName', repositoryName);
function handleRejection(reason) {
if (Issue.isErrorDueToIssuesBeingDisabled(reason)) {
route.transitionTo('disabled');
} else {
throw reason;
}
}
function process(hash) {
applicationController.set('myIssues', hash.userIssues || []);
findAllByRepositoryName: function(repositoryName) {
var service;
if (card.data.user) {
service = card.consumers.authenticatedGithubApi;
} else {
service = card.consumers.unauthenticatedGithubApi;
}
return service.request("ajax", {
url: '/repos/' + repositoryName + '/issues',
dataType: 'json'
});
},
model: function(){
return retrieveStargazers(card.data.user);
}
});
function retrieveStargazers(user) {
var repositoryName = card.data.repositoryName;
return Ember.RSVP.hash({
stargazers: Stargazers.findByRepositoryName(repositoryName, user),
isStarred: Stargazers.currentUserStarred(repositoryName, user)
}).then(function (hash) {
var stargazers = hash.stargazers;
return {
user: user,
repositoryName: repositoryName,
stargazers: stargazers.data,
totalStargazers: stargazers.total || stargazers.data.length,
isStarred: hash.isStarred
};
}).then(null, Conductor.error);
}