Sha256: 32d0f108e0c048d62605e4f7b4b92a11579108b06ea667ffcb4fef656f781a7d

Contents?: true

Size: 1.23 KB

Versions: 13

Compression:

Stored size: 1.23 KB

Contents

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

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

        route %r{\A/features/(?<feature_name>.*)/groups/?\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 Group'

          view_response :add_group
        end

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

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

          if Flipper.group_exists?(value)
            case params['operation']
            when 'enable'
              feature.enable_group value
            when 'disable'
              feature.disable_group value
            end

            redirect_to("/features/#{feature.key}")
          else
            error = "The group named #{value.inspect} has not been registered."
            redirect_to("/features/#{feature.key}/groups?error=#{error}")
          end
        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/groups_gate.rb
flipper-ui-1.0.0.pre lib/flipper/ui/actions/groups_gate.rb
flipper-ui-0.28.3 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-0.28.2 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-0.28.1 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-0.28.0 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-0.27.1 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-0.27.0 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-0.26.2 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-0.26.0 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-0.26.0.rc2 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-0.26.0.rc1 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-0.25.4 lib/flipper/ui/actions/groups_gate.rb