-
Notifications
You must be signed in to change notification settings - Fork 305
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
Allow dropdown text for unlisted choice to be configurable #777
Conversation
Wieeee this looks nice! Config namingThere is a coupling between the new config option and
I think it sounds fine with For reference, this is how the config may look 'profile_options': {
'image': {
'display_name': 'Image',
'choices': {
'base': {
'display_name': 'jupyter/base-notebook:latest',
'kubespawner_override': {
'image': 'jupyter/base-notebook:latest'
},
},
'minimal': {
'display_name': 'jupyter/minimal-notebook:latest',
'default': True,
'kubespawner_override': {
'image': 'jupyter/minimal-notebook:latest'
},
},
},
'unlisted_choice': {
'enabled': True,
'display_name': 'Other image',
'display_name_in_choices': 'Enter image manually',
'validation_regex': '^jupyter/.+:.+$',
'validation_message': 'Must be an image matching ^jupyter/<name>:<tag>$',
'kubespawner_override': {'image': '{value}'},
},
},
}, Initialized profile_listMaybe we should reduce complexity like below in the jinja2 template parsing a
If we in
|
… initialization to avoid logic in template
for more information, see https://pre-commit.ci
Yikes, so sorry about that, and thanks for fixing. Apologies the branch is still named
Sounds good to me! Pushed the change.
Have tried to do this with the latest commit. It seems to work, but would be great to get your eyes on those bits and if it lines up with how you were envisioning this. Thanks so much for the quick and thoughtful review! |
Am taking a look at the failing test. |
No no worries, I think that shouldn't matter for anyone in any way. You could do
Thanks! This section was added, and its something like that I was thinking. if option_config.get('unlisted_choice'):
if not 'display_name_in_choices' in option_config.get(
'unlisted_choice'
):
option_config['unlisted_choice'][
'display_name_in_choices'
] = "Other..." I think its important that we initialize unlisted_choice as a dictionary if needed as well, and I think we will check if option_config.get("unlisted_choice") is None:
option_config["unlisted_choice"] = {}
if option_config["unlisted_choice"].get("enabled") is None:
option_config["unlisted_choice"]["enabled"] = False
if option_config["unlisted_choice"].get("display_name_in_choices") is None:
option_config["unlisted_choice"]["display_name_in_choices"] = "Other..." I remembered now that there is a smoother way of writing this also, I suggest going with this! unlisted_choice = option_config.setdefault("unlisted_choice", {})
unlisted_choice.setdefault("enabled", False)
unlisted_choice.setdefault("display_name_in_choices", "Other...") There is also a comment above where this logic resides that should be updated to reflect that default values for unlisted_choice is populated as well. |
Co-authored-by: Erik Sundell <erik.i.sundell@gmail.com>
Co-authored-by: Erik Sundell <erik.i.sundell@gmail.com>
Looking into failing tests. |
for more information, see https://pre-commit.ci
@consideRatio made a small change to the |
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, I added a change suggestion also updating an outdated reference to other_text
- with that this LGTM!
On your end @batpad, is this ready to be merged? If so, I suggest we go for it! |
PR Summary
The profile's in
profile_list
can provideprofile_options
, for example to choose a pre-defined image from a list or opt to specify anunlisted_choice
- not part of this list. This pr adds theunlisted_choice.display_name_in_choices
configuration to specify how the option/choice added to the list of pre-defined entries should be presented.Before, it looked like:
After, it can be configured to look like:
cc @yuvipanda @consideRatio @GeorgianaElena
#757 should be a bit more straightforward than #756, so made this a separate smaller PR, correctly updated with latest
main
.Here we just add an option to the
unlisted_choice
options dictionary and output that in the select instead ofOther...
if present.I have called that option
other_text
, but that doesn't sound great to me, so if anyone has a better recommendation for naming, please let know / go ahead and make the change.I'm not sure if I missed adding documentation for this new option somewhere.
Many apologies for the delay getting to this, please let me know if this looks fine. I'll make a separate PR toward #756.
Thank you!