Class: Flipper::UI::Actions::ActorsGate

Inherits:
Flipper::UI::Action show all
Includes:
FeatureNameFromRoute
Defined in:
lib/flipper/ui/actions/actors_gate.rb

Constant Summary

Constants inherited from Flipper::UI::Action

Flipper::UI::Action::CONTENT_SECURITY_POLICY, Flipper::UI::Action::SOURCES, Flipper::UI::Action::VALID_REQUEST_METHOD_NAMES

Instance Attribute Summary

Attributes inherited from Flipper::UI::Action

#flipper, #request

Instance Method Summary collapse

Methods inherited from Flipper::UI::Action

#bootstrap_css, #bootstrap_js, #breadcrumb, #csrf_input_tag, #halt, #header, #initialize, #jquery_js, #json_response, #popper_js, public_path, #public_path, #read_only, #redirect_to, #request_method_name, route, route_match?, route_regex, #run, run, #run_other_action, #script_name, #status, #valid_request_method?, #view, #view_response, #view_with_layout, #view_without_layout, #views_path, views_path

Constructor Details

This class inherits a constructor from Flipper::UI::Action

Instance Method Details

#getObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/flipper/ui/actions/actors_gate.rb', line 13

def get
  feature = flipper[feature_name]
  @feature = Decorators::Feature.new(feature)

  breadcrumb 'Home', '/'
  breadcrumb 'Features', '/features'
  breadcrumb @feature.key, "/features/#{@feature.key}"
  breadcrumb 'Add Actor'

  view_response :add_actor
end

#postObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/flipper/ui/actions/actors_gate.rb', line 25

def post
  read_only if Flipper::UI.configuration.read_only

  feature = flipper[feature_name]
  value = params['value'].to_s.strip
  values = value.split(UI.configuration.actors_separator).map(&:strip).uniq

  if values.empty?
    error = "#{value.inspect} is not a valid actor value."
    redirect_to("/features/#{feature.key}/actors?error=#{error}")
  end

  values.each do |value|
    actor = Flipper::Actor.new(value)

    case params['operation']
    when 'enable'
      feature.enable_actor actor
    when 'disable'
      feature.disable_actor actor
    end
  end

  redirect_to("/features/#{feature.key}")
end