-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
3081 - auto_environment_variables (#3432)
* Launchers form w/ basic auto_environment_variable widget - WIP * Adds new auto_environment_variable functionality to launchers form * Comments out unrelated failing test * Adds ability to update environment variables * Additional work on auto_environment_variable * Small method refactor * Uncomments out test that has been fixed on master * Changes variable name * Minor fixes * Fixes syntax * Rsolves the problem where if the user chooses their own label, they can't see the name of the variable in the form.
- Loading branch information
1 parent
fdc57a7
commit 7f32801
Showing
11 changed files
with
133 additions
and
4 deletions.
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
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
46 changes: 46 additions & 0 deletions
46
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,46 @@ | ||
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 initialize(id, opts = {}) | ||
super | ||
|
||
@key = @opts.delete(:key) | ||
# reset the id to be unique from other auto_environment_variable_* | ||
@id = @key ? "#{id}_#{normalize_key(@key)}" : id | ||
end | ||
|
||
def widget | ||
'text_field' | ||
end | ||
|
||
def original_label | ||
return 'Environment Variable' if !@opts[:label] || opts[:label].match('Environment Variable') | ||
@opts[:label].to_s | ||
end | ||
|
||
def label(*) | ||
(opts[:label] || "Environment Variable: #{@key}").to_s | ||
end | ||
|
||
def field_options(fmt: nil) | ||
@key.blank? ? super.merge({readonly: true}) : super | ||
end | ||
|
||
def normalize_key(key_name) | ||
key_name.to_s.gsub('-', '_') | ||
end | ||
|
||
def submit(*) | ||
{ script: { job_environment: { @key.to_s.upcase => value }}} | ||
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
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