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

Launcher save fixed attributes #3784

Merged
merged 19 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from 8 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
29 changes: 24 additions & 5 deletions apps/dashboard/app/javascript/launcher_edit.js
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you submit the changes to this file in another pull request? I can't just glance at this to see what it is, so I'll need more time to look it over.

Original file line number Diff line number Diff line change
Expand Up @@ -164,18 +164,37 @@ function addInProgressField(event) {
}

function updateAutoEnvironmentVariable(event) {
var aev_name = event.target.value;
const aev_name = event.target.value;
const labelString = event.target.dataset.labelString;
var input_field = event.target.parentElement.children[2].children[1];
const idString = `launcher_auto_environment_variable_${aev_name}`;
const nameString = `launcher[auto_environment_variable_${aev_name}]`;
const input_field = event.target.parentElement.children[2].children[1];
const oldId = input_field.id;

input_field.removeAttribute('readonly');
input_field.id = `launcher_auto_environment_variable_${aev_name}`;
input_field.name = `launcher[auto_environment_variable_${aev_name}]`;
input_field.id = idString;
input_field.name = nameString;

if (labelString.match(/Environment( |\s)Variable/)) {
var label_field = event.target.parentElement.children[2].children[0];
const label_field = event.target.parentElement.children[2].children[0];
label_field.innerHTML = `Environment Variable: ${aev_name}`;
}

// Update the checkbox so that environment variables can be fixed when created
const fixedBoxGroup = event.target.parentElement.querySelector('.list-group-item');
const checkbox = fixedBoxGroup.querySelector("input[type='checkbox']");
checkbox.id = `${idString}_fixed`;
checkbox.name = `launcher[auto_environment_variable_${aev_name}_fixed]`;
checkbox.setAttribute('data-fixed-toggler', idString);

// Update hidden field if attribute is already fixed, otherwise just update label
if(fixedBoxGroup.children.length == 3) {
const hiddenField = fixedBoxGroup.querySelector("input[type='hidden']");
hiddenField.name = nameString;
}

const fixedLabel = fixedBoxGroup.querySelector('label');
fixedLabel.setAttribute('for', `${idString}_fixed`);
}

function fixExcludeBasedOnSelect(selectElement) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ def self.build_bc_num_slots(opts = {})

module Attributes
class BcNumSlots < Attribute
# Hash of options used to define this attribute
# @return [Hash] attribute options
def opts
@opts.reverse_merge(min: 1, step: 1)
def initialize(id, opts)
super(id, opts)
@opts = @opts.reverse_merge(min: 1, step: 1)
end

# Value of attribute
Expand Down
16 changes: 13 additions & 3 deletions apps/dashboard/app/models/launcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,19 @@ def add_default_fields(form: [], **_args)
def add_script_to_form(form: [], attributes: {})
form << 'auto_scripts' unless form.include?('auto_scripts')

attributes[:auto_scripts] = {
directory: project_dir
}
dir = { directory: project_dir }
attributes[:auto_scripts] = if attributes[:auto_scripts]
attributes[:auto_scripts].merge(dir)
else
dir
end

# Delete 'value' if it does not exist in the available options
# so that projects created from templates don't point to another
# user's script
script_value = attributes[:auto_scripts]['value']
script_options = attributes[:auto_scripts]['options']
attributes[:auto_scripts].delete('value') if script_options.none? { |opt| opt.include?(script_value) }
johrstrom marked this conversation as resolved.
Show resolved Hide resolved
end

def add_cluster_to_form(form: [], attributes: {})
Expand Down
1 change: 1 addition & 0 deletions apps/dashboard/test/system/project_manager_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,7 @@ def add_auto_environment_variable(project_id, script_id, save: true)
.stubs(:info).returns(OodCore::Job::Info.new(id: 'job-id-123', status: :running))

find("#launch_8woi7ghd").click

assert_selector('.alert-success', text: 'job-id-123')

# sleep here because this test can error with Errno::ENOTEMPTY: Directory not empty @ dir_s_rmdir
Expand Down
Loading