Sha256: 1100b68de2ae50a8442116d18372427b8e79fb42fdd27f88ad76a51cc4ace882

Contents?: true

Size: 902 Bytes

Versions: 3

Compression:

Stored size: 902 Bytes

Contents

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

module Flipper
  module UI
    module Actions
      class Features < UI::Action

        route %r{features/?\Z}

        def get
          @page_title = "Features"
          @features = flipper.features.map { |feature|
            Decorators::Feature.new(feature)
          }.sort

          @show_blank_slate = @features.empty?

          breadcrumb "Home", "/"
          breadcrumb "Features"

          view_response :features
        end

        def post
          value = params["value"]

          if Util.blank?(value)
            error = Rack::Utils.escape("#{value.inspect} is not a valid feature name.")
            redirect_to("/features/new?error=#{error}")
          end

          flipper.adapter.add(flipper[value])

          redirect_to "/features"
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
flipper-ui-0.2.0.beta5 lib/flipper/ui/actions/features.rb
flipper-ui-0.2.0.beta4 lib/flipper/ui/actions/features.rb
flipper-ui-0.2.0.beta3 lib/flipper/ui/actions/features.rb