зеркало из https://github.com/mozilla/treeherder.git
Bug 1402062 - Switch thNotify api to have named options (#2783)
* Bug 1402062 - Switch thNotify api to have named options * Bug 1402062 - Update all uses of sticky to new-style
This commit is contained in:
Родитель
dcdb96311c
Коммит
30f06d36bc
|
@ -115,7 +115,7 @@ treeherder.component("login", {
|
|||
.then(function () {
|
||||
ctrl.setLoggedOut();
|
||||
}, function (data) {
|
||||
thNotify.send(`Logout failed: ${data.data}`, "danger", true);
|
||||
thNotify.send(`Logout failed: ${data.data}`, "danger", { sticky: true });
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -395,7 +395,7 @@ treeherder.controller('BugFilerCtrl', [
|
|||
var data = response.data;
|
||||
if (data.failure) {
|
||||
var error = JSON.parse(data.failure.join(""));
|
||||
thNotify.send("Bugzilla error: " + error.message, "danger", true);
|
||||
thNotify.send("Bugzilla error: " + error.message, "danger", { sticky: true });
|
||||
$scope.toggleForm(false);
|
||||
} else {
|
||||
successCallback(data);
|
||||
|
|
|
@ -14,7 +14,7 @@ failureViewerApp.controller('FailureViewerCtrl', [
|
|||
if (query_string.classified_failure_id) {
|
||||
$scope.classifiedFailureId = query_string.classified_failure_id;
|
||||
} else {
|
||||
thNotify.send("No classified_failure_id specified", "danger", true);
|
||||
thNotify.send("No classified_failure_id specified", "danger", { sticky: true });
|
||||
}
|
||||
$scope.init = function () {
|
||||
if ($scope.classifiedFailureId) {
|
||||
|
|
|
@ -253,7 +253,7 @@ treeherderApp.controller('ResultSetCtrl', [
|
|||
).then(function (msg) {
|
||||
thNotify.send(msg, "success");
|
||||
}, function (e) {
|
||||
thNotify.send(ThTaskclusterErrors.format(e), 'danger', true);
|
||||
thNotify.send(ThTaskclusterErrors.format(e), 'danger', { sticky: true });
|
||||
});
|
||||
});
|
||||
};
|
||||
|
@ -275,7 +275,7 @@ treeherderApp.controller('ResultSetCtrl', [
|
|||
thNotify.send(results[1], "success");
|
||||
ThResultSetStore.deleteRunnableJobs($scope.repoName, $scope.resultset);
|
||||
}, function (e) {
|
||||
thNotify.send(ThTaskclusterErrors.format(e), 'danger', true);
|
||||
thNotify.send(ThTaskclusterErrors.format(e), 'danger', { sticky: true });
|
||||
});
|
||||
});
|
||||
} else {
|
||||
|
|
|
@ -159,7 +159,7 @@ logViewerApp.controller('LogviewerCtrl', [
|
|||
}, () => {
|
||||
$scope.loading = false;
|
||||
$scope.jobExists = false;
|
||||
thNotify.send('The job does not exist or has expired', 'danger', true);
|
||||
thNotify.send('The job does not exist or has expired', 'danger', { sticky: true });
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
@ -76,10 +76,13 @@ treeherder.controller('TCJobActionsCtrl', [
|
|||
message = 'Visit Taskcluster Tools site to access loaner:';
|
||||
url = `${url}/connect`;
|
||||
}
|
||||
$scope.$apply(thNotify.send(message, 'success', true, 'Open in Taskcluster', url));
|
||||
$scope.$apply(thNotify.send(message, 'success', {
|
||||
linkText: 'Open in Taskcluster',
|
||||
url,
|
||||
}));
|
||||
$uibModalInstance.close('request sent');
|
||||
}, function (e) {
|
||||
$scope.$apply(thNotify.send(ThTaskclusterErrors.format(e), 'danger', true));
|
||||
$scope.$apply(thNotify.send(ThTaskclusterErrors.format(e), 'danger', { sticky: true }));
|
||||
$scope.triggering = false;
|
||||
$uibModalInstance.close('error');
|
||||
});
|
||||
|
|
|
@ -1021,7 +1021,7 @@ treeherder.factory('ThResultSetStore', [
|
|||
return $q.all([loadRepositories, loadResultsets])
|
||||
.then(() => appendResultSets(repoName, resultsets),
|
||||
(data) => {
|
||||
thNotify.send("Error retrieving resultset data!", "danger", true);
|
||||
thNotify.send("Error retrieving resultset data!", "danger", { sticky: true });
|
||||
$log.error(data);
|
||||
appendResultSets(repoName, { results: [] });
|
||||
})
|
||||
|
@ -1116,7 +1116,7 @@ treeherder.factory('ThResultSetStore', [
|
|||
}, function () {
|
||||
// the job wasn't found in the db. Either never existed,
|
||||
// or was expired and deleted.
|
||||
thNotify.send("Unable to find job with id " + selectedJobId, "danger", true);
|
||||
thNotify.send("Unable to find job with id " + selectedJobId, "danger", { sticky: true });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ treeherder.factory('thBuildApi', [
|
|||
} else if (status === 202 || status === 200) {
|
||||
thNotify.send(action + " SUCCESS");
|
||||
} else {
|
||||
thNotify.send(action + " FAILED " + status, "danger", true);
|
||||
thNotify.send(action + " FAILED " + status, "danger", { sticky: true });
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -125,20 +125,24 @@ treeherder.factory('thNotify', [
|
|||
/*
|
||||
* send a message to the notification queue
|
||||
* @severity can be one of success|info|warning|danger
|
||||
* @sticky is a boolean indicating if you want the message to disappear
|
||||
* after a while or not
|
||||
* @opts is an object with up to three entries:
|
||||
* sticky -- Keeps notification visible until cleared if true
|
||||
* linkText -- Text to display as a link if exists
|
||||
* url -- Location the link should point to if exists
|
||||
*/
|
||||
send: function (message, severity, sticky, linkText, url) {
|
||||
send: function (message, severity, opts) {
|
||||
if (!_.isPlainObject(opts)) {
|
||||
throw new Error('Must pass an object as last argument to thNotify.send!');
|
||||
}
|
||||
$log.debug("received message", message);
|
||||
opts = opts || {};
|
||||
severity = severity || 'info';
|
||||
sticky = sticky || false;
|
||||
|
||||
var maxNsNotifications = 5;
|
||||
var notification = {
|
||||
message: message,
|
||||
severity: severity,
|
||||
sticky: sticky,
|
||||
linkText: linkText,
|
||||
url: url,
|
||||
...opts,
|
||||
message,
|
||||
severity,
|
||||
created: Date.now()
|
||||
};
|
||||
thNotify.notifications.unshift(notification);
|
||||
|
@ -146,7 +150,7 @@ treeherder.factory('thNotify', [
|
|||
thNotify.storedNotifications.splice(40);
|
||||
localStorageService.set('notifications', thNotify.storedNotifications);
|
||||
|
||||
if (!sticky) {
|
||||
if (!opts.sticky) {
|
||||
if (thNotify.notifications.length > maxNsNotifications) {
|
||||
$timeout(thNotify.shift);
|
||||
return;
|
||||
|
|
|
@ -30,7 +30,7 @@ treeherder.factory('tcactions', [
|
|||
},
|
||||
load: (decisionTaskID, job) => {
|
||||
if (!decisionTaskID) {
|
||||
thNotify.send("No decision task, can't find taskcluster actions", "danger", true);
|
||||
thNotify.send("No decision task, can't find taskcluster actions", "danger", { sticky: true });
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ treeherder.factory('tcactions', [
|
|||
return null;
|
||||
}
|
||||
if (response.data.version !== 1) {
|
||||
thNotify.send("Wrong version of actions.json, can't continue", "danger", true);
|
||||
thNotify.send("Wrong version of actions.json, can't continue", "danger", { sticky: true });
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ treeherder.controller('AnnotationsPluginCtrl', [
|
|||
classification.delete()
|
||||
.then(
|
||||
function () {
|
||||
thNotify.send("Classification successfully deleted", "success", false);
|
||||
thNotify.send("Classification successfully deleted", "success");
|
||||
var jobs = {};
|
||||
jobs[$scope.selectedJob.id] = $scope.selectedJob;
|
||||
|
||||
|
@ -53,7 +53,7 @@ treeherder.controller('AnnotationsPluginCtrl', [
|
|||
$rootScope.$emit(thEvents.jobsClassified, { jobs: jobs });
|
||||
},
|
||||
function () {
|
||||
thNotify.send("Classification deletion failed", "danger", true);
|
||||
thNotify.send("Classification deletion failed", "danger", { sticky: true });
|
||||
}
|
||||
);
|
||||
};
|
||||
|
@ -62,14 +62,14 @@ treeherder.controller('AnnotationsPluginCtrl', [
|
|||
bug.delete()
|
||||
.then(
|
||||
function () {
|
||||
thNotify.send("Association to bug " + bug.bug_id + " successfully deleted", "success", false);
|
||||
thNotify.send("Association to bug " + bug.bug_id + " successfully deleted", "success");
|
||||
var jobs = {};
|
||||
jobs[$scope.selectedJob.id] = $scope.selectedJob;
|
||||
|
||||
$rootScope.$emit(thEvents.bugsAssociated, { jobs: jobs });
|
||||
},
|
||||
function () {
|
||||
thNotify.send("Association to bug " + bug.bug_id + " deletion failed", "danger", true);
|
||||
thNotify.send("Association to bug " + bug.bug_id + " deletion failed", "danger", { sticky: true });
|
||||
}
|
||||
);
|
||||
};
|
||||
|
|
|
@ -410,7 +410,7 @@ treeherder.controller('PluginCtrl', [
|
|||
}, function (e) {
|
||||
// The full message is too large to fit in a Treeherder
|
||||
// notification box.
|
||||
$scope.$apply(thNotify.send(ThTaskclusterErrors.format(e), 'danger', true));
|
||||
$scope.$apply(thNotify.send(ThTaskclusterErrors.format(e), 'danger', { sticky: true }));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -443,7 +443,7 @@ treeherder.controller('PluginCtrl', [
|
|||
}, function (e) {
|
||||
// The full message is too large to fit in a Treeherder
|
||||
// notification box.
|
||||
$scope.$apply(thNotify.send(ThTaskclusterErrors.format(e), 'danger', true));
|
||||
$scope.$apply(thNotify.send(ThTaskclusterErrors.format(e), 'danger', { sticky: true }));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче