Commit 4ee8cf43 authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch '27452-update-issue-count' into 'master'

update issue count when closing/reopening an issue

Closes #27452

See merge request !9216
parents 1b6a671e b5cbca55
......@@ -54,16 +54,19 @@ require('vendor/task_list');
success: function(data, textStatus, jqXHR) {
if ('id' in data) {
$(document).trigger('issuable:change');
const currentTotal = Number($('.issue_counter').text());
if (isClose) {
$('a.btn-close').addClass('hidden');
$('a.btn-reopen').removeClass('hidden');
$('div.status-box-closed').removeClass('hidden');
$('div.status-box-open').addClass('hidden');
$('.issue_counter').text(currentTotal - 1);
} else {
$('a.btn-reopen').addClass('hidden');
$('a.btn-close').removeClass('hidden');
$('div.status-box-closed').addClass('hidden');
$('div.status-box-open').removeClass('hidden');
$('.issue_counter').text(currentTotal + 1);
}
} else {
new Flash(issueFailMessage, 'alert');
......
---
title: update issue count when closing/reopening an issue
merge_request:
author:
......@@ -105,6 +105,7 @@ require('~/issue');
expectIssueState(false);
expect($btnClose).toHaveProp('disabled', false);
expect($('.issue_counter')).toHaveText(0);
});
it('fails to close an issue with success:false', function() {
......@@ -121,6 +122,7 @@ require('~/issue');
expectIssueState(true);
expect($btnClose).toHaveProp('disabled', false);
expectErrorMessage();
expect($('.issue_counter')).toHaveText(1);
});
it('fails to closes an issue with HTTP error', function() {
......@@ -135,6 +137,7 @@ require('~/issue');
expectIssueState(true);
expect($btnClose).toHaveProp('disabled', true);
expectErrorMessage();
expect($('.issue_counter')).toHaveText(1);
});
});
......@@ -159,6 +162,7 @@ require('~/issue');
expectIssueState(true);
expect($btnReopen).toHaveProp('disabled', false);
expect($('.issue_counter')).toHaveText(1);
});
});
}).call(this);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment