@capillarytech/creatives-library 8.0.347 → 8.0.349
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/v2Containers/CreativesContainer/index.js +1 -1
- package/v2Containers/Templates/constants.js +8 -0
- package/v2Containers/Templates/index.js +28 -47
- package/v2Containers/Templates/messages.js +8 -0
- package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +0 -45
package/package.json
CHANGED
|
@@ -260,7 +260,7 @@ export class Creatives extends React.Component {
|
|
|
260
260
|
};
|
|
261
261
|
|
|
262
262
|
onEditTemplate = () => {
|
|
263
|
-
if (this.props.templateData
|
|
263
|
+
if (this.props.templateData?.isArchived) {
|
|
264
264
|
CapNotification.error({ message: this.props.intl.formatMessage(messages.cannotEditArchivedTemplate) });
|
|
265
265
|
return;
|
|
266
266
|
}
|
|
@@ -114,3 +114,11 @@ export const TOGGLE_TEMPLATE_SELECTION = 'app/v2Containers/Templates/TOGGLE_TEMP
|
|
|
114
114
|
export const SELECT_ALL_TEMPLATES = 'app/v2Containers/Templates/SELECT_ALL_TEMPLATES';
|
|
115
115
|
export const CLEAR_TEMPLATE_SELECTION = 'app/v2Containers/Templates/CLEAR_TEMPLATE_SELECTION';
|
|
116
116
|
export const SET_ARCHIVED_MODE = 'app/v2Containers/Templates/SET_ARCHIVED_MODE';
|
|
117
|
+
|
|
118
|
+
// Archive status values
|
|
119
|
+
export const ARCHIVE_STATUS_ACTIVE = 'active';
|
|
120
|
+
export const ARCHIVE_STATUS_ARCHIVED = 'archived';
|
|
121
|
+
|
|
122
|
+
// Archive listing refresh types
|
|
123
|
+
export const ARCHIVE_REFRESH_TYPE_ARCHIVE = 'ARCHIVE';
|
|
124
|
+
export const ARCHIVE_REFRESH_TYPE_UNARCHIVE = 'UNARCHIVE';
|
|
@@ -105,7 +105,7 @@ import {
|
|
|
105
105
|
FACEBOOK as FACEBOOK_CHANNEL,
|
|
106
106
|
CREATE,
|
|
107
107
|
} from '../App/constants';
|
|
108
|
-
import {MAX_WHATSAPP_TEMPLATES, WARNING_WHATSAPP_TEMPLATES , ACCOUNT_MAPPING_ON_CHANNEL, noFilteredWhatsappZaloTemplatesTitle, noFilteredWhatsappZaloTemplatesDesc, noApprovedWhatsappZaloTemplatesTitle, noApprovedWhatsappTemplatesDesc, zaloDescIllustration, noApprovedRcsTemplatesTitle, noApprovedRcsTemplatesDesc} from './constants';
|
|
108
|
+
import {MAX_WHATSAPP_TEMPLATES, WARNING_WHATSAPP_TEMPLATES , ACCOUNT_MAPPING_ON_CHANNEL, noFilteredWhatsappZaloTemplatesTitle, noFilteredWhatsappZaloTemplatesDesc, noApprovedWhatsappZaloTemplatesTitle, noApprovedWhatsappTemplatesDesc, zaloDescIllustration, noApprovedRcsTemplatesTitle, noApprovedRcsTemplatesDesc, ARCHIVE_STATUS_ACTIVE, ARCHIVE_STATUS_ARCHIVED, ARCHIVE_REFRESH_TYPE_ARCHIVE, ARCHIVE_REFRESH_TYPE_UNARCHIVE} from './constants';
|
|
109
109
|
import { COPY_OF, EMBEDDED } from '../../constants/unified';
|
|
110
110
|
import {
|
|
111
111
|
STATUS_OPTIONS,
|
|
@@ -839,18 +839,16 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
839
839
|
const wasBulkArchiving = this.props.Templates.bulkArchiveInProgress;
|
|
840
840
|
const isBulkArchiveDone = !nextProps.Templates.bulkArchiveInProgress && wasBulkArchiving;
|
|
841
841
|
if (isBulkArchiveDone && !nextProps.Templates.bulkArchiveError) {
|
|
842
|
-
const {
|
|
843
|
-
|
|
844
|
-
CapNotification.success({ message: msg });
|
|
842
|
+
const { count } = nextProps.Templates.bulkArchiveSuccessPayload || {};
|
|
843
|
+
CapNotification.success({ message: this.props.intl.formatMessage(messages.bulkArchiveSuccess, { count }) });
|
|
845
844
|
this.getAllTemplates({ params, resetPage: true });
|
|
846
845
|
}
|
|
847
846
|
|
|
848
847
|
const wasBulkUnarchiving = this.props.Templates.bulkUnarchiveInProgress;
|
|
849
848
|
const isBulkUnarchiveDone = !nextProps.Templates.bulkUnarchiveInProgress && wasBulkUnarchiving;
|
|
850
849
|
if (isBulkUnarchiveDone && !nextProps.Templates.bulkUnarchiveError) {
|
|
851
|
-
const {
|
|
852
|
-
|
|
853
|
-
CapNotification.success({ message: msg });
|
|
850
|
+
const { count } = nextProps.Templates.bulkUnarchiveSuccessPayload || {};
|
|
851
|
+
CapNotification.success({ message: this.props.intl.formatMessage(messages.bulkUnarchiveSuccess, { count }) });
|
|
854
852
|
this.getAllTemplates({ params, resetPage: true });
|
|
855
853
|
}
|
|
856
854
|
|
|
@@ -1947,14 +1945,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1947
1945
|
key: `${currentChannel}-card-${template?.name}`,
|
|
1948
1946
|
title: (
|
|
1949
1947
|
<span className="template-card-title">
|
|
1950
|
-
{
|
|
1951
|
-
<CapCheckbox
|
|
1952
|
-
checked={selectedIdsArrayForCard.includes(template._id)}
|
|
1953
|
-
onChange={() => !isAnyArchiveInProgress && this.props.actions.toggleTemplateSelection(template._id)}
|
|
1954
|
-
onClick={(e) => e.stopPropagation()}
|
|
1955
|
-
disabled={isAnyArchiveInProgress}
|
|
1956
|
-
/>
|
|
1957
|
-
)}
|
|
1948
|
+
{isCardArchiveEligible && this.renderCardSelectionCheckbox({ templateId: template._id, selectedIds: selectedIdsArrayForCard, isDisabled: isAnyArchiveInProgress })}
|
|
1958
1949
|
<CapLabel.CapLabelInline type="label1" title={template?.name} className="template-card-name">
|
|
1959
1950
|
{template?.name}
|
|
1960
1951
|
{currentChannel === INAPP && (
|
|
@@ -1965,7 +1956,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1965
1956
|
INAPP_LAYOUT_DETAILS[inappBodyType]?.tagTextColor
|
|
1966
1957
|
}
|
|
1967
1958
|
tagHeight="1.25rem"
|
|
1968
|
-
tagFontSize="
|
|
1959
|
+
tagFontSize="0.857rem"
|
|
1969
1960
|
>
|
|
1970
1961
|
{INAPP_LAYOUT_DETAILS[inappBodyType]?.text}
|
|
1971
1962
|
</CapColoredTag>
|
|
@@ -2089,7 +2080,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2089
2080
|
{(() => {
|
|
2090
2081
|
const channelUp = this.state.channel.toUpperCase();
|
|
2091
2082
|
if (!this.isChannelArchiveEligible(channelUp, status, rcsStatus)) return null;
|
|
2092
|
-
return !template
|
|
2083
|
+
return !template?.isArchived ? (
|
|
2093
2084
|
<CapMenu.Item
|
|
2094
2085
|
className={`archive-${channelLowerCase}`}
|
|
2095
2086
|
onClick={() => this.handleTemplateArchiveAction({ templateId: template._id, templateName: template.name })}
|
|
@@ -2386,14 +2377,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2386
2377
|
const { whatsappImageSrc = '', templateMsg, docPreview, whatsappVideoPreviewImg = '', templateHeaderPreview, templateFooterPreview, carouselData = [] } = getWhatsappContent(template);
|
|
2387
2378
|
templateData.title = (
|
|
2388
2379
|
<CapRow type="flex" align="middle">
|
|
2389
|
-
{
|
|
2390
|
-
<CapCheckbox
|
|
2391
|
-
checked={selectedIdsArrayForCard.includes(template._id)}
|
|
2392
|
-
onChange={() => !isAnyArchiveInProgress && this.props.actions.toggleTemplateSelection(template._id)}
|
|
2393
|
-
onClick={(e) => e.stopPropagation()}
|
|
2394
|
-
disabled={isAnyArchiveInProgress}
|
|
2395
|
-
/>
|
|
2396
|
-
)}
|
|
2380
|
+
{isCardArchiveEligible && this.renderCardSelectionCheckbox({ templateId: template._id, selectedIds: selectedIdsArrayForCard, isDisabled: isAnyArchiveInProgress })}
|
|
2397
2381
|
<CapLabel className="whatsapp-rcs-template-name">{template?.name}</CapLabel>
|
|
2398
2382
|
<WhatsappStatusContainer template={template} />
|
|
2399
2383
|
</CapRow>
|
|
@@ -2487,14 +2471,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2487
2471
|
const statusDisplay=getRcsStatusType(status);
|
|
2488
2472
|
templateData.title = (
|
|
2489
2473
|
<CapRow type="flex" align="middle">
|
|
2490
|
-
{
|
|
2491
|
-
<CapCheckbox
|
|
2492
|
-
checked={selectedIdsArrayForCard.includes(template._id)}
|
|
2493
|
-
onChange={() => !isAnyArchiveInProgress && this.props.actions.toggleTemplateSelection(template._id)}
|
|
2494
|
-
onClick={(e) => e.stopPropagation()}
|
|
2495
|
-
disabled={isAnyArchiveInProgress}
|
|
2496
|
-
/>
|
|
2497
|
-
)}
|
|
2474
|
+
{isCardArchiveEligible && this.renderCardSelectionCheckbox({ templateId: template._id, selectedIds: selectedIdsArrayForCard, isDisabled: isAnyArchiveInProgress })}
|
|
2498
2475
|
<CapLabel className="whatsapp-rcs-template-name">{name}</CapLabel>
|
|
2499
2476
|
<CapRow type="flex" align="middle" className="rcs-status-container zalo-status-color">
|
|
2500
2477
|
<CapStatus
|
|
@@ -2771,7 +2748,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2771
2748
|
<div className="archive-listing-spinner">
|
|
2772
2749
|
<CapSpin spinning />
|
|
2773
2750
|
<CapLabel.CapLabelInline type="label1">
|
|
2774
|
-
{archiveListingRefreshType ===
|
|
2751
|
+
{archiveListingRefreshType === ARCHIVE_REFRESH_TYPE_ARCHIVE ? this.props.intl.formatMessage(messages.archivalInProgress) : this.props.intl.formatMessage(messages.unarchivalInProgress)}
|
|
2775
2752
|
</CapLabel.CapLabelInline>
|
|
2776
2753
|
</div>
|
|
2777
2754
|
) : (
|
|
@@ -3603,6 +3580,18 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
3603
3580
|
this.setState({showModal: false});
|
|
3604
3581
|
}
|
|
3605
3582
|
|
|
3583
|
+
renderCardSelectionCheckbox = ({ templateId, selectedIds, isDisabled }) => {
|
|
3584
|
+
if (!this.props.isFullMode || this.props.location.query.type === EMBEDDED) return null;
|
|
3585
|
+
return (
|
|
3586
|
+
<CapCheckbox
|
|
3587
|
+
checked={selectedIds.includes(templateId)}
|
|
3588
|
+
onChange={() => !isDisabled && this.props.actions.toggleTemplateSelection(templateId)}
|
|
3589
|
+
onClick={(e) => e.stopPropagation()}
|
|
3590
|
+
disabled={isDisabled}
|
|
3591
|
+
/>
|
|
3592
|
+
);
|
|
3593
|
+
}
|
|
3594
|
+
|
|
3606
3595
|
handleBulkArchiveAction = ({ ids, count, isUnarchive = false }) => {
|
|
3607
3596
|
const { intl, actions } = this.props;
|
|
3608
3597
|
const { channel } = this.state;
|
|
@@ -3946,17 +3935,10 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
3946
3935
|
!(channel === RCS && [RCS_STATUSES.awaitingApproval, RCS_STATUSES.pending].includes(rcsStatus))
|
|
3947
3936
|
)
|
|
3948
3937
|
|
|
3949
|
-
|
|
3950
|
-
this.props.actions.setArchivedMode(
|
|
3951
|
-
this.setState({ searchText: '', page: 1 }, () => {
|
|
3952
|
-
this.getAllTemplates({ params: { name: '', sortBy: this.state.sortBy, archiveStatus: 'archived' }, resetPage: true }, true);
|
|
3953
|
-
});
|
|
3954
|
-
}
|
|
3955
|
-
|
|
3956
|
-
exitArchivedMode = () => {
|
|
3957
|
-
this.props.actions.setArchivedMode(false);
|
|
3938
|
+
setArchivedMode = (isArchived) => {
|
|
3939
|
+
this.props.actions.setArchivedMode(isArchived);
|
|
3958
3940
|
this.setState({ searchText: '', page: 1 }, () => {
|
|
3959
|
-
this.getAllTemplates({ params: { name: '', sortBy: this.state.sortBy, archiveStatus:
|
|
3941
|
+
this.getAllTemplates({ params: { name: '', sortBy: this.state.sortBy, archiveStatus: isArchived ? ARCHIVE_STATUS_ARCHIVED : ARCHIVE_STATUS_ACTIVE }, resetPage: true }, true);
|
|
3960
3942
|
});
|
|
3961
3943
|
}
|
|
3962
3944
|
isCreateDisabled = () => {
|
|
@@ -4676,7 +4658,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
4676
4658
|
<CapMenu>
|
|
4677
4659
|
<CapMenu.Item
|
|
4678
4660
|
key="archived"
|
|
4679
|
-
onClick={this.
|
|
4661
|
+
onClick={() => this.setArchivedMode(true)}
|
|
4680
4662
|
>
|
|
4681
4663
|
<FormattedMessage {...messages.archivedTemplates} />
|
|
4682
4664
|
</CapMenu.Item>
|
|
@@ -4727,7 +4709,6 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
4727
4709
|
className={`creatives-templates-list ${
|
|
4728
4710
|
this.props.isFullMode ? "full-mode" : "library-mode"
|
|
4729
4711
|
}`}
|
|
4730
|
-
style={{ position: 'relative' }}
|
|
4731
4712
|
>
|
|
4732
4713
|
<input
|
|
4733
4714
|
type="file"
|
|
@@ -4745,7 +4726,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
4745
4726
|
<CapIcon
|
|
4746
4727
|
type="back"
|
|
4747
4728
|
className="archived-mode-back-icon"
|
|
4748
|
-
onClick={this.
|
|
4729
|
+
onClick={() => this.setArchivedMode(false)}
|
|
4749
4730
|
/>
|
|
4750
4731
|
<CapHeading type="h3"><FormattedMessage {...messages.archivedTemplates} /></CapHeading>
|
|
4751
4732
|
</CapRow>
|
|
@@ -706,4 +706,12 @@ export default defineMessages({
|
|
|
706
706
|
id: `${scope}.bulkUnarchiveSuccess`,
|
|
707
707
|
defaultMessage: '{count} {count, plural, one {template} other {templates}} unarchived successfully',
|
|
708
708
|
},
|
|
709
|
+
"archivalInProgress": {
|
|
710
|
+
id: `${scope}.archivalInProgress`,
|
|
711
|
+
defaultMessage: 'Archival in progress',
|
|
712
|
+
},
|
|
713
|
+
"unarchivalInProgress": {
|
|
714
|
+
id: `${scope}.unarchivalInProgress`,
|
|
715
|
+
defaultMessage: 'Unarchival in progress',
|
|
716
|
+
},
|
|
709
717
|
});
|
|
@@ -192,11 +192,6 @@ exports[`Test Templates container Should render sms illustration when no templat
|
|
|
192
192
|
<Fragment>
|
|
193
193
|
<div
|
|
194
194
|
className="creatives-templates-list library-mode"
|
|
195
|
-
style={
|
|
196
|
-
Object {
|
|
197
|
-
"position": "relative",
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
195
|
>
|
|
201
196
|
<input
|
|
202
197
|
accept=".zip, .html, .htm"
|
|
@@ -381,11 +376,6 @@ exports[`Test Templates container Should render temlates when whatsapp templates
|
|
|
381
376
|
<Fragment>
|
|
382
377
|
<div
|
|
383
378
|
className="creatives-templates-list library-mode"
|
|
384
|
-
style={
|
|
385
|
-
Object {
|
|
386
|
-
"position": "relative",
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
379
|
>
|
|
390
380
|
<input
|
|
391
381
|
accept=".zip, .html, .htm"
|
|
@@ -638,11 +628,6 @@ exports[`Test Templates container Should render temlates when whatsapp templates
|
|
|
638
628
|
<Fragment>
|
|
639
629
|
<div
|
|
640
630
|
className="creatives-templates-list full-mode"
|
|
641
|
-
style={
|
|
642
|
-
Object {
|
|
643
|
-
"position": "relative",
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
631
|
>
|
|
647
632
|
<input
|
|
648
633
|
accept=".zip, .html, .htm"
|
|
@@ -1094,11 +1079,6 @@ exports[`Test Templates container Test max templates exceeded 1`] = `
|
|
|
1094
1079
|
<Fragment>
|
|
1095
1080
|
<div
|
|
1096
1081
|
className="creatives-templates-list full-mode"
|
|
1097
|
-
style={
|
|
1098
|
-
Object {
|
|
1099
|
-
"position": "relative",
|
|
1100
|
-
}
|
|
1101
|
-
}
|
|
1102
1082
|
>
|
|
1103
1083
|
<input
|
|
1104
1084
|
accept=".zip, .html, .htm"
|
|
@@ -1603,11 +1583,6 @@ exports[`Test Templates container Test max templates not exceeded 1`] = `
|
|
|
1603
1583
|
<Fragment>
|
|
1604
1584
|
<div
|
|
1605
1585
|
className="creatives-templates-list full-mode"
|
|
1606
|
-
style={
|
|
1607
|
-
Object {
|
|
1608
|
-
"position": "relative",
|
|
1609
|
-
}
|
|
1610
|
-
}
|
|
1611
1586
|
>
|
|
1612
1587
|
<input
|
|
1613
1588
|
accept=".zip, .html, .htm"
|
|
@@ -2112,11 +2087,6 @@ exports[`Test Templates container Test max templates warning 1`] = `
|
|
|
2112
2087
|
<Fragment>
|
|
2113
2088
|
<div
|
|
2114
2089
|
className="creatives-templates-list full-mode"
|
|
2115
|
-
style={
|
|
2116
|
-
Object {
|
|
2117
|
-
"position": "relative",
|
|
2118
|
-
}
|
|
2119
|
-
}
|
|
2120
2090
|
>
|
|
2121
2091
|
<input
|
|
2122
2092
|
accept=".zip, .html, .htm"
|
|
@@ -2621,11 +2591,6 @@ exports[`Test Templates container Test removing all whatsapp filterss 1`] = `
|
|
|
2621
2591
|
<Fragment>
|
|
2622
2592
|
<div
|
|
2623
2593
|
className="creatives-templates-list library-mode"
|
|
2624
|
-
style={
|
|
2625
|
-
Object {
|
|
2626
|
-
"position": "relative",
|
|
2627
|
-
}
|
|
2628
|
-
}
|
|
2629
2594
|
>
|
|
2630
2595
|
<input
|
|
2631
2596
|
accept=".zip, .html, .htm"
|
|
@@ -2904,11 +2869,6 @@ exports[`Test Templates container Test removing all whatsapp filterss 2`] = `
|
|
|
2904
2869
|
<Fragment>
|
|
2905
2870
|
<div
|
|
2906
2871
|
className="creatives-templates-list library-mode"
|
|
2907
|
-
style={
|
|
2908
|
-
Object {
|
|
2909
|
-
"position": "relative",
|
|
2910
|
-
}
|
|
2911
|
-
}
|
|
2912
2872
|
>
|
|
2913
2873
|
<input
|
|
2914
2874
|
accept=".zip, .html, .htm"
|
|
@@ -3161,11 +3121,6 @@ exports[`Test Templates container Test removing single filter 1`] = `
|
|
|
3161
3121
|
<Fragment>
|
|
3162
3122
|
<div
|
|
3163
3123
|
className="creatives-templates-list library-mode"
|
|
3164
|
-
style={
|
|
3165
|
-
Object {
|
|
3166
|
-
"position": "relative",
|
|
3167
|
-
}
|
|
3168
|
-
}
|
|
3169
3124
|
>
|
|
3170
3125
|
<input
|
|
3171
3126
|
accept=".zip, .html, .htm"
|