diff --git a/app/styles/components/_code.scss b/app/styles/components/_code.scss index 0269ee56f..3f997aab9 100644 --- a/app/styles/components/_code.scss +++ b/app/styles/components/_code.scss @@ -66,3 +66,13 @@ pre { color: #000; } } + +.codemirror-container { + textarea { + // We can't just use display: none or visibility hidden because then the + // text area can't receive focus which prevents the user from editing. + height: 0; + width: 0; + padding: 0; + } +} \ No newline at end of file diff --git a/lib/global-admin/addon/components/cru-cloud-credential/template.hbs b/lib/global-admin/addon/components/cru-cloud-credential/template.hbs index fc9a9dd5c..93f0c6cf4 100644 --- a/lib/global-admin/addon/components/cru-cloud-credential/template.hbs +++ b/lib/global-admin/addon/components/cru-cloud-credential/template.hbs @@ -169,9 +169,9 @@ - {{input - type="text" - class="form-control" + {{input-url + classNames="form-control" + id="server-url" value=config.vcenter placeholder=(t "nodeDriver.vmwarevsphere.vcenter.placeholder") }} diff --git a/lib/nodes/addon/components/driver-vmwarevsphere/component.js b/lib/nodes/addon/components/driver-vmwarevsphere/component.js index b2b34ebed..04d19bf61 100644 --- a/lib/nodes/addon/components/driver-vmwarevsphere/component.js +++ b/lib/nodes/addon/components/driver-vmwarevsphere/component.js @@ -1,5 +1,7 @@ import { alias } from '@ember/object/computed'; -import { get, set, computed, observer } from '@ember/object'; +import { + get, set, setProperties, computed, observer +} from '@ember/object'; import Component from '@ember/component'; import NodeDriver from 'shared/mixins/node-driver'; import layout from './template'; @@ -173,6 +175,9 @@ export default Component.extend(NodeDriver, { const clearKey = value ? 'config.datastore' : 'config.datastoreCluster'; set(this, clearKey, ''); + }, + updateCloudConfig(value) { + set(this, 'config.cloudConfig', value); } }, @@ -350,6 +355,7 @@ export default Component.extend(NodeDriver, { tag: [], customAttribute: [], cfgparam: ['disk.enableUUID=TRUE'], + cloudConfig: '#cloud-config\n\n', boot2dockerUrl: iso, datacenter: null, vappIpprotocol: initialVAppOptions.vappIpprotocol, @@ -450,11 +456,17 @@ export default Component.extend(NodeDriver, { set(this, 'config.customAttribute', configCustomAttribute); - const clearKey = get(this, 'config.useDataStoreCluster') + const datastoreClearKey = get(this, 'config.useDataStoreCluster') ? 'config.datastore' : 'config.datastoreCluster'; + const cloudClearKey = get(this, 'showRancherOsIso') + ? 'config.cloudConfig' + : 'config.cloudinit'; - set(this, clearKey, ''); + setProperties(this, { + [datastoreClearKey]: '', + [cloudClearKey]: '' + }); const vappMode = get(this, 'vappMode') diff --git a/lib/nodes/addon/components/driver-vmwarevsphere/template.hbs b/lib/nodes/addon/components/driver-vmwarevsphere/template.hbs index f5ee829d5..b4dc87e09 100644 --- a/lib/nodes/addon/components/driver-vmwarevsphere/template.hbs +++ b/lib/nodes/addon/components/driver-vmwarevsphere/template.hbs @@ -234,7 +234,7 @@ {{#if showContentLibrary}}
- - {{textarea-autogrow - value=config.cloudConfig - classNames="form-control no-resize" - placeholder="nodeDriver.vmwarevsphere.cloudinit.placeholder" - }} -

- {{t "nodeDriver.vmwarevsphere.cloudinit.help"}} -

+ {{#if showRancherOsIso }} + + {{input + type="text" + value=config.cloudinit + classNames="form-control" + placeholder=(t "nodeDriver.vmwarevsphere.cloudinit.placeholder") + }} +

+ {{t "nodeDriver.vmwarevsphere.cloudinit.help"}} +

+ {{else}} + + {{input-yaml + showDownload=false + showUpload=false + canChangeName=false + gutters=(array) + minHeight=500 + value=config.cloudConfig + valueUpdated=(action "updateCloudConfig") + }} + {{/if}}
diff --git a/lib/shared/addon/components/input-yaml/component.js b/lib/shared/addon/components/input-yaml/component.js index 916b6dc77..ec624997f 100644 --- a/lib/shared/addon/components/input-yaml/component.js +++ b/lib/shared/addon/components/input-yaml/component.js @@ -38,9 +38,10 @@ export default Component.extend(ThrottledResize, { showUpload: true, showDownload: true, showCopy: false, - shouldChangeName: true, + _isEditorVisible: false, + init() { this._super(...arguments); @@ -48,6 +49,17 @@ export default Component.extend(ThrottledResize, { window.jsyaml || (window.jsyaml = jsyaml); }, + didRender() { + this._super(...arguments); + // We're using _isEditorVisible to trigger a refresh in the ivy-codemirror as + // suggested by https://github.com/IvyApp/ivy-codemirror/issues/2. We do this + // trigger inside of render to ensure the component is already rendered even + // after 'loading' has changed. + next(() => { + set(this, '_isEditorVisible', !get(this, 'loading')); + }); + }, + actions: { click() { $('INPUT[type=file]')[0].click(); diff --git a/lib/shared/addon/components/input-yaml/template.hbs b/lib/shared/addon/components/input-yaml/template.hbs index cd0cf2444..3253d8e7d 100644 --- a/lib/shared/addon/components/input-yaml/template.hbs +++ b/lib/shared/addon/components/input-yaml/template.hbs @@ -24,7 +24,7 @@

{{title}}

-{{else}} +{{else if (or showCopy showUpload showDownload)}}
{{#if showCopy}} {{copy-to-clipboard @@ -62,6 +62,7 @@ placeholder=placeholder value=value valueUpdated=(if valueUpdated valueUpdated (action (mut value)) ) + isVisible=_isEditorVisible options=(hash autofocus=true theme="monokai" diff --git a/translations/en-us.yaml b/translations/en-us.yaml index 9a3d3f022..623e1386b 100644 --- a/translations/en-us.yaml +++ b/translations/en-us.yaml @@ -8357,6 +8357,12 @@ nodeDriver: hostOptions: any: label: 'Any' + cloudconfig: + label: Cloud Config YAML + contentLibrary: 'Content library:' + libraryTemplate: 'Library template:' + virtualMachine: 'Virtual machine:' + template: 'Template:' creationType: label: Creation method library: "Deploy from template: Content Library" @@ -8386,7 +8392,7 @@ nodeDriver: detail: Choose OVF environment properties vcenter: label: vCenter or ESXi Server - placeholder: vCenter or ESXi hostname/IP + placeholder: vcenter.domain.com vcenterPort: label: Port username: