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

Hides path selector button with rest of path selector #3459

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/dashboard/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ gem 'sdoc', group: :doc, require: false
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
gem 'pry'
gem 'climate_control', '~> 0.2'
gem 'timecop', '~> 0.9'
end
Expand Down
9 changes: 7 additions & 2 deletions apps/dashboard/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,18 @@ GEM
browser (2.7.1)
builder (3.2.4)
byebug (11.1.3)
capybara (3.39.2)
capybara (3.40.0)
addressable
matrix
mini_mime (>= 0.1.3)
nokogiri (~> 1.8)
nokogiri (~> 1.11)
rack (>= 1.6.0)
rack-test (>= 0.6.3)
regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2)
childprocess (4.1.0)
climate_control (0.2.0)
coderay (1.1.3)
coffee-rails (5.0.0)
coffee-script (>= 2.2.0)
railties (>= 5.2.0)
Expand Down Expand Up @@ -180,6 +181,9 @@ GEM
ood_support (0.0.5)
pbs (2.2.1)
ffi (~> 1.9, >= 1.9.6)
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
psych (5.1.2)
stringio
public_suffix (5.0.4)
Expand Down Expand Up @@ -303,6 +307,7 @@ DEPENDENCIES
ood_core (~> 0.24.1)
ood_support (~> 0.0.2)
pbs (~> 2.2.1)
pry
rails (= 7.0.8.1)
redcarpet (~> 3.3)
rest-client (~> 2.0)
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/app/javascript/dynamic_forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,10 +415,10 @@ function updateVisibility(event, changeId) {
const val = valueFromEvent(event);
const id = event.target['id'];
let changeElement = undefined;

$(`#${changeId}`).parents().each(function(_i, parent) {
if(parent.classList.contains('form-group')) {
changeElement = $(parent);
return false;
Copy link
Contributor Author

@HazelGrant HazelGrant Mar 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem here is that text_field is being passed a label option, which wraps the label/input HTML combination in its own div.form-group element. So far simply searching for the top .form-group parent has been easier than over-riding the wrapper_class on the text_field. ... But this isn't my favorite option. I'd rather figure out how to ensure that each widget is only wrapped in one .form-group div.

}
});

Expand Down
74 changes: 74 additions & 0 deletions apps/dashboard/test/system/batch_connect_widgets_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# frozen_string_literal: true

# TODO: Refactor batch_connect_test.rb to include tests that require slurm
# (testing that things submit) and pull out/write tests for widgets (do not
# require form submission) into this file - perhaps a batch_connect_test/
# directory

require 'application_system_test_case'
require 'ood_core/job/adapters/slurm'

class BatchConnectWidgetsTest < ApplicationSystemTestCase
def setup
stub_sys_apps
stub_user
Configuration.stubs(:bc_dynamic_js).returns(true)
Configuration.stubs(:bc_dynamic_js?).returns(true) #stub the alias too
end

def stub_git(dir)
Open3.stubs(:capture3)
.with('git', 'describe', '--always', '--tags', chdir: dir)
.returns(['1.2.3', '', exit_success])
end

def make_bc_app(dir, form)
SysRouter.stubs(:base_path).returns(Pathname.new(dir))
app_dir = "#{dir}/app".tap { |d| Dir.mkdir(d) }
stub_scontrol
stub_sacctmgr
stub_git(app_dir)
Pathname.new(app_dir).join('form.yml').write(form)
end

test 'path_selector can be hidden with data-hide-*' 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
- hide_path
attributes:
path:
widget: 'path_selector'
directory: "#{Rails.root}"
hide_path:
widget: 'select'
options:
- ['show path', 'show path']
- ['hide path', 'hide path', data-hide-path: true]
HEREDOC

Pathname.new("#{dir}/app/").join('form.yml').write(form)
base_id = 'batch_connect_session_context_path'

visit new_batch_connect_session_context_url('sys/app')

select('show path', from: 'batch_connect_session_context_hide_path')
assert find('#batch_connect_session_context_path')
assert find("[data-target='#batch_connect_session_context_path_path_selector']")

select('hide path', from: 'batch_connect_session_context_hide_path')
refute find('#batch_connect_session_context_path', visible: :hidden).visible?
refute find("[data-target='#batch_connect_session_context_path_path_selector']", visible: :hidden).visible?
end
end
end
Loading