summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/assets/javascripts/issue.js10
-rw-r--r--app/models/concerns/cache_markdown_field.rb2
-rw-r--r--app/views/projects/issues/show.html.haml2
-rw-r--r--app/views/shared/issuable/_close_reopen_report_toggle.html.haml2
-rw-r--r--changelogs/unreleased/218745-single-issue-api-performance-regression-degraded-by-8000ms-after-u.yml5
-rw-r--r--changelogs/unreleased/219323-no-event-fired-at-clicking-close-issue-button-in-issue-page.yml5
-rw-r--r--spec/frontend/fixtures/static/issue_with_mermaid_graph.html4
-rw-r--r--spec/models/concerns/cache_markdown_field_spec.rb8
-rw-r--r--spec/support/shared_examples/models/mentionable_shared_examples.rb60
9 files changed, 58 insertions, 40 deletions
diff --git a/app/assets/javascripts/issue.js b/app/assets/javascripts/issue.js
index 29bb6eff1b2..4b53225e100 100644
--- a/app/assets/javascripts/issue.js
+++ b/app/assets/javascripts/issue.js
@@ -89,9 +89,10 @@ export default class Issue {
initIssueBtnEventListeners() {
const issueFailMessage = __('Unable to update this issue at this time.');
- return $(document).on(
+ // NOTE: data attribute seems unnecessary but is actually necessary
+ return $('.js-issuable-buttons[data-action="close-reopen"]').on(
'click',
- '.js-issuable-actions a.btn-close, .js-issuable-actions a.btn-reopen, a.btn-close-anyway',
+ 'a.btn-close, a.btn-reopen, a.btn-close-anyway',
e => {
e.preventDefault();
e.stopImmediatePropagation();
@@ -108,10 +109,7 @@ export default class Issue {
} else {
this.disableCloseReopenButton($button);
- const url = $button.data('close-reopen-url');
- if (!url) {
- return;
- }
+ const url = $button.attr('href');
return axios
.put(url)
diff --git a/app/models/concerns/cache_markdown_field.rb b/app/models/concerns/cache_markdown_field.rb
index e4e0f55d5f4..04eb4659469 100644
--- a/app/models/concerns/cache_markdown_field.rb
+++ b/app/models/concerns/cache_markdown_field.rb
@@ -102,7 +102,7 @@ module CacheMarkdownField
def updated_cached_html_for(markdown_field)
return unless cached_markdown_fields.markdown_fields.include?(markdown_field)
- refresh_markdown_cache if attribute_invalidated?(cached_markdown_fields.html_field(markdown_field))
+ refresh_markdown_cache! if attribute_invalidated?(cached_markdown_fields.html_field(markdown_field))
cached_html_for(markdown_field)
end
diff --git a/app/views/projects/issues/show.html.haml b/app/views/projects/issues/show.html.haml
index c8ffa2e3720..525eb4b90c1 100644
--- a/app/views/projects/issues/show.html.haml
+++ b/app/views/projects/issues/show.html.haml
@@ -32,7 +32,7 @@
%a.btn.btn-default.float-right.d-block.d-sm-none.gutter-toggle.issuable-gutter-toggle.js-sidebar-toggle{ href: "#" }
= icon('angle-double-left')
- .detail-page-header-actions.js-issuable-actions
+ .detail-page-header-actions.js-issuable-actions.js-issuable-buttons{ data: { "action": "close-reopen" } }
.clearfix.issue-btn-group.dropdown
%button.btn.btn-default.float-left.d-md-none.d-lg-none.d-xl-none{ type: "button", data: { toggle: "dropdown" } }
Options
diff --git a/app/views/shared/issuable/_close_reopen_report_toggle.html.haml b/app/views/shared/issuable/_close_reopen_report_toggle.html.haml
index 8575a61aae8..9d718083d2d 100644
--- a/app/views/shared/issuable/_close_reopen_report_toggle.html.haml
+++ b/app/views/shared/issuable/_close_reopen_report_toggle.html.haml
@@ -11,7 +11,7 @@
.float-left.btn-group.prepend-left-10.issuable-close-dropdown.droplab-dropdown.js-issuable-close-dropdown
= link_to "#{display_button_action} #{display_issuable_type}", close_reopen_issuable_path(issuable),
- method: button_method, class: "#{button_class} btn-#{button_action} #{(add_blocked_class ? 'btn-issue-blocked' : '')}", title: "#{display_button_action} #{display_issuable_type}", data: { qa_selector: 'close_issue_button', 'close-reopen-url': close_reopen_issuable_path(issuable) }
+ method: button_method, class: "#{button_class} btn-#{button_action} #{(add_blocked_class ? 'btn-issue-blocked' : '')}", title: "#{display_button_action} #{display_issuable_type}", data: { qa_selector: 'close_issue_button' }
= button_tag type: 'button', class: "#{toggle_class} btn-#{button_action}-color",
data: { 'dropdown-trigger' => '#issuable-close-menu' }, 'aria-label' => _('Toggle dropdown') do
diff --git a/changelogs/unreleased/218745-single-issue-api-performance-regression-degraded-by-8000ms-after-u.yml b/changelogs/unreleased/218745-single-issue-api-performance-regression-degraded-by-8000ms-after-u.yml
new file mode 100644
index 00000000000..dafb281b779
--- /dev/null
+++ b/changelogs/unreleased/218745-single-issue-api-performance-regression-degraded-by-8000ms-after-u.yml
@@ -0,0 +1,5 @@
+---
+title: Fix issue and MR API performance regression when Markdown cache is stale
+merge_request: 33235
+author:
+type: fixed
diff --git a/changelogs/unreleased/219323-no-event-fired-at-clicking-close-issue-button-in-issue-page.yml b/changelogs/unreleased/219323-no-event-fired-at-clicking-close-issue-button-in-issue-page.yml
new file mode 100644
index 00000000000..8bad64fdac4
--- /dev/null
+++ b/changelogs/unreleased/219323-no-event-fired-at-clicking-close-issue-button-in-issue-page.yml
@@ -0,0 +1,5 @@
+---
+title: Fix close issue when user created the issue
+merge_request: 33294
+author:
+type: fixed
diff --git a/spec/frontend/fixtures/static/issue_with_mermaid_graph.html b/spec/frontend/fixtures/static/issue_with_mermaid_graph.html
index 4b60842a655..e9fa75c8ba9 100644
--- a/spec/frontend/fixtures/static/issue_with_mermaid_graph.html
+++ b/spec/frontend/fixtures/static/issue_with_mermaid_graph.html
@@ -15,14 +15,14 @@
<g class="edgeLabels"></g>
<g class="nodes">
<g
- class="node js-issuable-actions btn-close clickable"
+ class="node js-issuable-buttons btn-close clickable"
style="opacity: 1;"
id="A"
transform="translate(92.67500305175781,25.25)"
title="click to PUT"
>
<a
- class="js-issuable-actions btn-close clickable"
+ class="js-issuable-buttons btn-close clickable"
href="https://invalid"
rel="noopener"
>
diff --git a/spec/models/concerns/cache_markdown_field_spec.rb b/spec/models/concerns/cache_markdown_field_spec.rb
index 193144fcb0e..c46ebcf324c 100644
--- a/spec/models/concerns/cache_markdown_field_spec.rb
+++ b/spec/models/concerns/cache_markdown_field_spec.rb
@@ -209,8 +209,8 @@ describe CacheMarkdownField, :clean_gitlab_redis_cache do
thing.cached_markdown_version += 1
end
- it 'calls #refresh_markdown_cache' do
- expect(thing).to receive(:refresh_markdown_cache)
+ it 'calls #refresh_markdown_cache!' do
+ expect(thing).to receive(:refresh_markdown_cache!)
expect(thing.updated_cached_html_for(:description)).to eq(html)
end
@@ -227,8 +227,8 @@ describe CacheMarkdownField, :clean_gitlab_redis_cache do
thing.try(:save)
end
- it 'does not call #refresh_markdown_cache' do
- expect(thing).not_to receive(:refresh_markdown_cache)
+ it 'does not call #refresh_markdown_cache!' do
+ expect(thing).not_to receive(:refresh_markdown_cache!)
expect(thing.updated_cached_html_for(:description)).to eq(html)
end
diff --git a/spec/support/shared_examples/models/mentionable_shared_examples.rb b/spec/support/shared_examples/models/mentionable_shared_examples.rb
index d3e9035393f..dda5fa37b26 100644
--- a/spec/support/shared_examples/models/mentionable_shared_examples.rb
+++ b/spec/support/shared_examples/models/mentionable_shared_examples.rb
@@ -80,25 +80,21 @@ RSpec.shared_examples 'a mentionable' do
context 'when there are cached markdown fields' do
before do
- if subject.is_a?(CacheMarkdownField)
- subject.refresh_markdown_cache
- end
+ skip unless subject.is_a?(CacheMarkdownField)
end
it 'sends in cached markdown fields when appropriate' do
- if subject.is_a?(CacheMarkdownField) && subject.extractors[author].blank?
- expect_next_instance_of(Gitlab::ReferenceExtractor) do |ext|
- attrs = subject.class.mentionable_attrs.collect(&:first) & subject.cached_markdown_fields.markdown_fields
- attrs.each do |field|
- expect(ext).to receive(:analyze).with(subject.send(field), hash_including(rendered: anything))
- end
+ subject.extractors[author] = nil
+ expect_next_instance_of(Gitlab::ReferenceExtractor) do |ext|
+ attrs = subject.class.mentionable_attrs.collect(&:first) & subject.cached_markdown_fields.markdown_fields
+ attrs.each do |field|
+ expect(ext).to receive(:analyze).with(subject.send(field), hash_including(rendered: anything))
end
+ end
- expect(subject).not_to receive(:refresh_markdown_cache)
- expect(subject).to receive(:cached_markdown_fields).at_least(:once).and_call_original
+ expect(subject).to receive(:cached_markdown_fields).at_least(:once).and_call_original
- subject.all_references(author)
- end
+ subject.all_references(author)
end
end
@@ -126,26 +122,40 @@ RSpec.shared_examples 'an editable mentionable' do
context 'when there are cached markdown fields' do
before do
- if subject.is_a?(CacheMarkdownField)
- subject.refresh_markdown_cache
- end
- end
+ skip unless subject.is_a?(CacheMarkdownField)
- it 'refreshes markdown cache if necessary' do
subject.save!
+ end
+ it 'refreshes markdown cache if necessary' do
set_mentionable_text.call('This is a text')
- if subject.is_a?(CacheMarkdownField) && subject.extractors[author].blank?
- expect_next_instance_of(Gitlab::ReferenceExtractor) do |ext|
- subject.cached_markdown_fields.markdown_fields.each do |field|
- expect(ext).to receive(:analyze).with(subject.send(field), hash_including(rendered: anything))
- end
+ subject.extractors[author] = nil
+ expect_next_instance_of(Gitlab::ReferenceExtractor) do |ext|
+ subject.cached_markdown_fields.markdown_fields.each do |field|
+ expect(ext).to receive(:analyze).with(subject.send(field), hash_including(rendered: anything))
end
+ end
- expect(subject).to receive(:refresh_markdown_cache)
- expect(subject).to receive(:cached_markdown_fields).at_least(:once).and_call_original
+ expect(subject).to receive(:refresh_markdown_cache).and_call_original
+ expect(subject).to receive(:cached_markdown_fields).at_least(:once).and_call_original
+
+ subject.all_references(author)
+ end
+
+ context 'when the markdown cache is stale' do
+ before do
+ expect(subject).to receive(:latest_cached_markdown_version).at_least(:once) do
+ (Gitlab::MarkdownCache::CACHE_COMMONMARK_VERSION + 1) << 16
+ end
+ end
+
+ it 'persists the refreshed cache so that it does not have to be refreshed every time' do
+ expect(subject).to receive(:refresh_markdown_cache).once.and_call_original
+
+ subject.all_references(author)
+ subject.reload
subject.all_references(author)
end
end