Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(backup-ng/new): group saved & new schedules #3093

Merged
merged 3 commits into from Jun 22, 2018

Conversation

badrAZ
Copy link
Contributor

@badrAZ badrAZ commented Jun 22, 2018

See #2711

Check list

Check items when done or if not relevant

  • PR reference the relevant issue (e.g. Fixes #007)
  • if UI changes, a screenshot has been added to the PR
  • CHANGELOG updated
  • documentation updated

Process

  1. create a PR as soon as possible
  2. mark it as WiP: (Work in Progress) if not ready to be merged
  3. when you want a review, add a reviewer
  4. if necessary, update your PR, and readd a reviewer

List of packages to release

No need to mention xo-server and xo-web.

@badrAZ badrAZ self-assigned this Jun 22, 2018
@julien-f julien-f mentioned this pull request Jun 22, 2018
40 tasks
@badrAZ badrAZ requested a review from julien-f June 22, 2018 11:40
@badrAZ badrAZ changed the title [WiP] feat(backup-ng/new): group saved & new schedules feat(backup-ng/new): group saved & new schedules Jun 22, 2018
@@ -47,14 +46,21 @@ import { FormFeedback, FormGroup, Input, Number, Ul, Li } from './utils'

const normaliseTagValues = values => resolveIds(values).map(value => [value])

const normaliseCopyRentention = settings => {
const normaliseCopyRetention = settings => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...getNewSettings({
schedules: state.newSchedules,
...normaliseSettings({
settings: cloneDeep(state.settings),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need to clone this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the function normalizeSettings mutate the settings' properties in deep.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, my bad 🙂

@badrAZ badrAZ requested a review from julien-f June 22, 2018 12:33
@@ -202,10 +178,10 @@ export default [
name: state.name,
mode: state.isDelta ? 'delta' : 'full',
compression: state.compression ? 'native' : '',
schedules: getNewSchedules(state.newSchedules),
schedules: normalizeSchedules(cloneDeep(state.schedules)),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO, this would be simpler:

schedules: mapValues(state.schedules, ({ id, ...schedule }) => schedule)


if (newSchedule === undefined) {
return deleteSchedule(scheduleId)
return deleteSchedule(id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is settings correctly updated regarding this deletion?

Copy link
Contributor Author

@badrAZ badrAZ Jun 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, the effect deleteSchedule update the schedules and settings vars.

) {
return editSchedule({
id,
jobId: props.job.id,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need to send this property?

Can it change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, i will fix it.

})
if (
newSchedule.cron !== oldSchedule.cron ||
newSchedule.timezone !== oldSchedule.timezone
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newSchedule should simply contains the values that has been edited by the user.

const newSetting = settings[id]
const settings = cloneDeep(state.settings)
await Promise.all([
...map(state.schedules, async schedule => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why [...map()]?

Copy link
Contributor Author

@badrAZ badrAZ Jun 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an error, i will fix it.

for (const id in oldSettings) {
const oldSetting = oldSettings[id]
const newSetting = settings[id]
const settings = cloneDeep(state.settings)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you really need cloneDeep?
Isn't { ...state.settings } enough?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, my bad, due to the normalizeSettings below.

@julien-f julien-f merged commit 3b244c2 into master Jun 22, 2018
@julien-f julien-f deleted the backupNG-groupeSchedules branch July 20, 2018 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants