@capillarytech/creatives-library 6.12.11 → 6.12.12

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.11",
4
+ "version": "6.12.12",
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": "1.3.1",
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,7 +31,3 @@ 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, CapModal, CapSnackBar } from '@capillarytech/cap-ui-library';
5
+ import {CapNotification} 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, multipleOrgSwitch, utilsSessionStorageApi } from '@capillarytech/cap-ui-utils';
13
- import { injectIntl, FormattedMessage, intlShape, FormattedHTMLMessage } from 'react-intl';
12
+ import { GA } from '@capillarytech/cap-ui-utils';
13
+ import { injectIntl, FormattedMessage } from 'react-intl';
14
14
  import messages from './messages';
15
15
  import { makeSelectAuthenticated, makeSelectUser } from './selectors';
16
16
  import * as actions from './actions';
@@ -25,24 +25,8 @@ import {
25
25
  HELP_URL,
26
26
  ORG_SETTINGS_URL,
27
27
  CAMPAIGN_SETTINGS_URL,
28
- ORG_REFRESH_SEC,
29
- ORG_CHANGED
30
28
  } from './constants';
31
- import './_cap.scss';
32
- import { BugsnagClient } from '../../app';
33
-
34
29
  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;
46
30
 
47
31
  const CapWrapper = styled.div`
48
32
  margin: 0 auto;
@@ -61,11 +45,6 @@ export class Cap extends React.Component { // eslint-disable-line react/prefer-s
61
45
  this.state = {
62
46
  switchedOrg: false,
63
47
  isCreativesAccessible: true,
64
- refreshSeconds: ORG_REFRESH_SEC,
65
- selectedOrgId: null,
66
- showRefreshModal: false,
67
- showOrgChangeModal: false,
68
- localStorageOrgInfo: { oldValue: null, newValue: null },
69
48
  };
70
49
  this.changeOrg = this.changeOrg.bind(this);
71
50
  this.logout = this.logout.bind(this);
@@ -106,14 +85,6 @@ export class Cap extends React.Component { // eslint-disable-line react/prefer-s
106
85
  //locale = 'zh';
107
86
  console.log('Setting final locale as', locale);
108
87
  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);
117
88
  }
118
89
 
119
90
  componentWillReceiveProps(nextProps) {
@@ -148,41 +119,10 @@ export class Cap extends React.Component { // eslint-disable-line react/prefer-s
148
119
  }
149
120
  }
150
121
 
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
-
161
122
  componentWillUnmount() {
162
123
  this.setState({ switchedOrg: false });
163
124
  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
- );
180
125
  }
181
-
182
- tabOnloadEventHandler = () => {
183
- logNewTab(BugsnagClient);
184
- }
185
-
186
126
  setDimensionData() {
187
127
  const userGtmData = this.getUserGtmData();
188
128
  Object.values(userGtmData).forEach((value, index) => {
@@ -218,7 +158,6 @@ export class Cap extends React.Component { // eslint-disable-line react/prefer-s
218
158
  };
219
159
  return map[locale];
220
160
  }
221
-
222
161
  handleRemoveMessage(messageIndex) {
223
162
  this.props.actions.removeMessageFromQueue(messageIndex);
224
163
  }
@@ -233,157 +172,17 @@ export class Cap extends React.Component { // eslint-disable-line react/prefer-s
233
172
  this.props.actions.logout();
234
173
  }
235
174
  changeOrg(orgId) {
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
- }
175
+ this.props.actions.changeOrg(orgId);
176
+ this.navigateToDashboard();
245
177
  }
246
178
 
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
-
380
179
  render() {
381
180
  const { Global, location } = this.props;
382
181
  const { topbarMenuData, isLoggedIn, currentOrgDetails } = Global;
383
182
  const topbarMenuDataOptions = topbarMenuData && topbarMenuData.data ? topbarMenuData.data : [];
384
183
  const type = this.props.location.query.type;
385
184
  const toastMessages = this.props.Global.messages;
386
- const { isCreativesAccessible, showOrgChangeModal, showRefreshModal } = this.state;
185
+ const { isCreativesAccessible } = this.state;
387
186
  console.log('v2 locale loading', this.props.loader.localeLoading);
388
187
  return (
389
188
  <CapWrapper>
@@ -432,8 +231,6 @@ export class Cap extends React.Component { // eslint-disable-line react/prefer-s
432
231
  )
433
232
  }
434
233
  </> }
435
- {showRefreshModal && this.renderOrgRefreshModal()}
436
- {showOrgChangeModal && this.renderOrgChangeModal()}
437
234
  </CapWrapper>
438
235
  );
439
236
  }
@@ -447,7 +244,6 @@ Cap.propTypes = {
447
244
  appActions: PropTypes.object,
448
245
  locationActions: PropTypes.object,
449
246
  location: PropTypes.object,
450
- intl: intlShape.isRequired,
451
247
  };
452
248
 
453
249
  const mapStateToProps = createStructuredSelector({
@@ -72,45 +72,4 @@ 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
- },
116
75
  });
@@ -2666,8 +2666,7 @@ 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 { showImageSelectionBox = false } = this.state;
2670
- const showTestAndPreview = !showImageSelectionBox && getDefaultTags === 'outbound';
2669
+ const showTestAndPreview = getDefaultTags === 'outbound';
2671
2670
  return (
2672
2671
  <div className="email-container">
2673
2672
  <CapSpin spinning={isLoading}>