@capillarytech/creatives-library 7.17.12 → 7.17.13

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.
@@ -13,14 +13,14 @@ import React from 'react';
13
13
  import _ from 'lodash';
14
14
  // import messages from './messages';
15
15
  const loadScript = require('load-script');
16
- const defaultScriptUrl = "https://storage.crm.n.content-cdn.io/ckeditor_test/ckeditor4/ckeditor.js";
16
+ const defaultScriptUrl = "https://storage.crm.n.content-cdn.io/ckeditor_full/ckeditor/ckeditor.js";
17
17
  const user = localStorage.getItem('user');
18
18
  let locale = 'en';
19
19
  if (user && JSON.parse(user).lang) {
20
20
  locale = JSON.parse(user).lang;
21
21
  }
22
22
  const CKEditorConfig = {
23
- skin: 'moono',
23
+ skin: 'moono-lisa',
24
24
  toolbar: [
25
25
  { name: 'document', items: ['Source', '-'] },
26
26
  { name: 'clipboard', items: ['Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo'] },
@@ -18,4 +18,13 @@ export const GET_TRANSLATION_MAPPED = {
18
18
  'ja-JP': 'ja-JP',
19
19
  };
20
20
 
21
- export const JAPANESE_HIDE_DATE_ARRAY = ['mm/dd/yyyy', 'dd/mm/yyyy', 'mm/dd/yy', 'dd Mon yyyy', 'Day, Mon dd, yy', 'dd.mm.yy', 'dd Mon', 'dd/m/yyyy'];
21
+ export const JAPANESE_HIDE_DATE_ARRAY = [
22
+ "mm/dd/yyyy",
23
+ "dd/mm/yyyy",
24
+ "mm/dd/yy",
25
+ "dd Mon yyyy",
26
+ "Day, Mon dd, yy",
27
+ "dd.mm.yy",
28
+ "dd Mon",
29
+ "dd/m/yyyy",
30
+ ];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "7.17.12",
4
+ "version": "7.17.13",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -19,8 +19,14 @@ import { CARD_RELATED_TAGS } from '../../containers/App/constants';
19
19
  import { hasCardBasedScope } from '../../utils/common';
20
20
  import moment from 'moment';
21
21
  import { FONT_COLOR_05 } from '@capillarytech/cap-ui-library/styled/variables';
22
- import { GET_TRANSLATION_MAPPED, JAPANESE_HELP_TEXT, JAPANESE_HIDE_DATE_ARRAY, TAG_TRANSLATION_DOC } from '../../containers/TagList/constants';
22
+ import {
23
+ GET_TRANSLATION_MAPPED,
24
+ JAPANESE_HELP_TEXT,
25
+ TAG_TRANSLATION_DOC,
26
+ } from "../../containers/TagList/constants";
23
27
  import { HIDE_ENGAGEMENT_CHANNELS } from '../../v2Containers/App/constants';
28
+ import { hideDateLocale } from '../../v2Containers/TagList/utils';
29
+
24
30
 
25
31
  const {Search} = CapInput;
26
32
  const {CapTreeNode} = CapTree;
@@ -156,9 +162,9 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
156
162
  };
157
163
 
158
164
  renderTags(tags, searchString = '') {
159
- const { disableRelatedTags, childTagsToDisable, parentTagstoDisable, showCardsRelatedTags } = this.props.disableTagsDetails;
160
- const { accessibleFeatures = [] } = this.props.currentOrgDetails || {};
161
- const hideDefaultJpTranslation = accessibleFeatures.includes(HIDE_ENGAGEMENT_CHANNELS);
165
+ const { disableRelatedTags, childTagsToDisable, parentTagstoDisable, showCardsRelatedTags } = this?.props?.disableTagsDetails;
166
+ const { accessibleFeatures = [] } = this?.props?.currentOrgDetails || {};
167
+ const hideDateTagsForJpLocale = accessibleFeatures.includes(HIDE_ENGAGEMENT_CHANNELS);
162
168
  const list = [];
163
169
  const loyaltyAttrDisableText = <FormattedMessage {...messages.loyaltyAttributeDisable} />;
164
170
  let clonedTags = _.cloneDeep(tags);
@@ -174,7 +180,7 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
174
180
  if (_.has(val, 'subtags')) {
175
181
  const disabled = disableRelatedTags ? parentTagstoDisable.includes(key) : false;
176
182
  const temp = this.renderTags(val.subtags, '', disabled);
177
- const tempNode = (
183
+ const tagValue = (
178
184
  <CapTreeNode
179
185
  title={disabled ? <CapTooltip title={loyaltyAttrDisableText}>{val.name}</CapTooltip> : val.name}
180
186
  tag={val}
@@ -184,13 +190,7 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
184
190
  {temp}
185
191
  </CapTreeNode>
186
192
  );
187
- if (hideDefaultJpTranslation) {
188
- if (!JAPANESE_HIDE_DATE_ARRAY.includes(val.name)) {
189
- list.push(tempNode);
190
- }
191
- } else {
192
- list.push(tempNode);
193
- }
193
+ hideDateLocale(hideDateTagsForJpLocale, val, list, tagValue);
194
194
  } else if (searchString === '' || !searchString || ((val.name || '').toLowerCase().indexOf(searchString.toLowerCase()) !== -1)) {
195
195
  const childDisabled = disableRelatedTags ? childTagsToDisable.includes(key) : false;
196
196
  const tempNode = (
@@ -202,13 +202,7 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
202
202
  disabled={childDisabled}
203
203
  >
204
204
  </CapTreeNode>);
205
- if (hideDefaultJpTranslation) {
206
- if (!JAPANESE_HIDE_DATE_ARRAY.includes(val.name)) {
207
- list.push(tempNode);
208
- }
209
- } else {
210
- list.push(tempNode);
211
- }
205
+ hideDateLocale(hideDateTagsForJpLocale, val, list, tempNode);
212
206
  }
213
207
  });
214
208
  return list;
@@ -294,15 +288,15 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
294
288
  >
295
289
  {contentSection}
296
290
  </CapModal> :
297
- <CapPopover
298
- visible={visible}
299
- onVisibleChange={this.togglePopoverVisibility}
300
- content={contentSection}
301
- trigger="click"
302
- placement="rightTop"
291
+ <CapPopover
292
+ visible={visible}
293
+ onVisibleChange={this.togglePopoverVisibility}
294
+ content={contentSection}
295
+ trigger="click"
296
+ placement="rightTop"
303
297
  >
304
- <CapButton isAddBtn type="flat">{label || ''}</CapButton>
305
- </CapPopover>
298
+ <CapButton isAddBtn type="flat">{label || ''}</CapButton>
299
+ </CapPopover>
306
300
  }
307
301
  <CapModal
308
302
  visible={this.state.showModal}
@@ -13,14 +13,14 @@ import React from 'react';
13
13
  import _ from 'lodash';
14
14
  // import messages from './messages';
15
15
  const loadScript = require('load-script');
16
- const defaultScriptUrl = "https://storage.crm.n.content-cdn.io/ckeditor_test/ckeditor4/ckeditor.js";
16
+ const defaultScriptUrl = "https://storage.crm.n.content-cdn.io/ckeditor_full/ckeditor/ckeditor.js";
17
17
  const user = localStorage.getItem('user');
18
18
  let locale = 'en';
19
19
  if (user && JSON.parse(user).lang) {
20
20
  locale = JSON.parse(user).lang;
21
21
  }
22
22
  const CKEditorConfig = {
23
- skin: 'moono',
23
+ skin: 'moono-lisa',
24
24
  toolbar: [
25
25
  { name: 'document', items: ['Source', '-'] },
26
26
  { name: 'clipboard', items: ['Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo'] },
@@ -0,0 +1,44 @@
1
+ import React, { Component } from "react";
2
+ import { injectIntl } from "react-intl";
3
+ import "@testing-library/jest-dom";
4
+ import { render, getByText, screen } from "../../../utils/test-utils";
5
+ import Ckeditor from "../index";
6
+
7
+ const initializeComponent = () => {
8
+ const Component = injectIntl(Ckeditor);
9
+
10
+ //const originalComponentDidMount = Ckeditor.prototype.componentDidMount;
11
+ Ckeditor.prototype.componentDidMount = jest.fn();
12
+ Ckeditor.prototype.handleContentChange = jest.fn();
13
+
14
+ //Render with default props.
15
+ return render(<Component />);
16
+ };
17
+
18
+ describe("Load Ckeditor", () => {
19
+ it("Test if Ckeditor Mounts", () => {
20
+ initializeComponent();
21
+
22
+ expect(Ckeditor.prototype.componentDidMount).toHaveBeenCalled();
23
+ });
24
+
25
+ it("Test if Ckeditor un-Mounts", () => {
26
+ // Spy on the componentWillUnmount method
27
+ const componentWillUnmountSpy = jest.spyOn(
28
+ Ckeditor.prototype,
29
+ "componentWillUnmount"
30
+ );
31
+
32
+ // Render the component
33
+ const { unmount } = initializeComponent();
34
+
35
+ // Manually unmount the component (simulate unmounting)
36
+ unmount();
37
+
38
+ // Assert that componentWillUnmount has been called
39
+ expect(componentWillUnmountSpy).toHaveBeenCalled();
40
+
41
+ // Clean up the spy
42
+ componentWillUnmountSpy.mockRestore();
43
+ });
44
+ });
@@ -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: "0.313rem",
355
355
  },
356
356
  customComponent: true,
357
357
  width: 2,
@@ -56,7 +56,7 @@ export const LineText = ({
56
56
  const [messageTitle, updateTextMessageTitle] = useState('');
57
57
  const [isDrawerRequired, updateDrawerRequirement] = useState(false);
58
58
  const [selectedTemplate, updateSelectedTemplate] = useState();
59
- const [translationLang, updateTranslationLang] = useState('');
59
+ const [translationLang, updateTranslationLang] = useState('en');
60
60
 
61
61
  useEffect(() => {
62
62
  const { messageTitle = '', messageContent = '', type, isInit } = content;
@@ -73,19 +73,17 @@ export const LineText = ({
73
73
  }
74
74
  }
75
75
  }, [content]);
76
- const getTranslationMappedLocale = (locale) => {
77
- return GET_TRANSLATION_MAPPED?.[locale];
78
- }
79
-
76
+
77
+ //To Find from which locale user is loggedin
80
78
  useEffect(() => {
81
- const user = localStorage.getItem('user');
82
- let locale = 'en';
83
- moment.locale(locale);
84
- if (user) {
85
- locale = JSON.parse(user).lang || locale;
86
- }
87
- locale = getTranslationMappedLocale(locale);
88
- updateTranslationLang(locale);
79
+ const user = localStorage.getItem("user");
80
+ let locale = "en";
81
+ if (user) {
82
+ locale = JSON.parse(user).lang || locale;
83
+ }
84
+ locale = GET_TRANSLATION_MAPPED?.[locale];
85
+ moment.locale(locale);
86
+ updateTranslationLang(locale);
89
87
  }, []);
90
88
 
91
89
  useEffect(() => {
@@ -77,7 +77,7 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
77
77
  if (!tag['tag-header']) {
78
78
  mainTags[tag.value] = {
79
79
  name: tag.label[userLocale] ? tag.label[userLocale] : tag.label.en,
80
- desc: tag.desc ? tag.desc : tag.label[userLocale],
80
+ desc: tag.label[userLocale] ? tag.label[userLocale] : tag.label.en,
81
81
  };
82
82
  } else if (tag['tag-header'] && mainTags[tag.value]) {
83
83
  mainTags[tag.value].subtags = _.concat(mainTags[tag.value].subtags, tag.subtags);
@@ -86,7 +86,7 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
86
86
  mainTags[tag.value] = {
87
87
  'tag-header': true,
88
88
  "name": tag.label[userLocale] ? tag.label[userLocale] : tag.label.en,
89
- "desc": tag.desc ? tag.desc : tag.label[userLocale],
89
+ "desc": tag.label[userLocale] ? tag.label[userLocale] : tag.label.en,
90
90
  "subtags": tag.subtags,
91
91
  };
92
92
  }
@@ -0,0 +1,17 @@
1
+ import "@testing-library/jest-dom";
2
+ import { hideDateLocale } from "../utils";
3
+
4
+ describe("Test utils", () => {
5
+ it("it should test when hideDateTagsForJpLocale is available", () => {
6
+ const result = hideDateLocale(true, { name: "店舗名" }, [], { name: "店舗名" });
7
+ expect(result).toEqual([{name: "店舗名"}]);
8
+ });
9
+ it("it should test when hideDateTagsForJpLocale is available", () => {
10
+ const result = hideDateLocale(true, { name: "mm/dd/yyyy" }, [], { name: "mm/dd/yyyy" });
11
+ expect(result).toEqual([]);
12
+ });
13
+ it("it should test when val name is not available", () => {
14
+ const result = hideDateLocale(false, { name: "店舗名" }, [], { name: "店舗名" });
15
+ expect(result).toEqual([{name: "店舗名"}]);
16
+ });
17
+ });
@@ -0,0 +1,15 @@
1
+ import { JAPANESE_HIDE_DATE_ARRAY } from "../../containers/TagList/constants";
2
+
3
+
4
+ export const hideDateLocale = (hideDateTagsForJpLocale, val, list, value) => {
5
+
6
+ if (hideDateTagsForJpLocale) {
7
+ // hidden date tags from the japanese locale
8
+ if (!JAPANESE_HIDE_DATE_ARRAY?.includes(val.name)) {
9
+ list.push(value);
10
+ }
11
+ } else {
12
+ list.push(value);
13
+ }
14
+ return list;
15
+ };