diff --git a/Gemfile.lock b/Gemfile.lock index 35b6d9f..28727c0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,7 +8,7 @@ GIT PATH remote: . specs: - rollout_ui (0.2.0) + rollout_ui (0.3.0) rollout GEM diff --git a/lib/rollout_ui/engine/app/assets/stylesheets/rollout_ui/layout.css b/lib/rollout_ui/engine/app/assets/stylesheets/rollout_ui/layout.css index a479e41..fb403fb 100644 --- a/lib/rollout_ui/engine/app/assets/stylesheets/rollout_ui/layout.css +++ b/lib/rollout_ui/engine/app/assets/stylesheets/rollout_ui/layout.css @@ -30,6 +30,10 @@ h1 img { padding: 0 25px; } +.add-feature { + margin: 30px 0; +} + #container { width: 960px; margin: 0 auto; @@ -52,12 +56,28 @@ h1 img { margin-bottom: 25px; } +#features .feature header { + display: -webkit-box; + display: -moz-box; + display: box; + display: flex; +} + #features .feature h2 { - margin: 0px 0 23px; - text-align: center; + display: flex; font-size: 20px; - font-weight: normal; - letter-spacing: 1px; + -webkit-box-flex: 1; + -moz-box-flex: 1; + box-flex: 1; + -webkit-flex: 1; + -moz-flex: 1; + -ms-flex: 1; + flex: 1; + padding: 0 25px; +} + +#features .feature nav { + padding: 20px 29px; } #features .feature .groups { diff --git a/lib/rollout_ui/engine/app/controllers/rollout_ui/features_controller.rb b/lib/rollout_ui/engine/app/controllers/rollout_ui/features_controller.rb index 84b87a8..8957338 100644 --- a/lib/rollout_ui/engine/app/controllers/rollout_ui/features_controller.rb +++ b/lib/rollout_ui/engine/app/controllers/rollout_ui/features_controller.rb @@ -1,11 +1,17 @@ module RolloutUi class FeaturesController < RolloutUi::ApplicationController - before_filter :wrapper, :only => [:index] + before_filter :wrapper, :only => [:index, :create, :destroy] def index @features = @wrapper.features.map{ |feature| RolloutUi::Feature.new(feature) } end + def create + @wrapper.add_feature(params[:name]) + + redirect_to features_path + end + def update @feature = RolloutUi::Feature.new(params[:id]) @@ -16,6 +22,12 @@ def update redirect_to features_path end + def destroy + @wrapper.remove_feature(params[:id]) + + redirect_to features_path + end + private def wrapper diff --git a/lib/rollout_ui/engine/app/views/rollout_ui/features/_feature.html.erb b/lib/rollout_ui/engine/app/views/rollout_ui/features/_feature.html.erb index 68716cd..6375230 100644 --- a/lib/rollout_ui/engine/app/views/rollout_ui/features/_feature.html.erb +++ b/lib/rollout_ui/engine/app/views/rollout_ui/features/_feature.html.erb @@ -1,4 +1,12 @@ -

<%= feature.name %>

+
+

<%= feature.name %>

+ + +
<%= form_tag feature_path(feature.name), :class => "percentage_form", :method => :put, :remote => true do %> diff --git a/lib/rollout_ui/engine/app/views/rollout_ui/features/index.html.erb b/lib/rollout_ui/engine/app/views/rollout_ui/features/index.html.erb index 015f00d..92b7449 100644 --- a/lib/rollout_ui/engine/app/views/rollout_ui/features/index.html.erb +++ b/lib/rollout_ui/engine/app/views/rollout_ui/features/index.html.erb @@ -4,6 +4,13 @@ <% end %> +
+ <%= form_tag features_path do %> + + + <% end %> +
+ <% content_for :onready do %> $("select").chosen({no_results_text: "No groups matched"}); $("input.users").chosen(); diff --git a/lib/rollout_ui/engine/config/routes.rb b/lib/rollout_ui/engine/config/routes.rb index 121c161..596d6bf 100644 --- a/lib/rollout_ui/engine/config/routes.rb +++ b/lib/rollout_ui/engine/config/routes.rb @@ -1,5 +1,5 @@ RolloutUi::Engine.routes.draw do - resources :features, :only => [:index, :update] + resources :features, :only => [:index, :create, :update, :destroy] root :to => "features#index" end diff --git a/lib/rollout_ui/wrapper.rb b/lib/rollout_ui/wrapper.rb index ca11666..24aa324 100644 --- a/lib/rollout_ui/wrapper.rb +++ b/lib/rollout_ui/wrapper.rb @@ -17,6 +17,10 @@ def add_feature(feature) redis.sadd(:features, feature) end + def remove_feature(feature) + redis.srem(:features, feature) + end + def features features = redis.smembers(:features) features ? features.sort : [] diff --git a/spec/lib/rollout_ui/wrapper_spec.rb b/spec/lib/rollout_ui/wrapper_spec.rb index d0f332e..9c5a505 100644 --- a/spec/lib/rollout_ui/wrapper_spec.rb +++ b/spec/lib/rollout_ui/wrapper_spec.rb @@ -69,4 +69,14 @@ @rollout_ui.features.should == ["featureA"] end end + + describe "#remove_feature" do + it "removes a feature from the list of features" do + @rollout_ui.add_feature(:feature) + + @rollout_ui.remove_feature(:feature) + + @rollout_ui.features.should == [] + end + end end diff --git a/spec/requests/engine/engine_spec.rb b/spec/requests/engine/engine_spec.rb index 869fabd..ff3b6e0 100644 --- a/spec/requests/engine/engine_spec.rb +++ b/spec/requests/engine/engine_spec.rb @@ -14,6 +14,18 @@ page.should have_content("featureA") end + describe "remove button" do + it "removes the feature" do + visit "/rollout" + + within("#featureA .feature-header") do + click_button "remove" + end + + $rollout.active?(:featureA, user).should be_false + end + end + describe "percentage" do it "allows changing of the percentage" do visit "/rollout" @@ -104,6 +116,19 @@ page.body.should =~ Regexp.new("#{elements.join('.*')}.*", Regexp::MULTILINE) end end + + describe "adding a feature" do + it "displays the added feature in the UI" do + visit "/rollout" + + within(".add-feature") do + fill_in "name", with: "featureB" + click_button "Add Feature" + end + + page.should have_content("featureB") + end + end end end