@contentful/field-editor-reference 4.2.2 → 4.3.1

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.
@@ -2255,13 +2255,14 @@ function useEditorPermissions(props) {
2255
2255
 
2256
2256
  function _checkCreateAccess() {
2257
2257
  _checkCreateAccess = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
2258
- var canCreate;
2258
+ var canCreate, _canCreate;
2259
+
2259
2260
  return runtime_1.wrap(function _callee$(_context) {
2260
2261
  while (1) {
2261
2262
  switch (_context.prev = _context.next) {
2262
2263
  case 0:
2263
2264
  if (!(entityType === 'Asset')) {
2264
- _context.next = 5;
2265
+ _context.next = 8;
2265
2266
  break;
2266
2267
  }
2267
2268
 
@@ -2269,15 +2270,28 @@ function useEditorPermissions(props) {
2269
2270
  return canPerformAction('create', 'Asset');
2270
2271
 
2271
2272
  case 3:
2272
- canCreate = _context.sent;
2273
+ _context.t0 = _context.sent;
2274
+
2275
+ if (_context.t0) {
2276
+ _context.next = 6;
2277
+ break;
2278
+ }
2279
+
2280
+ _context.t0 = true;
2281
+
2282
+ case 6:
2283
+ canCreate = _context.t0;
2273
2284
  setCanCreateEntity(canCreate);
2274
2285
 
2275
- case 5:
2286
+ case 8:
2276
2287
  if (entityType === 'Entry') {
2277
- setCanCreateEntity(creatableContentTypes.length > 0);
2288
+ // Hardcoded `true` value following https://contentful.atlassian.net/browse/DANTE-486
2289
+ // TODO: refine permissions check in order to account for tags in rules
2290
+ _canCreate = readableContentTypes.length > 0 || true;
2291
+ setCanCreateEntity(_canCreate);
2278
2292
  }
2279
2293
 
2280
- case 6:
2294
+ case 9:
2281
2295
  case "end":
2282
2296
  return _context.stop();
2283
2297
  }
@@ -2301,7 +2315,8 @@ function useEditorPermissions(props) {
2301
2315
 
2302
2316
  function _checkLinkAccess() {
2303
2317
  _checkLinkAccess = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
2304
- var canRead;
2318
+ var canRead, _canRead;
2319
+
2305
2320
  return runtime_1.wrap(function _callee2$(_context2) {
2306
2321
  while (1) {
2307
2322
  switch (_context2.prev = _context2.next) {
@@ -2330,7 +2345,10 @@ function useEditorPermissions(props) {
2330
2345
 
2331
2346
  case 8:
2332
2347
  if (entityType === 'Entry') {
2333
- setCanLinkEntity(readableContentTypes.length > 0);
2348
+ // Hardcoded `true` value following https://contentful.atlassian.net/browse/DANTE-486
2349
+ // TODO: refine permissions check in order to account for tags in rules
2350
+ _canRead = readableContentTypes.length > 0 || true;
2351
+ setCanLinkEntity(_canRead);
2334
2352
  }
2335
2353
 
2336
2354
  case 9:
@@ -2417,7 +2435,8 @@ function SingleReferenceEditor(props) {
2417
2435
  });
2418
2436
  }
2419
2437
  SingleReferenceEditor.defaultProps = {
2420
- hasCardEditActions: true
2438
+ hasCardEditActions: true,
2439
+ hasCardRemoveActions: true
2421
2440
  };
2422
2441
 
2423
2442
  var getEntryTitle = entityHelpers.getEntryTitle,
@@ -2432,7 +2451,8 @@ var styles$1 = {
2432
2451
  var defaultProps = {
2433
2452
  isClickable: true,
2434
2453
  hasCardEditActions: true,
2435
- hasMoveOptions: true
2454
+ hasCardMoveActions: true,
2455
+ hasCardRemoveActions: true
2436
2456
  };
2437
2457
  function WrappedEntryCard(props) {
2438
2458
  var _props$entry;
@@ -2509,18 +2529,18 @@ function WrappedEntryCard(props) {
2509
2529
  onClick: function onClick() {
2510
2530
  props.onEdit && props.onEdit();
2511
2531
  }
2512
- }, "Edit") : null, props.onRemove ? createElement(MenuItem, {
2532
+ }, "Edit") : null, props.hasCardRemoveActions && props.onRemove ? createElement(MenuItem, {
2513
2533
  key: "delete",
2514
2534
  testId: "delete",
2515
2535
  onClick: function onClick() {
2516
2536
  props.onRemove && props.onRemove();
2517
2537
  }
2518
- }, "Remove") : null, props.hasMoveOptions && (props.onMoveTop || props.onMoveBottom) ? createElement(MenuDivider, null) : null, props.hasMoveOptions && props.onMoveTop ? createElement(MenuItem, {
2538
+ }, "Remove") : null, props.hasCardMoveActions && (props.onMoveTop || props.onMoveBottom) ? createElement(MenuDivider, null) : null, props.hasCardMoveActions && props.onMoveTop ? createElement(MenuItem, {
2519
2539
  onClick: function onClick() {
2520
2540
  return props.onMoveTop && props.onMoveTop();
2521
2541
  },
2522
2542
  testId: "move-top"
2523
- }, "Move to top") : null, props.hasMoveOptions && props.onMoveBottom ? createElement(MenuItem, {
2543
+ }, "Move to top") : null, props.hasCardMoveActions && props.onMoveBottom ? createElement(MenuItem, {
2524
2544
  onClick: function onClick() {
2525
2545
  return props.onMoveBottom && props.onMoveBottom();
2526
2546
  },
@@ -2706,11 +2726,15 @@ function FetchingWrappedEntryCard(props) {
2706
2726
  onMoveTop: props.onMoveTop,
2707
2727
  onMoveBottom: props.onMoveBottom
2708
2728
  };
2709
- var hasCardEditActions = props.hasCardEditActions;
2729
+ var hasCardEditActions = props.hasCardEditActions,
2730
+ hasCardMoveActions = props.hasCardMoveActions,
2731
+ hasCardRemoveActions = props.hasCardRemoveActions;
2710
2732
 
2711
2733
  function renderDefaultCard(props) {
2712
2734
  var builtinCardProps = _extends({}, sharedCardProps, props, {
2713
2735
  hasCardEditActions: hasCardEditActions,
2736
+ hasCardMoveActions: hasCardMoveActions,
2737
+ hasCardRemoveActions: hasCardRemoveActions,
2714
2738
  getAsset: getOrLoadAsset,
2715
2739
  getEntityScheduledActions: loadEntityScheduledActions,
2716
2740
  entry: (props == null ? void 0 : props.entity) || sharedCardProps.entity,
@@ -2742,6 +2766,7 @@ function SingleEntryReferenceEditor(props) {
2742
2766
  entityId = _ref.entityId,
2743
2767
  setValue = _ref.setValue,
2744
2768
  renderCustomCard = _ref.renderCustomCard,
2769
+ hasCardRemoveActions = _ref.hasCardRemoveActions,
2745
2770
  hasCardEditActions = _ref.hasCardEditActions;
2746
2771
  return createElement(FetchingWrappedEntryCard, Object.assign({}, props, {
2747
2772
  allContentTypes: allContentTypes,
@@ -2749,6 +2774,7 @@ function SingleEntryReferenceEditor(props) {
2749
2774
  entryId: entityId,
2750
2775
  renderCustomCard: renderCustomCard,
2751
2776
  hasCardEditActions: hasCardEditActions,
2777
+ hasCardRemoveActions: hasCardRemoveActions,
2752
2778
  onRemove: function onRemove() {
2753
2779
  setValue(null);
2754
2780
  }