do not show selector on NT cloud keys page

rancher/rancher#18078

lint
This commit is contained in:
Westly Wright 2019-02-15 17:00:05 -07:00
parent 2af8a5e489
commit 1e3b8ca24a
No known key found for this signature in database
GPG Key ID: 4FAB3D8673DC54A3
4 changed files with 66 additions and 97 deletions

View File

@ -152,24 +152,28 @@
<li>
{{#link-to "global-admin.security.cloud-keys"}}
<span>{{t "nav.admin.security.cloudKeys"}}</span>
<i class="icon icon-secrets icon-fw"/>{{/link-to}}
<i class="icon icon-secrets icon-fw"/>
{{/link-to}}
</li>
<li>
{{#link-to "nodes.node-templates"}}
<span>{{t "nav.nodeTemplates.link"}}</span>
<i class="icon icon-host icon-fw"/>{{/link-to}}
<i class="icon icon-host icon-fw"/>
{{/link-to}}
</li>
<li role="separator" class="divider"></li>
<li>
{{#link-to "authenticated.prefs"}}
<span>{{t "nav.userPreferences.link"}}</span>
<i class="icon icon-gear icon-fw"/>{{/link-to}}
<i class="icon icon-gear icon-fw"/>
{{/link-to}}
</li>
<li role="separator" class="divider"></li>
<li>
{{#link-to "logout" class="user-logout"}}
<span>{{t "nav.user.logout"}}</span>
<i class="icon icon-logout icon-fw"/>{{/link-to}}
<i class="icon icon-logout icon-fw"/>
{{/link-to}}
</li>
{{/dd.content}}
{{!-- </ul> --}}

View File

@ -49,6 +49,7 @@ export default Component.extend(NewOrEdit, {
errors: null,
region: null,
regionChoices: REGIONS,
sinlgeCloudKeyChoice: null,
didReceiveAttrs() {
set(this, 'model', this.globalStore.createRecord({ type: 'cloudCredential' }));
@ -79,9 +80,11 @@ export default Component.extend(NewOrEdit, {
let match = CRED_CONFIG_CHOICES.findBy('driver', driverName);
next(() => {
set(this, 'cloudKeyType', get(match, 'name'));
setProperties(this, {
cloudKeyType: get(match, 'name'),
singleCloudKeyChoice: get(match, 'displayName'),
});
this.initCloudCredentialConfig();
})

View File

@ -18,6 +18,11 @@
{{t "modalAddCloudKey.type"}}
</label>
{{#if singleCloudKeyChoice}}
<div class="pt-10 pl-10">
{{singleCloudKeyChoice}}
</div>
{{else}}
<select
class="form-control"
onchange={{action "selectConfig" value="target.value"}}
@ -36,6 +41,7 @@
</option>
{{/each}}
</select>
{{/if}}
</div>

View File

@ -5,8 +5,6 @@ import {
import { alias } from '@ember/object/computed';
import Component from '@ember/component';
import NodeDriver, { registerDisplayLocation, registerDisplaySize } from 'shared/mixins/node-driver';
import fetch from '@rancher/ember-api-store/utils/fetch';
import { addQueryParam, addQueryParams } from 'shared/utils/util';
import layout from './template';
import { inject as service } from '@ember/service';
@ -14,7 +12,6 @@ registerDisplayLocation(DRIVER, 'config.region');
registerDisplaySize(DRIVER, 'config.size');
const DRIVER = 'digitalocean';
const DIGITALOCEAN_API = 'api.digitalocean.com/v2';
const VALID_IMAGES = [
'rancheros',
'centos-7-x64',
@ -167,45 +164,4 @@ export default Component.extend(NodeDriver, {
set(primaryResource, 'digitaloceanConfig', config);
},
apiRequest(command, opt, out) {
opt = opt || {};
let url = `${ get(this, 'app.proxyEndpoint') }/`;
let cloudCredentialId = get(this, 'primaryResource.cloudCredentialId');
if ( opt.url ) {
url += opt.url.replace(/^http[s]?\/\//, '');
} else {
url += `${ DIGITALOCEAN_API }/${ command }`;
url = addQueryParam(url, 'per_page', opt.per_page || 100);
url = addQueryParams(url, opt.params || {});
}
return fetch(url, {
headers: {
'Accept': 'application/json',
'x-api-cattleauth-header': `Bearer credID=${ cloudCredentialId } passwordField=accessToken`,
},
}).then((res) => {
let body = res.body;
if ( out ) {
out[command].pushObjects(body[command]);
} else {
out = body;
}
// De-paging
if ( body && body.links && body.links.pages && body.links.pages.next ) {
opt.url = body.links.pages.next;
return this.apiRequest(command, opt, out).then(() => {
return out;
});
} else {
return out;
}
});
}
});