Skip to content

Commit

Permalink
Bug 1364888 - Stop using deprecated $http callback methods
Browse files Browse the repository at this point in the history
Angular v1.4.4 deprecated `$http`'s `.success()` and `.error()`
callbacks in favour of `.then()` and `.catch()`. The deprecated forms
are finally removed in Angular 1.6, so we need to stop using them:
https://docs.angularjs.org/guide/migration#-http-
  • Loading branch information
edmorley committed Jan 5, 2018
1 parent 08e219b commit 27e516f
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion ui/js/controllers/perf/compare.js
Expand Up @@ -11,7 +11,7 @@ perf.controller('CompareChooserCtrl', [
thPerformanceBranches,
localStorageService,
compareBaseLineDefaultTimeRange) {
ThRepositoryModel.get_list().success(function (projects) {
ThRepositoryModel.get_list().then(({ data: projects }) => {
$scope.projects = projects;
$scope.originalTipList = [];
$scope.newTipList = [];
Expand Down
2 changes: 1 addition & 1 deletion ui/js/models/repository.js
Expand Up @@ -103,7 +103,7 @@ treeherder.factory('ThRepositoryModel', [

// return the promise of getting the repos
return get_list()
.success(function (data) {
.then(({ data }) => {
// FIXME: only supporting github + hg for now for pushlog
// + revision info (we also assume dvcs_type git===github)
function Repo(props) {
Expand Down
2 changes: 1 addition & 1 deletion ui/js/models/resultsets_store.js
Expand Up @@ -865,7 +865,7 @@ treeherder.factory('ThResultSetStore', [
$log.debug("loadRevisions: check out to load revisions", rs, repoName);
// these revisions have never been loaded; do so now.
return ThResultSetModel.get(rs.revisions_uri)
.success(function (data) {
.then(({ data }) => {

if (rs.revisions.length === 0) {
Array.prototype.push.apply(rs.revisions, data);
Expand Down
8 changes: 4 additions & 4 deletions ui/js/services/buildapi.js
Expand Up @@ -47,10 +47,10 @@ treeherder.factory('thBuildApi', [
},
withCredentials: true
})
.success(function (data, status) {
.then(({ status }) => {
notify(status, "cancel");
})
.error(function (data, status) {
.catch(({ status }) => {
notify(status, "cancel");
});
},
Expand All @@ -65,10 +65,10 @@ treeherder.factory('thBuildApi', [
withCredentials: true

})
.success(function (data, status) {
.then(({ status }) => {
notify(status, "cancel all jobs");
})
.error(function (data, status) {
.catch(({ status }) => {
notify(status, "cancel all jobs");
});
}
Expand Down
2 changes: 1 addition & 1 deletion ui/js/services/classifications.js
Expand Up @@ -27,7 +27,7 @@ treeherder.factory('thClassificationTypes', [

var load = function () {
return $http.get(thUrl.getRootUrl("/failureclassification/"), { cache: true })
.success(function (data) {
.then(({ data }) => {
data.forEach(addClassification);
});
};
Expand Down
14 changes: 7 additions & 7 deletions ui/js/services/pinboard.js
Expand Up @@ -24,15 +24,15 @@ treeherder.factory('thPinboard', [

classification.job_id = job.id;
classification.create()
.success(function () {
.then(() => {
thNotify.send("Classification saved for " + job.platform + " " + job.job_type_name, "success");
}).error(function (data) {
}).catch((response) => {
var message = "Error saving classification for " + job.platform + " " + job.job_type_name;
thNotify.send(
ThModelErrors.format(data, message),
ThModelErrors.format(response, message),
"danger"
);
$log.debug("classification failed", data);
$log.debug("classification failed", response);
});
}
};
Expand All @@ -45,12 +45,12 @@ treeherder.factory('thPinboard', [
type: 'annotation'
});
bjm.create()
.success(function () {
.then(() => {
thNotify.send("Bug association saved for " + job.platform + " " + job.job_type_name, "success");
}).error(function (data) {
}).catch((response) => {
var message = "Error saving bug association for " + job.platform + " " + job.job_type_name;
thNotify.send(
ThModelErrors.format(data, message),
ThModelErrors.format(response, message),
"danger"
);
});
Expand Down

0 comments on commit 27e516f

Please sign in to comment.