summaryrefslogtreecommitdiff
path: root/app/assets
diff options
context:
space:
mode:
authorLuke "Jared" Bennett <lbennett@gitlab.com>2017-07-03 17:00:59 +0100
committerLuke "Jared" Bennett <lbennett@gitlab.com>2017-07-07 14:57:28 +0100
commit55dd0d722d87a24f3b83a8a7692666a64387d668 (patch)
tree673d318330c0ca8d14b0147d74707a87686ebddf /app/assets
parentb8deafd0d8eacb5cbba9e868c445c92b514d537e (diff)
downloadgitlab-ce-55dd0d722d87a24f3b83a8a7692666a64387d668.tar.gz
Dont show toggle if only one action is available and do not show report as abuse for current_user's issuables
Diffstat (limited to 'app/assets')
-rw-r--r--app/assets/javascripts/issue.js31
-rw-r--r--app/assets/javascripts/merge_request.js24
-rw-r--r--app/assets/stylesheets/framework/filters.scss1
3 files changed, 48 insertions, 8 deletions
diff --git a/app/assets/javascripts/issue.js b/app/assets/javascripts/issue.js
index 62ffde6c93c..70007d4d4af 100644
--- a/app/assets/javascripts/issue.js
+++ b/app/assets/javascripts/issue.js
@@ -31,6 +31,11 @@ class Issue {
this.initCloseReopenReport();
+ if (!this.closeReopenReportToggle) {
+ this.closeButtons = $('a.btn-close');
+ this.reopenButtons = $('a.btn-reopen');
+ }
+
if (Issue.createMrDropdownWrap) {
this.createMergeRequestDropdown = new CreateMergeRequestDropdown(Issue.createMrDropdownWrap);
}
@@ -52,7 +57,7 @@ class Issue {
Issue.submitNoteForm($button.closest('form'));
}
- this.closeReopenReportToggle.setDisable(true);
+ this.disableCloseReopenButton($button, true);
url = $button.attr('href');
return $.ajax({
@@ -68,7 +73,7 @@ class Issue {
isClosedBadge.toggleClass('hidden', !isClosed);
isOpenBadge.toggleClass('hidden', isClosed);
- this.closeReopenReportToggle.updateButton(isClosed);
+ this.toggleCloseReopenButton(isClosed);
let numProjectIssues = Number(projectIssuesCounter.text().replace(/[^\d]/, ''));
numProjectIssues = isClosed ? numProjectIssues - 1 : numProjectIssues + 1;
@@ -87,13 +92,16 @@ class Issue {
new Flash(issueFailMessage);
}
- this.closeReopenReportToggle.setDisable(false);
+ this.disableCloseReopenButton($button, false);
});
});
}
initCloseReopenReport() {
const container = document.querySelector('.js-issuable-close-dropdown');
+
+ if (!container) return;
+
const dropdownTrigger = container.querySelector('.js-issuable-close-toggle');
const dropdownList = container.querySelector('.js-issuable-close-menu');
const button = container.querySelector('.js-issuable-close-button');
@@ -107,6 +115,23 @@ class Issue {
this.closeReopenReportToggle.initDroplab();
}
+ disableCloseReopenButton($button, shouldDisable) {
+ if (this.closeReopenReportToggle) {
+ this.closeReopenReportToggle.setDisable(shouldDisable);
+ } else {
+ $button.prop('disabled', shouldDisable);
+ }
+ }
+
+ toggleCloseReopenButton(isClosed) {
+ if (this.closeReopenReportToggle) {
+ this.closeReopenReportToggle.updateButton(isClosed);
+ } else {
+ this.closeButtons.toggleClass('hidden', isClosed);
+ this.reopenButtons.toggleClass('hidden', !isClosed);
+ }
+ }
+
static submitNoteForm(form) {
var noteText;
noteText = form.find("textarea.js-note-text").val();
diff --git a/app/assets/javascripts/merge_request.js b/app/assets/javascripts/merge_request.js
index 412d68dc37a..cae2f290f87 100644
--- a/app/assets/javascripts/merge_request.js
+++ b/app/assets/javascripts/merge_request.js
@@ -22,10 +22,12 @@ import CloseReopenReportToggle from './close_reopen_report_toggle';
return _this.showAllCommits();
};
})(this));
+
this.initTabs();
this.initMRBtnListeners();
this.initCommitMessageListeners();
- MergeRequest.initCloseReopenReport();
+ this.initCloseReopenReport();
+
if ($("a.btn-close").length) {
this.taskList = new gl.TaskList({
dataType: 'merge_request',
@@ -66,11 +68,15 @@ import CloseReopenReportToggle from './close_reopen_report_toggle';
if (shouldSubmit && $this.data('submitted')) {
return;
}
+
+ _this.disableCloseReopenButton($this, true);
+
if (shouldSubmit) {
if ($this.hasClass('btn-comment-and-close') || $this.hasClass('btn-comment-and-reopen')) {
e.preventDefault();
e.stopImmediatePropagation();
- return _this.submitNoteForm($this.closest('form'), $this);
+
+ _this.submitNoteForm($this.closest('form'), $this);
}
}
});
@@ -121,7 +127,7 @@ import CloseReopenReportToggle from './close_reopen_report_toggle';
$el.text(gl.text.addDelimiter(count));
};
- MergeRequest.initCloseReopenReport = function () {
+ MergeRequest.prototype.initCloseReopenReport = function () {
const container = document.querySelector('.js-issuable-close-dropdown');
if (!container) return;
@@ -130,13 +136,21 @@ import CloseReopenReportToggle from './close_reopen_report_toggle';
const dropdownList = container.querySelector('.js-issuable-close-menu');
const button = container.querySelector('.js-issuable-close-button');
- const closeReopenReportToggle = new CloseReopenReportToggle({
+ this.closeReopenReportToggle = new CloseReopenReportToggle({
dropdownTrigger,
dropdownList,
button,
});
- closeReopenReportToggle.initDroplab();
+ this.closeReopenReportToggle.initDroplab();
+ };
+
+ MergeRequest.prototype.disableCloseReopenButton = function ($button, shouldDisable) {
+ if (this.closeReopenReportToggle) {
+ this.closeReopenReportToggle.setDisable(shouldDisable);
+ } else {
+ $button.prop('disabled', shouldDisable);
+ }
};
return MergeRequest;
diff --git a/app/assets/stylesheets/framework/filters.scss b/app/assets/stylesheets/framework/filters.scss
index bc0c78ef5ed..bc2c536ba0e 100644
--- a/app/assets/stylesheets/framework/filters.scss
+++ b/app/assets/stylesheets/framework/filters.scss
@@ -83,6 +83,7 @@
flex: 1;
-webkit-flex: 1;
max-width: inherit;
+ padding: 0;
}
}