Sha256: 44e9d24eba0e2b9651d14744cd66804c14cecae13aed93ee4dde1590d7065835

Contents?: true

Size: 1.21 KB

Versions: 6

Compression:

Stored size: 1.21 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
          render_read_only if 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

6 entries across 6 versions & 1 rubygems

Version Path
flipper-ui-1.2.2 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-1.2.1 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-1.2.0 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-1.1.2 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-1.1.1 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-1.1.0 lib/flipper/ui/actions/groups_gate.rb