fix(xo-web/home): don't search in linked objects (#6881)

Introduced by 5928984069

For instance, searching the UUID of a running VM was showing all other VMs on the same host due to the UUID being present in their `container.residentVms`.
This commit is contained in:
Julien Fontanet
2023-08-10 14:42:07 +02:00
committed by GitHub
parent 56388557cb
commit 1b6ec2c545
2 changed files with 25 additions and 10 deletions

View File

@@ -16,6 +16,7 @@
- [LDAP] Mark the _Id attribute_ setting as required
- [Incremental Replication] Fix `TypeError: Cannot read properties of undefined (reading 'uuid') at #isAlreadyOnHealthCheckSr` [Forum#7492](https://xcp-ng.org/forum/topic/7492) (PR [#6969](https://github.com/vatesfr/xen-orchestra/pull/6969))
- [File Restore] Increase timeout from one to ten minutes when restoring through XO Proxy
- [Home/VMs] Filtering with a UUID will no longer show other VMs on the same host/pool
### Packages to release

View File

@@ -452,11 +452,19 @@ const NoObjects = props =>
(hosts, pools) => ({ ...hosts, ...pools })
)
const getItems = createSelector(getContainers, createGetObjectsOfType(getType), (containers, items) =>
mapValues(items, item => ({
...item,
container: containers[item.$container || item.$pool],
physicalUsageBySize: item.type === 'SR' ? (item.size > 0 ? item.physical_usage / item.size : 0) : undefined,
}))
mapValues(items, item =>
// ComplexMatcher works on own enumerable properties, therefore the
// injected properties should be non-enumerable
Object.defineProperties(
{ ...item },
{
container: { value: containers[item.$container || item.$pool] },
physicalUsageBySize: {
value: item.type === 'SR' ? (item.size > 0 ? item.physical_usage / item.size : 0) : undefined,
},
}
)
)
)
// VMs are handled separately because we need to inject their 'vdisUsage'
const getVms = createSelector(
@@ -465,11 +473,17 @@ const NoObjects = props =>
createGetObjectsOfType('VBD'),
createGetObjectsOfType('VDI'),
(containers, vms, vbds, vdis) =>
mapValues(vms, vm => ({
...vm,
container: containers[vm.$container || vm.$pool],
vdisUsage: sumBy(compact(map(vm.$VBDs, vbdId => get(() => vdis[vbds[vbdId].VDI]))), 'usage'),
}))
mapValues(vms, vm =>
// ComplexMatcher works on own enumerable properties, therefore the
// injected properties should be non-enumerable
Object.defineProperties(
{ ...vm },
{
container: { value: containers[vm.$container || vm.$pool] },
vdisUsage: { value: sumBy(compact(map(vm.$VBDs, vbdId => get(() => vdis[vbds[vbdId].VDI]))), 'usage') },
}
)
)
)
return (state, props) => {