@capillarytech/creatives-library 8.0.349 → 8.0.350

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.
@@ -52,6 +52,7 @@ export const EXTENDED_TAG = 'ExtendedTagMessage';
52
52
  export const BADGES_UI_ENABLED = 'BADGES_UI_ENABLED';
53
53
  export const JP_LOCALE_HIDE_FEATURE = 'JP_LOCALE_HIDE_FEATURE';
54
54
  export const ENABLE_WECHAT = 'ENABLE_WECHAT';
55
+ export const ENABLE_CREATIVES_ARCHIVAL = 'ENABLE_CREATIVES_ARCHIVAL';
55
56
  export const ENABLE_WEBPUSH = 'ENABLE_WEBPUSH';
56
57
  export const ENABLE_CUSTOMER_BARCODE_TAG = 'ENABLE_CUSTOMER_BARCODE_TAG';
57
58
  export const EMAIL_UNSUBSCRIBE_TAG_MANDATORY = 'EMAIL_UNSUBSCRIBE_TAG_MANDATORY';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "8.0.349",
4
+ "version": "8.0.350",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
package/utils/common.js CHANGED
@@ -27,6 +27,7 @@ import {
27
27
  ENABLE_NEW_MPUSH,
28
28
  ENABLE_NEW_EDITOR_FLOW_INAPP,
29
29
  SUPPORT_ENGAGEMENT_MODULE,
30
+ ENABLE_CREATIVES_ARCHIVAL,
30
31
  } from '../constants/unified';
31
32
  import { apiMessageFormatHandler } from './commonUtils';
32
33
 
@@ -122,6 +123,11 @@ export const hasWechatFeatureEnabled = Auth.hasFeatureAccess.bind(
122
123
  ENABLE_WECHAT,
123
124
  );
124
125
 
126
+ export const hasCreativesArchivalEnabled = Auth.hasFeatureAccess.bind(
127
+ null,
128
+ ENABLE_CREATIVES_ARCHIVAL,
129
+ );
130
+
125
131
  export const hasWebPushFeatureEnabled = Auth.hasFeatureAccess.bind(
126
132
  null,
127
133
  ENABLE_WEBPUSH,
@@ -260,7 +260,7 @@ export class Creatives extends React.Component {
260
260
  };
261
261
 
262
262
  onEditTemplate = () => {
263
- if (this.props.templateData?.isArchived) {
263
+ if (commonUtil.hasCreativesArchivalEnabled() && this.props.templateData?.isArchived) {
264
264
  CapNotification.error({ message: this.props.intl.formatMessage(messages.cannotEditArchivedTemplate) });
265
265
  return;
266
266
  }
@@ -2140,7 +2140,7 @@ export class Creatives extends React.Component {
2140
2140
  onSave={this.saveMessage}
2141
2141
  onDiscard={this.discardMessage}
2142
2142
  onEditTemplate={this.onEditTemplate}
2143
- isTemplateArchived={!!(this.props.templateData && this.props.templateData.isArchived)}
2143
+ isTemplateArchived={!!(commonUtil.hasCreativesArchivalEnabled() && this.props.templateData && this.props.templateData.isArchived)}
2144
2144
  slidBoxContent={slidBoxContent}
2145
2145
  onCreateNextStep={this.onCreateNextStep}
2146
2146
  currentChannel={currentChannel.toUpperCase()}
@@ -1216,6 +1216,7 @@
1216
1216
  justify-content: space-between;
1217
1217
  align-items: center;
1218
1218
  gap: $CAP_SPACE_08;
1219
+ margin-right: $CAP_SPACE_32;
1219
1220
  }
1220
1221
 
1221
1222
  .template-listing-more-btn {
@@ -1938,9 +1938,10 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1938
1938
  // Archive eligibility per template: Zalo never; WhatsApp/RCS not when pending/awaiting
1939
1939
  const cardWhatsappStatus = get(template, `versions.base.content.${WHATSAPP_LOWERCASE}.status`, '');
1940
1940
  const cardRcsStatus = get(template, 'versions.base.content.RCS.rcsContent.cardContent[0].Status', '');
1941
- const isCardArchiveEligible = this.isChannelArchiveEligible(currentChannel, cardWhatsappStatus, cardRcsStatus);
1942
- const isArchivedMode = get(this.props, 'Templates.isArchivedMode', false);
1943
- const isAnyArchiveInProgress = !!(get(this.props, 'Templates.archiveInProgress') || get(this.props, 'Templates.unarchiveInProgress') || get(this.props, 'Templates.bulkArchiveInProgress') || get(this.props, 'Templates.bulkUnarchiveInProgress'));
1941
+ const isArchivalEnabled = commonUtil.hasCreativesArchivalEnabled();
1942
+ const isCardArchiveEligible = isArchivalEnabled && this.isChannelArchiveEligible(currentChannel, cardWhatsappStatus, cardRcsStatus);
1943
+ const isArchivedMode = isArchivalEnabled && get(this.props, 'Templates.isArchivedMode', false);
1944
+ const isAnyArchiveInProgress = isArchivalEnabled && !!(get(this.props, 'Templates.archiveInProgress') || get(this.props, 'Templates.unarchiveInProgress') || get(this.props, 'Templates.bulkArchiveInProgress') || get(this.props, 'Templates.bulkUnarchiveInProgress'));
1944
1945
  const templateData = {
1945
1946
  key: `${currentChannel}-card-${template?.name}`,
1946
1947
  title: (
@@ -2077,7 +2078,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2077
2078
  </CapMenu.Item>
2078
2079
  )}
2079
2080
  {/* Archive/Unarchive menu item (full mode only, not for Zalo, not for WhatsApp/RCS awaiting/pending) */}
2080
- {(() => {
2081
+ {commonUtil.hasCreativesArchivalEnabled() && (() => {
2081
2082
  const channelUp = this.state.channel.toUpperCase();
2082
2083
  if (!this.isChannelArchiveEligible(channelUp, status, rcsStatus)) return null;
2083
2084
  return !template?.isArchived ? (
@@ -2626,11 +2627,12 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2626
2627
 
2627
2628
  const noLoaderAndSearchText = isEmpty(this.state.searchText) && !isLoading;
2628
2629
 
2629
- const isArchivedModeLocal = get(this.props, 'Templates.isArchivedMode', false);
2630
+ const isArchivalEnabledLocal = commonUtil.hasCreativesArchivalEnabled();
2631
+ const isArchivedModeLocal = isArchivalEnabledLocal && get(this.props, 'Templates.isArchivedMode', false);
2630
2632
  const selectedIdsLocal = get(this.props, 'Templates.selectedTemplateIds', []);
2631
2633
  const selectedIdsArrayLocal = selectedIdsLocal && typeof selectedIdsLocal.toJS === 'function' ? selectedIdsLocal.toJS() : (Array.isArray(selectedIdsLocal) ? selectedIdsLocal : []);
2632
2634
  const selectedCountLocal = selectedIdsArrayLocal.length;
2633
- const hasSelectionLocal = this.props.isFullMode && selectedCountLocal > 0;
2635
+ const hasSelectionLocal = isArchivalEnabledLocal && this.props.isFullMode && selectedCountLocal > 0;
2634
2636
 
2635
2637
  return (<div>
2636
2638
  {[WECHAT, MOBILE_PUSH, WEBPUSH, INAPP, WHATSAPP, ZALO, RCS].includes(currentChannel) && this.showAccountName()}
@@ -3840,7 +3842,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
3840
3842
  <span className="template-name" style={{ fontWeight: `${this.state.channel.toLowerCase() === 'wechat' ? '400' : '600'}` }}>
3841
3843
  { template && template.versions && template.versions.history && template.versions.history.length > 1 && this.state.channel.toLowerCase() !== 'mobilepush' && <i style={{fontSize: '16px', margin: '0 8px 0 0', verticalAlign: 'middle'}} className="material-icons">filter_none</i>}
3842
3844
  {template?.name}
3843
- {template.isArchived && <CapColoredTag tagColor={CAP_G08} tagTextColor={CAP_G05} className="archived-tag">{this.props.intl.formatMessage(messages.archivedTag)}</CapColoredTag>}
3845
+ {commonUtil.hasCreativesArchivalEnabled() && template.isArchived && <CapColoredTag tagColor={CAP_G08} tagTextColor={CAP_G05} className="archived-tag">{this.props.intl.formatMessage(messages.archivedTag)}</CapColoredTag>}
3844
3846
  </span>
3845
3847
  {this.props.location.query.type !== EMBEDDED && <CapPopover
3846
3848
  trigger="click"
@@ -3851,7 +3853,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
3851
3853
  {this.props.intl.formatMessage(messages.duplicateButton)}
3852
3854
  </CapButton>
3853
3855
  </div>}
3854
- {this.props.isFullMode && isTemplateArchiveEligible && !template.isArchived && <div className="popover-action-container">
3856
+ {commonUtil.hasCreativesArchivalEnabled() && this.props.isFullMode && isTemplateArchiveEligible && !template.isArchived && <div className="popover-action-container">
3855
3857
  <CapButton
3856
3858
  type="link"
3857
3859
  onClick={() => this.handleTemplateArchiveAction({ templateId: template._id, templateName: template.name })}
@@ -3861,7 +3863,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
3861
3863
  <CapLabel.CapLabelInline type="label1">{this.props.intl.formatMessage(messages.archiveButton)}</CapLabel.CapLabelInline>
3862
3864
  </CapButton>
3863
3865
  </div>}
3864
- {this.props.isFullMode && isTemplateArchiveEligible && template.isArchived && <div className="popover-action-container">
3866
+ {commonUtil.hasCreativesArchivalEnabled() && this.props.isFullMode && isTemplateArchiveEligible && template.isArchived && <div className="popover-action-container">
3865
3867
  <CapButton
3866
3868
  type="link"
3867
3869
  onClick={() => this.handleTemplateArchiveAction({ templateId: template._id, templateName: template.name, isUnarchive: true })}
@@ -4478,10 +4480,11 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
4478
4480
  if (([WHATSAPP_LOWERCASE, ZALO_LOWERCASE, RCS_LOWERCASE].includes(this.state?.channel?.toLocaleLowerCase()) && isEmpty(this.state?.hostName))) {
4479
4481
  isfilterContentVisisble = false;
4480
4482
  }
4481
- const _isArchivedMode = get(this.props, 'Templates.isArchivedMode', false);
4483
+ const _isArchivalEnabled = commonUtil.hasCreativesArchivalEnabled();
4484
+ const _isArchivedMode = _isArchivalEnabled && get(this.props, 'Templates.isArchivedMode', false);
4482
4485
  const _renderSelectedIds = get(this.props, 'Templates.selectedTemplateIds', []);
4483
4486
  const _renderSelectedIdsArray = _renderSelectedIds && typeof _renderSelectedIds.toJS === 'function' ? _renderSelectedIds.toJS() : (Array.isArray(_renderSelectedIds) ? _renderSelectedIds : []);
4484
- const _renderHasSelection = this.props.isFullMode && _renderSelectedIdsArray.length > 0;
4487
+ const _renderHasSelection = _isArchivalEnabled && this.props.isFullMode && _renderSelectedIdsArray.length > 0;
4485
4488
 
4486
4489
  const filterContent = (( isfilterContentVisisble || [WECHAT, MOBILE_PUSH, INAPP].includes(this.state.channel.toUpperCase())) && <div className="action-container">
4487
4490
  {isfilterContentVisisble && <CapInput.Search
@@ -4650,8 +4653,8 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
4650
4653
  )
4651
4654
  : isfilterContentVisisble && !isWechatEmbedded && !this.props.isDltFromRcs && createButton
4652
4655
  )}
4653
- {/* More (⋯) menu: full mode only, not archived mode, not Zalo (no archive support), not when selection active */}
4654
- {!_isArchivedMode && !_renderHasSelection && this.props.isFullMode && this.props.location.query.type !== EMBEDDED && channelLowerCase !== ZALO_LOWERCASE && (
4656
+ {/* More (⋯) menu: full mode only, not archived mode, not Zalo (no archive support), not when selection active, archive flag enabled */}
4657
+ {commonUtil.hasCreativesArchivalEnabled() && !_isArchivedMode && !_renderHasSelection && this.props.isFullMode && this.props.location.query.type !== EMBEDDED && channelLowerCase !== ZALO_LOWERCASE && (
4655
4658
  <CapDropdown
4656
4659
  trigger={['click']}
4657
4660
  overlay={
@@ -4720,8 +4723,8 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
4720
4723
  }
4721
4724
  />
4722
4725
 
4723
- {/* Archived mode header with back arrow (full mode only) */}
4724
- {this.props.isFullMode && get(this.props, 'Templates.isArchivedMode', false) && (
4726
+ {/* Archived mode header with back arrow (full mode only, archive flag enabled) */}
4727
+ {commonUtil.hasCreativesArchivalEnabled() && this.props.isFullMode && get(this.props, 'Templates.isArchivedMode', false) && (
4725
4728
  <CapRow type="flex" align="middle" className="archived-mode-header">
4726
4729
  <CapIcon
4727
4730
  type="back"
@@ -831,37 +831,6 @@ exports[`Test Templates container Should render temlates when whatsapp templates
831
831
  >
832
832
  Create new
833
833
  </CapButton>
834
- <CapDropdown
835
- overlay={
836
- <CapMenu>
837
- <withItemHOC
838
- onClick={[Function]}
839
- >
840
- <FormattedMessage
841
- defaultMessage="Archived templates"
842
- id="creatives.containersV2.Templates.archivedTemplates"
843
- values={Object {}}
844
- />
845
- </withItemHOC>
846
- </CapMenu>
847
- }
848
- placement="bottomRight"
849
- trigger={
850
- Array [
851
- "click",
852
- ]
853
- }
854
- >
855
- <CapButton
856
- className="template-listing-more-btn"
857
- isAddBtn={false}
858
- type="flat"
859
- >
860
- <CapIcon
861
- type="more"
862
- />
863
- </CapButton>
864
- </CapDropdown>
865
834
  </div>
866
835
  </div>
867
836
  </div>
@@ -1282,37 +1251,6 @@ exports[`Test Templates container Test max templates exceeded 1`] = `
1282
1251
  >
1283
1252
  Create new
1284
1253
  </CapButton>
1285
- <CapDropdown
1286
- overlay={
1287
- <CapMenu>
1288
- <withItemHOC
1289
- onClick={[Function]}
1290
- >
1291
- <FormattedMessage
1292
- defaultMessage="Archived templates"
1293
- id="creatives.containersV2.Templates.archivedTemplates"
1294
- values={Object {}}
1295
- />
1296
- </withItemHOC>
1297
- </CapMenu>
1298
- }
1299
- placement="bottomRight"
1300
- trigger={
1301
- Array [
1302
- "click",
1303
- ]
1304
- }
1305
- >
1306
- <CapButton
1307
- className="template-listing-more-btn"
1308
- isAddBtn={false}
1309
- type="flat"
1310
- >
1311
- <CapIcon
1312
- type="more"
1313
- />
1314
- </CapButton>
1315
- </CapDropdown>
1316
1254
  </div>
1317
1255
  </div>
1318
1256
  </div>
@@ -1786,37 +1724,6 @@ exports[`Test Templates container Test max templates not exceeded 1`] = `
1786
1724
  >
1787
1725
  Create new
1788
1726
  </CapButton>
1789
- <CapDropdown
1790
- overlay={
1791
- <CapMenu>
1792
- <withItemHOC
1793
- onClick={[Function]}
1794
- >
1795
- <FormattedMessage
1796
- defaultMessage="Archived templates"
1797
- id="creatives.containersV2.Templates.archivedTemplates"
1798
- values={Object {}}
1799
- />
1800
- </withItemHOC>
1801
- </CapMenu>
1802
- }
1803
- placement="bottomRight"
1804
- trigger={
1805
- Array [
1806
- "click",
1807
- ]
1808
- }
1809
- >
1810
- <CapButton
1811
- className="template-listing-more-btn"
1812
- isAddBtn={false}
1813
- type="flat"
1814
- >
1815
- <CapIcon
1816
- type="more"
1817
- />
1818
- </CapButton>
1819
- </CapDropdown>
1820
1727
  </div>
1821
1728
  </div>
1822
1729
  </div>
@@ -2290,37 +2197,6 @@ exports[`Test Templates container Test max templates warning 1`] = `
2290
2197
  >
2291
2198
  Create new
2292
2199
  </CapButton>
2293
- <CapDropdown
2294
- overlay={
2295
- <CapMenu>
2296
- <withItemHOC
2297
- onClick={[Function]}
2298
- >
2299
- <FormattedMessage
2300
- defaultMessage="Archived templates"
2301
- id="creatives.containersV2.Templates.archivedTemplates"
2302
- values={Object {}}
2303
- />
2304
- </withItemHOC>
2305
- </CapMenu>
2306
- }
2307
- placement="bottomRight"
2308
- trigger={
2309
- Array [
2310
- "click",
2311
- ]
2312
- }
2313
- >
2314
- <CapButton
2315
- className="template-listing-more-btn"
2316
- isAddBtn={false}
2317
- type="flat"
2318
- >
2319
- <CapIcon
2320
- type="more"
2321
- />
2322
- </CapButton>
2323
- </CapDropdown>
2324
2200
  </div>
2325
2201
  </div>
2326
2202
  </div>