From 13eb50172b275c8b3003597e8c472e37660cfc44 Mon Sep 17 00:00:00 2001 From: Cody Jackson Date: Thu, 19 Dec 2019 13:24:45 -0700 Subject: [PATCH 1/3] Removing naked strings that I found --- .../addon/components/driver-vmwarevsphere/template.hbs | 8 ++++---- translations/en-us.yaml | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/nodes/addon/components/driver-vmwarevsphere/template.hbs b/lib/nodes/addon/components/driver-vmwarevsphere/template.hbs index f5ee829d5..684fbedbe 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}}
Date: Thu, 19 Dec 2019 16:34:13 -0700 Subject: [PATCH 2/3] Add support for using input-yaml in modals When adding input-yaml to a modal it required the user to click on the input before the value would be loaded and the editor resized. I found a github issue which suggested making use of the isVisible property to force a refresh so I added the use of it to force refreshing to happen. I also made it so the header didn't add a margin if the header wasn't present. --- app/styles/components/_code.scss | 10 ++++++++++ .../addon/components/input-yaml/component.js | 14 +++++++++++++- .../addon/components/input-yaml/template.hbs | 3 ++- 3 files changed, 25 insertions(+), 2 deletions(-) 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/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" From 9e03d4a41b98b3d1a3b9d1eb09205039e327c2f3 Mon Sep 17 00:00:00 2001 From: Cody Jackson Date: Thu, 19 Dec 2019 16:43:48 -0700 Subject: [PATCH 3/3] Improve Vsphere UX around cloudinit/cloudconfig There was confusion and misuse around cloudinit and cloudconfig. This change switches things up so cloudinit is only used for the legacy creation type and cloudconfig is used for all other creation types. Changes the textarea that was used for cloudconfig to input-yaml to make it clear to users that they can enter yaml. Switches the vmware cloud credential vcenter input to an input-url so that we automatically strip the scheme from the input. rancher/rancher#24314 --- .../cru-cloud-credential/template.hbs | 6 +-- .../driver-vmwarevsphere/component.js | 18 +++++++-- .../driver-vmwarevsphere/template.hbs | 38 +++++++++++++------ translations/en-us.yaml | 4 +- 4 files changed, 48 insertions(+), 18 deletions(-) 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 684fbedbe..b4dc87e09 100644 --- a/lib/nodes/addon/components/driver-vmwarevsphere/template.hbs +++ b/lib/nodes/addon/components/driver-vmwarevsphere/template.hbs @@ -278,17 +278,33 @@
- - {{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/translations/en-us.yaml b/translations/en-us.yaml index f52496b30..623e1386b 100644 --- a/translations/en-us.yaml +++ b/translations/en-us.yaml @@ -8357,6 +8357,8 @@ nodeDriver: hostOptions: any: label: 'Any' + cloudconfig: + label: Cloud Config YAML contentLibrary: 'Content library:' libraryTemplate: 'Library template:' virtualMachine: 'Virtual machine:' @@ -8390,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: