work on envvars
This commit is contained in:
parent
918453a3a5
commit
cb9c26d3a5
38
app/components/add-env-var.coffee
Normal file
38
app/components/add-env-var.coffee
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
`import Ember from 'ember'`
|
||||||
|
|
||||||
|
AddEnvVarComponent = Ember.Component.extend
|
||||||
|
|
||||||
|
classNames: ['form--envvar']
|
||||||
|
|
||||||
|
store: Ember.inject.service()
|
||||||
|
|
||||||
|
isValid: () ->
|
||||||
|
true
|
||||||
|
|
||||||
|
reset: ->
|
||||||
|
@setProperties(name: null, value: null, public: null)
|
||||||
|
|
||||||
|
actions:
|
||||||
|
save: ->
|
||||||
|
return if @get('isSaving')
|
||||||
|
@set('isSaving', true)
|
||||||
|
|
||||||
|
if @isValid()
|
||||||
|
env_var = @get('store').createRecord('env_var',
|
||||||
|
name: @get('name')
|
||||||
|
value: @get('value')
|
||||||
|
public: @get('public')
|
||||||
|
repo: @get('repo')
|
||||||
|
)
|
||||||
|
|
||||||
|
self = this
|
||||||
|
env_var.save().then =>
|
||||||
|
@set('isSaving', false)
|
||||||
|
@reset()
|
||||||
|
, =>
|
||||||
|
@set('isSaving', false)
|
||||||
|
else
|
||||||
|
@set('isSaving', false)
|
||||||
|
|
||||||
|
|
||||||
|
`export default AddEnvVarComponent`
|
|
@ -4,12 +4,6 @@ EnvVarComponent = Ember.Component.extend
|
||||||
|
|
||||||
classNames: ['settings-envvar']
|
classNames: ['settings-envvar']
|
||||||
|
|
||||||
name: DS.attr()
|
|
||||||
value: DS.attr()
|
|
||||||
public: DS.attr('boolean')
|
|
||||||
|
|
||||||
repo: DS.belongsTo('repo', async: true)
|
|
||||||
|
|
||||||
isEditing: false
|
isEditing: false
|
||||||
isDeleting: false
|
isDeleting: false
|
||||||
|
|
||||||
|
@ -20,14 +14,11 @@ EnvVarComponent = Ember.Component.extend
|
||||||
showValueField: Ember.computed.alias('public')
|
showValueField: Ember.computed.alias('public')
|
||||||
|
|
||||||
value: ( (key, value) ->
|
value: ( (key, value) ->
|
||||||
if arguments.length == 2
|
if @get('envVar.public')
|
||||||
@get('model').set('value', value)
|
@get('envVar.value')
|
||||||
value
|
|
||||||
else if @get('public')
|
|
||||||
@get('model.value')
|
|
||||||
else
|
else
|
||||||
'••••••••••••••••'
|
'••••••••••••••••'
|
||||||
).property('model.value', 'public')
|
).property('envVar.value', 'envVar.public')
|
||||||
|
|
||||||
actions:
|
actions:
|
||||||
delete: ->
|
delete: ->
|
||||||
|
|
7
app/controllers/settings.coffee
Normal file
7
app/controllers/settings.coffee
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
`import Ember from 'ember'`
|
||||||
|
|
||||||
|
SettingsController = Ember.Controller.extend
|
||||||
|
|
||||||
|
envVars: Ember.computed.filterBy('model.envVars', 'isNew', false)
|
||||||
|
|
||||||
|
`export default SettingsController`
|
|
@ -3,6 +3,18 @@
|
||||||
Route = TravisRoute.extend
|
Route = TravisRoute.extend
|
||||||
needsAuth: true
|
needsAuth: true
|
||||||
setupController: (controller, model) ->
|
setupController: (controller, model) ->
|
||||||
|
@_super.apply(this, arguments)
|
||||||
|
controller.set('repo', @modelFor('repo'))
|
||||||
@controllerFor('repo').activate('settings')
|
@controllerFor('repo').activate('settings')
|
||||||
|
|
||||||
|
fetchEnvVars: () ->
|
||||||
|
repo = @modelFor('repo')
|
||||||
|
repo.get('envVars.promise')
|
||||||
|
|
||||||
|
model: () ->
|
||||||
|
return Ember.RSVP.hash({
|
||||||
|
envVars: this.fetchEnvVars(),
|
||||||
|
# sshKey: this.fetchSshKey()
|
||||||
|
});
|
||||||
|
|
||||||
`export default Route`
|
`export default Route`
|
||||||
|
|
|
@ -6,7 +6,6 @@ Route = TravisRoute.extend
|
||||||
|
|
||||||
model: ->
|
model: ->
|
||||||
repo = @modelFor('repo')
|
repo = @modelFor('repo')
|
||||||
console.log('######### YEHA ###############')
|
|
||||||
|
|
||||||
repo.fetchSettings().then (settings) ->
|
repo.fetchSettings().then (settings) ->
|
||||||
|
|
||||||
|
|
|
@ -114,6 +114,12 @@
|
||||||
|
|
||||||
.env-var-value
|
.env-var-value
|
||||||
@extend %settings-value-section
|
@extend %settings-value-section
|
||||||
|
|
||||||
|
// public value
|
||||||
|
// background-image: none;
|
||||||
|
// font-size: 16px;
|
||||||
|
// padding: 0.4rem 0 0.4rem 0.7rem;
|
||||||
|
|
||||||
input
|
input
|
||||||
display: inline-block
|
display: inline-block
|
||||||
width: 100%
|
width: 100%
|
||||||
|
|
|
@ -81,12 +81,6 @@ $button-border-color: #d4d4d4
|
||||||
position: relative
|
position: relative
|
||||||
top: -0.15em
|
top: -0.15em
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
.btn
|
|
||||||
@extend .button
|
|
||||||
border-radius: 2px
|
|
||||||
>>>>>>> master
|
|
||||||
.button--green
|
.button--green
|
||||||
border: none
|
border: none
|
||||||
font-size: $font-size-small
|
font-size: $font-size-small
|
||||||
|
|
47
app/templates/components/add-env-var.hbs
Normal file
47
app/templates/components/add-env-var.hbs
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
<form {{action "save" on="submit"}}>
|
||||||
|
<div class="form-elem">
|
||||||
|
{{input value=name class="env-name" placeholder="Name"}}
|
||||||
|
</div>
|
||||||
|
<div class="form-elem">
|
||||||
|
{{input value=value class="env-value" placeholder="Value"}}
|
||||||
|
</div>
|
||||||
|
<div class="form-elem">
|
||||||
|
{{travis-switch active=public}}
|
||||||
|
</div>
|
||||||
|
<div class="form-elem">
|
||||||
|
<input type="submit" value="Add" class="form-submit {{if isSaving "saving"}}" disabled={{isSaving}} />
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{{!--
|
||||||
|
|
||||||
|
|
||||||
|
<form class="env-var" {{action "save" on="submit"}}>
|
||||||
|
{{#travis-field "name"}}
|
||||||
|
|
||||||
|
{{input value=name class="env-name" placeholder="Name"}} {{travis-errors "name"}}
|
||||||
|
{{/travis-field}}
|
||||||
|
<span class="equals">=</span>
|
||||||
|
{{#if showValueField}}
|
||||||
|
<div class="field value value--extra">
|
||||||
|
{{#label for="value" class="value"}}Value:{{/label}}
|
||||||
|
{{input value=value class="env-value" placeholder="Value"}}
|
||||||
|
</div>
|
||||||
|
{{else}}
|
||||||
|
<div class="field name">
|
||||||
|
<span class="value value-display secure">{{value}}</span>
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
|
<div class="field field--switch">
|
||||||
|
{{travis-switch active=public}}
|
||||||
|
{{#label for="secure" class="public"}}Display value in build logs{{/label}}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="actions">
|
||||||
|
<input type="submit" {{bind-attr value=actionType class=":submit-env-var isSaving:saving" disabled=isSaving}} />
|
||||||
|
<span class="or">or</span>
|
||||||
|
<a href="#" class="cancel-env-var" {{action "cancel"}}>Cancel</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
--}}
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
<div class="env-var-name">THIS_IS_THE_ENV_NAME</div>
|
<div class="env-var-name">{{envVar.name}}</div>
|
||||||
<div class="env-var-value">
|
<div class="env-var-value">
|
||||||
<input type="pw" value="••••••••••••••••" readonly="readonly">
|
<input type="pw" value="{{value}}" readonly="readonly">
|
||||||
</div>
|
</div>
|
||||||
<div class="env-var-action">
|
<div class="env-var-action">
|
||||||
<div class="tooltip">
|
<div class="tooltip">
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
|
<div class="switch-inner">
|
||||||
<span class="on">
|
<span class="on">
|
||||||
ON
|
ON
|
||||||
</span>
|
</span>
|
||||||
<span class="off">
|
<span class="off">
|
||||||
OFF
|
OFF
|
||||||
</span>
|
</span>
|
||||||
|
</div>
|
||||||
|
<span class="label">Display value in build log</span>
|
||||||
|
|
|
@ -18,29 +18,13 @@
|
||||||
<h2 class="small-title">Environment Variables</h2>
|
<h2 class="small-title">Environment Variables</h2>
|
||||||
|
|
||||||
<ul class="settings-list--envvars">
|
<ul class="settings-list--envvars">
|
||||||
<li>{{env-var}}</li>
|
{{#each envVars as |envVar|}}
|
||||||
<li>{{env-var}}</li>
|
<li>{{env-var envVar=envVar}}</li>
|
||||||
<li>{{env-var}}</li>
|
{{/each}}
|
||||||
<li>{{env-var}}</li>
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
{{add-env-var repo=repo}}
|
||||||
|
|
||||||
<div class="form--envvar">
|
|
||||||
<form action="">
|
|
||||||
<div class="form-elem">
|
|
||||||
<input type="text" placeholder="Name">
|
|
||||||
</div>
|
|
||||||
<div class="form-elem">
|
|
||||||
<input type="text" placeholder="Value">
|
|
||||||
</div>
|
|
||||||
<div class="form-elem">
|
|
||||||
{{settings-switch inline="true"}}
|
|
||||||
</div>
|
|
||||||
<div class="form-elem">
|
|
||||||
<input type="submit" class="form-submit" value="Add">
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
{{#if config.endpoints.sshKey}}
|
{{#if config.endpoints.sshKey}}
|
||||||
|
|
12
tests/unit/controllers/settings-test.coffee
Normal file
12
tests/unit/controllers/settings-test.coffee
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
`import { test, moduleFor } from 'ember-qunit'`
|
||||||
|
|
||||||
|
moduleFor 'controller:settings', {
|
||||||
|
# Specify the other units that are required for this test.
|
||||||
|
# needs: ['controller:foo']
|
||||||
|
}
|
||||||
|
|
||||||
|
# Replace this with your real tests.
|
||||||
|
test 'it exists', (assert) ->
|
||||||
|
controller = @subject()
|
||||||
|
assert.ok controller
|
||||||
|
|
Loading…
Reference in New Issue
Block a user