From def9f947b7bef50c62e1705dfa4c01a7b2165148 Mon Sep 17 00:00:00 2001 From: badrAZ Date: Thu, 23 Aug 2018 10:15:45 +0200 Subject: [PATCH] feat(xo-web/new-vm): show error when getting coreOS default template fails (#3343) Fixes #3227 --- CHANGELOG.md | 1 + packages/xo-web/src/common/intl/messages.js | 2 ++ packages/xo-web/src/xo-app/new-vm/index.js | 29 +++++++++++++-------- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a5463fc34..e425425cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - [Backup NG form] Move VMs' selection to a dedicated card [#2711](https://github.com/vatesfr/xen-orchestra/issues/2711) (PR [#3338](https://github.com/vatesfr/xen-orchestra/pull/3338)) - [Backup NG smart mode] Exclude replicated VMs [#2338](https://github.com/vatesfr/xen-orchestra/issues/2338) (PR [#3312](https://github.com/vatesfr/xen-orchestra/pull/3312)) - [Backup NG form] Show the compression checkbox when the full mode is active [#3236](https://github.com/vatesfr/xen-orchestra/issues/3236) (PR [#3345](https://github.com/vatesfr/xen-orchestra/pull/3345)) +- [New VM] Display an error when the getting of the coreOS default template fails [#3227](https://github.com/vatesfr/xen-orchestra/issues/3227) (PR [#3343](https://github.com/vatesfr/xen-orchestra/pull/3343)) ### Bug fixes diff --git a/packages/xo-web/src/common/intl/messages.js b/packages/xo-web/src/common/intl/messages.js index 0ae609c8b..632724037 100644 --- a/packages/xo-web/src/common/intl/messages.js +++ b/packages/xo-web/src/common/intl/messages.js @@ -1181,6 +1181,8 @@ const messages = { availableTemplateVarsTitle: 'Available template variables', templateNameInfo: 'the VM\'s name. It must not contain "_"', templateIndexInfo: "the VM's index, it will take 0 in case of single VM", + coreOsDefaultTemplateError: + 'Error on getting the default coreOS cloud template', newVmBootAfterCreate: 'Boot VM after creation', newVmMacPlaceholder: 'Auto-generated if empty', newVmCpuWeightLabel: 'CPU weight', diff --git a/packages/xo-web/src/xo-app/new-vm/index.js b/packages/xo-web/src/xo-app/new-vm/index.js index 3d3b2d597..91d89696e 100644 --- a/packages/xo-web/src/xo-app/new-vm/index.js +++ b/packages/xo-web/src/xo-app/new-vm/index.js @@ -6,6 +6,7 @@ import classNames from 'classnames' import defined, { get } from 'xo-defined' import Icon from 'icon' import isIp from 'is-ip' +import Link from 'link' import Page from '../page' import PropTypes from 'prop-types' import React from 'react' @@ -76,7 +77,6 @@ import { formatSize, getCoresPerSocketPossibilities, generateReadableRandomString, - noop, resolveIds, resolveResourceSet, } from 'utils' @@ -526,8 +526,9 @@ export default class NewVm extends BaseComponent { if (template.name_label === 'CoreOS') { getCloudInitConfig(template.id).then( - cloudConfig => this._setState({ cloudConfig }), - noop + cloudConfig => + this._setState({ cloudConfig, coreOsDefaultTemplateError: false }), + () => this._setState({ coreOsDefaultTemplateError: true }) ) } } @@ -1017,7 +1018,7 @@ export default class NewVm extends BaseComponent { } _renderInstallSettings = () => { - const { template } = this.state.state + const { template, coreOsDefaultTemplateError } = this.state.state if (!template) { return } @@ -1204,13 +1205,19 @@ export default class NewVm extends BaseComponent { )} {template.name_label === 'CoreOS' && (
- - + {' '} + {!coreOsDefaultTemplateError ? ( + + ) : ( + + {_('coreOsDefaultTemplateError')} + + )}
)}