Sha256: caa5aa085d2c999be41fc708a777b0b3cab9528e113a49fe4e8ef19b85bcfc15

Contents?: true

Size: 1.3 KB

Versions: 17

Compression:

Stored size: 1.3 KB

Contents

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

module Flipper
  module UI
    module Actions
      class GroupsGate < UI::Action
        route %r{features/[^/]*/groups/?\Z}

        def get
          feature_name = Rack::Utils.unescape(request.path.split('/')[-2])
          feature = flipper[feature_name.to_sym]
          @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
          feature_name = Rack::Utils.unescape(request.path.split('/')[-2])
          feature = flipper[feature_name.to_sym]
          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 = Rack::Utils.escape("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

17 entries across 17 versions & 1 rubygems

Version Path
flipper-ui-0.15.0 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-0.14.0 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-0.13.0 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-0.13.0.beta1 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-0.12.2 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-0.12.1 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-0.12.0 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-0.11.0 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-0.11.0.rc1 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-0.11.0.beta9 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-0.11.0.beta8 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-0.11.0.beta7 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-0.11.0.beta6 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-0.11.0.beta5 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-0.11.0.beta4 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-0.11.0.beta3 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-0.11.0.beta1 lib/flipper/ui/actions/groups_gate.rb