fix(xo-web/new-vm): cloud init should only be available in Premium (#4174)

This commit is contained in:
Pierre Donias
2019-05-02 17:01:06 +02:00
committed by GitHub
parent f084b6def9
commit f4ac73b3b4
4 changed files with 31 additions and 15 deletions

View File

@@ -87,3 +87,5 @@ export const DEFAULT_NETWORK_CONFIG_TEMPLATE = `#network:
# name: eth0
# subnets:
# - type: dhcp`
export const CAN_CLOUD_INIT = +process.env.XOA_PLAN > 3

View File

@@ -1321,6 +1321,7 @@ const messages = {
newVmSshKey: 'SSH key',
noConfigDrive: 'No config drive',
newVmCustomConfig: 'Custom config',
premiumOnly: 'Only available in Premium',
availableTemplateVarsInfo:
'Click here to see the available template variables',
availableTemplateVarsTitle: 'Available template variables',

View File

@@ -37,7 +37,9 @@ export class TooltipViewer extends Component {
return (
<div
className={classNames(
show ? styles.tooltipEnabled : styles.tooltipDisabled,
show && content !== undefined
? styles.tooltipEnabled
: styles.tooltipDisabled,
className
)}
style={{

View File

@@ -16,6 +16,7 @@ import Tooltip from 'tooltip'
import Wizard, { Section } from 'wizard'
import {
AvailableTemplateVars,
CAN_CLOUD_INIT,
DEFAULT_CLOUD_CONFIG_TEMPLATE,
DEFAULT_NETWORK_CONFIG_TEMPLATE,
NetworkConfigInfo,
@@ -1163,13 +1164,18 @@ export default class NewVm extends BaseComponent {
<br />
<LineItem>
<label>
<input
checked={installMethod === 'SSH'}
name='installMethod'
onChange={this._linkState('installMethod')}
type='radio'
value='SSH'
/>
<Tooltip
content={CAN_CLOUD_INIT ? undefined : _('premiumOnly')}
>
<input
checked={installMethod === 'SSH'}
disabled={!CAN_CLOUD_INIT}
name='installMethod'
onChange={this._linkState('installMethod')}
type='radio'
value='SSH'
/>
</Tooltip>
&nbsp;
{_('newVmSshKey')}
</label>
@@ -1201,13 +1207,18 @@ export default class NewVm extends BaseComponent {
<br />
<LineItem>
<label>
<input
checked={installMethod === 'customConfig'}
name='installMethod'
onChange={this._linkState('installMethod')}
type='radio'
value='customConfig'
/>
<Tooltip
content={CAN_CLOUD_INIT ? undefined : _('premiumOnly')}
>
<input
checked={installMethod === 'customConfig'}
disabled={!CAN_CLOUD_INIT}
name='installMethod'
onChange={this._linkState('installMethod')}
type='radio'
value='customConfig'
/>
</Tooltip>
&nbsp;
{_('newVmCustomConfig')}
</label>