From ddf47d571599f45844ef9a88206ff8f677ddd55b Mon Sep 17 00:00:00 2001 From: Igor Serebryany Date: Wed, 30 Sep 2020 20:54:25 -0700 Subject: [PATCH 1/3] gemspec: remove bundler dependency this prevents annoying errors on machines with newer versions of bunder (most machines, since 1.17 is pretty old) i was seeing an error like so: ``` Bundler could not find compatible versions for gem "bundler": In Gemfile: bundler (~> 1.17) Current Bundler version: bundler (2.1.4) This Gemfile requires a different version of Bundler. Perhaps you need to update Bundler by running `gem install bundler`? Could not find gem 'bundler (~> 1.17)' in any of the relevant sources: the local ruby installation ``` --- rollout-ui.gemspec | 1 - 1 file changed, 1 deletion(-) diff --git a/rollout-ui.gemspec b/rollout-ui.gemspec index d598fa8..eebd1d2 100644 --- a/rollout-ui.gemspec +++ b/rollout-ui.gemspec @@ -26,7 +26,6 @@ Gem::Specification.new do |spec| spec.add_dependency 'sinatra', '~> 2.0' spec.add_dependency 'slim', '~> 4.0' - spec.add_development_dependency 'bundler', '~> 1.17' spec.add_development_dependency 'rake', '~> 10.0' spec.add_development_dependency 'rspec', '~> 3.0' spec.add_development_dependency 'rerun', '~> 0.13' From 48cf74d3ffe2059f2d112b90c7d3a94fa3e1180e Mon Sep 17 00:00:00 2001 From: Igor Serebryany Date: Wed, 30 Sep 2020 20:56:54 -0700 Subject: [PATCH 2/3] README: reference to `be` -> `bundle exec` this looks like a local alias for the original author --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b146615..836a983 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ And visit [http://localhost:9292/](http://localhost:9292/). Alternatively you can also configure which Redis with: ```sh -REDIS_HOST=localhost REDIS_PORT=6379 REDIS_DB=10 be rerun rackup +REDIS_HOST=localhost REDIS_PORT=6379 REDIS_DB=10 bundle exec rerun rackup ``` ## License From 66e28977ad50904f59fb4c95c2e16c069ec6262f Mon Sep 17 00:00:00 2001 From: Igor Serebryany Date: Wed, 30 Sep 2020 21:35:03 -0700 Subject: [PATCH 3/3] Display and update extra data we display extra data fields in the form. we allow updating them. we keep the type of data the same -- if we want to change data type, we should use the console. this will allow rapid updates of extra data, which helps when rollup is being used as a config store --- lib/rollout/ui/views/features/show.slim | 16 ++++++++++++++++ lib/rollout/ui/web.rb | 15 ++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/lib/rollout/ui/views/features/show.slim b/lib/rollout/ui/views/features/show.slim index 333379c..6949bfa 100644 --- a/lib/rollout/ui/views/features/show.slim +++ b/lib/rollout/ui/views/features/show.slim @@ -58,6 +58,22 @@ form.p-6.bg-gray-100.max-w-lg.w-full.text-sm.rounded-sm action=feature_path(@fea ) = @feature.users.join(', ') + .mb-5 + label.block.text-gray-500.mb-2 Additional Data + + dl + - @feature.data.each do |name, val| + - next if name == 'description' + .sm:grid.sm:grid-cols-3.sm:gap-4.sm:px-6 + dd.text-sm.leading-5.font-medium.text-gray-500 = name + input.appearance-none.border.rounded-sm.w-full.py-2.px-4.text-gray-600.leading-relaxed.bg-white.mt-1.sm:mt-0.sm:col-span-2( + name=name + id=name + value=(val == true ? 'true' : (val == false ? 'false' : val)) + class='hover:border-gray-500' + ) + + .flex.items-center.justify-end form action=delete_feature_path(@feature.name) method='POST' button.mr-5.text-gray-600(class='hover:underline' type='submit' onclick="return confirm('Are you sure you want to delete #{@feature.name}?')") diff --git a/lib/rollout/ui/web.rb b/lib/rollout/ui/web.rb index 39be013..edcd493 100644 --- a/lib/rollout/ui/web.rb +++ b/lib/rollout/ui/web.rb @@ -45,7 +45,20 @@ class Web < Sinatra::Base if params[:users] feature.users = params[:users].split(',').map(&:strip).uniq.sort end - feature.data.update(description: params[:description]) + feature.data.each do |name, old_val| + new_val = params[name] + + # keep type the same (for integers/boolean/strings) + new_val = if old_val.is_a? Integer + new_val.to_i + elsif !!old_val == old_val + new_val == 'true' ? true : (new_val == 'false' ? false : !!new_val) + else + new_val + end + + feature.data.update(name => new_val) + end end end