chore(xo-web/backup-ng/new): better globalSettings management (#3237)
This commit is contained in:
parent
2d596af9a5
commit
9d2f15cf33
@ -129,19 +129,21 @@ const getInitialState = () => ({
|
|||||||
$pool: {},
|
$pool: {},
|
||||||
backupMode: false,
|
backupMode: false,
|
||||||
compression: true,
|
compression: true,
|
||||||
concurrency: 0,
|
concurrency: undefined,
|
||||||
crMode: false,
|
crMode: false,
|
||||||
deltaMode: false,
|
deltaMode: false,
|
||||||
drMode: false,
|
drMode: false,
|
||||||
editionMode: undefined,
|
editionMode: undefined,
|
||||||
formId: generateRandomId(),
|
formId: generateRandomId(),
|
||||||
|
inputConcurrencyId: generateRandomId(),
|
||||||
|
inputReportWhenId: generateRandomId(),
|
||||||
inputTimeoutId: generateRandomId(),
|
inputTimeoutId: generateRandomId(),
|
||||||
name: '',
|
name: '',
|
||||||
offlineSnapshot: false,
|
offlineSnapshot: undefined,
|
||||||
paramsUpdated: false,
|
paramsUpdated: false,
|
||||||
powerState: 'All',
|
powerState: 'All',
|
||||||
remotes: [],
|
remotes: [],
|
||||||
reportWhen: 'failure',
|
reportWhen: undefined,
|
||||||
schedules: {},
|
schedules: {},
|
||||||
settings: {},
|
settings: {},
|
||||||
showErrors: false,
|
showErrors: false,
|
||||||
@ -265,15 +267,21 @@ export default [
|
|||||||
)
|
)
|
||||||
|
|
||||||
const globalSettings = props.job.settings['']
|
const globalSettings = props.job.settings['']
|
||||||
|
const {
|
||||||
|
concurrency = globalSettings.concurrency,
|
||||||
|
offlineSnapshot = globalSettings.offlineSnapshot,
|
||||||
|
reportWhen = globalSettings.reportWhen,
|
||||||
|
timeout,
|
||||||
|
} = state
|
||||||
settings[''] = {
|
settings[''] = {
|
||||||
...globalSettings,
|
...globalSettings,
|
||||||
reportWhen: state.reportWhen,
|
reportWhen,
|
||||||
concurrency: state.concurrency,
|
concurrency: state.concurrency === '' ? undefined : concurrency,
|
||||||
offlineSnapshot: state.offlineSnapshot,
|
offlineSnapshot,
|
||||||
timeout:
|
timeout:
|
||||||
state.timeout === ''
|
timeout === ''
|
||||||
? undefined
|
? undefined
|
||||||
: state.timeout * 1e3 || globalSettings.timeout,
|
: timeout * 1e3 || globalSettings.timeout,
|
||||||
}
|
}
|
||||||
|
|
||||||
await editBackupNgJob({
|
await editBackupNgJob({
|
||||||
@ -357,8 +365,6 @@ export default [
|
|||||||
const remotes =
|
const remotes =
|
||||||
job.remotes !== undefined ? destructPattern(job.remotes) : []
|
job.remotes !== undefined ? destructPattern(job.remotes) : []
|
||||||
const srs = job.srs !== undefined ? destructPattern(job.srs) : []
|
const srs = job.srs !== undefined ? destructPattern(job.srs) : []
|
||||||
const { concurrency, reportWhen, offlineSnapshot } =
|
|
||||||
job.settings[''] || {}
|
|
||||||
const settings = cloneDeep(job.settings)
|
const settings = cloneDeep(job.settings)
|
||||||
delete settings['']
|
delete settings['']
|
||||||
const drMode = job.mode === 'full' && !isEmpty(srs)
|
const drMode = job.mode === 'full' && !isEmpty(srs)
|
||||||
@ -384,9 +390,6 @@ export default [
|
|||||||
crMode,
|
crMode,
|
||||||
remotes,
|
remotes,
|
||||||
srs,
|
srs,
|
||||||
reportWhen: reportWhen || 'failure',
|
|
||||||
concurrency: concurrency || 0,
|
|
||||||
offlineSnapshot,
|
|
||||||
settings,
|
settings,
|
||||||
schedules,
|
schedules,
|
||||||
...destructVmsPattern(job.vms),
|
...destructVmsPattern(job.vms),
|
||||||
@ -522,13 +525,12 @@ export default [
|
|||||||
|
|
||||||
return getInitialState()
|
return getInitialState()
|
||||||
},
|
},
|
||||||
setReportWhen: (_, { value }) => state => ({
|
setReportWhen: (_, { value }) => () => ({
|
||||||
...state,
|
|
||||||
reportWhen: value,
|
reportWhen: value,
|
||||||
}),
|
}),
|
||||||
setConcurrency: (_, concurrency) => state => ({
|
setConcurrency: (_, concurrency) => (_, { job }) => ({
|
||||||
...state,
|
concurrency:
|
||||||
concurrency,
|
concurrency === undefined && job !== undefined ? '' : concurrency,
|
||||||
}),
|
}),
|
||||||
setTimeout: (_, timeout) => (_, { job }) => ({
|
setTimeout: (_, timeout) => (_, { job }) => ({
|
||||||
timeout: timeout === undefined && job !== undefined ? '' : timeout,
|
timeout: timeout === undefined && job !== undefined ? '' : timeout,
|
||||||
@ -583,7 +585,13 @@ export default [
|
|||||||
}),
|
}),
|
||||||
injectState,
|
injectState,
|
||||||
({ state, effects, remotesById, job }) => {
|
({ state, effects, remotesById, job }) => {
|
||||||
const { timeout: jobTimeout } = get(() => job.settings['']) || {}
|
const {
|
||||||
|
concurrency: jobConcurrency,
|
||||||
|
offlineSnapshot: jobOfflineSnapshot,
|
||||||
|
reportWhen: jobReportWhen = 'failure',
|
||||||
|
timeout: jobTimeout,
|
||||||
|
} =
|
||||||
|
get(() => job.settings['']) || {}
|
||||||
|
|
||||||
if (state.needUpdateParams) {
|
if (state.needUpdateParams) {
|
||||||
effects.updateParams()
|
effects.updateParams()
|
||||||
@ -829,28 +837,28 @@ export default [
|
|||||||
<CardHeader>{_('newBackupAdvancedSettings')}</CardHeader>
|
<CardHeader>{_('newBackupAdvancedSettings')}</CardHeader>
|
||||||
<CardBlock>
|
<CardBlock>
|
||||||
<FormGroup>
|
<FormGroup>
|
||||||
<label>
|
<label htmlFor={state.inputReportWhenId}>
|
||||||
<strong>{_('reportWhen')}</strong>
|
<strong>{_('reportWhen')}</strong>
|
||||||
</label>
|
</label>
|
||||||
<Select
|
<Select
|
||||||
|
id={state.inputReportWhenId}
|
||||||
labelKey='label'
|
labelKey='label'
|
||||||
onChange={effects.setReportWhen}
|
onChange={effects.setReportWhen}
|
||||||
optionRenderer={getOptionRenderer}
|
optionRenderer={getOptionRenderer}
|
||||||
options={REPORT_WHEN_FILTER_OPTIONS}
|
options={REPORT_WHEN_FILTER_OPTIONS}
|
||||||
required
|
required
|
||||||
value={state.reportWhen}
|
value={state.reportWhen || jobReportWhen}
|
||||||
valueKey='value'
|
valueKey='value'
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
<FormGroup>
|
<FormGroup>
|
||||||
<label>
|
<label htmlFor={state.inputConcurrencyId}>
|
||||||
<strong>{_('concurrency')}</strong>
|
<strong>{_('concurrency')}</strong>
|
||||||
</label>
|
</label>
|
||||||
<Number
|
<Number
|
||||||
min='0'
|
id={state.inputConcurrencyId}
|
||||||
onChange={effects.setConcurrency}
|
onChange={effects.setConcurrency}
|
||||||
required
|
value={defined(state.concurrency, jobConcurrency)}
|
||||||
value={state.concurrency}
|
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
<FormGroup>
|
<FormGroup>
|
||||||
@ -876,7 +884,10 @@ export default [
|
|||||||
<Icon icon='info' />
|
<Icon icon='info' />
|
||||||
</Tooltip>{' '}
|
</Tooltip>{' '}
|
||||||
<input
|
<input
|
||||||
checked={state.offlineSnapshot}
|
checked={defined(
|
||||||
|
state.offlineSnapshot,
|
||||||
|
jobOfflineSnapshot
|
||||||
|
)}
|
||||||
name='offlineSnapshot'
|
name='offlineSnapshot'
|
||||||
onChange={effects.setCheckboxValue}
|
onChange={effects.setCheckboxValue}
|
||||||
type='checkbox'
|
type='checkbox'
|
||||||
|
Loading…
Reference in New Issue
Block a user