feat(xo-web/xoa/update): warn before upgrade if jobs running (#2795)
Fixes #2250
This commit is contained in:
parent
20d5047b55
commit
ed5e0c3509
@ -1524,6 +1524,9 @@ const messages = {
|
|||||||
promptUpgradeReloadTitle: 'Upgrade successful',
|
promptUpgradeReloadTitle: 'Upgrade successful',
|
||||||
promptUpgradeReloadMessage:
|
promptUpgradeReloadMessage:
|
||||||
'Your XOA has successfully upgraded, and your browser must reload the application. Do you want to reload now ?',
|
'Your XOA has successfully upgraded, and your browser must reload the application. Do you want to reload now ?',
|
||||||
|
upgradeWarningTitle: 'Upgrade warning',
|
||||||
|
upgradeWarningMessage:
|
||||||
|
'You have some backup jobs in progress. If you upgrade now, these jobs will be interrupted! Are you sure you want to continue?',
|
||||||
|
|
||||||
// ----- OS Disclaimer -----
|
// ----- OS Disclaimer -----
|
||||||
disclaimerTitle: 'Xen Orchestra from the sources',
|
disclaimerTitle: 'Xen Orchestra from the sources',
|
||||||
|
@ -7,15 +7,16 @@ import Icon from 'icon'
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import Tooltip from 'tooltip'
|
import Tooltip from 'tooltip'
|
||||||
import xoaUpdater, { exposeTrial, isTrialRunning } from 'xoa-updater'
|
import xoaUpdater, { exposeTrial, isTrialRunning } from 'xoa-updater'
|
||||||
import { confirm } from 'modal'
|
import { addSubscriptions, connectStore } from 'utils'
|
||||||
import { connectStore } from 'utils'
|
import { assign, includes, isEmpty, map, some } from 'lodash'
|
||||||
import { Card, CardBlock, CardHeader } from 'card'
|
import { Card, CardBlock, CardHeader } from 'card'
|
||||||
|
import { confirm } from 'modal'
|
||||||
import { Container, Row, Col } from 'grid'
|
import { Container, Row, Col } from 'grid'
|
||||||
|
import { createSelector } from 'selectors'
|
||||||
import { error } from 'notification'
|
import { error } from 'notification'
|
||||||
import { injectIntl } from 'react-intl'
|
import { injectIntl } from 'react-intl'
|
||||||
import { Password } from 'form'
|
import { Password } from 'form'
|
||||||
import { serverVersion } from 'xo'
|
import { serverVersion, subscribeBackupNgJobs, subscribeJobs } from 'xo'
|
||||||
import { assign, includes, isEmpty, map } from 'lodash'
|
|
||||||
|
|
||||||
import pkg from '../../../../package'
|
import pkg from '../../../../package'
|
||||||
|
|
||||||
@ -50,8 +51,18 @@ const states = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const update = () => xoaUpdater.update()
|
const update = () => xoaUpdater.update()
|
||||||
const upgrade = () => xoaUpdater.upgrade()
|
const upgrade = ({ runningJobsExist }) =>
|
||||||
|
runningJobsExist
|
||||||
|
? confirm({
|
||||||
|
title: _('upgradeWarningTitle'),
|
||||||
|
body: _('upgradeWarningMessage'),
|
||||||
|
}).then(() => xoaUpdater.upgrade())
|
||||||
|
: xoaUpdater.upgrade()
|
||||||
|
|
||||||
|
@addSubscriptions({
|
||||||
|
backupNgJobs: subscribeBackupNgJobs,
|
||||||
|
jobs: subscribeJobs,
|
||||||
|
})
|
||||||
@connectStore(state => {
|
@connectStore(state => {
|
||||||
return {
|
return {
|
||||||
configuration: state.xoaConfiguration,
|
configuration: state.xoaConfiguration,
|
||||||
@ -156,6 +167,15 @@ export default class XoaUpdates extends Component {
|
|||||||
update()
|
update()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_getRunningJobsExist = createSelector(
|
||||||
|
() => this.props.jobs,
|
||||||
|
() => this.props.backupNgJobs,
|
||||||
|
(jobs, backupNgJobs) =>
|
||||||
|
jobs !== undefined &&
|
||||||
|
backupNgJobs !== undefined &&
|
||||||
|
some(jobs.concat(backupNgJobs), job => job.runId !== undefined)
|
||||||
|
)
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const textClasses = {
|
const textClasses = {
|
||||||
info: 'text-info',
|
info: 'text-info',
|
||||||
@ -209,6 +229,7 @@ export default class XoaUpdates extends Component {
|
|||||||
</ActionButton>{' '}
|
</ActionButton>{' '}
|
||||||
<ActionButton
|
<ActionButton
|
||||||
btnStyle='success'
|
btnStyle='success'
|
||||||
|
data-runningJobsExist={this._getRunningJobsExist()}
|
||||||
handler={upgrade}
|
handler={upgrade}
|
||||||
icon='upgrade'
|
icon='upgrade'
|
||||||
>
|
>
|
||||||
|
Loading…
Reference in New Issue
Block a user