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:
parent
122030742b
commit
8699daa016
@ -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
|
||||
|
@ -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
|
||||
|
@ -161,6 +161,7 @@ const VmSchedulingTab = ({
|
||||
)}
|
||||
{isDeleteEnabled && (
|
||||
<DeleteSchedButton
|
||||
vmId={id}
|
||||
onSubmit={() => handleRemove(ID)}
|
||||
schedule={schedule}
|
||||
oneConfig={oneConfig}
|
||||
|
@ -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 (
|
||||
|
Loading…
x
Reference in New Issue
Block a user