diff --git a/app/components/ssh-key.coffee b/app/components/ssh-key.coffee index 72eb23f7..490d7aaa 100644 --- a/app/components/ssh-key.coffee +++ b/app/components/ssh-key.coffee @@ -4,4 +4,7 @@ SshKeyComponent = Ember.Component.extend classNames: ['settings-sshkey'] + isCustom: () -> + false + `export default SshKeyComponent` diff --git a/app/routes/settings.coffee b/app/routes/settings.coffee index cb9a0f0e..1c50a2f5 100644 --- a/app/routes/settings.coffee +++ b/app/routes/settings.coffee @@ -1,4 +1,5 @@ `import TravisRoute from 'travis/routes/basic'` +`import Ajax from 'travis/utils/ajax'` Route = TravisRoute.extend needsAuth: true @@ -11,10 +12,26 @@ Route = TravisRoute.extend repo = @modelFor('repo') repo.get('envVars.promise') + fetchSshKey: () -> + repo = @modelFor('repo') + self = this + @store.find('sshKey', repo.get('id')).then ( (result) -> result unless result.get('isNew') ), (xhr) -> + if xhr.status == 404 + # if there is no model, just return null. I'm not sure if this is the + # best answer, maybe we should just redirect to different route, like + # ssh_key.new or ssh_key.no_key + return false + + fetchCustomSshKey: () -> + repo = @modelFor('repo') + Ajax.get "/repos/#{repo.get('id')}/key", (data) => + Ember.Object.create(fingerprint: data.fingerprint) + model: () -> return Ember.RSVP.hash({ envVars: this.fetchEnvVars(), - # sshKey: this.fetchSshKey() + sshKey: this.fetchSshKey(), + customSshKey: this.fetchCustomSshKey() }); `export default Route` diff --git a/app/templates/components/ssh-key.hbs b/app/templates/components/ssh-key.hbs index 94c5c741..3e4a2350 100644 --- a/app/templates/components/ssh-key.hbs +++ b/app/templates/components/ssh-key.hbs @@ -1,11 +1,12 @@ -{{#if custom}} +{{#if isCustom}}