Sha256: 3cd8486a6585eff04ab7c226d72ebba928edf4a4ea92eff8caa2ff5919c13c00

Contents?: true

Size: 1.17 KB

Versions: 11

Compression:

Stored size: 1.17 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
          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

11 entries across 11 versions & 1 rubygems

Version Path
flipper-ui-0.25.3 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-0.25.2 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-0.25.1 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-0.25.0 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-0.24.1 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-0.24.0 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-0.23.1 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-0.23.0 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-0.22.2 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-0.22.1 lib/flipper/ui/actions/groups_gate.rb
flipper-ui-0.22.0 lib/flipper/ui/actions/groups_gate.rb