Skip to content

Commit

Permalink
add confirm modal
Browse files Browse the repository at this point in the history
  • Loading branch information
stephane-m-dev committed Nov 14, 2024
1 parent 501c8e2 commit da1b169
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
2 changes: 2 additions & 0 deletions packages/xo-web/src/common/intl/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -1476,6 +1476,8 @@ const messages = {
logAction: 'Action',

// ----- VM advanced tab -----
allowMigrationTitle: "Allow migration",
allowMigrationconfirm: "This will allow migration blocked for this reason: ",
attachedPcis: 'Attached PCIs',
attachingDetachingPciNeedVmBoot: 'Attaching/detaching a PCI will be taken into consideration for the next VM boot.',
attachPcis: 'Attach PCIs',
Expand Down
33 changes: 26 additions & 7 deletions packages/xo-web/src/xo-app/vm/tab-advanced.js
Original file line number Diff line number Diff line change
Expand Up @@ -596,14 +596,33 @@ export default class TabAdvanced extends Component {
}

_onChangeAllowMigration = allow => {
editVm(this.props.vm, {
blockedOperations: Object.assign.apply(
null,
['migrate_send', 'pool_migrate'].map(op => ({ [op]: allow ? null : 'Migration blocked' }))
),
console.log({allow})
const reasons = Object.keys(this.props.vm.blockedOperations).join(' ')
console.log({reasons})
confirm({
title: _('allowMigrationTitle'),
body: <p>{_('allowMigrationconfirm')} {reasons}</p>,
})
.then(() => {
console.log("the user click ok");
console.log({vm: this.props.vm})
console.log({time: "before editVm", allow, blockedOperations: this.props.vm.blockedOperations})
editVm(this.props.vm, {
blockedOperations: Object.assign.apply(
null,
['migrate_send', 'pool_migrate'].map(op => ({ [op]: allow ? null : 'Migration blocked' }))
),
})
.then(() => {
console.log({time: "after editVm", allow, blockedOperations: this.props.vm.blockedOperations})
})
})
}

.catch(error => {
console.log("the user click cancel");
console.log({allow, blockedOperations: this.props.vm.blockedOperations})
})
};

_onChangeBlockStop = block =>
editVm(this.props.vm, {
blockedOperations: Object.assign.apply(
Expand Down

0 comments on commit da1b169

Please sign in to comment.