-
Notifications
You must be signed in to change notification settings - Fork 108
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
Adds auto_environment_variable smart attribute #3301
Closed
Closed
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e3c064b
Adds auto_environment_variable smart attribute
HazelGrant 2453dcb
Removes require pry from scripts controller
HazelGrant d18004c
Removes binding.pry
HazelGrant 249e3b3
Removes binding.pry
HazelGrant 76c0dbf
Comments out irrelevant test assertion
HazelGrant f1afc39
WIP - restructures auto_environment_variable
HazelGrant 96b70a3
Fixes typo
HazelGrant 2902fad
Updates script.rb
HazelGrant File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
apps/dashboard/app/lib/smart_attributes/attributes/auto_environment_variable.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
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 | ||
|
||
def options_to_serialize(fmt: nil) | ||
opts[:job_environment] | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
apps/dashboard/app/views/scripts/editable_form_fields/_editable_key_value_pair.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<%- | ||
field_id = "#{form.object_name}_#{attrib.id}" | ||
-%> | ||
|
||
<div class="editable-form-field"> | ||
<div data-multiple-input="group"> | ||
<%= form.text_field :auto_environment_variable_name, data: { multiple_input: 'name' } %> | ||
<%= form.text_field :auto_environment_variable_value, data: { multiple_input: 'value' } %> | ||
</div> | ||
|
||
<div class="d-none edit-group"> | ||
</div> | ||
|
||
<%= render(partial: 'scripts/editable_form_fields/edit_field_buttons', locals: { field_id: field_id }) %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need the addition of
job_environment
here - it should work just like all the other smart attributes.I think the structure of this is a bit off - like you're doing a lot of the work in this model when a lot of this parsing & updating logic should be embedded in the smart attribute itself.
I.e., it knows how to build itself and apply attributes to it.
So given a YAML like this:
That would call the factory method like
Then in the factory - we can do something similar to what
auto_modules
does - the factory parses out FOO and supplies it as an argument to the builderondemand/apps/dashboard/app/lib/smart_attributes/attribute_factory.rb
Lines 13 to 17 in a61aef6