Skip to content

Commit

Permalink
Refs jupyterhub#756 - allow dropdown text for unlisted choice to be c…
Browse files Browse the repository at this point in the history
…onfigurable
  • Loading branch information
batpad committed Sep 2, 2023
1 parent 156245d commit 8697732
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions kubespawner/spawner.py
Original file line number Diff line number Diff line change
Expand Up @@ -1543,6 +1543,7 @@ def _validate_image_pull_secrets(self, proposal):
selected "Other" as a choice:
- `enabled`: Boolean, whether the free form input should be enabled
- `display_name`: String, label for input field
- `other_text`: Optional, text to show in Select Dropdown for Other option
- `validation_regex`: Optional, regex that the free form input should match - eg. ^pangeo/.*$
- `validation_message`: Optional, validation message for the regex. Should describe the required
input format in a human-readable way.
Expand Down Expand Up @@ -1604,6 +1605,7 @@ def _validate_image_pull_secrets(self, proposal):
},
'unlisted_choice': {
'enabled': True,
'other_text': 'Enter image manually',
'display_name': 'Other image',
'validation_regex': '^jupyter/.+:.+$',
'validation_message': 'Must be an image matching ^jupyter/<name>:<tag>$',
Expand Down
8 changes: 7 additions & 1 deletion kubespawner/templates/form.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ <h3>{{ profile.display_name }}</h3>
<option value="{{ k }}" {% if choice.default %}selected{% endif %}>{{ choice.display_name }}</option>
{%- endfor %}
{%- if option['unlisted_choice'] and option['unlisted_choice']['enabled'] %}
<option value="unlisted-choice">Other...</option>
<option value="unlisted-choice">
{%- if option['unlisted_choice']['other_text'] %}
{{ option['unlisted_choice']['other_text'] }}
{%- else %}
Other...
{%- endif %}
</option>
{%- endif %}
</select>
</div>
Expand Down

0 comments on commit 8697732

Please sign in to comment.