@capillarytech/creatives-library 9.1.8-alpha.sprint-cap-214249.39 → 9.2.0
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/constants/unified.js +4 -0
- package/package.json +1 -1
- package/translations/en.json +1 -0
- package/translations/ja-JP.json +1 -0
- package/translations/zh.json +1 -0
- package/utils/common.js +6 -0
- package/utils/createMobilePushPayload.js +33 -50
- package/utils/tagValidations.js +35 -4
- package/utils/templateVarUtils.js +49 -0
- package/utils/tests/createMobilePushPayload.test.js +8 -113
- package/utils/tests/tagValidations.test.js +48 -0
- package/utils/tests/templateVarUtils.test.js +89 -0
- package/v2Components/CapMpushCTA/index.js +9 -10
- package/v2Components/CapMpushCTA/index.scss +3 -29
- package/v2Components/CapTagList/TagFallbackPanel.js +124 -0
- package/v2Components/CapTagList/constants.js +5 -0
- package/v2Components/CapTagList/index.js +46 -7
- package/v2Components/CapTagList/messages.js +44 -0
- package/v2Components/CapTagList/style.scss +113 -1
- package/v2Components/CapTagList/tests/TagFallback.test.js +222 -0
- package/v2Components/CapTagList/utils.js +17 -0
- package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +12 -20
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +1 -13
- package/v2Components/CommonTestAndPreview/constants.js +3 -2
- package/v2Components/CommonTestAndPreview/index.js +61 -61
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +5 -81
- package/v2Components/CommonTestAndPreview/tests/index.test.js +0 -86
- package/v2Components/CommonTestAndPreview/tests/utils.test.js +102 -0
- package/v2Components/CommonTestAndPreview/utils.js +42 -3
- package/v2Components/FormBuilder/Classic.js +24 -14
- package/v2Components/FormBuilder/Functional/channels/mobilepush/config.js +1 -0
- package/v2Components/FormBuilder/Functional/channels/mobilepush/getEditorErrorDescriptor.js +1 -1
- package/v2Components/FormBuilder/Functional/channels/mobilepush/tests/validate.test.js +57 -0
- package/v2Components/FormBuilder/Functional/channels/mobilepush/validate.js +4 -4
- package/v2Components/FormBuilder/Functional/channels/sms/getEditorErrorDescriptor.js +3 -0
- package/v2Components/FormBuilder/Functional/channels/sms/tests/getEditorErrorDescriptor.test.js +5 -0
- package/v2Components/FormBuilder/Functional/channels/sms/tests/validate.test.js +6 -0
- package/v2Components/FormBuilder/Functional/channels/sms/validate.js +3 -1
- package/v2Components/FormBuilder/Functional/renderers/mpushRenderers.js +3 -0
- package/v2Components/FormBuilder/Functional/tests/mpushRenderers.test.js +22 -0
- package/v2Components/TemplatePreview/_templatePreview.scss +2 -12
- package/v2Components/TemplatePreview/index.js +16 -24
- package/v2Components/TemplatePreview/tests/index.test.js +0 -68
- package/v2Containers/Cap/messages.js +4 -0
- package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +1 -0
- package/v2Containers/CreativesContainer/SlideBoxContent.js +6 -4
- package/v2Containers/CreativesContainer/index.js +1 -2
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +0 -43
- package/v2Containers/InApp/index.js +4 -1
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +3 -0
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +2 -0
- package/v2Containers/Line/Container/Text/index.js +3 -1
- package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +16 -0
- package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +18 -0
- package/v2Containers/MobilePushNew/components/CtaButtons.js +47 -52
- package/v2Containers/MobilePushNew/components/MediaUploaders.js +216 -297
- package/v2Containers/MobilePushNew/components/PlatformContentFields.js +125 -158
- package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +208 -30
- package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +108 -464
- package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +35 -106
- package/v2Containers/MobilePushNew/constants.js +0 -5
- package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +1 -63
- package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +0 -52
- package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +1 -40
- package/v2Containers/MobilePushNew/hooks/useUpload.js +39 -29
- package/v2Containers/MobilePushNew/index.js +239 -488
- package/v2Containers/MobilePushNew/index.scss +4 -205
- package/v2Containers/MobilePushNew/messages.js +6 -106
- package/v2Containers/MobilePushNew/tests/index.test.js +1 -469
- package/v2Containers/MobilePushNew/tests/utils.test.js +0 -70
- package/v2Containers/MobilePushNew/utils.js +0 -56
- package/v2Containers/Rcs/index.js +8 -1
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +59 -0
- package/v2Containers/SmsTrai/Create/tests/__snapshots__/index.test.js.snap +4 -0
- package/v2Containers/SmsTrai/Edit/index.js +17 -7
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +42 -0
- package/v2Containers/Templates/_templates.scss +2 -10
- package/v2Containers/Templates/index.js +81 -83
- package/v2Containers/Templates/tests/index.test.js +0 -68
- package/v2Containers/Viber/index.js +3 -1
- package/v2Containers/WebPush/Create/utils/validation.js +6 -0
- package/v2Containers/WebPush/Create/utils/validation.test.js +50 -0
- package/v2Containers/Whatsapp/index.js +9 -5
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +2 -2
- package/v2Containers/Zalo/index.js +4 -1
- package/v2Components/CapMpushCTA/tests/index.test.js +0 -89
- package/v2Containers/MobilePushNew/components/TapLinkActions.js +0 -76
|
@@ -347,7 +347,7 @@ export const Viber = (props) => {
|
|
|
347
347
|
// validation on Text area and tags validation
|
|
348
348
|
const updateTextContentError = (value) => {
|
|
349
349
|
let errorMessage = false;
|
|
350
|
-
const { valid, isBraceError } = validateTags({
|
|
350
|
+
const { valid, isBraceError, isDefaultQuoteError } = validateTags({
|
|
351
351
|
content: value,
|
|
352
352
|
tagsParam: tags,
|
|
353
353
|
location,
|
|
@@ -360,6 +360,8 @@ export const Viber = (props) => {
|
|
|
360
360
|
errorMessage = formatMessage(messages.limitExceededContentErrorMessage);
|
|
361
361
|
} else if (isBraceError) {
|
|
362
362
|
errorMessage = formatMessage(globalMessages.unbalanacedCurlyBraces);
|
|
363
|
+
} else if (isDefaultQuoteError) {
|
|
364
|
+
errorMessage = formatMessage(globalMessages.unquotedTagDefaultValue);
|
|
363
365
|
} else if (!valid) {
|
|
364
366
|
errorMessage = formatMessage(messages.invalidTagError);
|
|
365
367
|
}
|
|
@@ -37,6 +37,9 @@ export const validateTitle = (value, formatMessage, messages, restrictPersonaliz
|
|
|
37
37
|
if (validationResponse?.isBraceError) {
|
|
38
38
|
return formatMessage(globalMessages.unbalanacedCurlyBraces);
|
|
39
39
|
}
|
|
40
|
+
if (validationResponse?.isDefaultQuoteError) {
|
|
41
|
+
return formatMessage(globalMessages.unquotedTagDefaultValue);
|
|
42
|
+
}
|
|
40
43
|
}
|
|
41
44
|
|
|
42
45
|
return '';
|
|
@@ -83,6 +86,9 @@ export const validateMessageContent = (value, formatMessage, messages, validatio
|
|
|
83
86
|
if (validationResponse?.isBraceError) {
|
|
84
87
|
return formatMessage(globalMessages.unbalanacedCurlyBraces);
|
|
85
88
|
}
|
|
89
|
+
if (validationResponse?.isDefaultQuoteError) {
|
|
90
|
+
return formatMessage(globalMessages.unquotedTagDefaultValue);
|
|
91
|
+
}
|
|
86
92
|
|
|
87
93
|
if (restrictPersonalization && hasPersonalizationTags(value)) {
|
|
88
94
|
return formatMessage(messages.personalizationTokensErrorMessage);
|
|
@@ -24,6 +24,9 @@ jest.mock('../../../Cap/messages', () => ({
|
|
|
24
24
|
unbalanacedCurlyBraces: {
|
|
25
25
|
defaultMessage: 'Unbalanced curly braces',
|
|
26
26
|
},
|
|
27
|
+
unquotedTagDefaultValue: {
|
|
28
|
+
defaultMessage: 'Default value must be within quotes',
|
|
29
|
+
},
|
|
27
30
|
}));
|
|
28
31
|
|
|
29
32
|
import { validateTags } from '../../../../utils/tagValidations';
|
|
@@ -148,6 +151,27 @@ describe('validation', () => {
|
|
|
148
151
|
});
|
|
149
152
|
});
|
|
150
153
|
|
|
154
|
+
it('should return default quote error when validateTags returns isDefaultQuoteError', () => {
|
|
155
|
+
validateTags.mockReturnValue({ isBraceError: false, isDefaultQuoteError: true });
|
|
156
|
+
const result = validateTitle('{{name | default: x}}', mockFormatMessage, mockMessages, false, {}, false);
|
|
157
|
+
expect(result).toBe('Default value must be within quotes');
|
|
158
|
+
expect(mockFormatMessage).toHaveBeenCalledWith(globalMessages.unquotedTagDefaultValue);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it('should prefer brace error over default quote error', () => {
|
|
162
|
+
validateTags.mockReturnValue({ isBraceError: true, isDefaultQuoteError: true });
|
|
163
|
+
const result = validateTitle('{{name', mockFormatMessage, mockMessages, false, {}, false);
|
|
164
|
+
expect(result).toBe('Unbalanced curly braces');
|
|
165
|
+
expect(mockFormatMessage).not.toHaveBeenCalledWith(globalMessages.unquotedTagDefaultValue);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it('should return empty when validateTags has no errors or returns null/undefined', () => {
|
|
169
|
+
[{ isBraceError: false, isDefaultQuoteError: false }, null, undefined].forEach((response) => {
|
|
170
|
+
validateTags.mockReturnValue(response);
|
|
171
|
+
expect(validateTitle('Valid Title', mockFormatMessage, mockMessages, false, {}, false)).toBe('');
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
|
|
151
175
|
it('should not run tag validation when validationConfig is null', () => {
|
|
152
176
|
validateTags.mockClear();
|
|
153
177
|
const result = validateTitle('Valid Title', mockFormatMessage, mockMessages, false, null);
|
|
@@ -266,6 +290,32 @@ describe('validation', () => {
|
|
|
266
290
|
expect(mockFormatMessage).toHaveBeenCalledWith(globalMessages.unbalanacedCurlyBraces);
|
|
267
291
|
});
|
|
268
292
|
|
|
293
|
+
it('should return default quote error when validateTags returns isDefaultQuoteError', () => {
|
|
294
|
+
validateTags.mockReturnValue({ isBraceError: false, isDefaultQuoteError: true });
|
|
295
|
+
const result = validateMessageContent('{{name | default: x}}', mockFormatMessage, mockMessages, mockValidationConfig);
|
|
296
|
+
expect(result).toBe('Default value must be within quotes');
|
|
297
|
+
expect(mockFormatMessage).toHaveBeenCalledWith(globalMessages.unquotedTagDefaultValue);
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
it('should prefer brace error over default quote error', () => {
|
|
301
|
+
validateTags.mockReturnValue({ isBraceError: true, isDefaultQuoteError: true });
|
|
302
|
+
const result = validateMessageContent('{{name', mockFormatMessage, mockMessages, mockValidationConfig);
|
|
303
|
+
expect(result).toBe('Unbalanced curly braces');
|
|
304
|
+
expect(mockFormatMessage).not.toHaveBeenCalledWith(globalMessages.unquotedTagDefaultValue);
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
it('should return default quote error before personalization error', () => {
|
|
308
|
+
validateTags.mockReturnValue({ isDefaultQuoteError: true });
|
|
309
|
+
const result = validateMessageContent('{{first_name | default: x}}', mockFormatMessage, mockMessages, mockValidationConfig, false, true);
|
|
310
|
+
expect(result).toBe('Default value must be within quotes');
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
it('should return empty when isDefaultQuoteError is false', () => {
|
|
314
|
+
validateTags.mockReturnValue({ isBraceError: false, isDefaultQuoteError: false });
|
|
315
|
+
const result = validateMessageContent('Valid message', mockFormatMessage, mockMessages, mockValidationConfig);
|
|
316
|
+
expect(result).toBe('');
|
|
317
|
+
});
|
|
318
|
+
|
|
269
319
|
it('should pass validation config to validateTags', () => {
|
|
270
320
|
const customConfig = {
|
|
271
321
|
tagsParam: [{ id: 1, name: 'Tag1' }],
|
|
@@ -637,17 +637,18 @@ export const Whatsapp = (props) => {
|
|
|
637
637
|
tagModule: getDefaultTags,
|
|
638
638
|
isFullMode,
|
|
639
639
|
}) || {};
|
|
640
|
+
const hasTagSyntaxError = !!(validationResponse.isBraceError || validationResponse.isDefaultQuoteError);
|
|
640
641
|
if (type === HEADER_TEXT) {
|
|
641
642
|
headerTagValidationResponse = validationResponse;
|
|
642
|
-
updateIsHeaderTagValidationError(
|
|
643
|
+
updateIsHeaderTagValidationError(hasTagSyntaxError);
|
|
643
644
|
} else if (type === CAROUSEL_TEXT) {
|
|
644
645
|
return [
|
|
645
|
-
{ fieldName: "carouselTagValidationErrMessage", value:
|
|
646
|
-
{ fieldName: "carouselTagValidationErr", value:
|
|
646
|
+
{ fieldName: "carouselTagValidationErrMessage", value: hasTagSyntaxError ? validationResponse : {} },
|
|
647
|
+
{ fieldName: "carouselTagValidationErr", value: hasTagSyntaxError },
|
|
647
648
|
];
|
|
648
649
|
} else {
|
|
649
650
|
tagValidationResponse = validationResponse;
|
|
650
|
-
updateIsTagValidationError(
|
|
651
|
+
updateIsTagValidationError(hasTagSyntaxError);
|
|
651
652
|
}
|
|
652
653
|
}
|
|
653
654
|
};
|
|
@@ -2837,10 +2838,13 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
|
|
|
2837
2838
|
} else {
|
|
2838
2839
|
validationResponse = tagValidationResponse;
|
|
2839
2840
|
}
|
|
2840
|
-
const { isBraceError } = validationResponse || {};
|
|
2841
|
+
const { isBraceError, isDefaultQuoteError } = validationResponse || {};
|
|
2841
2842
|
if (isBraceError) {
|
|
2842
2843
|
return <CapError>{formatMessage(globalMessages.unbalanacedCurlyBraces)}</CapError>;
|
|
2843
2844
|
}
|
|
2845
|
+
if (isDefaultQuoteError) {
|
|
2846
|
+
return <CapError>{formatMessage(globalMessages.unquotedTagDefaultValue)}</CapError>;
|
|
2847
|
+
}
|
|
2844
2848
|
return null;
|
|
2845
2849
|
};
|
|
2846
2850
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 57312915 bytes
|
|
4
|
+
sha256: 297ff99f24988ebb3e7289712381c4345e1104c2184c67094070a6bf65072c26
|
|
@@ -281,10 +281,13 @@ export const Zalo = (props) => {
|
|
|
281
281
|
tagModule: getDefaultTags,
|
|
282
282
|
isFullMode,
|
|
283
283
|
}) || {};
|
|
284
|
-
const { isBraceError } = tagValidationResponse;
|
|
284
|
+
const { isBraceError, isDefaultQuoteError } = tagValidationResponse;
|
|
285
285
|
if (isBraceError) {
|
|
286
286
|
return formatMessage(globalMessages.unbalanacedCurlyBraces);
|
|
287
287
|
}
|
|
288
|
+
if (isDefaultQuoteError) {
|
|
289
|
+
return formatMessage(globalMessages.unquotedTagDefaultValue);
|
|
290
|
+
}
|
|
288
291
|
return '';
|
|
289
292
|
};
|
|
290
293
|
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { shallow } from 'enzyme';
|
|
3
|
-
import CapIcon from '@capillarytech/cap-ui-library/CapIcon';
|
|
4
|
-
import { CapMpushCTA } from '../index';
|
|
5
|
-
import CapTagListWithInput from '../../CapTagListWithInput';
|
|
6
|
-
import { DEEP_LINK, EXTERNAL_URL } from '../constants';
|
|
7
|
-
import { PRIMARY } from '../../../v2Containers/MobilePushNew/constants';
|
|
8
|
-
|
|
9
|
-
jest.mock('../../../v2Containers/TagList', () => () => null);
|
|
10
|
-
jest.mock('../../CapTagListWithInput', () => () => null);
|
|
11
|
-
|
|
12
|
-
const intl = { formatMessage: (msg) => msg?.defaultMessage || '' };
|
|
13
|
-
|
|
14
|
-
const renderCta = (cta, extraProps = {}) => shallow(
|
|
15
|
-
<CapMpushCTA
|
|
16
|
-
intl={intl}
|
|
17
|
-
ctaData={[{ index: 0, text: 'Shop', ...cta }]}
|
|
18
|
-
buttonType={PRIMARY}
|
|
19
|
-
updateHandler={jest.fn()}
|
|
20
|
-
deleteHandler={jest.fn()}
|
|
21
|
-
deepLink={[{ value: 'app://home', label: 'Home' }]}
|
|
22
|
-
location={{ query: {} }}
|
|
23
|
-
{...extraProps}
|
|
24
|
-
/>,
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
describe('CapMpushCTA', () => {
|
|
28
|
-
describe('saved button card', () => {
|
|
29
|
-
it('uses the mask-free "open-in-new" icon, not "launch"', () => {
|
|
30
|
-
const wrapper = renderCta({ urlType: EXTERNAL_URL, url: 'https://google.com', isSaved: true });
|
|
31
|
-
const iconTypes = wrapper.find(CapIcon).map((icon) => icon.prop('type'));
|
|
32
|
-
|
|
33
|
-
expect(iconTypes).toContain('open-in-new');
|
|
34
|
-
expect(iconTypes).not.toContain('launch');
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('shows the external URL in the link column with the URL as tooltip', () => {
|
|
38
|
-
const wrapper = renderCta({ urlType: EXTERNAL_URL, url: 'https://google.com', isSaved: true });
|
|
39
|
-
const link = wrapper.find('.mpush-saved-cta-link');
|
|
40
|
-
|
|
41
|
-
expect(link.prop('children')).toBe('https://google.com');
|
|
42
|
-
expect(link.prop('title')).toBe('https://google.com');
|
|
43
|
-
expect(wrapper.find('.cta-type-label').prop('children')).toBe('External link');
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('shows the selected deep link label in the link column', () => {
|
|
47
|
-
const wrapper = renderCta({ urlType: DEEP_LINK, url: 'app://home', isSaved: true });
|
|
48
|
-
|
|
49
|
-
expect(wrapper.find('.mpush-saved-cta-link').prop('children')).toBe('Home');
|
|
50
|
-
expect(wrapper.find('.cta-type-label').prop('children')).toBe('Deep link');
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('lays out the card rows horizontally with vertically centred items', () => {
|
|
54
|
-
const wrapper = renderCta({ urlType: EXTERNAL_URL, url: 'https://google.com', isSaved: true });
|
|
55
|
-
|
|
56
|
-
expect(wrapper.find('.mpush-cta-row').props()).toEqual(expect.objectContaining({ type: 'flex', align: 'middle' }));
|
|
57
|
-
expect(wrapper.find('.cta-action-grp').props()).toEqual(expect.objectContaining({ type: 'flex', align: 'middle' }));
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('reopens the button for editing and deletes it from the card icons', () => {
|
|
61
|
-
const updateHandler = jest.fn();
|
|
62
|
-
const deleteHandler = jest.fn();
|
|
63
|
-
const wrapper = renderCta(
|
|
64
|
-
{ urlType: EXTERNAL_URL, url: 'https://google.com', isSaved: true },
|
|
65
|
-
{ updateHandler, deleteHandler },
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
wrapper.find('.mpush-saved-cta-edit-icon').simulate('click');
|
|
69
|
-
expect(updateHandler).toHaveBeenCalledWith(expect.objectContaining({ isSaved: false }), 0);
|
|
70
|
-
|
|
71
|
-
wrapper.find('.cta-del-icon').simulate('click');
|
|
72
|
-
expect(deleteHandler).toHaveBeenCalledWith(0);
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it('keeps the "External link" heading on one line in the edit form', () => {
|
|
77
|
-
const wrapper = renderCta({ urlType: EXTERNAL_URL, url: '', isSaved: false });
|
|
78
|
-
|
|
79
|
-
expect(wrapper.find(CapTagListWithInput).prop('headingStyle')).toEqual(
|
|
80
|
-
expect.objectContaining({ whiteSpace: 'nowrap' }),
|
|
81
|
-
);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it('wraps the External link field so its label row lines up with "Type of link"', () => {
|
|
85
|
-
const wrapper = renderCta({ urlType: EXTERNAL_URL, url: '', isSaved: false });
|
|
86
|
-
|
|
87
|
-
expect(wrapper.find('.mpush-cta-external-link-field').find(CapTagListWithInput).exists()).toBe(true);
|
|
88
|
-
});
|
|
89
|
-
});
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
|
-
import CapRow from "@capillarytech/cap-ui-library/CapRow";
|
|
4
|
-
import CapColumn from "@capillarytech/cap-ui-library/CapColumn";
|
|
5
|
-
import CapButton from "@capillarytech/cap-ui-library/CapButton";
|
|
6
|
-
import CapIcon from "@capillarytech/cap-ui-library/CapIcon";
|
|
7
|
-
import CapTag from "@capillarytech/cap-ui-library/CapTag";
|
|
8
|
-
import CapTooltip from "@capillarytech/cap-ui-library/CapTooltip";
|
|
9
|
-
import globalMessages from "../../Cap/messages";
|
|
10
|
-
import messages from "../messages";
|
|
11
|
-
import { DEEP_LINK } from "../constants";
|
|
12
|
-
// Saved-row styles (.cap-mpush-saved-cta, .cta-type-label, ...) shared with the buttons
|
|
13
|
-
import "../../../v2Components/CapMpushCTA/index.scss";
|
|
14
|
-
|
|
15
|
-
// Save / Delete under an open tap link, as in the button form
|
|
16
|
-
export const TapLinkSaveDelete = ({
|
|
17
|
-
isSaveDisabled, onSave, onDelete, formatMessage,
|
|
18
|
-
}) => (
|
|
19
|
-
<CapRow type="flex" align="middle" className="mpush-tap-save-delete-btn">
|
|
20
|
-
<CapTooltip title={isSaveDisabled ? formatMessage(messages.tapLinkSaveDisabled) : ""}>
|
|
21
|
-
<span className="button-disabled-tooltip-wrapper">
|
|
22
|
-
<CapButton onClick={onSave} disabled={isSaveDisabled} className="mpush-tap-save-btn">
|
|
23
|
-
{formatMessage(globalMessages.save)}
|
|
24
|
-
</CapButton>
|
|
25
|
-
</span>
|
|
26
|
-
</CapTooltip>
|
|
27
|
-
<CapButton onClick={onDelete} type="secondary" className="mpush-tap-delete-btn">
|
|
28
|
-
{formatMessage(globalMessages.delete)}
|
|
29
|
-
</CapButton>
|
|
30
|
-
</CapRow>
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
TapLinkSaveDelete.propTypes = {
|
|
34
|
-
isSaveDisabled: PropTypes.bool.isRequired,
|
|
35
|
-
onSave: PropTypes.func.isRequired,
|
|
36
|
-
onDelete: PropTypes.func.isRequired,
|
|
37
|
-
formatMessage: PropTypes.func.isRequired,
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
// Collapsed row for a saved tap link, as for a saved button
|
|
41
|
-
export const SavedTapLink = ({
|
|
42
|
-
linkType, linkText, onEdit, onDelete, formatMessage,
|
|
43
|
-
}) => (
|
|
44
|
-
<CapRow type="flex" align="middle" className="cap-mpush-saved-cta mpush-saved-tap-link">
|
|
45
|
-
<CapColumn>
|
|
46
|
-
<CapTag className="cta-type-label">
|
|
47
|
-
{formatMessage(linkType === DEEP_LINK ? messages.tapActionDeepLink : messages.tapActionExternalLink)}
|
|
48
|
-
</CapTag>
|
|
49
|
-
</CapColumn>
|
|
50
|
-
<CapColumn className="mpush-saved-cta-link" title={linkText}>
|
|
51
|
-
{linkText}
|
|
52
|
-
</CapColumn>
|
|
53
|
-
<CapColumn>
|
|
54
|
-
<CapRow type="flex" align="middle" className="cta-action-grp">
|
|
55
|
-
<CapColumn className="mpush-saved-tap-link-edit-icon" onClick={onEdit}>
|
|
56
|
-
<CapIcon size="s" type="edit" className="cta-action" />
|
|
57
|
-
</CapColumn>
|
|
58
|
-
<CapColumn className="cta-del-icon mpush-saved-tap-link-delete-icon" onClick={onDelete}>
|
|
59
|
-
<CapIcon size="s" type="delete" className="cta-action" />
|
|
60
|
-
</CapColumn>
|
|
61
|
-
</CapRow>
|
|
62
|
-
</CapColumn>
|
|
63
|
-
</CapRow>
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
SavedTapLink.propTypes = {
|
|
67
|
-
linkType: PropTypes.string.isRequired,
|
|
68
|
-
linkText: PropTypes.string,
|
|
69
|
-
onEdit: PropTypes.func.isRequired,
|
|
70
|
-
onDelete: PropTypes.func.isRequired,
|
|
71
|
-
formatMessage: PropTypes.func.isRequired,
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
SavedTapLink.defaultProps = {
|
|
75
|
-
linkText: "",
|
|
76
|
-
};
|