Sha256: 094550acbfe570dc22901f593a7bc6a0dcbc30099e876b862eeacc4220f70f3e

Contents?: true

Size: 1.2 KB

Versions: 6

Compression:

Stored size: 1.2 KB

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 do |feature|
            Decorators::Feature.new(feature)
          end.sort

          @show_blank_slate = @features.empty?

          breadcrumb 'Home', '/'
          breadcrumb 'Features'

          view_response :features
        end

        def post
          unless Flipper::UI.feature_creation_enabled
            status 403

            breadcrumb 'Home', '/'
            breadcrumb 'Features', '/features'
            breadcrumb 'Noooooope'

            halt view_response(:feature_creation_disabled)
          end

          value = params['value'].to_s.strip

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

          feature = flipper[value]
          feature.add

          redirect_to "/features/#{Rack::Utils.escape_path(value)}"
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
flipper-ui-0.14.0 lib/flipper/ui/actions/features.rb
flipper-ui-0.13.0 lib/flipper/ui/actions/features.rb
flipper-ui-0.13.0.beta1 lib/flipper/ui/actions/features.rb
flipper-ui-0.12.2 lib/flipper/ui/actions/features.rb
flipper-ui-0.12.1 lib/flipper/ui/actions/features.rb
flipper-ui-0.12.0 lib/flipper/ui/actions/features.rb