fix(xo-web/vm/disks): don't pass null
to Size
component (#4811)
Fixes support#2181 - `vdi.size` should always be defined - `null` was passed when `vdi.size` was `0`
This commit is contained in:
parent
44956dff85
commit
814e08edd4
@ -490,7 +490,8 @@ export class XoSelect extends Editable {
|
||||
|
||||
export class Size extends Editable {
|
||||
static propTypes = {
|
||||
value: PropTypes.number.isRequired,
|
||||
value: PropTypes.oneOfType([PropTypes.number, PropTypes.oneOf([null])])
|
||||
.isRequired,
|
||||
}
|
||||
|
||||
get value() {
|
||||
@ -498,7 +499,15 @@ export class Size extends Editable {
|
||||
}
|
||||
|
||||
_renderDisplay() {
|
||||
return this.props.children || formatSize(this.props.value)
|
||||
if (this.props.children !== undefined) {
|
||||
return this.props.children
|
||||
}
|
||||
|
||||
if (this.props.value != null) {
|
||||
return formatSize(this.props.value)
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
_saveIfUnfocused = () => {
|
||||
|
@ -2,6 +2,7 @@ import _, { messages } from 'intl'
|
||||
import ActionButton from 'action-button'
|
||||
import Component from 'base-component'
|
||||
import copy from 'copy-to-clipboard'
|
||||
import defined from '@xen-orchestra/defined'
|
||||
import HTML5Backend from 'react-dnd-html5-backend'
|
||||
import Icon from 'icon'
|
||||
import IsoDevice from 'iso-device'
|
||||
@ -131,7 +132,7 @@ const COLUMNS_VM_PV = [
|
||||
{
|
||||
itemRenderer: ({ vdi }) => (
|
||||
<Size
|
||||
value={vdi.size || null}
|
||||
value={defined(vdi.size, null)}
|
||||
onChange={size => editVdi(vdi, { size })}
|
||||
/>
|
||||
),
|
||||
|
Loading…
Reference in New Issue
Block a user