Sha256: 739be0e813b9f052914a4bcbcf74fc2fdae795bfd0101f14e4967c200d2e14fb

Contents?: true

Size: 1.21 KB

Versions: 19

Compression:

Stored size: 1.21 KB

Contents

require 'flipper/ui/action'
require 'flipper/ui/decorators/feature'
require 'flipper/ui/util'

module Flipper
  module UI
    module Actions
      class ActorsGate < UI::Action
        include FeatureNameFromRoute

        route %r{\A/features/(?<feature_name>.*)/actors/?\Z}

        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

        def post
          feature = flipper[feature_name]
          value = params['value'].to_s.strip

          if Util.blank?(value)
            error = Rack::Utils.escape("#{value.inspect} is not a valid actor value.")
            redirect_to("/features/#{feature.key}/actors?error=#{error}")
          end

          actor = Flipper::Actor.new(value)

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

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

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
flipper-ui-0.21.0 lib/flipper/ui/actions/actors_gate.rb
flipper-ui-0.21.0.rc2 lib/flipper/ui/actions/actors_gate.rb
flipper-ui-0.21.0.rc1 lib/flipper/ui/actions/actors_gate.rb
flipper-ui-0.20.4 lib/flipper/ui/actions/actors_gate.rb
flipper-ui-0.20.3 lib/flipper/ui/actions/actors_gate.rb
flipper-ui-0.20.2 lib/flipper/ui/actions/actors_gate.rb
flipper-ui-0.20.1 lib/flipper/ui/actions/actors_gate.rb
flipper-ui-0.20.0 lib/flipper/ui/actions/actors_gate.rb
flipper-ui-0.20.0.beta3 lib/flipper/ui/actions/actors_gate.rb
flipper-ui-0.20.0.beta2 lib/flipper/ui/actions/actors_gate.rb
flipper-ui-0.20.0.beta1 lib/flipper/ui/actions/actors_gate.rb
flipper-ui-0.19.1 lib/flipper/ui/actions/actors_gate.rb
flipper-ui-0.19.0 lib/flipper/ui/actions/actors_gate.rb
flipper-ui-0.18.0 lib/flipper/ui/actions/actors_gate.rb
flipper-ui-0.17.2 lib/flipper/ui/actions/actors_gate.rb
flipper-ui-0.17.1 lib/flipper/ui/actions/actors_gate.rb
flipper-ui-0.16.2 lib/flipper/ui/actions/actors_gate.rb
flipper-ui-0.16.1 lib/flipper/ui/actions/actors_gate.rb
flipper-ui-0.16.0 lib/flipper/ui/actions/actors_gate.rb