@capillarytech/creatives-library 7.17.8 → 7.17.9

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.
@@ -5,3 +5,15 @@
5
5
  */
6
6
 
7
7
  export const DEFAULT_ACTION = 'app/TagList/DEFAULT_ACTION';
8
+
9
+ export const JAPANESE_HELP_TEXT = 'ヘルプ :トークンの定義';
10
+
11
+ export const TAG_TRANSLATION_DOC = 'https://docs.capillarytech.com/docs/tags-translation';
12
+
13
+ export const GET_TRANSLATION_MAPPED = {
14
+ 'en': 'en-US',
15
+ 'zh-cn': 'zh',
16
+ 'zh': 'zh',
17
+ 'en-US': 'en-US',
18
+ 'ja-JP': 'ja-JP',
19
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "7.17.8",
4
+ "version": "7.17.9",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -18,6 +18,8 @@ import { makeSelectLoyaltyPromotionDisplay } from '../../v2Containers/Cap/select
18
18
  import { CARD_RELATED_TAGS } from '../../containers/App/constants';
19
19
  import { hasCardBasedScope } from '../../utils/common';
20
20
  import moment from 'moment';
21
+ import { FONT_COLOR_05 } from '@capillarytech/cap-ui-library/styled/variables';
22
+ import { GET_TRANSLATION_MAPPED, JAPANESE_HELP_TEXT, TAG_TRANSLATION_DOC } from '../../containers/TagList/constants';
21
23
 
22
24
  const {Search} = CapInput;
23
25
  const {CapTreeNode} = CapTree;
@@ -33,31 +35,24 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
33
35
  visible: false,
34
36
  dynamicDateValue: '',
35
37
  showModal: false,
36
- japaneseLang: '',
38
+ translationLang: '',
37
39
  };
38
40
  this.renderTags = this.renderTags.bind(this);
39
41
  this.getSearchedExpandedKeys = this.getSearchedExpandedKeys.bind(this);
40
42
  }
41
- getMappedLocale = (locale) => {
42
- const map = {
43
- 'en': 'en-US',
44
- 'zh-cn': 'zh',
45
- 'zh': 'zh',
46
- 'en-US': 'en-US',
47
- 'ja-JP': 'ja-JP',
48
- };
49
- return map[locale];
50
- };
43
+ getTranslationMappedLocale(locale) {
44
+ return GET_TRANSLATION_MAPPED?.[locale];
45
+ }
51
46
  componentDidMount() {
52
47
  const user = localStorage.getItem('user');
53
- let locale = localStorage.getItem('jlocale') || 'en';
48
+ let locale = 'en';
54
49
  moment.locale(locale);
55
50
  if (user) {
56
51
  locale = JSON.parse(user).lang || locale;
57
52
  }
58
- locale = this.getMappedLocale(locale);
53
+ locale = this.getTranslationMappedLocale(locale);
59
54
  this.setState({
60
- japaneseLang: locale,
55
+ translationLang: locale,
61
56
  });
62
57
  }
63
58
 
@@ -203,13 +198,13 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
203
198
  return list;
204
199
  }
205
200
  openTranslationLink = () => {
206
- window.open(`https://docs.capillarytech.com/docs/tags-translation`, "_blank");
201
+ window.open(TAG_TRANSLATION_DOC, '_blank');
207
202
  }
208
203
  render() {
209
204
  const { hidePopover = false, tags = {}, intl = {}, moduleFilterEnabled, label, modalProps } = this.props;
210
205
  const tg = tags;
211
206
  const {formatMessage} = intl;
212
- const { tagValue, expandedKeys, autoExpandParent, searchValue, visible, japaneseLang } = this.state;
207
+ const { tagValue, expandedKeys, autoExpandParent, searchValue, visible, translationLang } = this.state;
213
208
  const options = [
214
209
  {
215
210
  value: "All",
@@ -248,34 +243,27 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
248
243
  expandedKeys={expandedKeys}
249
244
  autoExpandParent={autoExpandParent}
250
245
  onExpand={this.onExpand}
251
- >
246
+ >
252
247
  {this.renderTags(tg, searchValue)}
253
248
  </CapTree>
254
- {
255
- japaneseLang === "ja-JP" &&
256
- <div className = 'tag-list-footer'>
257
- <CapIcon
258
- type="help"
259
- size="s"
260
- />
261
-
262
- <CapLink>
263
- <CapButton type="flat" style={{padding: '0px'}} onClick={this.openTranslationLink} >
264
- <div className = 'tag-list-footer-icon'>
265
- <div>ヘルプ :トークンの定義</div>
266
- <CapIcon
267
- type="open-in-new-light"
268
- size="s"
269
- style={{ marginRight: 4 }}
270
-
271
- svgProps={{
272
- fill: '#2466ea',
273
- }}
274
- />
275
- </div>
276
- </CapButton>
277
- </CapLink>
278
-
249
+ {translationLang === "ja-JP" &&
250
+ <div className="tag-list-footer">
251
+ <CapIcon
252
+ type="help"
253
+ size="s"
254
+ />
255
+ <CapLink>
256
+ <CapButton id="translationtagfooter" type="flat" onClick={this.openTranslationLink} >
257
+ <div className="tag-list-footer-icon">
258
+ <div>{JAPANESE_HELP_TEXT}</div>
259
+ <CapIcon
260
+ type="open-in-new-light"
261
+ size="s"
262
+ svgProps={{ color: FONT_COLOR_05 }}
263
+ />
264
+ </div>
265
+ </CapButton>
266
+ </CapLink>
279
267
  </div>
280
268
  }
281
269
 
@@ -287,18 +275,18 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
287
275
  visible={this.props.visibleTaglist}
288
276
  footer={[]}
289
277
  {...modalProps}
290
- >
278
+ >
291
279
  {contentSection}
292
280
  </CapModal> :
293
- <CapPopover
294
- visible={visible}
295
- onVisibleChange={this.togglePopoverVisibility}
296
- content={contentSection}
297
- trigger="click"
298
- placement="rightTop"
281
+ <CapPopover
282
+ visible={visible}
283
+ onVisibleChange={this.togglePopoverVisibility}
284
+ content={contentSection}
285
+ trigger="click"
286
+ placement="rightTop"
299
287
  >
300
- <CapButton isAddBtn type="flat">{label || ''}</CapButton>
301
- </CapPopover>
288
+ <CapButton isAddBtn type="flat">{label || ''}</CapButton>
289
+ </CapPopover>
302
290
  }
303
291
  <CapModal
304
292
  visible={this.state.showModal}
@@ -50,6 +50,11 @@ export const VIBER = 'viber';
50
50
  export const FACEBOOK = 'facebook';
51
51
  export const WHATSAPP = 'whatsapp';
52
52
  export const RCS = 'rcs';
53
+ export const LINE = 'line';
54
+ export const EMAIL = 'email';
55
+ export const ASSETS = 'assets';
56
+
57
+ export const HIDE_ENGAGEMENT_CHANNELS = 'HIDE_ENGAGEMENT_CHANNELS';
53
58
 
54
59
  export const TRACK_EDIT_SMS = 'editSms';
55
60
  export const TRACK_EDIT_EMAIL = 'editEmail';
@@ -351,7 +351,7 @@ export const response = {
351
351
  fontFamily: "open-sans, sans-serif",
352
352
  fontStyle: "normal",
353
353
  fontWeight: "600",
354
- justifyContent: "flex-end",
354
+ marginLeft: "5px",
355
355
  },
356
356
  customComponent: true,
357
357
  width: 2,
@@ -1,3 +1,4 @@
1
+ @import '~@capillarytech/cap-ui-library/styles/_variables.scss';
1
2
  .ant-tree li span.ant-tree-switcher {
2
3
  margin-left: 0 !important ;
3
4
  }
@@ -13,8 +14,13 @@
13
14
  }
14
15
  .tag-list-footer-icon {
15
16
  display: flex;
17
+ align-items: center;
18
+ padding: 0rem 0.625rem;
16
19
  }
17
20
  .tag-list-footer-icon > div {
18
- color: #2466ea;
19
- padding: 0px 10px;
21
+ color: $FONT_COLOR_05;
22
+ padding: 0rem 0.313rem;
23
+ }
24
+ #translationtagfooter {
25
+ padding: 0rem;
20
26
  }
@@ -29,9 +29,10 @@ import FTP from '../FTP';
29
29
  import Gallery from '../Assets/Gallery';
30
30
  import withStyles from '../../hoc/withStyles';
31
31
  import styles, { CapTabStyle } from './TemplatesV2.style';
32
- import { CREATIVES_UI_VIEW, LOYALTY, WHATSAPP, RCS } from '../App/constants';
32
+ import { CREATIVES_UI_VIEW, LOYALTY, WHATSAPP, RCS, LINE, EMAIL, ASSETS, HIDE_ENGAGEMENT_CHANNELS } from '../App/constants';
33
33
  import AccessForbidden from '../../v2Components/AccessForbidden';
34
34
  import { getObjFromQueryParams } from '../../utils/v2common';
35
+ import { selectCurrentOrgDetails } from "../../v2Containers/Cap/selectors";
35
36
 
36
37
  const {CapCustomCardList} = CapCustomCard;
37
38
 
@@ -51,6 +52,8 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
51
52
  onChannelChange,
52
53
  showDisabledFBInfo,
53
54
  enableNewChannels = [],
55
+ currentOrgDetails = {},
56
+ cap = {},
54
57
  } = props;
55
58
 
56
59
  const defaultPanes = {
@@ -112,6 +115,15 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
112
115
  return pane;
113
116
  });
114
117
 
118
+ // This data will be available when it will be accessed in full mode
119
+ const { accessibleFeatures = [] } = currentOrgDetails || {};
120
+ // This data will be available when it will be accessed in library mode
121
+ const { currentOrgDetails: { accessibleFeatures: libModeAccessibleFeatures = [] } = {} } = cap || {};
122
+ const hideEngagementChannel = accessibleFeatures.includes(HIDE_ENGAGEMENT_CHANNELS) || libModeAccessibleFeatures.includes(HIDE_ENGAGEMENT_CHANNELS);
123
+ // Show only line and email channel content with both channel tabs if the HIDE_ENGAGEMENT_CHANNELS feature is enabled;
124
+ filteredPanes = hideEngagementChannel ? filteredPanes?.filter((pane) => [EMAIL, LINE, ASSETS].includes(pane?.key) && pane) : filteredPanes;
125
+ defaultChannel = hideEngagementChannel ? EMAIL : defaultChannel;
126
+
115
127
  const channel = ['sms', 'email', 'mobilepush', 'line', 'call_task'];
116
128
  if (!isEmpty(channelsToDisable)) {
117
129
  channel.some((ch) => {
@@ -341,15 +353,18 @@ TemplatesV2.propTypes = {
341
353
  authData: PropTypes.object,
342
354
  FTPMode: PropTypes.string,
343
355
  messageStrategy: PropTypes.string,
356
+ currentOrgDetails: PropTypes.object,
344
357
  };
345
358
 
346
359
  TemplatesV2.defaultProps = {
347
360
  isFullMode: true,
361
+ currentOrgDetails: {},
348
362
  };
349
363
 
350
364
  const mapStateToProps = createStructuredSelector({
351
365
  Templates: makeSelectTemplates(),
352
366
  TemplatesList: makeSelectTemplatesResponse(),
367
+ currentOrgDetails: selectCurrentOrgDetails(),
353
368
  });
354
369
 
355
370
  function mapDispatchToProps(dispatch) {
@@ -0,0 +1,98 @@
1
+ import React from 'react';
2
+ import { injectIntl } from 'react-intl';
3
+ import '@testing-library/jest-dom';
4
+ import cloneDeep from 'lodash/cloneDeep';
5
+ import { Provider } from 'react-redux';
6
+ import configureStore from '../../../store';
7
+ import {
8
+ render,
9
+ screen,
10
+ } from '../../../utils/test-utils';
11
+ import { TemplatesV2 } from '../index';
12
+ import { Templates, authData, currentOrgDetails } from './mockData';
13
+
14
+ const ComponentToRender = injectIntl(TemplatesV2);
15
+ const renderComponent = (props) => {
16
+ const store = configureStore({}, null);
17
+ return render(
18
+ <Provider store={store}>
19
+ <ComponentToRender {...props} />
20
+ </Provider>,
21
+ );
22
+ };
23
+
24
+ // Mock the UserAuthWrapper module
25
+ jest.mock('../../../utils/authWrapper', () => ({
26
+ UserIsAuthenticated: jest.fn((config) => config),
27
+ }));
28
+
29
+ describe("Test TemplatesV2", () => {
30
+ const templateActions = {
31
+ templateActions: jest.fn(),
32
+ deleteTemplate: jest.fn(),
33
+ getAccountsSettings: jest.fn(),
34
+ getAllTemplates: jest.fn(),
35
+ getCdnTransformationConfig: jest.fn(),
36
+ getDefaultBeeTemplates: jest.fn(),
37
+ getSenderDetails: jest.fn(),
38
+ getTemplateDetails: jest.fn(),
39
+ getUserList: jest.fn(),
40
+ getWeCrmAccounts: jest.fn(),
41
+ handleHtmlUpload: jest.fn(),
42
+ handleZipUpload: jest.fn(),
43
+ resetAccount: jest.fn(),
44
+ resetTemplate: jest.fn(),
45
+ resetTemplateData: jest.fn(),
46
+ resetTemplateStoreData: jest.fn(),
47
+ resetUploadData: jest.fn(),
48
+ setBEETemplate: jest.fn(),
49
+ setChannelAccount: jest.fn(),
50
+ setEdmTemplate: jest.fn(),
51
+ setFacebookAccount: jest.fn(),
52
+ setViberAccount: jest.fn(),
53
+ setWeChatAccount: jest.fn(),
54
+ };
55
+ const props = {
56
+ actions: { defaultAction: jest.fn(), getTemplates: jest.fn() },
57
+ Templates,
58
+ TemplatesList: Templates?.templates,
59
+ authData,
60
+ templateActions,
61
+ isFullMode: true,
62
+ channelsToHide: [],
63
+ channelsToDisable: [],
64
+ onChannelChange: jest.fn(),
65
+ enableNewChannels: [],
66
+ currentOrgDetails,
67
+ location: {
68
+ pathname: "v2",
69
+ basename: "/creatives/ui/",
70
+ query: {},
71
+ },
72
+ };
73
+ const { getByText, queryByText } = screen;
74
+
75
+ it("Should show only Email, Line channels and Gallery", () => {
76
+ renderComponent(props);
77
+ expect(getByText('Email')).toBeInTheDocument();
78
+ expect(getByText('Line')).toBeInTheDocument();
79
+ expect(getByText('Gallery')).toBeInTheDocument();
80
+ expect(queryByText('RCS')).toBeNull();
81
+ });
82
+
83
+ it("Should show all other channels", () => {
84
+ const updatedProps = cloneDeep(props);
85
+ updatedProps.currentOrgDetails.accessibleFeatures.pop();
86
+ renderComponent(updatedProps);
87
+ expect(getByText('SMS')).toBeInTheDocument();
88
+ expect(getByText('RCS')).toBeInTheDocument();
89
+ expect(getByText('Email')).toBeInTheDocument();
90
+ expect(getByText('Push notification')).toBeInTheDocument();
91
+ expect(getByText('Line')).toBeInTheDocument();
92
+ expect(getByText('Wechat')).toBeInTheDocument();
93
+ expect(getByText('Viber')).toBeInTheDocument();
94
+ expect(getByText('Facebook')).toBeInTheDocument();
95
+ expect(getByText('WhatsApp')).toBeInTheDocument();
96
+ expect(getByText('Gallery')).toBeInTheDocument();
97
+ });
98
+ });