diff --git a/UPGRADE.md b/UPGRADE.md new file mode 100644 index 00000000..9d16d0dd --- /dev/null +++ b/UPGRADE.md @@ -0,0 +1,13 @@ +## Migration from Mailtrain v1 to Mailtrain v2 + +The migration should almost happen automatically. There are however the following caveats: + +1. Structure of config files (under `config`) has changed at many places. Revisit the default config (`config/default.toml`) + and update your configs accordingly. + +2. Images uploaded in a template editor (Mosaico, GrapeJS, etc.) need to be manually moved to a new destination (under `client`). + For Mosaico, this means to move folders named by a number from `public/mosaico` to `client/public/mosaico`. + +3. Directory for custom Mosaico templates has changed from `public/mosaico/templates` to `client/public/mosaico/templates`. + +4. Imports are not migrated. If you have any pending imports, complete them before migration to v2. \ No newline at end of file diff --git a/client/src/campaigns/CUD.js b/client/src/campaigns/CUD.js index 6fdd3577..07f7b619 100644 --- a/client/src/campaigns/CUD.js +++ b/client/src/campaigns/CUD.js @@ -217,34 +217,28 @@ export default class CUD extends Component { const t = this.props.t; const isEdit = !!this.props.entity; + for (const key of state.keys()) { + state.setIn([key, 'error'], null); + } + if (!state.getIn(['name', 'value'])) { state.setIn(['name', 'error'], t('Name must not be empty')); - } else { - state.setIn(['name', 'error'], null); } if (!state.getIn(['list', 'value'])) { state.setIn(['list', 'error'], t('List must be selected')); - } else { - state.setIn(['list', 'error'], null); } if (state.getIn(['useSegmentation', 'value']) && !state.getIn(['segment', 'value'])) { state.setIn(['segment', 'error'], t('Segment must be selected')); - } else { - state.setIn(['segment', 'error'], null); } if (!state.getIn(['send_configuration', 'value'])) { state.setIn(['send_configuration', 'error'], t('Send configuration must be selected')); - } else { - state.setIn(['send_configuration', 'error'], null); } if (state.getIn(['from_email_overriden', 'value']) && !state.getIn(['from_email_override', 'value'])) { state.setIn(['from_email_override', 'error'], t('"From" email must not be empty')); - } else { - state.setIn(['from_email_override', 'error'], null); } @@ -252,12 +246,6 @@ export default class CUD extends Component { const sourceTypeKey = Number.parseInt(state.getIn(['source', 'value'])); - for (const key of state.keys()) { - if (key.startsWith('data_')) { - state.setIn([key, 'error'], null); - } - } - if (sourceTypeKey === CampaignSource.TEMPLATE || (!isEdit && sourceTypeKey === CampaignSource.CUSTOM_FROM_TEMPLATE)) { if (!state.getIn(['data_sourceTemplate', 'value'])) { state.setIn(['data_sourceTemplate', 'error'], t('Template must be selected')); @@ -292,7 +280,6 @@ export default class CUD extends Component { } validateNamespace(t, state); - } async submitHandler() { @@ -361,8 +348,11 @@ export default class CUD extends Component { }); if (submitResponse) { + const sourceTypeKey = Number.parseInt(this.getFormValue('source')); if (this.props.entity) { this.navigateToWithFlashMessage('/campaigns', 'success', t('Campaign saved')); + } else if (sourceTypeKey === CampaignSource.CUSTOM || sourceTypeKey === CampaignSource.CUSTOM_FROM_TEMPLATE || sourceTypeKey === CampaignSource.CUSTOM_FROM_CAMPAIGN) { + this.navigateToWithFlashMessage(`/campaigns/${submitResponse}/content`, 'success', t('Campaign saved')); } else { this.navigateToWithFlashMessage(`/campaigns/${submitResponse}/edit`, 'success', t('Campaign saved')); } @@ -494,6 +484,14 @@ export default class CUD extends Component { templateEdit = } + let saveButtonLabel; + if (isEdit) { + saveButtonLabel = t('Save'); + } else if (sourceTypeKey === CampaignSource.CUSTOM || sourceTypeKey === CampaignSource.CUSTOM_FROM_TEMPLATE || sourceTypeKey === CampaignSource.CUSTOM_FROM_CAMPAIGN) { + saveButtonLabel = t('Save and edit content'); + } else { + saveButtonLabel = t('Save and edit campaign'); + } return (
@@ -545,7 +543,7 @@ export default class CUD extends Component { {templateEdit} -