From 70dbe010f3e3cbd3614ce6ff1884e8f3705c760c Mon Sep 17 00:00:00 2001 From: Jorge Miguel Lobo Escalona Date: Wed, 25 May 2022 10:53:17 +0200 Subject: [PATCH] M #5819: fix datatable zombies and add data-cy (#2077) --- .../src/client/components/Tables/Wilds/row.js | 2 +- .../client/components/Tables/Zombies/index.js | 2 +- .../client/components/Tables/Zombies/row.js | 6 ++--- src/fireedge/src/client/models/Host.js | 24 ++++++++++++------- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/fireedge/src/client/components/Tables/Wilds/row.js b/src/fireedge/src/client/components/Tables/Wilds/row.js index 123b543388..454f348fe4 100644 --- a/src/fireedge/src/client/components/Tables/Wilds/row.js +++ b/src/fireedge/src/client/components/Tables/Wilds/row.js @@ -33,7 +33,7 @@ const Row = memo(({ original, ...props }) => { const { DEPLOY_ID, VM_NAME } = original return ( -
+
diff --git a/src/fireedge/src/client/components/Tables/Zombies/index.js b/src/fireedge/src/client/components/Tables/Zombies/index.js index 962af5622b..cc67016645 100644 --- a/src/fireedge/src/client/components/Tables/Zombies/index.js +++ b/src/fireedge/src/client/components/Tables/Zombies/index.js @@ -38,7 +38,7 @@ const ZombiesTable = (props) => { data={useMemo(() => zombies, [zombies])} rootProps={rootProps} searchProps={searchProps} - getRowId={(row) => String(row.ZOMBIE_VM)} + getRowId={(row) => String(row.DEPLOY_ID)} RowComponent={ZombieRow} {...rest} /> diff --git a/src/fireedge/src/client/components/Tables/Zombies/row.js b/src/fireedge/src/client/components/Tables/Zombies/row.js index 6ea175c70d..7ccf5d4635 100644 --- a/src/fireedge/src/client/components/Tables/Zombies/row.js +++ b/src/fireedge/src/client/components/Tables/Zombies/row.js @@ -30,14 +30,14 @@ import { Row as RowType } from 'react-table' */ const Row = memo(({ original, ...props }) => { const classes = rowStyles() - const { ZOMBIE_VM } = original + const { DEPLOY_ID, VM_NAME } = original return ( -
+
- {ZOMBIE_VM} + {VM_NAME}
diff --git a/src/fireedge/src/client/models/Host.js b/src/fireedge/src/client/models/Host.js index 3e3b08111a..ba5406da98 100644 --- a/src/fireedge/src/client/models/Host.js +++ b/src/fireedge/src/client/models/Host.js @@ -133,12 +133,15 @@ export const getKvmMachines = (hosts = []) => { * @param {Host} host - Host * @returns {object[]} - List of zombies from host */ -export const getHostZombies = (host = {}) => - [ - host?.TEMPLATE?.ZOMBIES?.split(', ')?.map((zombie) => ({ - ZOMBIE_VM: zombie, - })) ?? [], - ].flat() +export const getHostZombies = (host = {}) => { + const zombies = host?.TEMPLATE?.ZOMBIES?.split(', ') ?? [] + + const vms = [host?.TEMPLATE?.VM ?? []] + .flat() + .filter((vm) => vm.VCENTER_TEMPLATE === 'YES') + + return vms.filter((vm) => vm?.VM_NAME && zombies.includes(vm?.VM_NAME)) +} /** * Returns list of Wilds available from the host. @@ -146,10 +149,15 @@ export const getHostZombies = (host = {}) => * @param {Host} host - Host * @returns {object[]} - List of wilds from host */ -export const getHostWilds = (host = {}) => - [host?.TEMPLATE?.VM ?? []] +export const getHostWilds = (host = {}) => { + const wilds = host?.TEMPLATE?.WILDS?.split(', ') ?? [] + + const vms = [host?.TEMPLATE?.VM ?? []] .flat() .filter((vm) => vm.VCENTER_TEMPLATE === 'YES') + + return vms.filter((vm) => vm?.VM_NAME && wilds.includes(vm?.VM_NAME)) +} /** * Returns list of Numa available from the host. *