Add customSshKey to controller after it's created in the component

This commit is contained in:
Piotr Sarnacki 2015-07-21 14:32:21 +02:00
parent 7293e06c0e
commit 8f7603c9fe
3 changed files with 9 additions and 5 deletions

View File

@ -40,10 +40,10 @@ AddSshKeyComponent = Ember.Component.extend
error = errArr[0]
if error.code == 'not_a_private_key'
this.set('valueError', 'This key is not a private key.')
else if error.code == 'key_with_a_passphrase'
else if error.code == 'key_with_a_passphrase'
this.set('valueError', 'We can\'t use key with a passphrase.')
actions:
actions:
save: ->
this.set('valueError', false)
@ -55,10 +55,12 @@ AddSshKeyComponent = Ember.Component.extend
description: @get('description')
value: @get('value')
)
self = this
ssh_key.save().then =>
@set('isSaving', false)
@reset()
@sendAction('sshKeyAdded', ssh_key)
, (error) =>
@set('isSaving', false)
if error.errors

View File

@ -1,7 +1,9 @@
`import Ember from 'ember'`
SettingsController = Ember.Controller.extend
envVars: Ember.computed.filterBy('model.envVars', 'isNew', false)
actions:
sshKeyAdded: (sshKey) ->
@set('model.customSshKey', sshKey)
`export default SettingsController`

View File

@ -35,7 +35,7 @@
{{ssh-key key=model.customSshKey}}
{{else}}
{{ssh-key key=model.sshKey}}
{{add-ssh-key repo=repo}}
{{add-ssh-key repo=repo sshKeyAdded="sshKeyAdded"}}
{{/if}}
</section>