From 2accdd56264d4a9d09dd7f936e059cdfd2413674 Mon Sep 17 00:00:00 2001 From: Lisa Passing Date: Fri, 17 Jul 2015 11:39:46 +0200 Subject: [PATCH] try fetching ssh keys --- app/components/ssh-key.coffee | 3 +++ app/routes/settings.coffee | 19 +++++++++++++- app/templates/components/ssh-key.hbs | 10 +++++--- app/templates/settings.hbs | 37 ++++++++++++++++------------ 4 files changed, 48 insertions(+), 21 deletions(-) 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}}
- TRAVIS_PRIVATE_KEY + {{key.description}}
- e1:b1:83:06:7e:51:6d:5e:e0:e0:60:96:ca:ac:3d:8a + {{key.fingerprint}} + {{fingerprint}}
@@ -22,7 +23,8 @@
- e1:b1:83:06:7e:51:6d:5e:e0:e0:60:96:ca:ac:3d:8a + {{key.fingerprint}} + {{fingerprint}}
diff --git a/app/templates/settings.hbs b/app/templates/settings.hbs index 93689a2b..ec8954ae 100644 --- a/app/templates/settings.hbs +++ b/app/templates/settings.hbs @@ -31,23 +31,28 @@

SSH Key

- {{ssh-key}} - {{ssh-key custom=true}} + {{#if sshKey}} + {{ssh-key key=sshKey}} -
- Add custom SSH Key -
-
- -
-
- -
-
- -
-
-
+
+ Add custom SSH Key +
+
+ +
+
+ +
+
+ +
+
+
+ {{else}} + {{ssh-key key=customSshKey}} + {{/if}} + +
{{/if}}