@capillarytech/creatives-library 7.17.7 → 7.17.8
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 +1 -1
- package/v2Components/CapTagList/index.js +67 -13
- package/v2Containers/App/constants.js +0 -5
- package/v2Containers/TagList/_tagList.scss +12 -0
- package/v2Containers/TemplatesV2/index.js +1 -16
- package/v2Containers/TemplatesV2/tests/index.test.js +0 -98
- package/v2Containers/TemplatesV2/tests/mockData.js +0 -685
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@ import PropTypes from 'prop-types';
|
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import { connect } from 'react-redux';
|
|
10
10
|
// import styled from 'styled-components';
|
|
11
|
-
import { CapSpin, CapModal, CapButton, CapPopover, CapInput, CapTree, CapSelect, CapTooltip } from '@capillarytech/cap-ui-library';
|
|
11
|
+
import { CapSpin, CapModal, CapButton, CapPopover, CapInput, CapTree, CapSelect, CapTooltip, CapLink, CapIcon } from '@capillarytech/cap-ui-library';
|
|
12
12
|
|
|
13
13
|
import _ from 'lodash';
|
|
14
14
|
import { FormattedMessage, injectIntl, intlShape } from 'react-intl';
|
|
@@ -17,6 +17,7 @@ import messages from './messages';
|
|
|
17
17
|
import { makeSelectLoyaltyPromotionDisplay } from '../../v2Containers/Cap/selectors';
|
|
18
18
|
import { CARD_RELATED_TAGS } from '../../containers/App/constants';
|
|
19
19
|
import { hasCardBasedScope } from '../../utils/common';
|
|
20
|
+
import moment from 'moment';
|
|
20
21
|
|
|
21
22
|
const {Search} = CapInput;
|
|
22
23
|
const {CapTreeNode} = CapTree;
|
|
@@ -32,10 +33,33 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
32
33
|
visible: false,
|
|
33
34
|
dynamicDateValue: '',
|
|
34
35
|
showModal: false,
|
|
36
|
+
japaneseLang: '',
|
|
35
37
|
};
|
|
36
38
|
this.renderTags = this.renderTags.bind(this);
|
|
37
39
|
this.getSearchedExpandedKeys = this.getSearchedExpandedKeys.bind(this);
|
|
38
40
|
}
|
|
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
|
+
};
|
|
51
|
+
componentDidMount() {
|
|
52
|
+
const user = localStorage.getItem('user');
|
|
53
|
+
let locale = localStorage.getItem('jlocale') || 'en';
|
|
54
|
+
moment.locale(locale);
|
|
55
|
+
if (user) {
|
|
56
|
+
locale = JSON.parse(user).lang || locale;
|
|
57
|
+
}
|
|
58
|
+
locale = this.getMappedLocale(locale);
|
|
59
|
+
this.setState({
|
|
60
|
+
japaneseLang: locale,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
39
63
|
|
|
40
64
|
onChange = (e) => {
|
|
41
65
|
const value = e.target.value;
|
|
@@ -178,12 +202,14 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
178
202
|
});
|
|
179
203
|
return list;
|
|
180
204
|
}
|
|
181
|
-
|
|
205
|
+
openTranslationLink = () => {
|
|
206
|
+
window.open(`https://docs.capillarytech.com/docs/tags-translation`, "_blank");
|
|
207
|
+
}
|
|
182
208
|
render() {
|
|
183
209
|
const { hidePopover = false, tags = {}, intl = {}, moduleFilterEnabled, label, modalProps } = this.props;
|
|
184
210
|
const tg = tags;
|
|
185
211
|
const {formatMessage} = intl;
|
|
186
|
-
const { tagValue, expandedKeys, autoExpandParent, searchValue, visible } = this.state;
|
|
212
|
+
const { tagValue, expandedKeys, autoExpandParent, searchValue, visible, japaneseLang } = this.state;
|
|
187
213
|
const options = [
|
|
188
214
|
{
|
|
189
215
|
value: "All",
|
|
@@ -222,9 +248,37 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
222
248
|
expandedKeys={expandedKeys}
|
|
223
249
|
autoExpandParent={autoExpandParent}
|
|
224
250
|
onExpand={this.onExpand}
|
|
225
|
-
|
|
251
|
+
>
|
|
226
252
|
{this.renderTags(tg, searchValue)}
|
|
227
253
|
</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
|
+
|
|
279
|
+
</div>
|
|
280
|
+
}
|
|
281
|
+
|
|
228
282
|
</CapSpin>
|
|
229
283
|
</div>);
|
|
230
284
|
return (
|
|
@@ -233,18 +287,18 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
233
287
|
visible={this.props.visibleTaglist}
|
|
234
288
|
footer={[]}
|
|
235
289
|
{...modalProps}
|
|
236
|
-
|
|
290
|
+
>
|
|
237
291
|
{contentSection}
|
|
238
292
|
</CapModal> :
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
293
|
+
<CapPopover
|
|
294
|
+
visible={visible}
|
|
295
|
+
onVisibleChange={this.togglePopoverVisibility}
|
|
296
|
+
content={contentSection}
|
|
297
|
+
trigger="click"
|
|
298
|
+
placement="rightTop"
|
|
245
299
|
>
|
|
246
|
-
|
|
247
|
-
|
|
300
|
+
<CapButton isAddBtn type="flat">{label || ''}</CapButton>
|
|
301
|
+
</CapPopover>
|
|
248
302
|
}
|
|
249
303
|
<CapModal
|
|
250
304
|
visible={this.state.showModal}
|
|
@@ -50,11 +50,6 @@ 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';
|
|
58
53
|
|
|
59
54
|
export const TRACK_EDIT_SMS = 'editSms';
|
|
60
55
|
export const TRACK_EDIT_EMAIL = 'editEmail';
|
|
@@ -29,10 +29,9 @@ 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
|
|
32
|
+
import { CREATIVES_UI_VIEW, LOYALTY, WHATSAPP, RCS } from '../App/constants';
|
|
33
33
|
import AccessForbidden from '../../v2Components/AccessForbidden';
|
|
34
34
|
import { getObjFromQueryParams } from '../../utils/v2common';
|
|
35
|
-
import { selectCurrentOrgDetails } from "../../v2Containers/Cap/selectors";
|
|
36
35
|
|
|
37
36
|
const {CapCustomCardList} = CapCustomCard;
|
|
38
37
|
|
|
@@ -52,8 +51,6 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
|
|
|
52
51
|
onChannelChange,
|
|
53
52
|
showDisabledFBInfo,
|
|
54
53
|
enableNewChannels = [],
|
|
55
|
-
currentOrgDetails = {},
|
|
56
|
-
cap = {},
|
|
57
54
|
} = props;
|
|
58
55
|
|
|
59
56
|
const defaultPanes = {
|
|
@@ -115,15 +112,6 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
|
|
|
115
112
|
return pane;
|
|
116
113
|
});
|
|
117
114
|
|
|
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
|
-
|
|
127
115
|
const channel = ['sms', 'email', 'mobilepush', 'line', 'call_task'];
|
|
128
116
|
if (!isEmpty(channelsToDisable)) {
|
|
129
117
|
channel.some((ch) => {
|
|
@@ -353,18 +341,15 @@ TemplatesV2.propTypes = {
|
|
|
353
341
|
authData: PropTypes.object,
|
|
354
342
|
FTPMode: PropTypes.string,
|
|
355
343
|
messageStrategy: PropTypes.string,
|
|
356
|
-
currentOrgDetails: PropTypes.object,
|
|
357
344
|
};
|
|
358
345
|
|
|
359
346
|
TemplatesV2.defaultProps = {
|
|
360
347
|
isFullMode: true,
|
|
361
|
-
currentOrgDetails: {},
|
|
362
348
|
};
|
|
363
349
|
|
|
364
350
|
const mapStateToProps = createStructuredSelector({
|
|
365
351
|
Templates: makeSelectTemplates(),
|
|
366
352
|
TemplatesList: makeSelectTemplatesResponse(),
|
|
367
|
-
currentOrgDetails: selectCurrentOrgDetails(),
|
|
368
353
|
});
|
|
369
354
|
|
|
370
355
|
function mapDispatchToProps(dispatch) {
|
|
@@ -1,98 +0,0 @@
|
|
|
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
|
-
});
|