Sha256: 353623d8684ceef908382333173df1a38a47f73cab6e9ee0df97d727c71312a4

Contents?: true

Size: 827 Bytes

Versions: 13

Compression:

Stored size: 827 Bytes

Contents

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

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

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

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

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

          begin
            feature.enable_percentage_of_actors params['value']
          rescue ArgumentError => exception
            error = "Invalid percentage of actors value: #{exception.message}"
            redirect_to("/features/#{@feature.key}?error=#{error}")
          end

          redirect_to "/features/#{@feature.key}"
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
flipper-ui-1.0.0 lib/flipper/ui/actions/percentage_of_actors_gate.rb
flipper-ui-1.0.0.pre lib/flipper/ui/actions/percentage_of_actors_gate.rb
flipper-ui-0.28.3 lib/flipper/ui/actions/percentage_of_actors_gate.rb
flipper-ui-0.28.2 lib/flipper/ui/actions/percentage_of_actors_gate.rb
flipper-ui-0.28.1 lib/flipper/ui/actions/percentage_of_actors_gate.rb
flipper-ui-0.28.0 lib/flipper/ui/actions/percentage_of_actors_gate.rb
flipper-ui-0.27.1 lib/flipper/ui/actions/percentage_of_actors_gate.rb
flipper-ui-0.27.0 lib/flipper/ui/actions/percentage_of_actors_gate.rb
flipper-ui-0.26.2 lib/flipper/ui/actions/percentage_of_actors_gate.rb
flipper-ui-0.26.0 lib/flipper/ui/actions/percentage_of_actors_gate.rb
flipper-ui-0.26.0.rc2 lib/flipper/ui/actions/percentage_of_actors_gate.rb
flipper-ui-0.26.0.rc1 lib/flipper/ui/actions/percentage_of_actors_gate.rb
flipper-ui-0.25.4 lib/flipper/ui/actions/percentage_of_actors_gate.rb