@capillarytech/creatives-library 7.16.13 → 7.16.19
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/containers/Cap/tests/__snapshots__/index.test.js.snap +220 -10
- package/containers/MobilePush/Create/index.js +18 -0
- package/containers/MobilePush/Create/messages.js +2 -2
- package/containers/MobilePush/Edit/index.js +18 -0
- package/containers/MobilePush/Edit/messages.js +2 -2
- package/package.json +1 -1
- package/translations/en.json +220 -10
- package/translations/ja-JP.json +212 -2
- package/translations/zh.json +212 -2
- package/v2Components/CapWhatsappCTA/index.js +1 -1
- package/v2Components/CapWhatsappCTA/messages.js +1 -5
- package/v2Components/FormBuilder/constants.js +1 -0
- package/v2Components/FormBuilder/index.js +48 -4
- package/v2Components/NavigationBar/index.js +10 -5
- package/v2Components/NavigationBar/tests/index.test.js +51 -0
- package/v2Components/NavigationBar/tests/mockData.js +36 -0
- package/v2Components/TopBar/index.js +3 -0
- package/v2Containers/Cap/constants.js +2 -0
- package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +220 -10
- package/v2Containers/ChannelTemplates/actions.js +20 -0
- package/v2Containers/ChannelTemplates/constants.js +8 -0
- package/v2Containers/ChannelTemplates/index.js +47 -0
- package/v2Containers/ChannelTemplates/messages.js +13 -0
- package/v2Containers/ChannelTemplates/reducer.js +34 -0
- package/v2Containers/ChannelTemplates/sagas.js +32 -0
- package/v2Containers/ChannelTemplates/selectors.js +25 -0
- package/v2Containers/CreativesContainer/constants.js +2 -0
- package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +8 -0
- package/v2Containers/LanguageProvider/index.js +3 -0
- package/v2Containers/LanguageProvider/tests/index.test.js +1 -0
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +663 -30
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +440 -20
- package/v2Containers/Line/Container/Video/index.js +2 -2
- package/v2Containers/Line/Container/Video/messages.js +9 -0
- package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +3740 -170
- package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +3960 -180
- package/v2Containers/MobilePush/Create/index.js +31 -3
- package/v2Containers/MobilePush/Create/messages.js +50 -2
- package/v2Containers/MobilePush/Edit/index.js +29 -1
- package/v2Containers/MobilePush/Edit/messages.js +50 -2
- package/v2Containers/MobilePush/commonMethods.js +2 -2
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +10349 -473
- package/v2Containers/Sms/Create/tests/sagas.test.js +82 -0
- package/v2Containers/SmsTrai/Create/tests/__snapshots__/index.test.js.snap +880 -40
- package/v2Containers/SmsTrai/Edit/index.js +1 -1
- package/v2Containers/SmsTrai/Edit/messages.js +1 -1
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +1760 -80
- package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +16 -0
- package/v2Containers/Whatsapp/index.js +3 -3
- package/v2Containers/Whatsapp/messages.js +3 -3
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +17965 -1789
|
@@ -385,7 +385,7 @@ export const CapWhatsappCTA = (props) => {
|
|
|
385
385
|
}}
|
|
386
386
|
autoAdjustOverflow
|
|
387
387
|
placement="right"
|
|
388
|
-
title={formatMessage(messages.dynamicUrlTooltip)}
|
|
388
|
+
title={formatMessage(messages.dynamicUrlTooltip, { one: '{{1}}' })}
|
|
389
389
|
/>
|
|
390
390
|
)}
|
|
391
391
|
</CapHeading>
|
|
@@ -82,7 +82,7 @@ export default defineMessages({
|
|
|
82
82
|
dynamicUrlTooltip: {
|
|
83
83
|
id: `${prefix}.dynamicUrlTooltip`,
|
|
84
84
|
defaultMessage:
|
|
85
|
-
'Only one variable can be added to a URL. No need to add {
|
|
85
|
+
'Only one variable can be added to a URL. No need to add {one} to the end of the URL',
|
|
86
86
|
},
|
|
87
87
|
staticUrlWithVarErrorMessage: {
|
|
88
88
|
id: `${prefix}.staticUrlWithVarErrorMessage`,
|
|
@@ -92,10 +92,6 @@ export default defineMessages({
|
|
|
92
92
|
id: `${prefix}.dynamicUrlWithMoreVarErrorMessage`,
|
|
93
93
|
defaultMessage: 'Button with url type as dynamic can have only 1 variable',
|
|
94
94
|
},
|
|
95
|
-
dynamicUrlUnknownVars: {
|
|
96
|
-
id: `${prefix}.dynamicUrlUnknownVars`,
|
|
97
|
-
defaultMessage: 'Valid variable is {{1}}',
|
|
98
|
-
},
|
|
99
95
|
useTwoBracketsOnly: {
|
|
100
96
|
id: `${prefix}.useTwoBracketsOnly`,
|
|
101
97
|
defaultMessage: 'Use two brackets on each side to declare a variable',
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const AI_SUGGESTION_API_URL = "wss://ai-suggestions.chinmayjain.live/";
|
|
@@ -11,9 +11,29 @@ import PropTypes from 'prop-types';
|
|
|
11
11
|
import React from 'react';
|
|
12
12
|
import _ from 'lodash';
|
|
13
13
|
import { Tabs, Table, Modal} from 'antd';
|
|
14
|
-
import {
|
|
14
|
+
import { connect } from 'react-redux';
|
|
15
|
+
import CapSpin from '@capillarytech/cap-ui-library/CapSpin';
|
|
16
|
+
import CapDrawer from '@capillarytech/cap-ui-library/CapDrawer';
|
|
17
|
+
import CapButton from '@capillarytech/cap-ui-library/CapButton';
|
|
18
|
+
import CapInput from '@capillarytech/cap-ui-library/CapInput';
|
|
19
|
+
import CapPopover from '@capillarytech/cap-ui-library/CapPopover';
|
|
20
|
+
import CapImage from '@capillarytech/cap-ui-library/CapImage';
|
|
21
|
+
import CapCheckbox from '@capillarytech/cap-ui-library/CapCheckbox';
|
|
22
|
+
import CapRadio from '@capillarytech/cap-ui-library/CapRadio';
|
|
23
|
+
import CapSelect from '@capillarytech/cap-ui-library/CapSelect';
|
|
24
|
+
import CapTable from '@capillarytech/cap-ui-library/CapTable';
|
|
25
|
+
import CapRow from '@capillarytech/cap-ui-library/CapRow';
|
|
26
|
+
import CapColumn from '@capillarytech/cap-ui-library/CapColumn';
|
|
27
|
+
import CapNotification from '@capillarytech/cap-ui-library/CapNotification';
|
|
28
|
+
import CapUploader from '@capillarytech/cap-ui-library/CapUploader';
|
|
29
|
+
import CapHeading from '@capillarytech/cap-ui-library/CapHeading';
|
|
30
|
+
import CapIcon from '@capillarytech/cap-ui-library/CapIcon';
|
|
31
|
+
import CapTooltip from '@capillarytech/cap-ui-library/CapTooltip';
|
|
32
|
+
import CapAiSuggestions from '@capillarytech/cap-ui-library/CapAiSuggestions';
|
|
33
|
+
|
|
15
34
|
import { injectIntl, intlShape, FormattedMessage } from 'react-intl';
|
|
16
35
|
import LabelHOC from '@capillarytech/cap-ui-library/assets/HOCs/ComponentWithLabelHOC';
|
|
36
|
+
import { createStructuredSelector } from 'reselect';
|
|
17
37
|
import { CAP_SPACE_12, CAP_SPACE_08, FONT_COLOR_05, FONT_COLOR_04 } from '@capillarytech/cap-ui-library/styled/variables';
|
|
18
38
|
import TemplatePreview from '../TemplatePreview';
|
|
19
39
|
import TagList from '../../v2Containers/TagList';
|
|
@@ -24,12 +44,14 @@ import EDMEditor from "../Edmeditor";
|
|
|
24
44
|
import BeeEditor from '../../v2Containers/BeeEditor';
|
|
25
45
|
import CustomPopOver from '../CustomPopOver';
|
|
26
46
|
import messages from './messages';
|
|
47
|
+
import { selectCurrentOrgDetails } from "../../v2Containers/Cap/selectors";
|
|
27
48
|
import './_formBuilder.scss';
|
|
28
49
|
import {updateCharCount, checkUnicode} from "../../utils/smsCharCountV2";
|
|
29
|
-
import { SMS, LINE } from '../../v2Containers/CreativesContainer/constants';
|
|
50
|
+
import { SMS, MOBILE_PUSH, LINE, ENABLE_AI_SUGGESTIONS } from '../../v2Containers/CreativesContainer/constants';
|
|
30
51
|
import { validateIfTagClosed } from '../../utils/tagValidations';
|
|
31
52
|
import globalMessages from '../../v2Containers/Cap/messages';
|
|
32
53
|
import { convert } from 'html-to-text';
|
|
54
|
+
import { AI_SUGGESTION_API_URL } from './constants';
|
|
33
55
|
const TabPane = Tabs.TabPane;
|
|
34
56
|
const {Column} = Table;
|
|
35
57
|
const {TextArea} = CapInput;
|
|
@@ -2278,6 +2300,12 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
2278
2300
|
const messageContent = isVersionEnable ? formData[`${currentTab - 1}`][val.id] : formData[val.id];
|
|
2279
2301
|
const { MISSING_TAG_ERROR, UNSUPPORTED_TAG_ERROR, TAG_BRACKET_COUNT_MISMATCH_ERROR } = errorMessageForTags;
|
|
2280
2302
|
const { formatMessage } = this.props.intl;
|
|
2303
|
+
|
|
2304
|
+
const { accessibleFeatures = [] } = this.props.currentOrgDetails || {};
|
|
2305
|
+
const hasAiSuggestionsEnabled = accessibleFeatures.includes(
|
|
2306
|
+
ENABLE_AI_SUGGESTIONS
|
|
2307
|
+
);
|
|
2308
|
+
|
|
2281
2309
|
let errorMessageText = false;
|
|
2282
2310
|
switch (errorType) {
|
|
2283
2311
|
case MISSING_TAG_ERROR:
|
|
@@ -2313,6 +2341,18 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
2313
2341
|
disabled={val.disabled}
|
|
2314
2342
|
cols={cols}
|
|
2315
2343
|
/>
|
|
2344
|
+
{[SMS, MOBILE_PUSH].includes(this.props.schema?.channel)
|
|
2345
|
+
&& hasAiSuggestionsEnabled
|
|
2346
|
+
&& this.props.isFullMode
|
|
2347
|
+
&& (
|
|
2348
|
+
<CapAiSuggestions
|
|
2349
|
+
text={messageContent || ""}
|
|
2350
|
+
setText={(x) => {
|
|
2351
|
+
this.updateFormData(x, val);
|
|
2352
|
+
}}
|
|
2353
|
+
websocketUrl={AI_SUGGESTION_API_URL}
|
|
2354
|
+
/>
|
|
2355
|
+
)}
|
|
2316
2356
|
</CapColumn>
|
|
2317
2357
|
);
|
|
2318
2358
|
}
|
|
@@ -3617,7 +3657,11 @@ FormBuilder.propTypes = {
|
|
|
3617
3657
|
setDrawerVisibility: PropTypes.bool,
|
|
3618
3658
|
capDrawerContent: PropTypes.array,
|
|
3619
3659
|
isFullMode: PropTypes.bool,
|
|
3620
|
-
|
|
3660
|
+
currentOrgDetails: PropTypes.object,
|
|
3621
3661
|
};
|
|
3622
3662
|
|
|
3623
|
-
|
|
3663
|
+
const mapStateToProps = createStructuredSelector({
|
|
3664
|
+
currentOrgDetails: selectCurrentOrgDetails(),
|
|
3665
|
+
});
|
|
3666
|
+
|
|
3667
|
+
export default connect(mapStateToProps)(injectIntl(FormBuilder));
|
|
@@ -17,6 +17,7 @@ import { LOYALTY } from '../../v2Containers/App/constants';
|
|
|
17
17
|
import {
|
|
18
18
|
HELP_URL,
|
|
19
19
|
LOYALTY_HELP_URL,
|
|
20
|
+
ENABLE_AI_SUGGESTIONS,
|
|
20
21
|
} from '../../v2Containers/Cap/constants';
|
|
21
22
|
const PRODUCT_MASTERS = 'masters';
|
|
22
23
|
const EMBEDDED = 'embedded';
|
|
@@ -43,7 +44,7 @@ const ComponentWrapper = styled.div`
|
|
|
43
44
|
padding: 24px 0;
|
|
44
45
|
`;
|
|
45
46
|
|
|
46
|
-
class NavigationBar extends React.Component {
|
|
47
|
+
export class NavigationBar extends React.Component {
|
|
47
48
|
constructor(props) {
|
|
48
49
|
super(props);
|
|
49
50
|
this.state = this.initializeSelectedProduct();
|
|
@@ -153,9 +154,9 @@ class NavigationBar extends React.Component {
|
|
|
153
154
|
return productsList;
|
|
154
155
|
};
|
|
155
156
|
|
|
156
|
-
getTopbarIcons = () => {
|
|
157
|
+
getTopbarIcons = (showDocumentationBot = false) => {
|
|
157
158
|
const {settingsIcon} = this.state;
|
|
158
|
-
|
|
159
|
+
const ICONS = [
|
|
159
160
|
{
|
|
160
161
|
iconType: 'help',
|
|
161
162
|
key: 'help',
|
|
@@ -163,7 +164,8 @@ class NavigationBar extends React.Component {
|
|
|
163
164
|
},
|
|
164
165
|
settingsIcon,
|
|
165
166
|
];
|
|
166
|
-
|
|
167
|
+
return showDocumentationBot ? ICONS.slice(1) : ICONS; // If showDocumentationBot is true, help icon will be replaced by Aira icon on UI
|
|
168
|
+
};
|
|
167
169
|
|
|
168
170
|
getDropdownMenu = () => {
|
|
169
171
|
const { formatMessage } = this.props.intl;
|
|
@@ -207,12 +209,14 @@ class NavigationBar extends React.Component {
|
|
|
207
209
|
topbarMenuData,
|
|
208
210
|
loggedIn,
|
|
209
211
|
type,
|
|
212
|
+
userData,
|
|
210
213
|
} = this.props;
|
|
214
|
+
const showDocumentationBot = userData?.currentOrgDetails?.accessibleFeatures?.includes(ENABLE_AI_SUGGESTIONS);
|
|
211
215
|
const productsList = this.getProductsList();
|
|
212
216
|
const proxyOrgList = this.getProxyOrgList();
|
|
213
217
|
const selectedOrg = loadItem('orgID');
|
|
214
218
|
const dropdownMenuProps = this.getDropdownMenu();
|
|
215
|
-
const topbarIcons = this.getTopbarIcons();
|
|
219
|
+
const topbarIcons = this.getTopbarIcons(showDocumentationBot);
|
|
216
220
|
const { selectedProduct } = this.state;
|
|
217
221
|
const customTopBarProps = {};
|
|
218
222
|
return (
|
|
@@ -229,6 +233,7 @@ class NavigationBar extends React.Component {
|
|
|
229
233
|
handleTopbarMenuChange={this.handleTopbarMenuChange}
|
|
230
234
|
dropdownMenuProps={dropdownMenuProps}
|
|
231
235
|
topbarIcons={topbarIcons}
|
|
236
|
+
showDocumentationBot={showDocumentationBot}
|
|
232
237
|
{...customTopBarProps}
|
|
233
238
|
/>
|
|
234
239
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
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 { BrowserRouter as Router } from 'react-router-dom';
|
|
6
|
+
import { render, screen } from '../../../utils/test-utils';
|
|
7
|
+
|
|
8
|
+
import { NavigationBar } from '../index';
|
|
9
|
+
import * as mockdata from './mockData';
|
|
10
|
+
|
|
11
|
+
const { userData } = mockdata;
|
|
12
|
+
|
|
13
|
+
const ComponentToRender = injectIntl(NavigationBar);
|
|
14
|
+
|
|
15
|
+
const renderComponent = (props) => {
|
|
16
|
+
render(
|
|
17
|
+
<Router>
|
|
18
|
+
<ComponentToRender {...props} />
|
|
19
|
+
</Router>,
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
describe('NavigationBar', () => {
|
|
24
|
+
const props = {
|
|
25
|
+
topbarMenuData: [{}],
|
|
26
|
+
history: [{}],
|
|
27
|
+
userData,
|
|
28
|
+
loggedIn: true,
|
|
29
|
+
isCreativesAccessible: true,
|
|
30
|
+
campaignOrgV2Status: true,
|
|
31
|
+
location: {
|
|
32
|
+
pathname: "v2",
|
|
33
|
+
key: "g9d1jt",
|
|
34
|
+
basename: "/creatives/ui/",
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
it('Show aria documentation bot icon if showDocumentationBot is true', () => {
|
|
39
|
+
renderComponent(props);
|
|
40
|
+
const ariaBotIcon = screen.getByLabelText('aria bot icon');
|
|
41
|
+
expect(ariaBotIcon).toBeInTheDocument();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('Should not show aria documentation bot icon if showDocumentationBot is false', () => {
|
|
45
|
+
const updatedProps = cloneDeep(props);
|
|
46
|
+
delete updatedProps.userData.currentOrgDetails.accessibleFeatures;
|
|
47
|
+
renderComponent(updatedProps);
|
|
48
|
+
const ariaBotIcon = screen.queryByLabelText('aria bot icon');
|
|
49
|
+
expect(ariaBotIcon).toBeNull();
|
|
50
|
+
});
|
|
51
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export const userData = {
|
|
2
|
+
user: {
|
|
3
|
+
orgName: 'org1',
|
|
4
|
+
orgID: 1001,
|
|
5
|
+
proxyOrgList: [
|
|
6
|
+
{
|
|
7
|
+
orgName: 'org2',
|
|
8
|
+
orgID: 1002,
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
orgName: 'org3',
|
|
12
|
+
orgID: 1003,
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
},
|
|
16
|
+
currentOrgDetails: {
|
|
17
|
+
module_details: [
|
|
18
|
+
{
|
|
19
|
+
code: 'code1',
|
|
20
|
+
name: 'name1',
|
|
21
|
+
url: 'url1',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
code: 'code2',
|
|
25
|
+
name: 'name2',
|
|
26
|
+
url: 'url2',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
code: 'code3',
|
|
30
|
+
name: 'name3',
|
|
31
|
+
url: 'url3',
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
accessibleFeatures: ['ENABLE_AI_SUGGESTIONS'],
|
|
35
|
+
},
|
|
36
|
+
};
|
|
@@ -19,6 +19,7 @@ const TopBar = (props) => {
|
|
|
19
19
|
handleTopbarMenuChange,
|
|
20
20
|
dropdownMenuProps,
|
|
21
21
|
topbarIcons,
|
|
22
|
+
showDocumentationBot,
|
|
22
23
|
intl,
|
|
23
24
|
} = props;
|
|
24
25
|
return (
|
|
@@ -54,6 +55,7 @@ const TopBar = (props) => {
|
|
|
54
55
|
}}
|
|
55
56
|
dropdownMenuProps={dropdownMenuProps}
|
|
56
57
|
topbarIcons={topbarIcons}
|
|
58
|
+
showDocumentationBot={showDocumentationBot}
|
|
57
59
|
/>
|
|
58
60
|
);
|
|
59
61
|
};
|
|
@@ -69,6 +71,7 @@ TopBar.propTypes = {
|
|
|
69
71
|
handleTopbarMenuChange: PropTypes.func,
|
|
70
72
|
topbarIcons: PropTypes.array,
|
|
71
73
|
dropdownMenuProps: PropTypes.array,
|
|
74
|
+
showDocumentationBot: PropTypes.bool,
|
|
72
75
|
intl: intlShape.isRequired,
|
|
73
76
|
};
|
|
74
77
|
export default injectIntl(TopBar);
|