Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(xo-web/VM): display creator email and template name #6771

Merged
merged 7 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

- [VM/Advanced] Automatically eject removable medias when converting a VM to a template [#6752](https://github.com/vatesfr/xen-orchestra/issues/6752) (PR [#6769](https://github.com/vatesfr/xen-orchestra/pull/6769))
- [Dashboard/Health] Add free space column for storage state table (PR [#6778](https://github.com/vatesfr/xen-orchestra/pull/6778))
- [VM/General] Displays the template name used to create the VM, as well as the email address of the VM creator for admin users (PR [#6771](https://github.com/vatesfr/xen-orchestra/pull/6771))

### Bug fixes

Expand Down
3 changes: 2 additions & 1 deletion packages/xo-web/src/common/intl/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -1120,11 +1120,12 @@ const messages = {
noIpv4Record: 'No IPv4 record',
noIpRecord: 'No IP record',
started: 'Started {ago}',
created: 'Created on {date}',
paraVirtualizedMode: 'Paravirtualization (PV)',
hardwareVirtualizedMode: 'Hardware virtualization (HVM)',
hvmModeWithPvDriversEnabled: 'Hardware virtualization with paravirtualization drivers enabled (PVHVM)',
pvInPvhMode: 'PV inside a PVH container (PV in PVH)',
vmCreatedAdmin: 'Created by {user}\non {date}\nwith template {template}',
vmCreatedNonAdmin: 'Created on {date}\nwith template {template}',
windowsUpdateTools: 'Manage Citrix PV drivers via Windows Update',
windowsToolsModalTitle: 'Windows Update Tools',
windowsToolsModalMessage:
Expand Down
4 changes: 0 additions & 4 deletions packages/xo-web/src/xo-app/vm/tab-advanced.js
Original file line number Diff line number Diff line change
Expand Up @@ -914,10 +914,6 @@ export default class TabAdvanced extends Component {
<h3>{_('miscLabel')}</h3>
<table className='table table-hover'>
<tbody>
<tr>
Rajaa-BARHTAOUI marked this conversation as resolved.
Show resolved Hide resolved
<th>{_('originalTemplate')}</th>
<td>{vm.other.base_template_name ? vm.other.base_template_name : _('unknownOriginalTemplate')}</td>
</tr>
<tr>
<th>{_('resourceSet')}</th>
<td>
Expand Down
62 changes: 51 additions & 11 deletions packages/xo-web/src/xo-app/vm/tab-general.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import isEmpty from 'lodash/isEmpty'
import map from 'lodash/map'
import React from 'react'
import HomeTags from 'home-tags'
import renderXoItem from 'render-xo-item'
import renderXoItem, { VmTemplate } from 'render-xo-item'
import Tooltip from 'tooltip'
import { addTag, editVm, removeTag } from 'xo'
import { addTag, editVm, removeTag, subscribeUsers } from 'xo'
import { BlockLink } from 'link'
import { FormattedRelative, FormattedDate } from 'react-intl'
import { Container, Row, Col } from 'grid'
Expand All @@ -20,10 +20,16 @@ import {
createGetVmLastShutdownTime,
createSelector,
getResolvedPendingTasks,
isAdmin,
} from 'selectors'
import { connectStore, formatSizeShort, getVirtualizationModeLabel, osFamily } from 'utils'
import { addSubscriptions, connectStore, formatSizeShort, getVirtualizationModeLabel, osFamily } from 'utils'
import { CpuSparkLines, MemorySparkLines, NetworkSparkLines, XvdSparkLines } from 'xo-sparklines'
import { injectState, provideState } from 'reaclette'
import { find } from 'lodash'

const CREATED_VM_STYLES = {
whiteSpace: 'pre-line',
}

const GuestToolsDetection = ({ vm }) => {
if (vm.power_state !== 'Running' || vm.pvDriversDetected === undefined) {
Expand Down Expand Up @@ -93,13 +99,25 @@ const GeneralTab = decorate([
)

return (state, props) => ({
isAdmin: isAdmin(state, props),
lastShutdownTime: createGetVmLastShutdownTime()(state, props),
// true: useResourceSet to bypass permissions
resolvedPendingTasks: getResolvedPendingTasks(state, props, true),
vgpu: getAttachedVgpu(state, props),
vgpuTypes: getVgpuTypes(state, props),
vmTemplate: createGetObjectsOfType('VM-template').find(
(_, { pool, vm }) =>
template =>
template.$poolId === pool.id && template.uuid === vm.creation?.template
)(state, props),
})
}),
addSubscriptions(
({ isAdmin, vm }) =>
isAdmin && {
vmCreator: cb => subscribeUsers(users => cb(find(users, user => user.id === vm.creation?.user))),
}
),
provideState({
computed: {
vmResolvedPendingTasks: (_, { resolvedPendingTasks, vm }) => {
Expand All @@ -109,7 +127,18 @@ const GeneralTab = decorate([
},
}),
injectState,
({ state: { vmResolvedPendingTasks }, lastShutdownTime, statsOverview, vgpu, vgpuTypes, vm, vmTotalDiskSpace }) => {
({
isAdmin,
state: { vmResolvedPendingTasks },
lastShutdownTime,
statsOverview,
vgpu,
vgpuTypes,
vm,
vmCreator,
vmTemplate,
vmTotalDiskSpace,
}) => {
const {
CPUs: cpus,
id,
Expand All @@ -122,6 +151,7 @@ const GeneralTab = decorate([
tags,
VIFs: vifs,
} = vm

return (
<Container>
{/* TODO: use CSS style */}
Expand Down Expand Up @@ -165,13 +195,23 @@ const GeneralTab = decorate([
<br />
<Row className='text-xs-center'>
<Col mediumSize={3}>
{installTime !== null && (
<div className='text-xs-center'>
{_('created', {
date: <FormattedDate day='2-digit' month='long' value={installTime * 1000} year='numeric' />,
})}
</div>
)}
<p style={CREATED_VM_STYLES}>
{_(isAdmin ? 'vmCreatedAdmin' : 'vmCreatedNonAdmin', {
user: vmCreator?.email ?? _('unknown'),
date:
installTime !== null ? (
<FormattedDate day='2-digit' month='long' value={installTime * 1000} year='numeric' />
) : (
_('unknown')
),
template:
vmTemplate !== undefined ? (
<VmTemplate id={vmTemplate.id} />
) : (
vm.other.base_template_name ?? _('unknown')
),
})}
</p>
{powerState === 'Running' || powerState === 'Paused' ? (
<div>
<p className='text-xs-center'>
Expand Down