diff --git a/client/src/campaigns/CUD.js b/client/src/campaigns/CUD.js index 3ce6b395..bc0fb9d7 100644 --- a/client/src/campaigns/CUD.js +++ b/client/src/campaigns/CUD.js @@ -35,6 +35,7 @@ import moment from 'moment'; import {getMailerTypes} from "../send-configurations/helpers"; import {getCampaignLabels} from "./helpers"; import {withComponentMixins} from "../lib/decorator-helpers"; +import interoperableErrors from "../../../shared/interoperable-errors"; @withComponentMixins([ withTranslation, @@ -157,12 +158,22 @@ export default class CUD extends Component { if (sendConfigurationId) { this.fetchSendConfigurationId = sendConfigurationId; - const result = await axios.get(getUrl(`rest/send-configurations-public/${sendConfigurationId}`)); + try { + const result = await axios.get(getUrl(`rest/send-configurations-public/${sendConfigurationId}`)); - if (sendConfigurationId === this.fetchSendConfigurationId) { - this.setState({ - sendConfiguration: result.data - }); + if (sendConfigurationId === this.fetchSendConfigurationId) { + this.setState({ + sendConfiguration: result.data + }); + } + } catch (err) { + if (err instanceof interoperableErrors.PermissionDeniedError) { + this.setState({ + sendConfiguration: null + }); + } else { + throw err; + } } } } diff --git a/client/src/campaigns/Status.js b/client/src/campaigns/Status.js index ef1c9617..494e825d 100644 --- a/client/src/campaigns/Status.js +++ b/client/src/campaigns/Status.js @@ -490,7 +490,8 @@ export default class Status extends Component { this.state = { entity: props.entity, - sendConfiguration: null + sendConfiguration: null, + sendConfigurationNotPermitted: false }; const { campaignTypeLabels, campaignStatusLabels } = getCampaignLabels(t); @@ -507,18 +508,26 @@ export default class Status extends Component { @withAsyncErrorHandler async refreshEntity() { + const newState = {} + let resp; resp = await axios.get(getUrl(`rest/campaigns-stats/${this.props.entity.id}`)); - const entity = resp.data; + newState.entity = resp.data; - resp = await axios.get(getUrl(`rest/send-configurations-public/${entity.send_configuration}`)); - const sendConfiguration = resp.data; + try { + resp = await axios.get(getUrl(`rest/send-configurations-public/${newState.entity.send_configuration}`)); + newState.sendConfiguration = resp.data; + } catch (err) { + if (err instanceof interoperableErrors.PermissionDeniedError) { + newState.sendConfiguration = null; + newState.sendConfigurationNotPermitted = true; + } else { + throw err; + } + } - this.setState({ - entity, - sendConfiguration - }); + this.setState(newState); } async periodicRefreshTask() { @@ -563,7 +572,11 @@ export default class Status extends Component { addOverridable('reply_to', t('replytoEmailAddress')); sendSettings.push({entity.subject}); } else { - sendSettings = {t('loadingSendConfiguration')} + if (this.state.sendConfigurationNotPermitted) { + sendSettings = null; + } else { + sendSettings = {t('loadingSendConfiguration')} + } } const listsColumns = [ diff --git a/client/src/lib/table.js b/client/src/lib/table.js index 0d11194f..f58c840f 100644 --- a/client/src/lib/table.js +++ b/client/src/lib/table.js @@ -150,12 +150,18 @@ class Table extends Component { values: keysToFetch }); + const oldSelectionMap = this.selectionMap; + this.selectionMap = new Map(); for (const row of response.data) { const key = row[this.props.selectionKeyIndex]; - if (this.selectionMap.has(key)) { - this.selectionMap.set(key, row); + if (oldSelectionMap.has(key)) { + this.selectionMap.set(key, row) } } + + if (this.selectionMap.size !== oldSelectionMap.size) { + this.notifySelection(this.props.onSelectionChangedAsync, this.selectionMap); + } } }