- 
                Notifications
    You must be signed in to change notification settings 
- Fork 0
Support limiting options for product #43
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
Conversation
| ❓ I decided not to validate the values as if we need to expand that, that would require a schema change. Semantically, however, it can result in excluding everything if there's a typo like  | 
| 
 So this canvas gem is used for theme developers to lint the theme before making changes, and therefore personally I think it should validate the exact values of 'experience' or 'accommodation' so they're not committing code that won't work. I've just added another example to the Trello ticket for how this should also be an option on the  I'm also just going to say 'extras' as I'm not sure if we've fully considered them for this work. We maybe we need to have refinement of the ticket to be clear what's in scope, let me know when you're free to discuss cc:@ianmooney | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @sldblog thanks for the rubocop clearup along the way.
I wasn't sure how to go about testing this and either I still haven't figured it out or, this is not behaving as we'd like it to. Please correct my approach:
- I've checked out this branch
- Run canvas lintinside a local version of a theme (alchemist in my case).
If I update a block schema to use only in the way we've outlined, then I get the below failure.
| Thanks @eballantine, I will add the choice validation here. I'm unsure what the options would be for variants, can we catch up offline about that, please? | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one, David. I just left a couple comments in there.
| end | ||
|  | ||
| def optional_keys | ||
| super.merge("only_show" => Array) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I'm looking at it, I wonder if only reads better than only_show.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that we should validate that the values passed to the only_show option are from an allowed list of options (experiences, accommodations and extras). I think these should be lower case but I don't have a strong opinion whether they should be pluralised or not.
This is because this list of allowed options is unlikely to change and if it did it would warrant a update to this canvas gem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in 5ec1e53
Warning: obsolete parameter `IgnoredMethods` (for `Style/BlockDelimiters`) found in .rubocop.yml `IgnoredMethods` has been renamed to `AllowedMethods` and/or `AllowedPatterns`. Warning: Style/BlockDelimiters does not support IgnoredMethods parameter.
The new attribute is 1. optional 2. has to be a non-empty array The intent is to provide a way for creators and theme developers to limit the available options to either experiences or accommodation, as appropriate. I decided not to validate the allowed values as I thought that would be too restrictive in the schema.
b0c8634    to
    ea407d4      
    Compare
  
    | @ianmooney @eballantine 👍 Thank you for your reviews! | 
0e28164    to
    db14753      
    Compare
  
    To avoid accidental typos and misuse in the user input
(This is a new, non-breaking feature)
db14753    to
    f4e5214      
    Compare
  
    It's generally quicker than installing the gem, but installing the gem is better for final testing
f4e5214    to
    e5ab567      
    Compare
  
    There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works great 🚀
| ``` | ||
| cd alchemist_theme | ||
| ../canvas/bin/canvas lint | ||
| ``` | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one for updating these docs with a quicker way to test things 🚀
| 🎩 Thank you! | 


Extends the
type: Productschema to allow a new attribute,only.We want to allow creators to choose the relevant types of products for blocks using this type.
Example: