copy some methods from ssh-key controller to add-ssh-key component
This commit is contained in:
parent
fcfd634591
commit
87ddf9979a
|
@ -19,7 +19,6 @@ AddEnvVarComponent = Ember.Component.extend
|
||||||
|
|
||||||
actions:
|
actions:
|
||||||
save: ->
|
save: ->
|
||||||
console.log('SUBMITTED')
|
|
||||||
return if @get('isSaving')
|
return if @get('isSaving')
|
||||||
@set('isSaving', true)
|
@set('isSaving', true)
|
||||||
|
|
||||||
|
|
|
@ -4,5 +4,56 @@ AddSshKeyComponent = Ember.Component.extend
|
||||||
|
|
||||||
classNames: ['form--sshkey']
|
classNames: ['form--sshkey']
|
||||||
|
|
||||||
|
store: Ember.inject.service()
|
||||||
|
isSaving: false
|
||||||
|
|
||||||
|
isValid: () ->
|
||||||
|
true
|
||||||
|
|
||||||
|
reset: ->
|
||||||
|
@setProperties(description: null, value: null)
|
||||||
|
|
||||||
|
actions:
|
||||||
|
|
||||||
|
add: ->
|
||||||
|
# not sure how to integrate that with 'save' in the compotent
|
||||||
|
id = @get('repo.id')
|
||||||
|
model = @store.recordForId('sshKey', id)
|
||||||
|
# TODO: this can be removed in favor of simply unloading record
|
||||||
|
# once https://github.com/emberjs/data/pull/2867
|
||||||
|
# and https://github.com/emberjs/data/pull/2870 are merged
|
||||||
|
if model
|
||||||
|
@store.dematerializeRecord(model)
|
||||||
|
typeMap = @store.typeMapFor('sshKey')
|
||||||
|
idToRecord = typeMap.idToRecord
|
||||||
|
delete idToRecord[id]
|
||||||
|
|
||||||
|
model = @store.createRecord('sshKey', id: id)
|
||||||
|
@set('model', model)
|
||||||
|
@set('isEditing', true)
|
||||||
|
|
||||||
|
save: ->
|
||||||
|
return if @get('isSaving')
|
||||||
|
@set('isSaving', true)
|
||||||
|
|
||||||
|
if @isValid()
|
||||||
|
|
||||||
|
ssh_key = @get('store').createRecord('ssh_key',
|
||||||
|
description: @get('description')
|
||||||
|
value: @get('value')
|
||||||
|
fingerprint: 'I dont know?'
|
||||||
|
repo: @get('repo')
|
||||||
|
)
|
||||||
|
self = this
|
||||||
|
ssh_key.save().then =>
|
||||||
|
@set('isSaving', false)
|
||||||
|
@reset()
|
||||||
|
, =>
|
||||||
|
@set('isSaving', false)
|
||||||
|
|
||||||
|
# if error.errors
|
||||||
|
# @addErrorsFromResponse(error.errors)
|
||||||
|
else
|
||||||
|
@set('isSaving', false)
|
||||||
|
|
||||||
`export default AddSshKeyComponent`
|
`export default AddSshKeyComponent`
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
<form action="">
|
<form {{action "save" on="submit"}}>
|
||||||
<div class="form-elem">
|
<div class="form-elem">
|
||||||
<input type="text" placeholder="Description">
|
{{input value=description class="ssh-description" placeholder="Description"}}
|
||||||
</div>
|
</div>
|
||||||
<div class="form-elem">
|
<div class="form-elem">
|
||||||
<textarea name="" id="" cols="30" rows="10" placeholder="SSH key"></textarea>
|
{{textarea value=value class="ssh-value" rows="10" placeholder="SSH Key"}}
|
||||||
</div>
|
</div>
|
||||||
<div class="form-elem">
|
<div class="form-elem">
|
||||||
<input type="submit" class="form-submit" value="Add">
|
{{#if isSaving}}
|
||||||
|
{{loading-indicator}}
|
||||||
|
{{else}}
|
||||||
|
<input type="submit" value="Add" class="form-submit" />
|
||||||
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -35,10 +35,9 @@
|
||||||
{{ssh-key key=model.customSshKey}}
|
{{ssh-key key=model.customSshKey}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{ssh-key key=model.sshKey}}
|
{{ssh-key key=model.sshKey}}
|
||||||
{{add-ssh-key }}
|
{{add-ssh-key repo=repo}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<section class="settings-section">
|
<section class="settings-section">
|
||||||
|
|
Loading…
Reference in New Issue
Block a user