@capillarytech/creatives-library 9.0.37 → 9.0.39

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 (39) hide show
  1. package/package.json +1 -1
  2. package/translations/en.json +2 -2
  3. package/utils/permissions.js +59 -0
  4. package/utils/tests/permissions.test.js +116 -0
  5. package/v2Components/AccessForbidden/_accessForbidden.scss +14 -0
  6. package/v2Components/AccessForbidden/index.js +5 -3
  7. package/v2Components/AccessForbidden/messages.js +3 -2
  8. package/v2Components/NoPermissionWrapper/_noPermissionWrapper.scss +12 -0
  9. package/v2Components/NoPermissionWrapper/index.js +26 -0
  10. package/v2Containers/App/constants.js +5 -0
  11. package/v2Containers/Assets/Gallery/_gallery.scss +6 -0
  12. package/v2Containers/Assets/Gallery/index.js +34 -10
  13. package/v2Containers/Cap/index.js +5 -2
  14. package/v2Containers/Cap/messages.js +4 -0
  15. package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +2 -2
  16. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +6 -6
  17. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +4 -4
  18. package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +32 -32
  19. package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +36 -36
  20. package/v2Containers/Rcs/carouselUtils.js +46 -73
  21. package/v2Containers/Rcs/components/CarouselCard.js +6 -9
  22. package/v2Containers/Rcs/constants.js +2 -7
  23. package/v2Containers/Rcs/index.js +72 -126
  24. package/v2Containers/Rcs/rcsLibraryHydrationUtils.js +5 -43
  25. package/v2Containers/Rcs/tests/CarouselCard.test.js +1 -2
  26. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +118 -118
  27. package/v2Containers/Rcs/tests/carouselUtils.test.js +15 -15
  28. package/v2Containers/Rcs/tests/index.test.js +10 -232
  29. package/v2Containers/Rcs/tests/utils.test.js +0 -17
  30. package/v2Containers/Rcs/utils.js +12 -51
  31. package/v2Containers/SmsTrai/Create/tests/__snapshots__/index.test.js.snap +8 -8
  32. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +18 -18
  33. package/v2Containers/Templates/ChannelTypeIllustration.js +13 -2
  34. package/v2Containers/Templates/_templates.scss +6 -0
  35. package/v2Containers/Templates/index.js +141 -100
  36. package/v2Containers/Templates/tests/ChannelTypeIllustration.test.js +1 -1
  37. package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +174 -121
  38. package/v2Containers/TemplatesV2/index.js +16 -5
  39. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +268 -268
@@ -236,22 +236,26 @@ exports[`Test Templates container Should render sms illustration when no templat
236
236
  <div
237
237
  className="action-container__create-row"
238
238
  >
239
- <CapButton
240
- className="create-new-sms margin-l-8 margin-b-12"
241
- disabled={false}
242
- isAddBtn={true}
243
- onClick={[Function]}
244
- type="primary"
239
+ <NoPermissionWrapper
240
+ allowed={false}
245
241
  >
246
- Create new
247
- </CapButton>
242
+ <CapButton
243
+ className="create-new-sms margin-l-8 margin-b-12"
244
+ disabled={false}
245
+ onClick={[Function]}
246
+ type="primary"
247
+ >
248
+ Create new
249
+ </CapButton>
250
+ </NoPermissionWrapper>
248
251
  </div>
249
252
  </div>
250
253
  </div>
251
254
  </div>
252
255
  </CapRow>
253
256
  <div>
254
- <ChannelTypeIllustration
257
+ <InjectIntl(ChannelTypeIllustration)
258
+ canCreate={false}
255
259
  createTemplate={[Function]}
256
260
  currentChannel="SMS"
257
261
  hostName=""
@@ -504,17 +508,21 @@ exports[`Test Templates container Should render temlates when whatsapp templates
504
508
  <div
505
509
  className="action-container__create-row"
506
510
  >
507
- <CapLink
508
- className="create-new-link"
509
- onClick={[Function]}
510
- suffix={
511
- <CapIcon
512
- size="s"
513
- type="open-in-new"
514
- />
515
- }
516
- title="Create new template"
517
- />
511
+ <NoPermissionWrapper
512
+ allowed={false}
513
+ >
514
+ <CapLink
515
+ className="create-new-link"
516
+ onClick={[Function]}
517
+ suffix={
518
+ <CapIcon
519
+ size="s"
520
+ type="open-in-new"
521
+ />
522
+ }
523
+ title="Create new template"
524
+ />
525
+ </NoPermissionWrapper>
518
526
  </div>
519
527
  </div>
520
528
  </div>
@@ -811,15 +819,18 @@ exports[`Test Templates container Should render temlates when whatsapp templates
811
819
  <div
812
820
  className="action-container__create-row"
813
821
  >
814
- <CapButton
815
- className="create-new-whatsapp margin-l-8 margin-b-12"
816
- disabled={false}
817
- isAddBtn={true}
818
- onClick={[Function]}
819
- type="primary"
822
+ <NoPermissionWrapper
823
+ allowed={false}
820
824
  >
821
- Create new
822
- </CapButton>
825
+ <CapButton
826
+ className="create-new-whatsapp margin-l-8 margin-b-12"
827
+ disabled={false}
828
+ onClick={[Function]}
829
+ type="primary"
830
+ >
831
+ Create new
832
+ </CapButton>
833
+ </NoPermissionWrapper>
823
834
  </div>
824
835
  </div>
825
836
  </div>
@@ -1222,15 +1233,18 @@ exports[`Test Templates container Test max templates exceeded 1`] = `
1222
1233
  <div
1223
1234
  className="action-container__create-row"
1224
1235
  >
1225
- <CapButton
1226
- className="create-new-whatsapp margin-l-8 margin-b-12"
1227
- disabled={false}
1228
- isAddBtn={true}
1229
- onClick={[Function]}
1230
- type="primary"
1236
+ <NoPermissionWrapper
1237
+ allowed={false}
1231
1238
  >
1232
- Create new
1233
- </CapButton>
1239
+ <CapButton
1240
+ className="create-new-whatsapp margin-l-8 margin-b-12"
1241
+ disabled={false}
1242
+ onClick={[Function]}
1243
+ type="primary"
1244
+ >
1245
+ Create new
1246
+ </CapButton>
1247
+ </NoPermissionWrapper>
1234
1248
  </div>
1235
1249
  </div>
1236
1250
  </div>
@@ -1327,14 +1341,26 @@ Click {{unsubscribe}} to unsubscribe
1327
1341
  overlay={
1328
1342
  <CapMenuComponent>
1329
1343
  <withItemHOC
1330
- className="delete-whatsapp"
1344
+ className="delete-whatsapp rbac-disabled"
1331
1345
  onClick={[Function]}
1332
1346
  >
1333
- <FormattedMessage
1334
- defaultMessage="Delete"
1335
- id="creatives.containersV2.Templates.deleteButton"
1336
- values={Object {}}
1337
- />
1347
+ <CapTooltip
1348
+ title={
1349
+ <FormattedMessage
1350
+ defaultMessage="You don't have permission to perform this action."
1351
+ id="creatives.componentsV2.noPermissionAction"
1352
+ values={Object {}}
1353
+ />
1354
+ }
1355
+ >
1356
+ <span>
1357
+ <FormattedMessage
1358
+ defaultMessage="Delete"
1359
+ id="creatives.containersV2.Templates.deleteButton"
1360
+ values={Object {}}
1361
+ />
1362
+ </span>
1363
+ </CapTooltip>
1338
1364
  </withItemHOC>
1339
1365
  </CapMenuComponent>
1340
1366
  }
@@ -1344,12 +1370,7 @@ Click {{unsubscribe}} to unsubscribe
1344
1370
  />
1345
1371
  </CapDropdownComponent>,
1346
1372
  ],
1347
- "hoverOption": <CapButton
1348
- className="edit-whatsapp"
1349
- onClick={[Function]}
1350
- >
1351
- Overview
1352
- </CapButton>,
1373
+ "hoverOption": null,
1353
1374
  "key": "WHATSAPP-card-creatives_whatsapp6",
1354
1375
  "title": <CapRow
1355
1376
  align="middle"
@@ -1696,15 +1717,18 @@ exports[`Test Templates container Test max templates not exceeded 1`] = `
1696
1717
  <div
1697
1718
  className="action-container__create-row"
1698
1719
  >
1699
- <CapButton
1700
- className="create-new-whatsapp margin-l-8 margin-b-12"
1701
- disabled={false}
1702
- isAddBtn={true}
1703
- onClick={[Function]}
1704
- type="primary"
1720
+ <NoPermissionWrapper
1721
+ allowed={false}
1705
1722
  >
1706
- Create new
1707
- </CapButton>
1723
+ <CapButton
1724
+ className="create-new-whatsapp margin-l-8 margin-b-12"
1725
+ disabled={false}
1726
+ onClick={[Function]}
1727
+ type="primary"
1728
+ >
1729
+ Create new
1730
+ </CapButton>
1731
+ </NoPermissionWrapper>
1708
1732
  </div>
1709
1733
  </div>
1710
1734
  </div>
@@ -1801,14 +1825,26 @@ Click {{unsubscribe}} to unsubscribe
1801
1825
  overlay={
1802
1826
  <CapMenuComponent>
1803
1827
  <withItemHOC
1804
- className="delete-whatsapp"
1828
+ className="delete-whatsapp rbac-disabled"
1805
1829
  onClick={[Function]}
1806
1830
  >
1807
- <FormattedMessage
1808
- defaultMessage="Delete"
1809
- id="creatives.containersV2.Templates.deleteButton"
1810
- values={Object {}}
1811
- />
1831
+ <CapTooltip
1832
+ title={
1833
+ <FormattedMessage
1834
+ defaultMessage="You don't have permission to perform this action."
1835
+ id="creatives.componentsV2.noPermissionAction"
1836
+ values={Object {}}
1837
+ />
1838
+ }
1839
+ >
1840
+ <span>
1841
+ <FormattedMessage
1842
+ defaultMessage="Delete"
1843
+ id="creatives.containersV2.Templates.deleteButton"
1844
+ values={Object {}}
1845
+ />
1846
+ </span>
1847
+ </CapTooltip>
1812
1848
  </withItemHOC>
1813
1849
  </CapMenuComponent>
1814
1850
  }
@@ -1818,12 +1854,7 @@ Click {{unsubscribe}} to unsubscribe
1818
1854
  />
1819
1855
  </CapDropdownComponent>,
1820
1856
  ],
1821
- "hoverOption": <CapButton
1822
- className="edit-whatsapp"
1823
- onClick={[Function]}
1824
- >
1825
- Overview
1826
- </CapButton>,
1857
+ "hoverOption": null,
1827
1858
  "key": "WHATSAPP-card-creatives_whatsapp6",
1828
1859
  "title": <CapRow
1829
1860
  align="middle"
@@ -2170,15 +2201,18 @@ exports[`Test Templates container Test max templates warning 1`] = `
2170
2201
  <div
2171
2202
  className="action-container__create-row"
2172
2203
  >
2173
- <CapButton
2174
- className="create-new-whatsapp margin-l-8 margin-b-12"
2175
- disabled={false}
2176
- isAddBtn={true}
2177
- onClick={[Function]}
2178
- type="primary"
2204
+ <NoPermissionWrapper
2205
+ allowed={false}
2179
2206
  >
2180
- Create new
2181
- </CapButton>
2207
+ <CapButton
2208
+ className="create-new-whatsapp margin-l-8 margin-b-12"
2209
+ disabled={false}
2210
+ onClick={[Function]}
2211
+ type="primary"
2212
+ >
2213
+ Create new
2214
+ </CapButton>
2215
+ </NoPermissionWrapper>
2182
2216
  </div>
2183
2217
  </div>
2184
2218
  </div>
@@ -2275,14 +2309,26 @@ Click {{unsubscribe}} to unsubscribe
2275
2309
  overlay={
2276
2310
  <CapMenuComponent>
2277
2311
  <withItemHOC
2278
- className="delete-whatsapp"
2312
+ className="delete-whatsapp rbac-disabled"
2279
2313
  onClick={[Function]}
2280
2314
  >
2281
- <FormattedMessage
2282
- defaultMessage="Delete"
2283
- id="creatives.containersV2.Templates.deleteButton"
2284
- values={Object {}}
2285
- />
2315
+ <CapTooltip
2316
+ title={
2317
+ <FormattedMessage
2318
+ defaultMessage="You don't have permission to perform this action."
2319
+ id="creatives.componentsV2.noPermissionAction"
2320
+ values={Object {}}
2321
+ />
2322
+ }
2323
+ >
2324
+ <span>
2325
+ <FormattedMessage
2326
+ defaultMessage="Delete"
2327
+ id="creatives.containersV2.Templates.deleteButton"
2328
+ values={Object {}}
2329
+ />
2330
+ </span>
2331
+ </CapTooltip>
2286
2332
  </withItemHOC>
2287
2333
  </CapMenuComponent>
2288
2334
  }
@@ -2292,12 +2338,7 @@ Click {{unsubscribe}} to unsubscribe
2292
2338
  />
2293
2339
  </CapDropdownComponent>,
2294
2340
  ],
2295
- "hoverOption": <CapButton
2296
- className="edit-whatsapp"
2297
- onClick={[Function]}
2298
- >
2299
- Overview
2300
- </CapButton>,
2341
+ "hoverOption": null,
2301
2342
  "key": "WHATSAPP-card-creatives_whatsapp6",
2302
2343
  "title": <CapRow
2303
2344
  align="middle"
@@ -2587,17 +2628,21 @@ exports[`Test Templates container Test removing all whatsapp filterss 1`] = `
2587
2628
  <div
2588
2629
  className="action-container__create-row"
2589
2630
  >
2590
- <CapLink
2591
- className="create-new-link"
2592
- onClick={[Function]}
2593
- suffix={
2594
- <CapIcon
2595
- size="s"
2596
- type="open-in-new"
2597
- />
2598
- }
2599
- title="Create new template"
2600
- />
2631
+ <NoPermissionWrapper
2632
+ allowed={false}
2633
+ >
2634
+ <CapLink
2635
+ className="create-new-link"
2636
+ onClick={[Function]}
2637
+ suffix={
2638
+ <CapIcon
2639
+ size="s"
2640
+ type="open-in-new"
2641
+ />
2642
+ }
2643
+ title="Create new template"
2644
+ />
2645
+ </NoPermissionWrapper>
2601
2646
  </div>
2602
2647
  </div>
2603
2648
  </div>
@@ -2862,17 +2907,21 @@ exports[`Test Templates container Test removing all whatsapp filterss 2`] = `
2862
2907
  <div
2863
2908
  className="action-container__create-row"
2864
2909
  >
2865
- <CapLink
2866
- className="create-new-link"
2867
- onClick={[Function]}
2868
- suffix={
2869
- <CapIcon
2870
- size="s"
2871
- type="open-in-new"
2872
- />
2873
- }
2874
- title="Create new template"
2875
- />
2910
+ <NoPermissionWrapper
2911
+ allowed={false}
2912
+ >
2913
+ <CapLink
2914
+ className="create-new-link"
2915
+ onClick={[Function]}
2916
+ suffix={
2917
+ <CapIcon
2918
+ size="s"
2919
+ type="open-in-new"
2920
+ />
2921
+ }
2922
+ title="Create new template"
2923
+ />
2924
+ </NoPermissionWrapper>
2876
2925
  </div>
2877
2926
  </div>
2878
2927
  </div>
@@ -3112,17 +3161,21 @@ exports[`Test Templates container Test removing single filter 1`] = `
3112
3161
  <div
3113
3162
  className="action-container__create-row"
3114
3163
  >
3115
- <CapLink
3116
- className="create-new-link"
3117
- onClick={[Function]}
3118
- suffix={
3119
- <CapIcon
3120
- size="s"
3121
- type="open-in-new"
3122
- />
3123
- }
3124
- title="Create new template"
3125
- />
3164
+ <NoPermissionWrapper
3165
+ allowed={false}
3166
+ >
3167
+ <CapLink
3168
+ className="create-new-link"
3169
+ onClick={[Function]}
3170
+ suffix={
3171
+ <CapIcon
3172
+ size="s"
3173
+ type="open-in-new"
3174
+ />
3175
+ }
3176
+ title="Create new template"
3177
+ />
3178
+ </NoPermissionWrapper>
3126
3179
  </div>
3127
3180
  </div>
3128
3181
  </div>
@@ -34,7 +34,8 @@ import FTP from '../FTP';
34
34
  import Gallery from '../Assets/Gallery';
35
35
  import withStyles from '../../hoc/withStyles';
36
36
  import styles, { CapTabStyle } from './TemplatesV2.style';
37
- import { CREATIVES_UI_VIEW, FTP as FTP_CHANNEL, LOYALTY, WHATSAPP, RCS, LINE, EMAIL, ASSETS, JP_LOCALE_HIDE_FEATURE, ZALO, INAPP, WEBPUSH } from '../App/constants';
37
+ import { CREATIVES_UI_VIEW, CREATIVE_VIEW, FTP as FTP_CHANNEL, LOYALTY, WHATSAPP, RCS, LINE, EMAIL, ASSETS, JP_LOCALE_HIDE_FEATURE, ZALO, INAPP, WEBPUSH } from '../App/constants';
38
+ import { getUserAccess, hasPermission, PERMISSIONS } from '../../utils/permissions';
38
39
  import AccessForbidden from '../../v2Components/AccessForbidden';
39
40
  import { getObjFromQueryParams } from '../../utils/v2common';
40
41
  import { makeSelectAuthenticated, selectCurrentOrgDetails } from "../../v2Containers/Cap/selectors";
@@ -276,9 +277,16 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
276
277
  </CapSpin>
277
278
 
278
279
  </div>);
279
- };
280
-
281
- getGalleryComponent = (location) => <Gallery location={location} isFullMode={this.props.isFullMode}/>
280
+ }
281
+ getGalleryComponent = (location) => {
282
+ const userAccess = getUserAccess(this.props);
283
+ return (<Gallery
284
+ location={location}
285
+ isFullMode={this.props.isFullMode}
286
+ canCreate={hasPermission(userAccess, PERMISSIONS.CREATIVE_CREATE)}
287
+ canDelete={hasPermission(userAccess, PERMISSIONS.CREATIVE_DELETE)}
288
+ />);
289
+ }
282
290
  getCallTaskComponent = () => (
283
291
  <CallTask
284
292
  onCreateNew={this.props.createNew}
@@ -416,7 +424,10 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
416
424
  const useLocalTemplates = get(this.props, 'localTemplatesConfig.useLocalTemplates', false);
417
425
  const { accessiblePermissions = []} = cap.user || Global.user || {};
418
426
  let isCreativeAccessible = true;
419
- if (!accessiblePermissions.includes(CREATIVES_UI_VIEW)) {
427
+ if (
428
+ !accessiblePermissions.includes(CREATIVES_UI_VIEW) &&
429
+ !accessiblePermissions.includes(CREATIVE_VIEW)
430
+ ) {
420
431
  isCreativeAccessible = false;
421
432
  }
422
433
  // Recompute active pane content every render so local-list mode updates