@capillarytech/creatives-library 6.12.12 → 6.12.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capillarytech/creatives-library",
|
|
3
3
|
"author": "meharaj",
|
|
4
|
-
"version": "6.12.
|
|
4
|
+
"version": "6.12.14",
|
|
5
5
|
"description": "Capillary creatives ui",
|
|
6
6
|
"main": "./index.js",
|
|
7
7
|
"module": "./index.es.js",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"@babel/polyfill": "7.4.3",
|
|
16
16
|
"@bugsnag/js": "^7.2.1",
|
|
17
17
|
"@bugsnag/plugin-react": "^7.2.1",
|
|
18
|
-
"@capillarytech/cap-ui-utils": "
|
|
18
|
+
"@capillarytech/cap-ui-utils": "1.2.8",
|
|
19
19
|
"@mailupinc/bee-plugin": "^1.2.0",
|
|
20
20
|
"babel-cli": "^6.26.0",
|
|
21
21
|
"chalk": "1.1.3",
|
|
@@ -31,3 +31,7 @@ export const CLEAR_TOPBAR_MENU_DATA = 'creatives/cap/CLEAR_TOPBAR_MENU_DATA';
|
|
|
31
31
|
export const CAMPAIGN_SETTINGS_URL = '/creatives/settings/message';
|
|
32
32
|
export const ORG_SETTINGS_URL = '/org/index';
|
|
33
33
|
export const HELP_URL = 'https://support.capillarytech.com/en/support/solutions/4000007853';
|
|
34
|
+
|
|
35
|
+
export const ORG_REFRESH_SEC = 10;
|
|
36
|
+
export const ORG_CHANGED = 'ORG_CHANGED';
|
|
37
|
+
|
|
@@ -2,15 +2,15 @@ import PropTypes from 'prop-types';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import Helmet from 'react-helmet';
|
|
4
4
|
import { connect } from 'react-redux';
|
|
5
|
-
import {CapNotification} from '@capillarytech/cap-ui-library';
|
|
5
|
+
import { CapNotification, CapModal, CapSnackBar } from '@capillarytech/cap-ui-library';
|
|
6
6
|
import { bindActionCreators } from 'redux';
|
|
7
7
|
import styled from 'styled-components';
|
|
8
8
|
import { createStructuredSelector } from 'reselect';
|
|
9
9
|
import _ from 'lodash';
|
|
10
10
|
import moment from 'moment';
|
|
11
11
|
// import 'moment/locale/zh-cn';
|
|
12
|
-
import { GA } from '@capillarytech/cap-ui-utils';
|
|
13
|
-
import { injectIntl, FormattedMessage } from 'react-intl';
|
|
12
|
+
import { GA, multipleOrgSwitch, utilsSessionStorageApi } from '@capillarytech/cap-ui-utils';
|
|
13
|
+
import { injectIntl, FormattedMessage, intlShape, FormattedHTMLMessage } from 'react-intl';
|
|
14
14
|
import messages from './messages';
|
|
15
15
|
import { makeSelectAuthenticated, makeSelectUser } from './selectors';
|
|
16
16
|
import * as actions from './actions';
|
|
@@ -25,8 +25,24 @@ import {
|
|
|
25
25
|
HELP_URL,
|
|
26
26
|
ORG_SETTINGS_URL,
|
|
27
27
|
CAMPAIGN_SETTINGS_URL,
|
|
28
|
+
ORG_REFRESH_SEC,
|
|
29
|
+
ORG_CHANGED
|
|
28
30
|
} from './constants';
|
|
31
|
+
import './_cap.scss';
|
|
32
|
+
import { BugsnagClient } from '../../app';
|
|
33
|
+
|
|
29
34
|
const gtm = window.dataLayer || [];
|
|
35
|
+
const {
|
|
36
|
+
logNewTab,
|
|
37
|
+
getOrgNameFromId,
|
|
38
|
+
tabBeforeUnloadEventHandler,
|
|
39
|
+
utilsHandleStorageChange,
|
|
40
|
+
isMultipleTabsOpen,
|
|
41
|
+
} = multipleOrgSwitch;
|
|
42
|
+
const {
|
|
43
|
+
loadSessionItem,
|
|
44
|
+
saveSessionItem,
|
|
45
|
+
} = utilsSessionStorageApi;
|
|
30
46
|
|
|
31
47
|
const CapWrapper = styled.div`
|
|
32
48
|
margin: 0 auto;
|
|
@@ -45,6 +61,11 @@ export class Cap extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
45
61
|
this.state = {
|
|
46
62
|
switchedOrg: false,
|
|
47
63
|
isCreativesAccessible: true,
|
|
64
|
+
refreshSeconds: ORG_REFRESH_SEC,
|
|
65
|
+
selectedOrgId: null,
|
|
66
|
+
showRefreshModal: false,
|
|
67
|
+
showOrgChangeModal: false,
|
|
68
|
+
localStorageOrgInfo: { oldValue: null, newValue: null },
|
|
48
69
|
};
|
|
49
70
|
this.changeOrg = this.changeOrg.bind(this);
|
|
50
71
|
this.logout = this.logout.bind(this);
|
|
@@ -85,6 +106,14 @@ export class Cap extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
85
106
|
//locale = 'zh';
|
|
86
107
|
console.log('Setting final locale as', locale);
|
|
87
108
|
moment.locale(locale);
|
|
109
|
+
window.addEventListener('storage', this.handleStorageChange, false);
|
|
110
|
+
document.addEventListener(
|
|
111
|
+
'visibilitychange',
|
|
112
|
+
this.handleVisibilityChange,
|
|
113
|
+
false,
|
|
114
|
+
);
|
|
115
|
+
window.addEventListener('pageshow', this.tabOnloadEventHandler, false);
|
|
116
|
+
window.addEventListener('pagehide', tabBeforeUnloadEventHandler, false);
|
|
88
117
|
}
|
|
89
118
|
|
|
90
119
|
componentWillReceiveProps(nextProps) {
|
|
@@ -119,10 +148,41 @@ export class Cap extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
119
148
|
}
|
|
120
149
|
}
|
|
121
150
|
|
|
151
|
+
componentDidUpdate(prevProps) {
|
|
152
|
+
if (
|
|
153
|
+
!(prevProps.Global.currentOrgDetails) &&
|
|
154
|
+
this.props.Global.currentOrgDetails &&
|
|
155
|
+
loadSessionItem(ORG_CHANGED)
|
|
156
|
+
) {
|
|
157
|
+
this.showOrgChangeSnackBar();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
122
161
|
componentWillUnmount() {
|
|
123
162
|
this.setState({ switchedOrg: false });
|
|
124
163
|
this.props.actions.clearTopbarMenuData();
|
|
164
|
+
window.removeEventListener('storage', this.handleStorageChange, false);
|
|
165
|
+
document.removeEventListener(
|
|
166
|
+
'visibilitychange',
|
|
167
|
+
this.handleVisibilityChange,
|
|
168
|
+
false,
|
|
169
|
+
);
|
|
170
|
+
window.removeEventListener(
|
|
171
|
+
'pageshow',
|
|
172
|
+
this.tabOnloadEventHandler,
|
|
173
|
+
false,
|
|
174
|
+
);
|
|
175
|
+
window.removeEventListener(
|
|
176
|
+
'pagehide',
|
|
177
|
+
tabBeforeUnloadEventHandler,
|
|
178
|
+
false,
|
|
179
|
+
);
|
|
125
180
|
}
|
|
181
|
+
|
|
182
|
+
tabOnloadEventHandler = () => {
|
|
183
|
+
logNewTab(BugsnagClient);
|
|
184
|
+
}
|
|
185
|
+
|
|
126
186
|
setDimensionData() {
|
|
127
187
|
const userGtmData = this.getUserGtmData();
|
|
128
188
|
Object.values(userGtmData).forEach((value, index) => {
|
|
@@ -158,6 +218,7 @@ export class Cap extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
158
218
|
};
|
|
159
219
|
return map[locale];
|
|
160
220
|
}
|
|
221
|
+
|
|
161
222
|
handleRemoveMessage(messageIndex) {
|
|
162
223
|
this.props.actions.removeMessageFromQueue(messageIndex);
|
|
163
224
|
}
|
|
@@ -172,17 +233,157 @@ export class Cap extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
172
233
|
this.props.actions.logout();
|
|
173
234
|
}
|
|
174
235
|
changeOrg(orgId) {
|
|
175
|
-
|
|
176
|
-
|
|
236
|
+
//display orgChangeModal if more than one tabs is open
|
|
237
|
+
if (isMultipleTabsOpen()) {
|
|
238
|
+
this.setState({
|
|
239
|
+
showOrgChangeModal: true,
|
|
240
|
+
selectedOrgId: orgId,
|
|
241
|
+
});
|
|
242
|
+
} else {
|
|
243
|
+
this.props.actions.changeOrg(orgId);
|
|
244
|
+
}
|
|
177
245
|
}
|
|
178
246
|
|
|
247
|
+
showOrgChangeSnackBar = () => {
|
|
248
|
+
saveSessionItem(ORG_CHANGED, false);
|
|
249
|
+
const {
|
|
250
|
+
Global: {
|
|
251
|
+
currentOrgDetails: {
|
|
252
|
+
basic_details: { name: currentOrgName } = {},
|
|
253
|
+
} = {},
|
|
254
|
+
} = {},
|
|
255
|
+
intl: { formatMessage } = {},
|
|
256
|
+
} = this.props;
|
|
257
|
+
CapSnackBar.warning({
|
|
258
|
+
content: (
|
|
259
|
+
<div>
|
|
260
|
+
{formatMessage(messages.orgChangedText)}
|
|
261
|
+
<b>
|
|
262
|
+
{formatMessage(messages.newOrgName, {
|
|
263
|
+
newOrgName: currentOrgName,
|
|
264
|
+
})}
|
|
265
|
+
</b>
|
|
266
|
+
</div>
|
|
267
|
+
),
|
|
268
|
+
showCloseIcon: true,
|
|
269
|
+
});
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
handleVisibilityChange = () => {
|
|
273
|
+
const activeDoc = document.hidden || false;
|
|
274
|
+
const { showRefreshModal, refreshSeconds } = this.state;
|
|
275
|
+
if (
|
|
276
|
+
activeDoc === false &&
|
|
277
|
+
showRefreshModal &&
|
|
278
|
+
refreshSeconds === ORG_REFRESH_SEC
|
|
279
|
+
) {
|
|
280
|
+
const timer = setInterval(() => {
|
|
281
|
+
this.setState(prevState => ({
|
|
282
|
+
refreshSeconds: prevState.refreshSeconds - 1,
|
|
283
|
+
}));
|
|
284
|
+
}, 1000);
|
|
285
|
+
setTimeout(() => {
|
|
286
|
+
clearInterval(timer);
|
|
287
|
+
saveSessionItem(ORG_CHANGED, true);
|
|
288
|
+
this.navigateToDashboard();
|
|
289
|
+
}, refreshSeconds * 1000);
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
handleStorageChange = (e) => {
|
|
294
|
+
const { oldValue, newValue } = e;
|
|
295
|
+
if (utilsHandleStorageChange(e, 'orgID')) {
|
|
296
|
+
const localStorageOrgInfo = { oldValue, newValue };
|
|
297
|
+
this.setState({ showRefreshModal: true, localStorageOrgInfo });
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
renderOrgRefreshModal = () => {
|
|
302
|
+
const {
|
|
303
|
+
localStorageOrgInfo: { oldValue: oldOrgId, newValue: newOrgId } = {},
|
|
304
|
+
showRefreshModal,
|
|
305
|
+
refreshSeconds,
|
|
306
|
+
} = this.state;
|
|
307
|
+
const {
|
|
308
|
+
Global: { user: { proxyOrgList } = {} } = {},
|
|
309
|
+
intl: { formatMessage } = {},
|
|
310
|
+
} = this.props;
|
|
311
|
+
const oldOrgName = getOrgNameFromId(Number(oldOrgId), proxyOrgList);
|
|
312
|
+
const newOrgName = getOrgNameFromId(Number(newOrgId), proxyOrgList);
|
|
313
|
+
const modalData = (
|
|
314
|
+
<CapModal
|
|
315
|
+
title={formatMessage(messages.orgRefreshHeading)}
|
|
316
|
+
visible={showRefreshModal}
|
|
317
|
+
closable={false}
|
|
318
|
+
centered
|
|
319
|
+
maskClosable={false}
|
|
320
|
+
footer={null}
|
|
321
|
+
>
|
|
322
|
+
<div className="modal-body">
|
|
323
|
+
<span className="title">
|
|
324
|
+
<FormattedHTMLMessage
|
|
325
|
+
{...messages.refreshOrgText}
|
|
326
|
+
values={{ oldOrgName, newOrgName }}
|
|
327
|
+
/>
|
|
328
|
+
</span>
|
|
329
|
+
<div className="content seconds-right">
|
|
330
|
+
{formatMessage(messages.refreshText, {
|
|
331
|
+
time: `${refreshSeconds}s`,
|
|
332
|
+
})}
|
|
333
|
+
</div>
|
|
334
|
+
</div>
|
|
335
|
+
</CapModal>
|
|
336
|
+
);
|
|
337
|
+
return modalData;
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
renderOrgChangeModal = () => {
|
|
341
|
+
const { selectedOrgId, showOrgChangeModal } = this.state;
|
|
342
|
+
const {
|
|
343
|
+
Global: { user: { proxyOrgList } = {},
|
|
344
|
+
currentOrgDetails: { basic_details: { name: oldOrgName } = {} } = {},
|
|
345
|
+
},
|
|
346
|
+
intl: { formatMessage } = {},
|
|
347
|
+
} = this.props;
|
|
348
|
+
const newOrgName = getOrgNameFromId(selectedOrgId, proxyOrgList);
|
|
349
|
+
return (
|
|
350
|
+
<CapModal
|
|
351
|
+
className="change-org-confirm"
|
|
352
|
+
title={formatMessage(messages.areYouSureText)}
|
|
353
|
+
visible={showOrgChangeModal}
|
|
354
|
+
onOk={this.handleOrgChangeOk}
|
|
355
|
+
onCancel={this.handleOrgChangeCancel}
|
|
356
|
+
centered
|
|
357
|
+
okText={formatMessage(messages.changeOk)}
|
|
358
|
+
cancelText={formatMessage(messages.cancel)}
|
|
359
|
+
>
|
|
360
|
+
<FormattedHTMLMessage
|
|
361
|
+
{...messages.orgChangeText}
|
|
362
|
+
values={{ oldOrgName, newOrgName }}
|
|
363
|
+
/>
|
|
364
|
+
</CapModal>
|
|
365
|
+
);
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
handleOrgChangeOk = () => {
|
|
369
|
+
const { selectedOrgId: orgId } = this.state;
|
|
370
|
+
if (orgId !== null) {
|
|
371
|
+
this.props.actions.changeOrg(orgId);
|
|
372
|
+
this.setState({ showOrgChangeModal: false });
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
handleOrgChangeCancel = () => {
|
|
377
|
+
this.setState({ showOrgChangeModal: false });
|
|
378
|
+
};
|
|
379
|
+
|
|
179
380
|
render() {
|
|
180
381
|
const { Global, location } = this.props;
|
|
181
382
|
const { topbarMenuData, isLoggedIn, currentOrgDetails } = Global;
|
|
182
383
|
const topbarMenuDataOptions = topbarMenuData && topbarMenuData.data ? topbarMenuData.data : [];
|
|
183
384
|
const type = this.props.location.query.type;
|
|
184
385
|
const toastMessages = this.props.Global.messages;
|
|
185
|
-
const { isCreativesAccessible } = this.state;
|
|
386
|
+
const { isCreativesAccessible, showOrgChangeModal, showRefreshModal } = this.state;
|
|
186
387
|
console.log('v2 locale loading', this.props.loader.localeLoading);
|
|
187
388
|
return (
|
|
188
389
|
<CapWrapper>
|
|
@@ -231,6 +432,8 @@ export class Cap extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
231
432
|
)
|
|
232
433
|
}
|
|
233
434
|
</> }
|
|
435
|
+
{showRefreshModal && this.renderOrgRefreshModal()}
|
|
436
|
+
{showOrgChangeModal && this.renderOrgChangeModal()}
|
|
234
437
|
</CapWrapper>
|
|
235
438
|
);
|
|
236
439
|
}
|
|
@@ -244,6 +447,7 @@ Cap.propTypes = {
|
|
|
244
447
|
appActions: PropTypes.object,
|
|
245
448
|
locationActions: PropTypes.object,
|
|
246
449
|
location: PropTypes.object,
|
|
450
|
+
intl: intlShape.isRequired,
|
|
247
451
|
};
|
|
248
452
|
|
|
249
453
|
const mapStateToProps = createStructuredSelector({
|
|
@@ -72,4 +72,45 @@ export default defineMessages({
|
|
|
72
72
|
id: 'creatives.containersV2.incentive',
|
|
73
73
|
defaultMessage: 'Incentive',
|
|
74
74
|
},
|
|
75
|
+
|
|
76
|
+
//refresh due to org change messages
|
|
77
|
+
|
|
78
|
+
"refreshOrgText": {
|
|
79
|
+
id: `creatives.containersV2.refreshOrgText`,
|
|
80
|
+
defaultMessage:
|
|
81
|
+
'Refreshing this page & changing the Org from <b>{oldOrgName}</b> to <b>{newOrgName}</b>. At a time only one Org can be selected on the browser.',
|
|
82
|
+
},
|
|
83
|
+
"refreshText": {
|
|
84
|
+
id: `creatives.containersV2.refreshText`,
|
|
85
|
+
defaultMessage: 'Refreshing in {time}...',
|
|
86
|
+
},
|
|
87
|
+
"areYouSureText": {
|
|
88
|
+
id: `creatives.containersV2.areYouSureText`,
|
|
89
|
+
defaultMessage: 'Are you sure?',
|
|
90
|
+
},
|
|
91
|
+
"changeOk": {
|
|
92
|
+
id: `creatives.containersV2.changeOk`,
|
|
93
|
+
defaultMessage: 'Ok, change',
|
|
94
|
+
},
|
|
95
|
+
"cancel": {
|
|
96
|
+
id: `creatives.containersV2.cancel`,
|
|
97
|
+
defaultMessage: 'Cancel',
|
|
98
|
+
},
|
|
99
|
+
"orgChangeText": {
|
|
100
|
+
id: `creatives.containersV2.orgChangeText`,
|
|
101
|
+
defaultMessage:
|
|
102
|
+
'Changing from <b>{oldOrgName}</b> to <b>{newOrgName}</b> will change the organisation for applications open in other tabs as well.<br/>Do you want to make the change to <b>{newOrgName}</b>?',
|
|
103
|
+
},
|
|
104
|
+
"orgChangedText": {
|
|
105
|
+
id: `creatives.containersV2.orgChangedText`,
|
|
106
|
+
defaultMessage: 'Organization changed to ',
|
|
107
|
+
},
|
|
108
|
+
"orgRefreshHeading": {
|
|
109
|
+
id: `creatives.containersV2.orgRefreshHeading`,
|
|
110
|
+
defaultMessage: 'Org refresh',
|
|
111
|
+
},
|
|
112
|
+
"newOrgName": {
|
|
113
|
+
id: `creatives.containersV2.newOrgName`,
|
|
114
|
+
defaultMessage: '{newOrgName}',
|
|
115
|
+
},
|
|
75
116
|
});
|
|
@@ -2666,7 +2666,8 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
2666
2666
|
if (this.props.location.query.type === 'embedded' && this.props.location.query.module === 'library' && !this.props.getDefaultTags) {
|
|
2667
2667
|
tags = this.props.supportedTags;
|
|
2668
2668
|
}
|
|
2669
|
-
const
|
|
2669
|
+
const { showImageSelectionBox = false } = this.state;
|
|
2670
|
+
const showTestAndPreview = !showImageSelectionBox && getDefaultTags === 'outbound';
|
|
2670
2671
|
return (
|
|
2671
2672
|
<div className="email-container">
|
|
2672
2673
|
<CapSpin spinning={isLoading}>
|