-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2334 from avivtur/bulk-actions-not-changing
CNV-54239: selected VMs is not getting updates
- Loading branch information
Showing
4 changed files
with
56 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 0 additions & 23 deletions
23
src/views/virtualmachines/list/components/VirtualMachineActionButton.tsx
This file was deleted.
Oops, something went wrong.
37 changes: 37 additions & 0 deletions
37
src/views/virtualmachines/list/components/VirtualMachineBulkActionButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React, { FC, useMemo } from 'react'; | ||
|
||
import { V1VirtualMachine } from '@kubevirt-ui/kubevirt-api/kubevirt'; | ||
import ActionsDropdown from '@kubevirt-utils/components/ActionsDropdown/ActionsDropdown'; | ||
import { useKubevirtTranslation } from '@kubevirt-utils/hooks/useKubevirtTranslation'; | ||
import { convertResourceArrayToMap } from '@kubevirt-utils/resources/shared'; | ||
import { isEmpty } from '@kubevirt-utils/utils/utils'; | ||
import useMultipleVirtualMachineActions from '@virtualmachines/actions/hooks/useMultipleVirtualMachineActions'; | ||
|
||
import { selectedVMs } from '../selectedVMs'; | ||
|
||
type VirtualMachineBulkActionButtonProps = { | ||
vms: V1VirtualMachine[]; | ||
}; | ||
const VirtualMachineBulkActionButton: FC<VirtualMachineBulkActionButtonProps> = ({ vms }) => { | ||
const { t } = useKubevirtTranslation(); | ||
|
||
const selectedVirtualMachines = useMemo(() => { | ||
const vmsMapper = convertResourceArrayToMap(vms, true); | ||
return selectedVMs.value.map( | ||
(selectedVM) => vmsMapper?.[selectedVM.namespace]?.[selectedVM.name], | ||
); | ||
}, [vms]); | ||
|
||
const actions = useMultipleVirtualMachineActions(selectedVirtualMachines); | ||
|
||
return ( | ||
<ActionsDropdown | ||
actions={actions} | ||
disabledTooltip={t('Select multiple VirtualMachines to perform an action for all of them')} | ||
isDisabled={isEmpty(selectedVMs.value)} | ||
variant="secondary" | ||
/> | ||
); | ||
}; | ||
|
||
export default VirtualMachineBulkActionButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters