Skip to content

Commit

Permalink
BUG Display a notification after publishing a campaign
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxime Rainville committed Nov 15, 2020
1 parent 921b049 commit 1a14b83
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions client/lang/src/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
"CampaignAdmin.NO_CHANGES": "No changes",
"CampaignAdmin.PUBLISHCAMPAIGN": "Publish campaign",
"CampaignAdmin.REMOVED": "Removed",
"CampaignAdmin.REVERTCAMPAIGN": "Revert"
}
"CampaignAdmin.REVERTCAMPAIGN": "Revert",
"CampaignAdmin.PUBLISH_FAIL": "Campaign could not be published.",
"CampaignAdmin.PUBLISH_SUCCESS": "\"%s\" campaign has been published."
}
12 changes: 12 additions & 0 deletions client/src/state/campaign/CampaignActions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* global window */
import ACTION_TYPES from './CampaignActionTypes';
import RECORD_ACTION_TYPES from 'state/records/RecordsActionTypes';
import * as toastsActions from 'state/toasts/ToastsActions';
import i18n from 'i18n';

export function setShowMessage(show, storage = window.localStorage) {
storage.setItem('campaign.showMessage', show);
Expand Down Expand Up @@ -64,12 +66,22 @@ export function publishCampaign(publishApi, recordType, campaignId) {
type: RECORD_ACTION_TYPES.FETCH_RECORD_SUCCESS,
payload: { recordType, data },
});
const message = i18n._t(
'CampaignAdmin.PUBLISH_SUCCESS',
'"%s" campaign has been published.'
);
dispatch(toastsActions.success(i18n.sprintf(message, data.Name)));
})
.catch((error) => {
dispatch({
type: ACTION_TYPES.PUBLISH_CAMPAIGN_FAILURE,
payload: { error },
});

const message = typeof error === 'string'
? error
: i18n._t('CampaignAdmin.PUBLISH_FAIL', 'Campaign could not be published.');
dispatch(toastsActions.error(message));
});
};
}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
},
"scripts": {
"build": "yarn && yarn lint && yarn test && NODE_ENV=production webpack -p --bail --progress",
"dev": "NODE_ENV=development webpack --progress",
"watch": "yarn && NODE_ENV=development webpack --watch --progress",
"css": "yarn && WEBPACK_CHILD=css webpack -p --bail --progress",
"test": "jest",
Expand Down

0 comments on commit 1a14b83

Please sign in to comment.