Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display and update extra data #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

igor47
Copy link

@igor47 igor47 commented Oct 1, 2020

rollup allows storing arbitrary extra data attributes. from the readme:

$rollout.set_feature_data(:chat, description: 'foo', release_date: 'bar', whatever: 'baz')

however, rollout-ui does not display the extra data (in this case, :release_data and :whatever) or allow updating it. in this PR, we enable both. it looks like this:

image

when updating, we try to keep the type of extra data the same -- if it was an integer, it will remain an integer, if it was a boolean, it will remain a boolean, and otherwise it will be a string.

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
```
this looks like a local alias for the original author
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
Copy link
Member

@reneklacan reneklacan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution, I made a few comments about things that we should address before merging this.

Also have you consider just having a data and textarea with nicely formatted json? that might work even better and would not require funky conditions to convert from string to int/booleans

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))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you can simply write this as value=val.to_s

new_val = params[name]

# keep type the same (for integers/boolean/strings)
new_val = if old_val.is_a? Integer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be more bulletproof and ellegant to use a regexp to see if it's a number, eg https://medium.com/launch-school/number-validation-with-regex-ruby-393954e46797

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nested ternary operators are crazy hard to read... using regex and case here might also be more readable

@huguesbr
Copy link
Contributor

huguesbr commented Jan 4, 2021

would love to see this PR merged 👍.
but yeah using a json field seems more adapted..

@nat-ser
Copy link

nat-ser commented Nov 6, 2024

@igor47 @reneklacan Our team would love to see this PR merged as well

We would be happy to push the requested changes to unblock merge @igor47 if you don't mind

@igor47
Copy link
Author

igor47 commented Nov 6, 2024

feel free to take it over! i'm not using this project any more so i don't have a need for it nor any way to test it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants