Resolve "Error while updating todo status: the button is stuck in the loading state"

This commit is contained in:
Marcos Barrera 2018-10-04 13:47:40 +00:00 committed by Phil Hughes
parent 7876a7397d
commit 4b5e00a848
2 changed files with 15 additions and 3 deletions

View File

@ -79,10 +79,13 @@ export default class Todos {
.then(({ data }) => {
this.updateRowState(target);
this.updateBadges(data);
}).catch(() => flash(__('Error updating todo status.')));
}).catch(() => {
this.updateRowState(target, true);
return flash(__('Error updating todo status.'));
});
}
updateRowState(target) {
updateRowState(target, isInactive = false) {
const row = target.closest('li');
const restoreBtn = row.querySelector('.js-undo-todo');
const doneBtn = row.querySelector('.js-done-todo');
@ -91,7 +94,10 @@ export default class Todos {
target.removeAttribute('disabled');
target.classList.remove('disabled');
if (target === doneBtn) {
if (isInactive === true) {
restoreBtn.classList.add('hidden');
doneBtn.classList.remove('hidden');
} else if (target === doneBtn) {
row.classList.add('done-reversible');
restoreBtn.classList.remove('hidden');
} else if (target === restoreBtn) {

View File

@ -0,0 +1,6 @@
---
title: Fix the state of the Done button when there is an error in the GitLab Todos
section
merge_request:
author: marcos8896
type: fixed