diff --git a/app/assets/javascripts/pages/projects/issues/form.js b/app/assets/javascripts/pages/projects/issues/form.js index 02a56685a3500842cc33261da496068de704f81c..f99023ad8e7a2088486ad708d9601e032f9ff863 100644 --- a/app/assets/javascripts/pages/projects/issues/form.js +++ b/app/assets/javascripts/pages/projects/issues/form.js @@ -17,7 +17,7 @@ export default () => { new MilestoneSelect(); new IssuableTemplateSelectors(); - if (gon.features.issueSuggestions && gon.features.graphql) { + if (gon.features.graphql) { initSuggestions(); } }; diff --git a/app/controllers/graphql_controller.rb b/app/controllers/graphql_controller.rb index 6ea4758ec3258aa901ad0465da64fa77ddd942ef..3ef03bc962263e4adacc08c0b3c45e75d71357bb 100644 --- a/app/controllers/graphql_controller.rb +++ b/app/controllers/graphql_controller.rb @@ -43,6 +43,6 @@ class GraphqlController < ApplicationController end def check_graphql_feature_flag! - render_404 unless Feature.enabled?(:graphql) + render_404 unless Gitlab::Graphql.enabled? end end diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index c6ab6b4642e892706b2c1dadc6476bed78144e35..5ed46fc0545845b1760390ec833d571c6c15a7fa 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -268,7 +268,6 @@ class Projects::IssuesController < Projects::ApplicationController end def set_suggested_issues_feature_flags - push_frontend_feature_flag(:graphql) - push_frontend_feature_flag(:issue_suggestions) + push_frontend_feature_flag(:graphql, default_enabled: true) end end diff --git a/app/views/shared/issuable/_form.html.haml b/app/views/shared/issuable/_form.html.haml index 1618655182c2ecca8b0d8016a0c6519dd449e7de..c6a391ae563e813e0f7a9e0edb78e7e7b509114c 100644 --- a/app/views/shared/issuable/_form.html.haml +++ b/app/views/shared/issuable/_form.html.haml @@ -17,7 +17,7 @@ = render 'shared/issuable/form/template_selector', issuable: issuable = render 'shared/issuable/form/title', issuable: issuable, form: form, has_wip_commits: commits && commits.detect(&:work_in_progress?) -- if Feature.enabled?(:issue_suggestions) && Feature.enabled?(:graphql) +- if Gitlab::Graphql.enabled? #js-suggestions{ data: { project_path: @project.full_path } } = render 'shared/form_elements/description', model: issuable, form: form, project: project diff --git a/config/routes/api.rb b/config/routes/api.rb index b1aebf4d606f8e18f45b2a7450c0e68945101a5a..3719b7d3a1ef0b1d38828982d5c0af9118a0c53b 100644 --- a/config/routes/api.rb +++ b/config/routes/api.rb @@ -1,4 +1,4 @@ -constraints(::Constraints::FeatureConstrainer.new(:graphql)) do +constraints(::Constraints::FeatureConstrainer.new(:graphql, default_enabled: true)) do post '/api/graphql', to: 'graphql#execute' mount GraphiQL::Rails::Engine, at: '/-/graphql-explorer', graphql_path: '/api/graphql' end diff --git a/lib/constraints/feature_constrainer.rb b/lib/constraints/feature_constrainer.rb index ca4376a9d3863b2ee38bc985244ec51994ecc31c..cd246cf37a4e55ea148e43f9341c306bbbf70e1c 100644 --- a/lib/constraints/feature_constrainer.rb +++ b/lib/constraints/feature_constrainer.rb @@ -2,14 +2,14 @@ module Constraints class FeatureConstrainer - attr_reader :feature + attr_reader :args - def initialize(feature) - @feature = feature + def initialize(*args) + @args = args end def matches?(_request) - Feature.enabled?(feature) + Feature.enabled?(*args) end end end diff --git a/lib/gitlab/graphql.rb b/lib/gitlab/graphql.rb index 74c04e5380e39b4e89f4a2d6ce7108b11d462160..8a59e83974f7702e159efbab6097c1e9e6fba06a 100644 --- a/lib/gitlab/graphql.rb +++ b/lib/gitlab/graphql.rb @@ -3,5 +3,9 @@ module Gitlab module Graphql StandardGraphqlError = Class.new(StandardError) + + def self.enabled? + Feature.enabled?(:graphql, default_enabled: true) + end end end diff --git a/spec/lib/constraints/feature_constrainer_spec.rb b/spec/lib/constraints/feature_constrainer_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..42efc164f81211ce9b94d81f851ad27f12d94568 --- /dev/null +++ b/spec/lib/constraints/feature_constrainer_spec.rb @@ -0,0 +1,11 @@ +require 'spec_helper' + +describe Constraints::FeatureConstrainer do + describe '#matches' do + it 'calls Feature.enabled? with the correct arguments' do + expect(Feature).to receive(:enabled?).with(:feature_name, "an object", default_enabled: true) + + described_class.new(:feature_name, "an object", default_enabled: true).matches?(double('request')) + end + end +end