This commit is contained in:
Tomas Bures 2019-08-21 13:18:03 +02:00
parent ebb6c2ff74
commit a17ee3d9bf
3 changed files with 46 additions and 16 deletions

View file

@ -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;
}
}
}
}

View file

@ -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(<AlignedRow key="subject" label={t('subjectLine')}>{entity.subject}</AlignedRow>);
} else {
sendSettings = <AlignedRow>{t('loadingSendConfiguration')}</AlignedRow>
if (this.state.sendConfigurationNotPermitted) {
sendSettings = null;
} else {
sendSettings = <AlignedRow>{t('loadingSendConfiguration')}</AlignedRow>
}
}
const listsColumns = [

View file

@ -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);
}
}
}