From 5e6a58040bcfaa4c933027cddfad04810042b904 Mon Sep 17 00:00:00 2001 From: Tristan Read Date: Fri, 9 Aug 2019 20:35:43 +0000 Subject: [PATCH] Remove gfm_embed_metrics flag from BE Removes the feature flag that controls whether metrics dashboard urls unfurl the metrics dashboard charts. --- .../behaviors/markdown/render_gfm.js | 4 +-- .../projects/environments_controller.rb | 2 +- .../tr-remove-embed-metrics-flag.yml | 5 +++ lib/banzai/filter/inline_embeds_filter.rb | 2 -- .../filter/inline_metrics_redactor_filter.rb | 2 -- lib/gitlab/gon_helper.rb | 5 --- .../projects/environments_controller_spec.rb | 33 +------------------ .../filter/inline_metrics_filter_spec.rb | 10 ------ .../inline_metrics_redactor_filter_spec.rb | 10 ------ 9 files changed, 8 insertions(+), 65 deletions(-) create mode 100644 changelogs/unreleased/tr-remove-embed-metrics-flag.yml diff --git a/app/assets/javascripts/behaviors/markdown/render_gfm.js b/app/assets/javascripts/behaviors/markdown/render_gfm.js index 789a057caf8..137cc7b4669 100644 --- a/app/assets/javascripts/behaviors/markdown/render_gfm.js +++ b/app/assets/javascripts/behaviors/markdown/render_gfm.js @@ -18,9 +18,7 @@ $.fn.renderGFM = function renderGFM() { highlightCurrentUser(this.find('.gfm-project_member').get()); initUserPopovers(this.find('.gfm-project_member').get()); initMRPopovers(this.find('.gfm-merge_request').get()); - if (gon.features && gon.features.gfmEmbeddedMetrics) { - renderMetrics(this.find('.js-render-metrics').get()); - } + renderMetrics(this.find('.js-render-metrics').get()); return this; }; diff --git a/app/controllers/projects/environments_controller.rb b/app/controllers/projects/environments_controller.rb index 4ae79186143..df9e55fda2a 100644 --- a/app/controllers/projects/environments_controller.rb +++ b/app/controllers/projects/environments_controller.rb @@ -161,7 +161,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController end def metrics_dashboard - if Feature.enabled?(:gfm_embedded_metrics, project) && params[:embedded] + if params[:embedded] result = dashboard_finder.find( project, current_user, diff --git a/changelogs/unreleased/tr-remove-embed-metrics-flag.yml b/changelogs/unreleased/tr-remove-embed-metrics-flag.yml new file mode 100644 index 00000000000..a327a6868d3 --- /dev/null +++ b/changelogs/unreleased/tr-remove-embed-metrics-flag.yml @@ -0,0 +1,5 @@ +--- +title: Link and embed metrics in GitLab Flavored Markdown +merge_request: 31106 +author: +type: added diff --git a/lib/banzai/filter/inline_embeds_filter.rb b/lib/banzai/filter/inline_embeds_filter.rb index 97394fd8f82..9f1ef0796f0 100644 --- a/lib/banzai/filter/inline_embeds_filter.rb +++ b/lib/banzai/filter/inline_embeds_filter.rb @@ -10,8 +10,6 @@ module Banzai # the link, and insert this node after any html content # surrounding the link. def call - return doc unless Feature.enabled?(:gfm_embedded_metrics, context[:project]) - doc.xpath(xpath_search).each do |node| next unless element = element_to_embed(node) diff --git a/lib/banzai/filter/inline_metrics_redactor_filter.rb b/lib/banzai/filter/inline_metrics_redactor_filter.rb index ff91be2cbb7..4d8a5028898 100644 --- a/lib/banzai/filter/inline_metrics_redactor_filter.rb +++ b/lib/banzai/filter/inline_metrics_redactor_filter.rb @@ -13,8 +13,6 @@ module Banzai # uses to identify the embedded content, removing # only unnecessary nodes. def call - return doc unless Feature.enabled?(:gfm_embedded_metrics, context[:project]) - nodes.each do |node| path = paths_by_node[node] user_has_access = user_access_by_path[path] diff --git a/lib/gitlab/gon_helper.rb b/lib/gitlab/gon_helper.rb index 41ec8741eb1..92917028851 100644 --- a/lib/gitlab/gon_helper.rb +++ b/lib/gitlab/gon_helper.rb @@ -38,11 +38,6 @@ module Gitlab gon.current_user_fullname = current_user.name gon.current_user_avatar_url = current_user.avatar_url end - - # Flag controls a GFM feature used across many routes. - # Pushing the flag from one place simplifies control - # and facilitates easy removal. - push_frontend_feature_flag(:gfm_embedded_metrics) end # Exposes the state of a feature flag to the frontend code. diff --git a/spec/controllers/projects/environments_controller_spec.rb b/spec/controllers/projects/environments_controller_spec.rb index b3852355d77..71ee1fd03bf 100644 --- a/spec/controllers/projects/environments_controller_spec.rb +++ b/spec/controllers/projects/environments_controller_spec.rb @@ -613,31 +613,13 @@ describe Projects::EnvironmentsController do end end - shared_examples_for 'dashboard cannot be embedded' do - context 'when the embedded flag is included' do - let(:dashboard_params) { { format: :json, embedded: true } } - - it_behaves_like 'the default dashboard' - end - end - let(:dashboard_params) { { format: :json } } it_behaves_like 'the default dashboard' it_behaves_like 'dashboard can be specified' it_behaves_like 'dashboard can be embedded' - context 'when multiple dashboards is enabled and embedding metrics is disabled' do - before do - stub_feature_flags(gfm_embedded_metrics: false) - end - - it_behaves_like 'the default dashboard' - it_behaves_like 'dashboard can be specified' - it_behaves_like 'dashboard cannot be embedded' - end - - context 'when multiple dashboards is disabled and embedding metrics is enabled' do + context 'when multiple dashboards is disabled' do before do stub_feature_flags(environment_metrics_show_multiple_dashboards: false) end @@ -646,19 +628,6 @@ describe Projects::EnvironmentsController do it_behaves_like 'dashboard cannot be specified' it_behaves_like 'dashboard can be embedded' end - - context 'when multiple dashboards and embedding metrics are disabled' do - before do - stub_feature_flags( - environment_metrics_show_multiple_dashboards: false, - gfm_embedded_metrics: false - ) - end - - it_behaves_like 'the default dashboard' - it_behaves_like 'dashboard cannot be specified' - it_behaves_like 'dashboard cannot be embedded' - end end describe 'GET #search' do diff --git a/spec/lib/banzai/filter/inline_metrics_filter_spec.rb b/spec/lib/banzai/filter/inline_metrics_filter_spec.rb index 772c94e3180..542a9ced6d7 100644 --- a/spec/lib/banzai/filter/inline_metrics_filter_spec.rb +++ b/spec/lib/banzai/filter/inline_metrics_filter_spec.rb @@ -40,16 +40,6 @@ describe Banzai::Filter::InlineMetricsFilter do expect(doc.at_css('p').to_s).to include paragraph expect(doc.at_css('.js-render-metrics')).to be_present end - - context 'when the feature is disabled' do - before do - stub_feature_flags(gfm_embedded_metrics: false) - end - - it 'does nothing' do - expect(doc.to_s).to eq input - end - end end end end diff --git a/spec/lib/banzai/filter/inline_metrics_redactor_filter_spec.rb b/spec/lib/banzai/filter/inline_metrics_redactor_filter_spec.rb index fb2186e9d12..a99cd7d6076 100644 --- a/spec/lib/banzai/filter/inline_metrics_redactor_filter_spec.rb +++ b/spec/lib/banzai/filter/inline_metrics_redactor_filter_spec.rb @@ -11,16 +11,6 @@ describe Banzai::Filter::InlineMetricsRedactorFilter do let(:input) { %(example) } let(:doc) { filter(input) } - context 'when the feature is disabled' do - before do - stub_feature_flags(gfm_embedded_metrics: false) - end - - it 'does nothing' do - expect(doc.to_s).to eq input - end - end - context 'without a metrics charts placeholder' do it 'leaves regular non-metrics links unchanged' do expect(doc.to_s).to eq input -- GitLab