@capillarytech/creatives-library 8.0.346 → 8.0.347

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.
Files changed (28) hide show
  1. package/package.json +1 -1
  2. package/services/api.js +20 -0
  3. package/services/tests/api.test.js +59 -0
  4. package/utils/tests/v2Common.test.js +46 -1
  5. package/utils/v2common.js +18 -0
  6. package/v2Components/CapCustomSkeleton/index.js +1 -1
  7. package/v2Components/CapCustomSkeleton/tests/__snapshots__/index.test.js.snap +12 -12
  8. package/v2Containers/Assets/images/archive_Empty_Illustration.svg +9 -0
  9. package/v2Containers/CreativesContainer/SlideBoxFooter.js +3 -1
  10. package/v2Containers/CreativesContainer/index.js +5 -0
  11. package/v2Containers/CreativesContainer/messages.js +4 -0
  12. package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +3 -0
  13. package/v2Containers/Templates/ChannelTypeIllustration.js +23 -6
  14. package/v2Containers/Templates/_templates.scss +179 -24
  15. package/v2Containers/Templates/actions.js +44 -0
  16. package/v2Containers/Templates/constants.js +23 -0
  17. package/v2Containers/Templates/index.js +378 -58
  18. package/v2Containers/Templates/messages.js +88 -0
  19. package/v2Containers/Templates/reducer.js +84 -1
  20. package/v2Containers/Templates/sagas.js +64 -0
  21. package/v2Containers/Templates/selectors.js +12 -0
  22. package/v2Containers/Templates/tests/ChannelTypeIllustration.test.js +12 -0
  23. package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +1345 -1122
  24. package/v2Containers/Templates/tests/index.test.js +6 -0
  25. package/v2Containers/Templates/tests/reducer.test.js +178 -0
  26. package/v2Containers/Templates/tests/sagas.test.js +390 -8
  27. package/v2Containers/Templates/tests/selector.test.js +32 -0
  28. package/v2Containers/TemplatesV2/TemplatesV2.style.js +1 -1
@@ -24,6 +24,7 @@ function SlideBoxFooter(props) {
24
24
  slidBoxContent,
25
25
  onSave,
26
26
  onEditTemplate,
27
+ isTemplateArchived,
27
28
  onCreateNextStep,
28
29
  isFullMode,
29
30
  fetchingCmsData,
@@ -214,7 +215,7 @@ function SlideBoxFooter(props) {
214
215
  <FormattedMessage {...(continueButtonLabel || messages.continue)} />
215
216
  </CapButton>
216
217
  )}
217
- {slidBoxContent === PREVIEW && (
218
+ {slidBoxContent === PREVIEW && !isTemplateArchived && (
218
219
  <CapButton onClick={onEditTemplate} type="secondary">
219
220
  <FormattedMessage {...messages.creativesTemplatesEdit} />
220
221
  </CapButton>
@@ -227,6 +228,7 @@ SlideBoxFooter.propTypes = {
227
228
  slidBoxContent: PropTypes.node,
228
229
  onSave: PropTypes.func,
229
230
  onEditTemplate: PropTypes.func,
231
+ isTemplateArchived: PropTypes.bool,
230
232
  onCreateNextStep: PropTypes.func,
231
233
  shouldShowContinueFooter: PropTypes.func,
232
234
  shouldShowDoneFooter: PropTypes.func,
@@ -260,6 +260,10 @@ export class Creatives extends React.Component {
260
260
  };
261
261
 
262
262
  onEditTemplate = () => {
263
+ if (this.props.templateData && this.props.templateData.isArchived) {
264
+ CapNotification.error({ message: this.props.intl.formatMessage(messages.cannotEditArchivedTemplate) });
265
+ return;
266
+ }
263
267
  this.setState({ slidBoxContent: 'editTemplate', showSlideBox: true, templateNameExists: true });
264
268
  };
265
269
 
@@ -2136,6 +2140,7 @@ export class Creatives extends React.Component {
2136
2140
  onSave={this.saveMessage}
2137
2141
  onDiscard={this.discardMessage}
2138
2142
  onEditTemplate={this.onEditTemplate}
2143
+ isTemplateArchived={!!(this.props.templateData && this.props.templateData.isArchived)}
2139
2144
  slidBoxContent={slidBoxContent}
2140
2145
  onCreateNextStep={this.onCreateNextStep}
2141
2146
  currentChannel={currentChannel.toUpperCase()}
@@ -390,4 +390,8 @@ export default defineMessages({
390
390
  id: `${scope}.personalizationTokensErrorMessage`,
391
391
  defaultMessage: `Personalization tags are not supported for anonymous customers, please remove the tags.`,
392
392
  },
393
+ "cannotEditArchivedTemplate": {
394
+ id: `${scope}.cannotEditArchivedTemplate`,
395
+ defaultMessage: 'Cannot edit an archived template. Please unarchive it first.',
396
+ },
393
397
  });
@@ -295,6 +295,7 @@ exports[`Test SlideBoxContent container campaign message, whatsapp edit all data
295
295
  isEmptyContent={false}
296
296
  isFullMode={false}
297
297
  isLiquidValidationError={false}
298
+ isTemplateArchived={false}
298
299
  isTemplateNameEmpty={false}
299
300
  onCreateNextStep={[Function]}
300
301
  onDiscard={[Function]}
@@ -434,6 +435,7 @@ exports[`Test SlideBoxContent container campaign message, whatsapp edit min data
434
435
  isEmptyContent={false}
435
436
  isFullMode={false}
436
437
  isLiquidValidationError={false}
438
+ isTemplateArchived={false}
437
439
  isTemplateNameEmpty={false}
438
440
  onCreateNextStep={[Function]}
439
441
  onDiscard={[Function]}
@@ -573,6 +575,7 @@ exports[`Test SlideBoxContent container it should clear the url, on channel chan
573
575
  isEmptyContent={false}
574
576
  isFullMode={false}
575
577
  isLiquidValidationError={false}
578
+ isTemplateArchived={false}
576
579
  isTemplateNameEmpty={false}
577
580
  onCreateNextStep={[Function]}
578
581
  onDiscard={[Function]}
@@ -1,5 +1,9 @@
1
1
  import React, { useMemo } from 'react';
2
2
  import PropTypes from 'prop-types';
3
+ import zaloillustration from '@capillarytech/cap-ui-library/assets/images/featureUiNotEnabledIllustration.svg';
4
+ import inAppIllustration from '@capillarytech/cap-ui-library/assets/images/featureUiNotEnabledIllustration.svg';
5
+ import { FormattedMessage } from 'react-intl';
6
+ import { CapIllustration } from "@capillarytech/cap-ui-library";
3
7
  import emailIllustration from '../Assets/images/emailIllustration.svg';
4
8
  import smsIllustration from '../Assets/images/smsIllustration.svg';
5
9
  import pushIllustration from '../Assets/images/pushIllustration.svg';
@@ -8,13 +12,12 @@ import lineIllustration from '../Assets/images/lineIllustration.svg';
8
12
  import facebookIllustration from '../Assets/images/facebookIllustration.svg';
9
13
  import whatsappIllustration from '../Assets/images/whatsappIllustration.png';
10
14
  import whatsappOrZaloAccountIllustration from '../Assets/images/whatsappOrZaloAccountIllustration.svg';
15
+ import archiveEmptyStateIllustration from '../Assets/images/archive_Empty_Illustration.svg';
11
16
  import rcsIllustration from '../Assets/images/rcsIllustration.png';
12
- import zaloillustration from '@capillarytech/cap-ui-library/assets/images/featureUiNotEnabledIllustration.svg';
13
- import inAppIllustration from '@capillarytech/cap-ui-library/assets/images/featureUiNotEnabledIllustration.svg';
14
17
  import messages from './messages';
15
- import { FormattedMessage } from 'react-intl';
16
- import { CapIllustration } from "@capillarytech/cap-ui-library";
17
- import { MOBILE_PUSH, SMS, EMAIL, LINE, VIBER, FACEBOOK, WHATSAPP, RCS, ZALO, INAPP, WEBPUSH } from '../CreativesContainer/constants';
18
+ import {
19
+ MOBILE_PUSH, SMS, EMAIL, LINE, VIBER, FACEBOOK, WHATSAPP, RCS, ZALO, INAPP, WEBPUSH,
20
+ } from '../CreativesContainer/constants';
18
21
 
19
22
 
20
23
  // Configuration object for channel types
@@ -80,7 +83,8 @@ function ChannelTypeIllustration(props) {
80
83
  isFullMode,
81
84
  createTemplate,
82
85
  currentChannel,
83
- hostName
86
+ hostName,
87
+ isArchivedMode,
84
88
  } = props;
85
89
 
86
90
  const templateText = useMemo(() => {
@@ -88,6 +92,18 @@ function ChannelTypeIllustration(props) {
88
92
  return isFullMode ? templateIntlMsg : '';
89
93
  }, [isFullMode]);
90
94
 
95
+ if (isArchivedMode) {
96
+ return (
97
+ <CapIllustration
98
+ illustrationImage={archiveEmptyStateIllustration}
99
+ title={<FormattedMessage {...messages.noArchivedCreatives} />}
100
+ description={<FormattedMessage {...messages.noArchivedCreativesDesc} />}
101
+ descriptionPosition="bottom"
102
+ descriptionClassName="illustration-desc archive-illustration"
103
+ />
104
+ );
105
+ }
106
+
91
107
  const getChannelTypeIllustrationInfo = (type, hostName) => {
92
108
  // Handle special cases with hostName dependency
93
109
  if (type === WHATSAPP) {
@@ -196,5 +212,6 @@ ChannelTypeIllustration.propTypes = {
196
212
  createTemplate: PropTypes.func.isRequired,
197
213
  currentChannel: PropTypes.string,
198
214
  hostName: PropTypes.string,
215
+ isArchivedMode: PropTypes.bool,
199
216
  };
200
217
  export default ChannelTypeIllustration;
@@ -1,34 +1,23 @@
1
1
  @import '~@capillarytech/cap-ui-library/styles/_variables.scss';
2
2
 
3
3
  .ant-tabs-content{
4
- margin-top: 16px;
4
+ margin-top: $CAP_SPACE_16;
5
5
  .ant-tabs-tabpane-active{
6
6
  padding: unset;
7
7
  }
8
8
  }
9
+ //removing current one as not required now in each row we'll have 3 cards for which css has been added
9
10
 
10
- @media screen and (max-width: 1172px) {
11
- .creatives-templates-list.full-mode{
12
- .v2-pagination-container {
13
- .cap-custom-card-list-row {
14
- .cap-custom-card-list-col{
15
- &:nth-child(3n+3) { //every 4th child
16
- margin-right: unset;
17
- }
18
- }
19
- }
20
- }
21
- }
22
- }
23
-
24
- @media screen and (min-width: 1172px) {
25
- .creatives-templates-list.full-mode{
26
- .v2-pagination-container {
27
- .cap-custom-card-list-row {
28
- .cap-custom-card-list-col{
29
- &:nth-child(4n+4) { //every 4th child
30
- margin-right: unset;
31
- }
11
+ // 3 cards per row across all breakpoints
12
+ .creatives-templates-list {
13
+ .v2-pagination-container,
14
+ .v2-pagination-container-half {
15
+ .cap-custom-card-list-row {
16
+ .cap-custom-card-list-col {
17
+ width: calc(33.33% - #{$CAP_SPACE_08});
18
+ margin-right: $CAP_SPACE_12;
19
+ &:nth-child(3n) {
20
+ margin-right: 0;
32
21
  }
33
22
  }
34
23
  }
@@ -36,6 +25,21 @@
36
25
  }
37
26
 
38
27
  .creatives-templates-list {
28
+ position: relative;
29
+
30
+ .archive-listing-spinner {
31
+ position: absolute;
32
+ top: 50%;
33
+ left: 50%;
34
+ transform: translate(-50%, -50%);
35
+ display: flex;
36
+ align-items: center;
37
+ gap: $CAP_SPACE_08;
38
+ background: $CAP_WHITE;
39
+ padding: $CAP_SPACE_08 $CAP_SPACE_16;
40
+ border-radius: $CAP_SPACE_08;
41
+ z-index: 10;
42
+ }
39
43
 
40
44
  .delete-template-confirm {
41
45
  .ant-modal-footer {
@@ -674,6 +678,37 @@
674
678
  font-size: 14px;
675
679
  }
676
680
 
681
+ // Archive/Unarchive confirm modal overrides — scoped to avoid affecting other modals
682
+ .archive-confirm-modal {
683
+ .ant-modal-body {
684
+ padding: $CAP_SPACE_32 $CAP_SPACE_32 $CAP_SPACE_24;
685
+ margin-top: 8.571rem;
686
+ }
687
+
688
+ // Remove the left margin added when an icon is present
689
+ .ant-modal-confirm-body {
690
+ > .anticon + .ant-modal-confirm-title + .ant-modal-confirm-content {
691
+ margin-left: 0;
692
+ }
693
+ }
694
+
695
+ // Left-align buttons, remove float
696
+ .ant-modal-confirm-btns {
697
+ float: none;
698
+ display: flex;
699
+ align-items: center;
700
+ gap: $CAP_SPACE_08;
701
+ margin-top: $CAP_SPACE_16;
702
+
703
+ // Cancel button styling
704
+ .ant-btn:not(.ant-btn-primary) {
705
+ background-color: $CAP_G08;
706
+ border-color: $CAP_G08;
707
+ color: $CAP_G01;
708
+ }
709
+ }
710
+ }
711
+
677
712
  .popover-action-container {
678
713
  line-height: 24px;
679
714
  }
@@ -1101,4 +1136,124 @@
1101
1136
  .inapp-illustration-parent {
1102
1137
  height: "calc(100vh - 325px)";
1103
1138
  overflow: 'auto';
1104
- }
1139
+ }
1140
+
1141
+ // Archive feature layout classes
1142
+ .illustration-scroll-wrapper {
1143
+ height: calc(100vh - 20.3125rem);
1144
+ overflow: auto;
1145
+ }
1146
+
1147
+ .filter-row {
1148
+ display: flex;
1149
+ align-items: center;
1150
+ justify-content: space-between;
1151
+ width: 102%;
1152
+ }
1153
+
1154
+ .filter-row-content {
1155
+ flex: 1;
1156
+ }
1157
+
1158
+ .bulk-selection-bar {
1159
+ display: flex;
1160
+ align-items: center;
1161
+ gap: $CAP_SPACE_12;
1162
+ flex-shrink: 0;
1163
+ margin-right: $CAP_SPACE_32;
1164
+ }
1165
+
1166
+ .archived-mode-header {
1167
+ display: flex;
1168
+ align-items: center;
1169
+ gap: $CAP_SPACE_12;
1170
+ margin-bottom: $CAP_SPACE_16;
1171
+
1172
+ .archived-mode-back-icon {
1173
+ cursor: pointer;
1174
+ font-size: 1.428rem;
1175
+ }
1176
+ }
1177
+
1178
+ .archived-tag {
1179
+ margin-left: $CAP_SPACE_08;
1180
+ font-size: 0.786rem;
1181
+ }
1182
+
1183
+ .popover-archive-action {
1184
+ cursor: pointer;
1185
+ padding: $CAP_SPACE_08 0;
1186
+ }
1187
+
1188
+ .archive-menu-item {
1189
+ display: inline-flex;
1190
+ align-items: center;
1191
+ gap: $CAP_SPACE_08;
1192
+ margin-top: 1rem;
1193
+ }
1194
+
1195
+ .archive-btn-label {
1196
+ margin-right: 0.714rem;
1197
+ }
1198
+
1199
+ .bulk-selection-bar .cap-button-v2-prefix {
1200
+ margin-top: 1rem;
1201
+ }
1202
+
1203
+ .bulk-selection-bar .ant-btn.cap-button-v2 > .cap-button-v2-prefix + span {
1204
+ margin-left: -$CAP_SPACE_06;
1205
+ }
1206
+
1207
+ .template-card-top-bar {
1208
+ display: flex;
1209
+ align-items: center;
1210
+ justify-content: space-between;
1211
+ padding: $CAP_SPACE_08 $CAP_SPACE_12 0;
1212
+ }
1213
+
1214
+ .template-listing-header-actions {
1215
+ display: flex;
1216
+ justify-content: space-between;
1217
+ align-items: center;
1218
+ gap: $CAP_SPACE_08;
1219
+ }
1220
+
1221
+ .template-listing-more-btn {
1222
+ padding: 0;
1223
+ margin-right: $CAP_SPACE_12;
1224
+ min-width: auto;
1225
+ }
1226
+
1227
+ .notification-template-label {
1228
+ color: $CAP_G04;
1229
+ }
1230
+
1231
+ .notification-template-name {
1232
+ color: $CAP_G01;
1233
+ }
1234
+
1235
+ .template-card-title {
1236
+ display: flex;
1237
+ align-items: center;
1238
+ min-width: 0;
1239
+
1240
+ .cap-checkbox-v2 {
1241
+ flex-shrink: 0;
1242
+ margin-right: $CAP_SPACE_04;
1243
+ // Remove the empty label span's padding that antd Checkbox renders when no children are passed
1244
+ .ant-checkbox + span {
1245
+ padding-left: 0;
1246
+ padding-right: 0;
1247
+ }
1248
+ }
1249
+
1250
+ .template-card-name {
1251
+ font-weight: 500;
1252
+ font-size: $FONT_SIZE_L;
1253
+ color: $CAP_G01;
1254
+ overflow: hidden;
1255
+ text-overflow: ellipsis;
1256
+ white-space: nowrap;
1257
+ min-width: 0;
1258
+ }
1259
+ }
@@ -167,3 +167,47 @@ export function getCdnTransformationConfig() {
167
167
  type: types.GET_CDN_TRANSFORMATION_CONFIG_REQUEST,
168
168
  };
169
169
  }
170
+
171
+ export function archiveTemplate(channel, id, successMessage, description) {
172
+ return {
173
+ type: types.ARCHIVE_TEMPLATE_REQUEST, channel, id, successMessage, description
174
+ };
175
+ }
176
+
177
+ export function unarchiveTemplate(channel, id, successMessage, description) {
178
+ return {
179
+ type: types.UNARCHIVE_TEMPLATE_REQUEST, channel, id, successMessage, description
180
+ };
181
+ }
182
+
183
+ export function bulkArchiveTemplates(channel, ids, successMessage) {
184
+ return {
185
+ type: types.BULK_ARCHIVE_REQUEST, channel, ids, successMessage
186
+ };
187
+ }
188
+
189
+ export function bulkUnarchiveTemplates(channel, ids, successMessage) {
190
+ return {
191
+ type: types.BULK_UNARCHIVE_REQUEST, channel, ids, successMessage
192
+ };
193
+ }
194
+
195
+ export function setArchiveFilter(filter) {
196
+ return { type: types.SET_ARCHIVE_FILTER, filter };
197
+ }
198
+
199
+ export function toggleTemplateSelection(id) {
200
+ return { type: types.TOGGLE_TEMPLATE_SELECTION, id };
201
+ }
202
+
203
+ export function selectAllTemplates(ids) {
204
+ return { type: types.SELECT_ALL_TEMPLATES, ids };
205
+ }
206
+
207
+ export function clearTemplateSelection() {
208
+ return { type: types.CLEAR_TEMPLATE_SELECTION };
209
+ }
210
+
211
+ export function setArchivedMode(isArchived) {
212
+ return { type: types.SET_ARCHIVED_MODE, isArchived };
213
+ }
@@ -91,3 +91,26 @@ export const noApprovedWhatsappTemplatesDesc ='noApprovedWhatsappTemplatesDesc'
91
91
  export const zaloDescIllustration='zaloDescIllustration'
92
92
  export const noApprovedRcsTemplatesTitle='noApprovedRcsTemplatesTitle'
93
93
  export const noApprovedRcsTemplatesDesc='noApprovedRcsTemplatesDesc'
94
+
95
+ // Archive feature
96
+ export const ARCHIVE_TEMPLATE_REQUEST = 'app/v2Containers/Templates/ARCHIVE_TEMPLATE_REQUEST';
97
+ export const ARCHIVE_TEMPLATE_SUCCESS = 'app/v2Containers/Templates/ARCHIVE_TEMPLATE_SUCCESS';
98
+ export const ARCHIVE_TEMPLATE_FAILURE = 'app/v2Containers/Templates/ARCHIVE_TEMPLATE_FAILURE';
99
+
100
+ export const UNARCHIVE_TEMPLATE_REQUEST = 'app/v2Containers/Templates/UNARCHIVE_TEMPLATE_REQUEST';
101
+ export const UNARCHIVE_TEMPLATE_SUCCESS = 'app/v2Containers/Templates/UNARCHIVE_TEMPLATE_SUCCESS';
102
+ export const UNARCHIVE_TEMPLATE_FAILURE = 'app/v2Containers/Templates/UNARCHIVE_TEMPLATE_FAILURE';
103
+
104
+ export const BULK_ARCHIVE_REQUEST = 'app/v2Containers/Templates/BULK_ARCHIVE_REQUEST';
105
+ export const BULK_ARCHIVE_SUCCESS = 'app/v2Containers/Templates/BULK_ARCHIVE_SUCCESS';
106
+ export const BULK_ARCHIVE_FAILURE = 'app/v2Containers/Templates/BULK_ARCHIVE_FAILURE';
107
+
108
+ export const BULK_UNARCHIVE_REQUEST = 'app/v2Containers/Templates/BULK_UNARCHIVE_REQUEST';
109
+ export const BULK_UNARCHIVE_SUCCESS = 'app/v2Containers/Templates/BULK_UNARCHIVE_SUCCESS';
110
+ export const BULK_UNARCHIVE_FAILURE = 'app/v2Containers/Templates/BULK_UNARCHIVE_FAILURE';
111
+
112
+ export const SET_ARCHIVE_FILTER = 'app/v2Containers/Templates/SET_ARCHIVE_FILTER';
113
+ export const TOGGLE_TEMPLATE_SELECTION = 'app/v2Containers/Templates/TOGGLE_TEMPLATE_SELECTION';
114
+ export const SELECT_ALL_TEMPLATES = 'app/v2Containers/Templates/SELECT_ALL_TEMPLATES';
115
+ export const CLEAR_TEMPLATE_SELECTION = 'app/v2Containers/Templates/CLEAR_TEMPLATE_SELECTION';
116
+ export const SET_ARCHIVED_MODE = 'app/v2Containers/Templates/SET_ARCHIVED_MODE';