Bug 1364888 - Stop using deprecated $http callback methods

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-
This commit is contained in:
Ed Morley 2017-12-28 13:38:30 +00:00
Родитель 08e219bfe3
Коммит 27e516ff4e
6 изменённых файлов: 15 добавлений и 15 удалений

Просмотреть файл

@ -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 = [];

Просмотреть файл

@ -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) {

Просмотреть файл

@ -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);

Просмотреть файл

@ -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");
});
},
@ -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");
});
}

Просмотреть файл

@ -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);
});
};

Просмотреть файл

@ -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);
});
}
};
@ -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"
);
});