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

backport #3375 to 3.1 #3399

Merged
merged 1 commit into from Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -30,7 +30,7 @@ def create_widget(form, attrib, format: nil, hide_excludable: true, hide_fixed:
form.collection_radio_buttons(attrib.id, attrib.select_choices, :second, :first, **opts)
end
when 'path_selector'
form.form_group attrib.id, help: field_options[:help] do
form.form_group(attrib.id) do
render(partial: 'path_selector', locals: { form: form, attrib: attrib, field_options: field_options })
end
when 'file_attachments'
Expand Down
Expand Up @@ -9,9 +9,10 @@
button_id = "#{path_selector_id}_button"
table_id = "#{path_selector_id}_table"
breadcrumb_id = "#{path_selector_id}_breadcrumb"
options = { data: { 'path-selector': true }}.merge(field_options)
%>

<%= form.text_field(attrib.id, class: 'form-control', data: { 'path-selector': true }) %>
<%= form.text_field(attrib.id, class: 'form-control', **options) %>

<button type="button" class="btn btn-primary mt-2" data-toggle="modal" data-target="#<%= path_selector_id %>">
Select Path
Expand Down
37 changes: 37 additions & 0 deletions apps/dashboard/test/system/batch_connect_test.rb
Expand Up @@ -1295,6 +1295,43 @@ def make_bc_app(dir, form)
end
end

test 'path selector can relabel' do
Dir.mktmpdir do |dir|
"#{dir}/app".tap { |d| Dir.mkdir(d) }
SysRouter.stubs(:base_path).returns(Pathname.new(dir))
stub_scontrol
stub_sacctmgr
stub_git("#{dir}/app")

form = <<~HEREDOC
---
cluster:
- owens
form:
- path
attributes:
path:
widget: 'path_selector'
help: 'select a path using the button below'
label: 'working directory'
HEREDOC

Pathname.new("#{dir}/app/").join('form.yml').write(form)
visit new_batch_connect_session_context_url('sys/app')

base_id = 'batch_connect_session_context_path'
input = find("##{base_id}")

# got the new label
label = find("label[for='#{base_id}']")
assert_equal('working directory', label.text)

# the input has help text sibling with correct text
help = input.sibling('small[class="form-text text-muted"]')
assert_equal('select a path using the button below', help.text)
end
end

test 'saves settings as a template' do
with_modified_env({ ENABLE_NATIVE_VNC: 'true', OOD_BC_SAVED_SETTINGS: 'true' }) do
Dir.mktmpdir do |dir|
Expand Down