1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-12 08:58:17 +03:00

B OpenNebula/one#6820: Detach option on vms with regular users (#3357)

Signed-off-by: dcarracedo <dcarracedo@opennebula.io>
Co-authored-by: Tino Vázquez <cvazquez@opennebula.io>
This commit is contained in:
David 2025-01-15 18:50:35 +01:00 committed by GitHub
parent 122030742b
commit 8699daa016
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 42 additions and 33 deletions

View File

@ -139,16 +139,18 @@ const UpdateSchedButton = memo(
* @param {object} props - Props
* @param {ScheduleAction} props.schedule - Schedule action
* @param {function():Promise} props.onSubmit - Submit function
* @param {number} props.vmId - VM id
* @returns {ReactElement} Button
*/
const DeleteSchedButton = memo(
({ onSubmit, schedule, oneConfig, adminGroup }) => {
({ onSubmit, schedule, oneConfig, adminGroup, vmId }) => {
const { ID, ACTION } = schedule
const titleAction = `#${ID} ${sentenceCase(ACTION)}`
// Disable action if the nic has a restricted attribute on the template
// Disable action if is a regular user and is deleting a sched action in a template and if the sched action has a restricted attribute on the template
const disabledAction =
!adminGroup &&
!vmId &&
hasRestrictedAttributes(
schedule,
'SCHED_ACTION',
@ -277,6 +279,7 @@ const ButtonPropTypes = {
backupjobs: PropTypes.bool,
service: PropTypes.object,
roles: PropTypes.object,
vmId: PropTypes.number,
}
CreateSchedButton.propTypes = ButtonPropTypes

View File

@ -109,10 +109,12 @@ const AttachAction = memo(
}
)
const DetachAction = memo(({ nic, onSubmit, sx, oneConfig, adminGroup }) => {
// Disable action if the nic has a restricted attribute on the template
const DetachAction = memo(
({ nic, onSubmit, sx, oneConfig, adminGroup, vmId }) => {
// Disable action if is a regular user and is dettaching a nic in a template and if the nic has a restricted attribute on the template
const disabledAction =
!adminGroup &&
!vmId &&
hasRestrictedAttributes(nic, 'NIC', oneConfig?.VM_RESTRICTED_ATTR)
return (
@ -141,7 +143,8 @@ const DetachAction = memo(({ nic, onSubmit, sx, oneConfig, adminGroup }) => {
]}
/>
)
})
}
)
const UpdateAction = memo(({ nic, onSubmit, sx, oneConfig, adminGroup }) => (
<ButtonToTriggerForm

View File

@ -161,6 +161,7 @@ const VmSchedulingTab = ({
)}
{isDeleteEnabled && (
<DeleteSchedButton
vmId={id}
onSubmit={() => handleRemove(ID)}
schedule={schedule}
oneConfig={oneConfig}

View File

@ -144,8 +144,10 @@ const DetachAction = memo(
await handleDetachDisk({ id: vmId, disk: DISK_ID })
}
// Disable action if is a regular user and is dettaching a disk in a template and if the disk has a restricted attribute on the template
const disabledAction =
!adminGroup &&
!vmId &&
hasRestrictedAttributes(disk, 'DISK', oneConfig?.VM_RESTRICTED_ATTR)
return (