Implement delete action for ssh-key

This commit is contained in:
Piotr Sarnacki 2015-07-21 14:32:33 +02:00
parent 8f7603c9fe
commit 34510791b0
4 changed files with 21 additions and 15 deletions

View File

@ -8,16 +8,14 @@ SshKeyComponent = Ember.Component.extend
actions:
delete: ->
console.log('isDeleting')
return if @get('isDeleting')
@set('isDeleting', true)
# return if @get('isDeleting')
# @set('isDeleting', true)
deletingDone = => @set('isDeleting', false)
# deletingDone = => @set('isDeleting', false)
# @get('model').deleteRecord()
# @get('model').save().then(deletingDone, deletingDone).then =>
# @set('model', null)
@get('key').deleteRecord()
@get('key').save().then(deletingDone, deletingDone).then =>
@sendAction('sshKeyDeleted')
`export default SshKeyComponent`

View File

@ -6,4 +6,8 @@ SettingsController = Ember.Controller.extend
actions:
sshKeyAdded: (sshKey) ->
@set('model.customSshKey', sshKey)
sshKeyDeleted: ->
@set('model.customSshKey', null)
`export default SettingsController`

View File

@ -8,12 +8,16 @@
<span>{{key.fingerprint}}</span>
</div>
<div class="ssh-key-action">
<div class="tooltip">
<a href="#" title="" {{action "delete"}}>
<span class="icon-delete"></span>
</a>
<div class="tooltip-bubble">Delete</div>
</div>
{{#if isDeleting}}
{{loading-indicator}}
{{else}}
<div class="tooltip">
<a href="#" title="" {{action "delete"}}>
<span class="icon-delete"></span>
</a>
<div class="tooltip-bubble">Delete</div>
</div>
{{/if}}
</div>
{{else}}
<div class="ssh-key-name">

View File

@ -32,7 +32,7 @@
<h2 class="small-title">SSH Key</h2>
{{#if model.customSshKey}}
{{ssh-key key=model.customSshKey}}
{{ssh-key key=model.customSshKey sshKeyDeleted="sshKeyDeleted"}}
{{else}}
{{ssh-key key=model.sshKey}}
{{add-ssh-key repo=repo sshKeyAdded="sshKeyAdded"}}