Skip to content

Commit

Permalink
Merge pull request #3399 from OSC/backport-path-selector-relabel
Browse files Browse the repository at this point in the history
backport #3375 to 3.1
  • Loading branch information
johrstrom authored Mar 5, 2024
2 parents 29eec32 + c2dd5f9 commit f67031f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit f67031f

Please sign in to comment.