From 965f30cea7052a4e0f9c12318d9194b6612f88a8 Mon Sep 17 00:00:00 2001 From: Tomas Bures Date: Sat, 4 Aug 2018 15:00:37 +0530 Subject: [PATCH] Editing of triggers seems to work. Some further fixes. --- UPGRADE.md | 13 + client/src/campaigns/CUD.js | 34 +- client/src/campaigns/List.js | 8 + client/src/campaigns/root.js | 33 +- client/src/campaigns/triggers/CUD.js | 237 +++++++++++++ client/src/campaigns/triggers/List.js | 81 +++++ client/src/campaigns/triggers/helpers.js | 35 ++ client/src/lib/urls.js | 5 +- client/src/lists/List.js | 13 +- client/src/lists/TriggersList.js | 75 ++++ client/src/lists/root.js | 7 +- client/src/templates/CUD.js | 8 +- client/src/templates/helpers.js | 8 +- config/default.toml | 322 ------------------ config/default.yaml | 268 +++++++++++++++ lib/urls.js | 3 +- models/campaigns.js | 18 +- models/lists.js | 14 +- models/triggers.js | 24 +- routes/rest/campaigns.js | 5 + .../migrations/20170506102634_v1_to_v2.js | 6 +- shared/triggers.js | 8 +- shared/urls.js | 7 + 23 files changed, 855 insertions(+), 377 deletions(-) create mode 100644 UPGRADE.md create mode 100644 client/src/campaigns/triggers/CUD.js create mode 100644 client/src/campaigns/triggers/List.js create mode 100644 client/src/campaigns/triggers/helpers.js create mode 100644 client/src/lists/TriggersList.js delete mode 100644 config/default.toml create mode 100644 config/default.yaml create mode 100644 shared/urls.js 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} -