Skip to content

Commit

Permalink
feedbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
MathieuRA committed May 30, 2023
1 parent 2a408ae commit a5f74ee
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 100 deletions.
2 changes: 1 addition & 1 deletion packages/xo-web/src/common/intl/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ const messages = {
backupVms: 'Backup VMs',
backupMetadata: 'Backup metadata',
mirrorBackup: 'Mirror backup',
mirrorBackupVms: 'Mirror Backup VMs',
mirrorBackupVms: 'Mirror backup VMs',
jobsOverviewPage: 'Overview',
jobsNewPage: 'New',
jobsSchedulingPage: 'Scheduling',
Expand Down
3 changes: 1 addition & 2 deletions packages/xo-web/src/icons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,9 @@
@extend .fa;
@extend .fa-check;
}
// @TODO: Check for another icon
&-mirror-backup {
@extend .fa;
@extend .fa-files-o
@extend .fa-files-o;
}
&-restore {
@extend .fa;
Expand Down
6 changes: 3 additions & 3 deletions packages/xo-web/src/xo-app/backup/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ export default decorate([
addSubscriptions({
jobs: subscribeBackupNgJobs,
metadataJobs: subscribeMetadataBackupJobs,
mirrorBackupJob: subscribeMirrorBackupJobs,
mirrorBackupJobs: subscribeMirrorBackupJobs,
schedulesByJob: cb =>
subscribeSchedules(schedules => {
cb(groupBy(schedules, 'jobId'))
}),
}),
provideState({
computed: {
job: (_, { jobs, metadataJobs, mirrorBackupJob, routeParams: { id } }) =>
defined(find(jobs, { id }), find(metadataJobs, { id }), find(mirrorBackupJob, { id })),
job: (_, { jobs, metadataJobs, mirrorBackupJobs, routeParams: { id } }) =>
defined(find(jobs, { id }), find(metadataJobs, { id }), find(mirrorBackupJobs, { id })),
schedules: (_, { schedulesByJob, routeParams: { id } }) => schedulesByJob && keyBy(schedulesByJob[id], 'id'),
loading: (_, props) =>
props.jobs === undefined || props.metadataJobs === undefined || props.schedulesByJob === undefined,
Expand Down
4 changes: 2 additions & 2 deletions packages/xo-web/src/xo-app/backup/new/_schedules/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ const Schedules = decorate([
...newSetting
} = await form({
defaultValue: setDefaultRetentions({ cron, name, timezone, ...setting }, state.retentions),
render: _props => (
<NewSchedule retentions={state.retentions} withHealthCheck={props.withHealthCheck} {..._props} />
render: formProps => (
<NewSchedule retentions={state.retentions} withHealthCheck={props.withHealthCheck} {...formProps} />
),
header: (
<span>
Expand Down
157 changes: 72 additions & 85 deletions packages/xo-web/src/xo-app/backup/new/mirror/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ const getInitialState = ({ job = {}, schedules = {} }) => {

sourceRemote: job.sourceRemote ?? {},
targetRemoteIds,
deleteFirstRemoteIds: [],

advancedSettings: advancedSettings ?? {},
proxyId: job.proxy ?? undefined,
Expand All @@ -62,32 +61,22 @@ const getInitialState = ({ job = {}, schedules = {} }) => {
}

const normalize = state => {
const {
name,
proxyId,
sourceRemote,
targetRemoteIds,
settings,
advancedSettings,
reportWhen,
reportRecipients,
} = state
const { name, proxyId, sourceRemote, targetRemoteIds, settings, advancedSettings, reportWhen, reportRecipients } =
state
let { schedules, mode } = state

schedules = mapValues(schedules, ({ id, ...schedule }) => schedule)
mode = state.isIncremental ? 'delta' : mode
settings[''] = {
...advancedSettings,
reportWhen: reportWhen.value,
reportRecipients: reportRecipients.length !== 0 ? reportRecipients : undefined,
}
const remotes = constructPattern(targetRemoteIds)
return {
name,
mode,
mode: state.isIncremental ? 'delta' : mode,
proxy: proxyId,
sourceRemote: resolveId(sourceRemote),
remotes,
remotes: constructPattern(targetRemoteIds),
schedules,
settings,
}
Expand All @@ -103,7 +92,6 @@ const NewMirrorBackup = decorate([
}),
deleteTargetRemoteId: (_, id) => state => ({
targetRemoteIds: state.targetRemoteIds.filter(remoteId => remoteId !== id),
deleteFirstRemoteIds: state.deleteFirstRemoteIds.filter(_id => id !== _id),
}),
setTargetDeleteFirst: (_, id) => state => ({
settings: {
Expand All @@ -119,7 +107,7 @@ const NewMirrorBackup = decorate([
setProxy: (_, id) => () => ({
proxyId: id,
}),
setReportWhen: (_, _reportWhen) => () => ({ reportWhen: _reportWhen === 'Never' ? 'never' : _reportWhen }),
setReportWhen: (_, reportWhen) => () => ({ reportWhen }),
addReportRecipient: (_, recipient) => state => ({
reportRecipients: !state.reportRecipients.includes(recipient)
? [...state.reportRecipients, recipient]
Expand All @@ -132,7 +120,7 @@ const NewMirrorBackup = decorate([
}
},
setConcurrency: ({ setAdvancedSettings }, concurrency) => setAdvancedSettings({ concurrency }),
setTimout: ({ setAdvancedSettings }, timeout) =>
setTimeout: ({ setAdvancedSettings }, timeout) =>
setAdvancedSettings({ timeout: timeout !== undefined ? timeout * 3600e3 : undefined }),
setMaxExportRate: ({ setAdvancedSettings }, rate) =>
setAdvancedSettings({ maxExportRate: rate !== undefined ? rate * (1024 * 1024) : undefined }),
Expand Down Expand Up @@ -214,7 +202,7 @@ const NewMirrorBackup = decorate([
computed: {
formId: generateId,
inputConcurrencyId: generateId,
inputTimoutId: generateId,
inputTimeoutId: generateId,
inputMaxExportRateId: generateId,
isBackupInvalid: state =>
state.isMissingName || state.isMissingBackupMode || state.isMissingSchedules || state.isMissingRetention,
Expand Down Expand Up @@ -286,13 +274,77 @@ const NewMirrorBackup = decorate([
{_('mirrorFullBackup')}
</ActionButton>{' '}
<br />
{/* @TODO Mirror doc backup? */}
<a className='text-muted' href={BACKUP_NG_DOC_LINK} rel='noopener noreferrer' target='_blank'>
<Icon icon='info' /> {_('backupNgLinkToDocumentationMessage')}
</a>
</div>
</CardBlock>
</FormFeedback>
<Card>
<CardHeader>
{_('newBackupSettings')}
<ActionButton
className='pull-right'
handler={effects.toggleAdvancedSettings}
icon={state.displayAdvancedSettings ? 'toggle-on' : 'toggle-off'}
iconColor={state.displayAdvancedSettings ? 'text-success' : undefined}
size='small'
>
{_('newBackupAdvancedSettings')}
</ActionButton>
</CardHeader>
<CardBlock>
<RemoteProxy onChange={effects.setProxy} value={state.proxyId} />
<ReportWhen value={state.reportWhen} required onChange={effects.setReportWhen} />
<ReportRecipients
recipients={state.reportRecipients}
add={effects.addReportRecipient}
remove={effects.removeReportRecipient}
/>
{state.displayAdvancedSettings && (
<div>
<FormGroup>
<label htmlFor={state.inputConcurrencyId}>
<strong>{_('concurrency')}</strong>
</label>
<Number
id={state.inputConcurrencyId}
min={1}
onChange={effects.setConcurrency}
value={concurrency}
/>
</FormGroup>
<FormGroup>
<label htmlFor={state.inputTimeoutId}>
<strong>{_('timeout')}</strong>
</label>{' '}
<Tooltip content={_('timeoutInfo')}>
<Icon icon='info' />
</Tooltip>
<Number
id={state.inputTimeoutId}
onChange={effects.setTimeout}
value={timeout ? timeout / 3600e3 : undefined}
placeholder={formatMessage(messages.timeoutUnit)}
/>
</FormGroup>
<FormGroup>
<label htmlFor={state.inputMaxExportRateId}>
<strong>{_('speedLimit')}</strong>
</label>
<Number
id={state.inputMaxExportRateId}
min={0}
onChange={effects.setMaxExportRate}
value={maxExportRate / (1024 * 1024)}
/>
</FormGroup>
</div>
)}
</CardBlock>
</Card>
</Col>
<Col mediumSize={6}>
<Card>
<CardHeader>
{_(
Expand Down Expand Up @@ -357,8 +409,6 @@ const NewMirrorBackup = decorate([
</FormGroup>
</CardBlock>
</Card>
</Col>
<Col mediumSize={6}>
<Schedules
handlerSchedules={effects.setSchedules}
handlerSettings={effects.setSettings}
Expand All @@ -369,69 +419,6 @@ const NewMirrorBackup = decorate([
settings={state.settings}
withHealthCheck
/>
<Card>
<CardHeader>
{_('newBackupSettings')}
<ActionButton
className='pull-right'
handler={effects.toggleAdvancedSettings}
icon={state.displayAdvancedSettings ? 'toggle-on' : 'toggle-off'}
iconColor={state.displayAdvancedSettings ? 'text-success' : undefined}
size='small'
>
{_('newBackupAdvancedSettings')}
</ActionButton>
</CardHeader>
<CardBlock>
<RemoteProxy onChange={effects.setProxy} value={state.proxyId} />
<ReportWhen value={state.reportWhen} required onChange={effects.setReportWhen} />
<ReportRecipients
recipients={state.reportRecipients}
add={effects.addReportRecipient}
remove={effects.removeReportRecipient}
/>
{state.displayAdvancedSettings && (
<div>
<FormGroup>
<label htmlFor={state.inputConcurrencyId}>
<strong>{_('concurrency')}</strong>
</label>
<Number
id={state.inputConcurrencyId}
min={1}
onChange={effects.setConcurrency}
value={concurrency}
/>
</FormGroup>
<FormGroup>
<label htmlFor={state.inputTimoutId}>
<strong>{_('timeout')}</strong>
</label>{' '}
<Tooltip content={_('timeoutInfo')}>
<Icon icon='info' />
</Tooltip>
<Number
id={state.inputTimoutId}
onChange={effects.setTimout}
value={timeout ? timeout / 3600e3 : undefined}
placeholder={formatMessage(messages.timeoutUnit)}
/>
</FormGroup>
<FormGroup>
<label htmlFor={state.inputMaxExportRateId}>
<strong>{_('speedLimit')}</strong>
</label>
<Number
id={state.inputMaxExportRateId}
min={0}
onChange={effects.setMaxExportRate}
value={maxExportRate / (1024 * 1024)}
/>
</FormGroup>
</div>
)}
</CardBlock>
</Card>
</Col>
</Row>
<Row>
Expand Down
12 changes: 5 additions & 7 deletions packages/xo-web/src/xo-app/backup/overview/tab-jobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,11 @@ const _runBackupJob = ({ id, name, nVms, schedule, type }) =>
})}
</span>
),
}).then(() =>
type === 'backup'
? runBackupNgJob({ id, schedule })
: isMirrorBackup({ type })
? runMirrorBackupJob({ id, schedule })
: runMetadataBackupJob({ id, schedule })
)
}).then(() => {
const method =
type === 'backup' ? runBackupNgJob : isMirrorBackup({ type }) ? runMirrorBackupJob : runMetadataBackupJob
return method({ id, schedule })
})

const CURSOR_POINTER_STYLE = { cursor: 'pointer' }
const GoToLogs = decorate([
Expand Down

0 comments on commit a5f74ee

Please sign in to comment.