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

3081: auto_environment_variable smart attr for scripts #3230

Closed
wants to merge 48 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
0786594
WIP: Starts auto_environment_variable smart attr for scripts
HazelGrant Dec 6, 2023
b9d5fdf
Fixes broken test
HazelGrant Dec 6, 2023
75c3c72
remove el7 from the CI (#3232)
johrstrom Dec 6, 2023
13b5843
lint a random file (#3234)
osc-bot Dec 7, 2023
717c32d
remove featured routes and views (#3231)
johrstrom Dec 7, 2023
8246f3d
add test for DOS encoded files (#3228)
johrstrom Dec 7, 2023
12f2cfe
Ensures auto_environment_variable is picked up in the form correctly
HazelGrant Dec 7, 2023
06e0ec9
Changes strategy for auto_environment_variable
HazelGrant Dec 7, 2023
c359f7c
enhance this helper for building test assets (#3238)
johrstrom Dec 7, 2023
fbcc2b3
update dependencies (#3245)
osc-bot Dec 11, 2023
7f365e9
Update Changelog (#3244)
osc-bot Dec 11, 2023
86f2c50
Fixes to SettingsController after CurrentUser settings refactoring (#…
abujeda Dec 11, 2023
88efd9e
fix cache key for path selector (#3247)
johrstrom Dec 12, 2023
3292b1f
lint a random file (#3243)
osc-bot Dec 12, 2023
7fe8208
lint a random file (#3250)
osc-bot Dec 13, 2023
fe9a2da
Display errors in projects show page when fetching job information (#…
abujeda Dec 13, 2023
fdf234d
WIP - reads auto_environment_variable values to_yaml correctly
HazelGrant Dec 11, 2023
b688eb3
Allows multiple environment variables
HazelGrant Dec 13, 2023
8dac86d
Fixes failing specs
HazelGrant Dec 13, 2023
9cd0f01
fix the CI for new chrome version (#3256)
johrstrom Dec 19, 2023
d0c3788
bc apps rsync with safer args (#3239)
johrstrom Dec 19, 2023
ef3dd02
Added cluster validation to projects.show page to disable script acti…
abujeda Dec 20, 2023
36454ff
only test the first 5 so we dont have to update these all the time (#…
johrstrom Dec 20, 2023
bf38433
update dependencies (#3261)
osc-bot Dec 20, 2023
f5b404d
lint a random file (#3265)
osc-bot Dec 27, 2023
645b5bb
update dependencies (#3267)
osc-bot Dec 27, 2023
3910052
Update Changelog (#3266)
osc-bot Dec 27, 2023
b99394c
Adding custom completed.{md, html}.erb (#3269)
canoalberto Dec 27, 2023
748d0cd
update dependencies (#3272)
osc-bot Jan 2, 2024
4fcb9bc
lint a random file (#3270)
osc-bot Jan 2, 2024
85d8e5b
Update Changelog (#3271)
osc-bot Jan 2, 2024
8aa5bea
Improvements to automatic profile selection (#3252)
abujeda Jan 2, 2024
20283d3
Added support for multiple domains for Apache config in portal gener…
abujeda Jan 2, 2024
f97c901
refactor session_time method with partial (#3229)
akuppa9 Jan 2, 2024
c750ad2
correctly handle options that start with numbers (#3241)
johrstrom Jan 2, 2024
5ae612e
add the config option to disable uploads and downloads (#3236)
johrstrom Jan 2, 2024
5170447
path selector bugfix (#3274)
johrstrom Jan 3, 2024
a23c2f7
refactor completed_view method (#3277)
akuppa9 Jan 5, 2024
d2ae0ee
WIP: Starts auto_environment_variable smart attr for scripts
HazelGrant Dec 6, 2023
d60d112
Fixes broken test
HazelGrant Dec 6, 2023
68f5061
Ensures auto_environment_variable is picked up in the form correctly
HazelGrant Dec 7, 2023
4d91db8
Changes strategy for auto_environment_variable
HazelGrant Dec 7, 2023
2a3148d
WIP - reads auto_environment_variable values to_yaml correctly
HazelGrant Dec 11, 2023
ce00d63
Allows multiple environment variables
HazelGrant Dec 13, 2023
8f8c4b6
Fixes failing specs
HazelGrant Dec 13, 2023
c84c098
WIP
HazelGrant Jan 8, 2024
51015da
WIP - bundle install
HazelGrant Jan 8, 2024
7d992b5
Merge branch '3081-pm-scripts-support-env-vars' of https://github.com…
HazelGrant Jan 8, 2024
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
7 changes: 7 additions & 0 deletions apps/dashboard/app/helpers/scripts_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ def create_editable_widget(form, attrib, format: nil)
render(partial: editable_partial('editable_number'), locals: locals)
when 'select'
render(partial: editable_partial('editable_select'), locals: locals)
when 'key_value_pair'
render(partial: editable_partial('editable_key_value_pair'), locals: locals)
else
render(partial: editable_partial('generic'), locals: locals)
end
Expand Down Expand Up @@ -53,6 +55,11 @@ def auto_accounts_template
create_editable_widget(script_form_double, attrib)
end

def auto_environment_variable_template
attrib = SmartAttributes::AttributeFactory.build_auto_environment_variable
create_editable_widget(script_form_double, attrib)
end

# We need a form builder to build the template divs. These are
# templates so that they are not a part of the _actual_ form (yet).
# Otherwise you'd have required fields that you cannot actually edit
Expand Down
7 changes: 6 additions & 1 deletion apps/dashboard/app/javascript/script_edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ const newFieldData = {
bc_num_slots: {
label: "Nodes",
help: "How many nodes the job will run on."
},
auto_environment_variable: {
label: "Environment Variable",
help: "Add an environment variable."
}
}

Expand Down Expand Up @@ -65,7 +69,8 @@ function updateNewFieldOptions(selectMenu) {
const field = document.getElementById(`script_${newField}`);

// if the field doesn't already exist, it's an option for a new field.
if(field === null) {
// TODO: maybe JS equiv of ALLOW_MULTIPLE_FIELDS.include?(newField)
HazelGrant marked this conversation as resolved.
Show resolved Hide resolved
if(field === null || newField == "auto_environment_variable") {
const option = document.createElement("option");
option.value = newField;
option.text = newFieldData[newField].label;
Expand Down
1 change: 1 addition & 0 deletions apps/dashboard/app/lib/smart_attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ module SmartAttributes
require 'smart_attributes/attributes/bc_queue'
require 'smart_attributes/attributes/bc_vnc_idle'
require 'smart_attributes/attributes/bc_vnc_resolution'
require 'smart_attributes/attributes/auto_environment_variable'
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module SmartAttributes
class AttributeFactory
extend AccountCache

def self.build_auto_environment_variable(opts = {})
Attributes::AutoEnvironmentVariable.new('auto_environment_variable', opts)
end
end

module Attributes
class AutoEnvironmentVariable < Attribute
def widget
'key_value_pair'
end

def label(*)
(opts[:label] || 'Environment Variable').to_s
end
end
end
end
4 changes: 4 additions & 0 deletions apps/dashboard/app/views/scripts/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@
<template id="auto_accounts_template">
<%= auto_accounts_template %>
</template>

<template id="auto_environment_variable_template">
<%= auto_environment_variable_template %>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<%-
field_id = "#{form.object_name}_#{attrib.id}"
-%>

<div class="editable-form-field">

KEY VALUE PAIR FORM: <%= field_id %>

<div class="d-none edit-group">
</div>

<%= render(partial: 'scripts/editable_form_fields/edit_field_buttons', locals: { field_id: field_id }) %>
</div>
2 changes: 1 addition & 1 deletion apps/dashboard/test/system/jobs_app_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ def add_bc_num_hours(project_id, script_id)
new_field_id = 'add_new_field_select'

actual_new_options = page.all("##{new_field_id} option").map(&:value).to_set
expected_new_options = ['bc_num_hours', 'auto_queues', 'bc_num_slots', 'auto_accounts'].to_set
expected_new_options = ['bc_num_hours', 'auto_queues', 'bc_num_slots', 'auto_accounts', 'auto_environment_variable'].to_set
assert_equal expected_new_options, actual_new_options
end
end
Expand Down
Loading