Compare commits

...

3 Commits

Author SHA1 Message Date
Pizzosaure
b3624ae804 Changes after review 2024-02-23 13:57:22 +01:00
Pizzosaure
73c607a0a7 Changelog entry 2024-02-19 17:06:45 +01:00
Pizzosaure
dcaa2ed75b feat(xo-web/storage): handle link to VM for suspend VDIs 2024-02-19 17:00:51 +01:00
3 changed files with 63 additions and 51 deletions

View File

@@ -9,6 +9,7 @@
- Disable search engine indexing via a `robots.txt`
- [Stats] Support format used by XAPI 23.31
- [Storage/Disks] Handle link to VM for suspended VDIs (PR [#7391](https://github.com/vatesfr/xen-orchestra/pull/7391))
### Bug fixes
@@ -40,6 +41,6 @@
- vhd-lib patch
- xo-server minor
- xo-server-audit patch
- xo-web patch
- xo-web minor
<!--packages-end-->

View File

@@ -413,6 +413,7 @@ const TRANSFORMS = {
startTime: metrics && toTimestamp(metrics.start_time),
secureBoot: obj.platform.secureboot === 'true',
suspendSr: link(obj, 'suspend_SR'),
suspendVdi: link(obj, 'suspend_VDI'),
tags: obj.tags,
VIFs: link(obj, 'VIFs'),
VTPMs: link(obj, 'VTPMs'),
@@ -449,7 +450,6 @@ const TRANSFORMS = {
vm.snapshot_time = toTimestamp(obj.snapshot_time)
vm.$snapshot_of = link(obj, 'snapshot_of')
vm.suspendVdi = link(obj, 'suspend_VDI')
} else if (obj.is_a_template) {
const defaultTemplate = isDefaultTemplate(obj)
vm.type += '-template'

View File

@@ -12,7 +12,7 @@ import PropTypes from 'prop-types'
import React from 'react'
import SortedTable from 'sorted-table'
import TabButton from 'tab-button'
import renderXoItem, { Vdi } from 'render-xo-item'
import renderXoItem, { Vdi, Vm } from 'render-xo-item'
import { confirm } from 'modal'
import { injectIntl } from 'react-intl'
import { Text } from 'editable'
@@ -123,67 +123,76 @@ const COLUMNS = [
vms: getAllVms(state, props),
vbds: getVbds(state, props),
})
})(({ vbds, vms }) => {
})(({ item: vdi, vbds, vms, userData: { vmsSnapshotsBySuspendVdi } }) => {
const vmSnapshot = vmsSnapshotsBySuspendVdi[vdi.uuid]?.[0]
if (isEmpty(vms)) {
return null
}
return (
<Container>
{map(vbds, (vbd, index) => {
const vm = vms[vbd.VM]
{vbds.length > 0 ? (
map(vbds, (vbd, index) => {
const vm = vms[vbd.VM]
if (vm === undefined) {
return null
}
if (vm === undefined) {
return null
}
const type = vm.type
let link
if (type === 'VM') {
link = `/vms/${vm.id}`
} else if (type === 'VM-template') {
link = `/home?s=${vm.id}&t=VM-template`
} else {
link = vm.$snapshot_of === undefined ? '/dashboard/health' : `/vms/${vm.$snapshot_of}/snapshots`
}
const type = vm.type
let link
if (type === 'VM') {
link = `/vms/${vm.id}`
} else if (type === 'VM-template') {
link = `/home?s=${vm.id}&t=VM-template`
} else {
link = vm.$snapshot_of === undefined ? '/dashboard/health' : `/vms/${vm.$snapshot_of}/snapshots`
}
return (
<Row className={index > 0 && 'mt-1'}>
<Col mediumSize={8}>
<Link to={link}>{renderXoItem(vm)}</Link>
</Col>
<Col mediumSize={4}>
<ButtonGroup>
{vbd.attached ? (
return (
<Row className={index > 0 && 'mt-1'}>
<Col mediumSize={8}>
<Link to={link}>{renderXoItem(vm)}</Link>
</Col>
<Col mediumSize={4}>
<ButtonGroup>
{vbd.attached ? (
<ActionRowButton
btnStyle='danger'
handler={disconnectVbd}
handlerParam={vbd}
icon='disconnect'
tooltip={_('vbdDisconnect')}
/>
) : (
<ActionRowButton
btnStyle='primary'
disabled={some(vbds, 'attached') || !isVmRunning(vm)}
handler={connectVbd}
handlerParam={vbd}
icon='connect'
tooltip={_('vbdConnect')}
/>
)}
<ActionRowButton
btnStyle='danger'
handler={disconnectVbd}
handler={deleteVbd}
handlerParam={vbd}
icon='disconnect'
tooltip={_('vbdDisconnect')}
icon='vdi-forget'
tooltip={_('vdiForget')}
/>
) : (
<ActionRowButton
btnStyle='primary'
disabled={some(vbds, 'attached') || !isVmRunning(vm)}
handler={connectVbd}
handlerParam={vbd}
icon='connect'
tooltip={_('vbdConnect')}
/>
)}
<ActionRowButton
btnStyle='danger'
handler={deleteVbd}
handlerParam={vbd}
icon='vdi-forget'
tooltip={_('vdiForget')}
/>
</ButtonGroup>
</Col>
</Row>
)
})}
</ButtonGroup>
</Col>
</Row>
)
})
) : (
<Col mediumSize={8}>
<Link to={`/vms/${vmSnapshot.$snapshot_of}/snapshots`}>
<Vm id={vmSnapshot.$snapshot_of} />
</Link>
</Col>
)}
</Container>
)
}),
@@ -304,6 +313,7 @@ class NewDisk extends Component {
@connectStore(() => ({
checkPermissions: getCheckPermissions,
vbds: createGetObjectsOfType('VBD'),
vmsSnapshotsBySuspendVdi: createGetObjectsOfType('VM-snapshot').groupBy('suspendVdi'),
}))
export default class SrDisks extends Component {
_closeNewDiskForm = () => this.setState({ newDisk: false })
@@ -434,6 +444,7 @@ export default class SrDisks extends Component {
columns={COLUMNS}
data-isVdiAttached={this._getIsVdiAttached()}
data-vdisByBaseCopy={this._getVdisByBaseCopy()}
data-vmsSnapshotsBySuspendVdi={this.props.vmsSnapshotsBySuspendVdi}
defaultFilter='filterOnlyManaged'
filters={FILTERS}
groupedActions={GROUPED_ACTIONS}