Bug 1473167 - Fix 'Retrigger All' provides no feedback (#3766)

This commit is contained in:
Cameron Dawson 2018-07-13 22:10:12 -07:00 коммит произвёл GitHub
Родитель bc4e8a7b14
Коммит 057c3415cc
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 15 добавлений и 2 удалений

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

@ -21,7 +21,7 @@ export const formatModelError = function formatModelError(e, message) {
}
// If there is nothing in the server message use the HTTP response status.
const errorMessage = `${e.data.detail || e.status} ${e.statusText}`;
const errorMessage = `${e.data && e.data.detail || e.status} ${e.statusText}`;
return `${message}: ${errorMessage}`;
};

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

@ -181,7 +181,20 @@ export default class PinBoard extends React.Component {
retriggerAllPinnedJobs() {
// pushing pinned jobs to a list.
const jobIds = Object.keys(this.props.pinnedJobs);
JobModel.retrigger(this.$rootScope.repoName, jobIds);
const plurality = jobIds.length > 1 ? 's' : '';
JobModel.retrigger(this.$rootScope.repoName, jobIds)
.then((resp) => {
if (resp.ok) {
this.thNotify.send(
`Retrigger request sent for ${jobIds.length} pinned job${plurality}`,
'success');
} else {
throw new Error(formatModelError(resp, `Unable to send retrigger${plurality}`));
}
})
.catch(error => this.$timeout(this.thNotify.send(error, 'danger')))
.finally(() => this.$rootScope.$apply());
}
cancelAllPinnedJobsTitle() {