@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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,24 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [4.3.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@4.3.0...@contentful/field-editor-reference@4.3.1) (2022-04-28)
7
+
8
+ ### Bug Fixes
9
+
10
+ - always show create asset button to be save in regards of tag-based permissions ([#1124](https://github.com/contentful/field-editors/issues/1124)) ([0aa6db6](https://github.com/contentful/field-editors/commit/0aa6db608201750c03a97c941218ba42a56e9aac))
11
+
12
+ # [4.3.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@4.2.3...@contentful/field-editor-reference@4.3.0) (2022-04-28)
13
+
14
+ ### Features
15
+
16
+ - reference hide actions prop [DANTE-488] ([#1120](https://github.com/contentful/field-editors/issues/1120)) ([1f53844](https://github.com/contentful/field-editors/commit/1f538449ad07b36bed908d6e1b0e3744eafa079d))
17
+
18
+ ## [4.2.3](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@4.2.2...@contentful/field-editor-reference@4.2.3) (2022-04-19)
19
+
20
+ ### Bug Fixes
21
+
22
+ - always show link existing button to account for tag based permissions [ZEND-1864] ([#1107](https://github.com/contentful/field-editors/issues/1107)) ([3b4ca1f](https://github.com/contentful/field-editors/commit/3b4ca1f2acca530cceab659346fe7769757d90f4))
23
+
6
24
  ## [4.2.2](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@4.2.1...@contentful/field-editor-reference@4.2.2) (2022-03-31)
7
25
 
8
26
  ### Bug Fixes
@@ -9,6 +9,8 @@ export interface ReferenceEditorProps {
9
9
  */
10
10
  isInitiallyDisabled: boolean;
11
11
  hasCardEditActions: boolean;
12
+ hasCardMoveActions?: boolean;
13
+ hasCardRemoveActions?: boolean;
12
14
  sdk: FieldExtensionSDK;
13
15
  viewType: ViewType;
14
16
  renderCustomCard?: CustomCardRenderer;
@@ -9,6 +9,7 @@ declare type ChildProps = {
9
9
  allContentTypes: ContentType[];
10
10
  renderCustomCard?: ReferenceEditorProps['renderCustomCard'];
11
11
  hasCardEditActions: boolean;
12
+ hasCardRemoveActions?: boolean;
12
13
  };
13
14
  export declare function SingleReferenceEditor(props: ReferenceEditorProps & {
14
15
  entityType: ContentEntityType;
@@ -17,6 +18,7 @@ export declare function SingleReferenceEditor(props: ReferenceEditorProps & {
17
18
  export declare namespace SingleReferenceEditor {
18
19
  var defaultProps: {
19
20
  hasCardEditActions: boolean;
21
+ hasCardRemoveActions: boolean;
20
22
  };
21
23
  }
22
24
  export {};
@@ -17,16 +17,18 @@ export interface WrappedEntryCardProps {
17
17
  entry: Entry;
18
18
  renderDragHandle?: RenderDragFn;
19
19
  isClickable?: boolean;
20
- hasCardEditActions: boolean;
21
20
  onMoveTop?: () => void;
22
21
  onMoveBottom?: () => void;
23
- hasMoveOptions?: boolean;
22
+ hasCardEditActions: boolean;
23
+ hasCardMoveActions?: boolean;
24
+ hasCardRemoveActions?: boolean;
24
25
  }
25
26
  export declare function WrappedEntryCard(props: WrappedEntryCardProps): JSX.Element;
26
27
  export declare namespace WrappedEntryCard {
27
28
  var defaultProps: {
28
29
  isClickable: boolean;
29
30
  hasCardEditActions: boolean;
30
- hasMoveOptions: boolean;
31
+ hasCardMoveActions: boolean;
32
+ hasCardRemoveActions: boolean;
31
33
  };
32
34
  }
@@ -2262,13 +2262,14 @@ function useEditorPermissions(props) {
2262
2262
 
2263
2263
  function _checkCreateAccess() {
2264
2264
  _checkCreateAccess = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
2265
- var canCreate;
2265
+ var canCreate, _canCreate;
2266
+
2266
2267
  return runtime_1.wrap(function _callee$(_context) {
2267
2268
  while (1) {
2268
2269
  switch (_context.prev = _context.next) {
2269
2270
  case 0:
2270
2271
  if (!(entityType === 'Asset')) {
2271
- _context.next = 5;
2272
+ _context.next = 8;
2272
2273
  break;
2273
2274
  }
2274
2275
 
@@ -2276,15 +2277,28 @@ function useEditorPermissions(props) {
2276
2277
  return canPerformAction('create', 'Asset');
2277
2278
 
2278
2279
  case 3:
2279
- canCreate = _context.sent;
2280
+ _context.t0 = _context.sent;
2281
+
2282
+ if (_context.t0) {
2283
+ _context.next = 6;
2284
+ break;
2285
+ }
2286
+
2287
+ _context.t0 = true;
2288
+
2289
+ case 6:
2290
+ canCreate = _context.t0;
2280
2291
  setCanCreateEntity(canCreate);
2281
2292
 
2282
- case 5:
2293
+ case 8:
2283
2294
  if (entityType === 'Entry') {
2284
- setCanCreateEntity(creatableContentTypes.length > 0);
2295
+ // Hardcoded `true` value following https://contentful.atlassian.net/browse/DANTE-486
2296
+ // TODO: refine permissions check in order to account for tags in rules
2297
+ _canCreate = readableContentTypes.length > 0 || true;
2298
+ setCanCreateEntity(_canCreate);
2285
2299
  }
2286
2300
 
2287
- case 6:
2301
+ case 9:
2288
2302
  case "end":
2289
2303
  return _context.stop();
2290
2304
  }
@@ -2308,7 +2322,8 @@ function useEditorPermissions(props) {
2308
2322
 
2309
2323
  function _checkLinkAccess() {
2310
2324
  _checkLinkAccess = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
2311
- var canRead;
2325
+ var canRead, _canRead;
2326
+
2312
2327
  return runtime_1.wrap(function _callee2$(_context2) {
2313
2328
  while (1) {
2314
2329
  switch (_context2.prev = _context2.next) {
@@ -2337,7 +2352,10 @@ function useEditorPermissions(props) {
2337
2352
 
2338
2353
  case 8:
2339
2354
  if (entityType === 'Entry') {
2340
- setCanLinkEntity(readableContentTypes.length > 0);
2355
+ // Hardcoded `true` value following https://contentful.atlassian.net/browse/DANTE-486
2356
+ // TODO: refine permissions check in order to account for tags in rules
2357
+ _canRead = readableContentTypes.length > 0 || true;
2358
+ setCanLinkEntity(_canRead);
2341
2359
  }
2342
2360
 
2343
2361
  case 9:
@@ -2424,7 +2442,8 @@ function SingleReferenceEditor(props) {
2424
2442
  });
2425
2443
  }
2426
2444
  SingleReferenceEditor.defaultProps = {
2427
- hasCardEditActions: true
2445
+ hasCardEditActions: true,
2446
+ hasCardRemoveActions: true
2428
2447
  };
2429
2448
 
2430
2449
  var getEntryTitle = fieldEditorShared.entityHelpers.getEntryTitle,
@@ -2439,7 +2458,8 @@ var styles$1 = {
2439
2458
  var defaultProps = {
2440
2459
  isClickable: true,
2441
2460
  hasCardEditActions: true,
2442
- hasMoveOptions: true
2461
+ hasCardMoveActions: true,
2462
+ hasCardRemoveActions: true
2443
2463
  };
2444
2464
  function WrappedEntryCard(props) {
2445
2465
  var _props$entry;
@@ -2516,18 +2536,18 @@ function WrappedEntryCard(props) {
2516
2536
  onClick: function onClick() {
2517
2537
  props.onEdit && props.onEdit();
2518
2538
  }
2519
- }, "Edit") : null, props.onRemove ? React.createElement(f36Components.MenuItem, {
2539
+ }, "Edit") : null, props.hasCardRemoveActions && props.onRemove ? React.createElement(f36Components.MenuItem, {
2520
2540
  key: "delete",
2521
2541
  testId: "delete",
2522
2542
  onClick: function onClick() {
2523
2543
  props.onRemove && props.onRemove();
2524
2544
  }
2525
- }, "Remove") : null, props.hasMoveOptions && (props.onMoveTop || props.onMoveBottom) ? React.createElement(f36Components.MenuDivider, null) : null, props.hasMoveOptions && props.onMoveTop ? React.createElement(f36Components.MenuItem, {
2545
+ }, "Remove") : null, props.hasCardMoveActions && (props.onMoveTop || props.onMoveBottom) ? React.createElement(f36Components.MenuDivider, null) : null, props.hasCardMoveActions && props.onMoveTop ? React.createElement(f36Components.MenuItem, {
2526
2546
  onClick: function onClick() {
2527
2547
  return props.onMoveTop && props.onMoveTop();
2528
2548
  },
2529
2549
  testId: "move-top"
2530
- }, "Move to top") : null, props.hasMoveOptions && props.onMoveBottom ? React.createElement(f36Components.MenuItem, {
2550
+ }, "Move to top") : null, props.hasCardMoveActions && props.onMoveBottom ? React.createElement(f36Components.MenuItem, {
2531
2551
  onClick: function onClick() {
2532
2552
  return props.onMoveBottom && props.onMoveBottom();
2533
2553
  },
@@ -2713,11 +2733,15 @@ function FetchingWrappedEntryCard(props) {
2713
2733
  onMoveTop: props.onMoveTop,
2714
2734
  onMoveBottom: props.onMoveBottom
2715
2735
  };
2716
- var hasCardEditActions = props.hasCardEditActions;
2736
+ var hasCardEditActions = props.hasCardEditActions,
2737
+ hasCardMoveActions = props.hasCardMoveActions,
2738
+ hasCardRemoveActions = props.hasCardRemoveActions;
2717
2739
 
2718
2740
  function renderDefaultCard(props) {
2719
2741
  var builtinCardProps = _extends({}, sharedCardProps, props, {
2720
2742
  hasCardEditActions: hasCardEditActions,
2743
+ hasCardMoveActions: hasCardMoveActions,
2744
+ hasCardRemoveActions: hasCardRemoveActions,
2721
2745
  getAsset: getOrLoadAsset,
2722
2746
  getEntityScheduledActions: loadEntityScheduledActions,
2723
2747
  entry: (props == null ? void 0 : props.entity) || sharedCardProps.entity,
@@ -2749,6 +2773,7 @@ function SingleEntryReferenceEditor(props) {
2749
2773
  entityId = _ref.entityId,
2750
2774
  setValue = _ref.setValue,
2751
2775
  renderCustomCard = _ref.renderCustomCard,
2776
+ hasCardRemoveActions = _ref.hasCardRemoveActions,
2752
2777
  hasCardEditActions = _ref.hasCardEditActions;
2753
2778
  return React.createElement(FetchingWrappedEntryCard, Object.assign({}, props, {
2754
2779
  allContentTypes: allContentTypes,
@@ -2756,6 +2781,7 @@ function SingleEntryReferenceEditor(props) {
2756
2781
  entryId: entityId,
2757
2782
  renderCustomCard: renderCustomCard,
2758
2783
  hasCardEditActions: hasCardEditActions,
2784
+ hasCardRemoveActions: hasCardRemoveActions,
2759
2785
  onRemove: function onRemove() {
2760
2786
  setValue(null);
2761
2787
  }