@contentful/field-editor-reference 4.2.1 → 4.3.0

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.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)
7
+
8
+ ### Features
9
+
10
+ - reference hide actions prop [DANTE-488] ([#1120](https://github.com/contentful/field-editors/issues/1120)) ([1f53844](https://github.com/contentful/field-editors/commit/1f538449ad07b36bed908d6e1b0e3744eafa079d))
11
+
12
+ ## [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)
13
+
14
+ ### Bug Fixes
15
+
16
+ - 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))
17
+
18
+ ## [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)
19
+
20
+ ### Bug Fixes
21
+
22
+ - pass already known entry link id to onAction ([#1089](https://github.com/contentful/field-editors/issues/1089)) ([5b30d2f](https://github.com/contentful/field-editors/commit/5b30d2fade2edce5c99956108167aa5732b9bfbb))
23
+
6
24
  ## [4.2.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@4.2.0...@contentful/field-editor-reference@4.2.1) (2022-03-29)
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
  }
@@ -2308,7 +2308,8 @@ function useEditorPermissions(props) {
2308
2308
 
2309
2309
  function _checkLinkAccess() {
2310
2310
  _checkLinkAccess = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
2311
- var canRead;
2311
+ var canRead, _canRead;
2312
+
2312
2313
  return runtime_1.wrap(function _callee2$(_context2) {
2313
2314
  while (1) {
2314
2315
  switch (_context2.prev = _context2.next) {
@@ -2337,7 +2338,10 @@ function useEditorPermissions(props) {
2337
2338
 
2338
2339
  case 8:
2339
2340
  if (entityType === 'Entry') {
2340
- setCanLinkEntity(readableContentTypes.length > 0);
2341
+ // Hardcoded `true` value following https://contentful.atlassian.net/browse/DANTE-486
2342
+ // TODO: refine permissions check in order to account for tags in rules
2343
+ _canRead = readableContentTypes.length > 0 || true;
2344
+ setCanLinkEntity(_canRead);
2341
2345
  }
2342
2346
 
2343
2347
  case 9:
@@ -2424,7 +2428,8 @@ function SingleReferenceEditor(props) {
2424
2428
  });
2425
2429
  }
2426
2430
  SingleReferenceEditor.defaultProps = {
2427
- hasCardEditActions: true
2431
+ hasCardEditActions: true,
2432
+ hasCardRemoveActions: true
2428
2433
  };
2429
2434
 
2430
2435
  var getEntryTitle = fieldEditorShared.entityHelpers.getEntryTitle,
@@ -2439,7 +2444,8 @@ var styles$1 = {
2439
2444
  var defaultProps = {
2440
2445
  isClickable: true,
2441
2446
  hasCardEditActions: true,
2442
- hasMoveOptions: true
2447
+ hasCardMoveActions: true,
2448
+ hasCardRemoveActions: true
2443
2449
  };
2444
2450
  function WrappedEntryCard(props) {
2445
2451
  var _props$entry;
@@ -2516,18 +2522,18 @@ function WrappedEntryCard(props) {
2516
2522
  onClick: function onClick() {
2517
2523
  props.onEdit && props.onEdit();
2518
2524
  }
2519
- }, "Edit") : null, props.onRemove ? React.createElement(f36Components.MenuItem, {
2525
+ }, "Edit") : null, props.hasCardRemoveActions && props.onRemove ? React.createElement(f36Components.MenuItem, {
2520
2526
  key: "delete",
2521
2527
  testId: "delete",
2522
2528
  onClick: function onClick() {
2523
2529
  props.onRemove && props.onRemove();
2524
2530
  }
2525
- }, "Remove") : null, props.hasMoveOptions && (props.onMoveTop || props.onMoveBottom) ? React.createElement(f36Components.MenuDivider, null) : null, props.hasMoveOptions && props.onMoveTop ? React.createElement(f36Components.MenuItem, {
2531
+ }, "Remove") : null, props.hasCardMoveActions && (props.onMoveTop || props.onMoveBottom) ? React.createElement(f36Components.MenuDivider, null) : null, props.hasCardMoveActions && props.onMoveTop ? React.createElement(f36Components.MenuItem, {
2526
2532
  onClick: function onClick() {
2527
2533
  return props.onMoveTop && props.onMoveTop();
2528
2534
  },
2529
2535
  testId: "move-top"
2530
- }, "Move to top") : null, props.hasMoveOptions && props.onMoveBottom ? React.createElement(f36Components.MenuItem, {
2536
+ }, "Move to top") : null, props.hasCardMoveActions && props.onMoveBottom ? React.createElement(f36Components.MenuItem, {
2531
2537
  onClick: function onClick() {
2532
2538
  return props.onMoveBottom && props.onMoveBottom();
2533
2539
  },
@@ -2622,7 +2628,7 @@ function FetchingWrappedEntryCard(props) {
2622
2628
  switch (_context.prev = _context.next) {
2623
2629
  case 0:
2624
2630
  _context.next = 2;
2625
- return openEntry(props.sdk, get(entry, 'sys.id'), {
2631
+ return openEntry(props.sdk, props.entryId, {
2626
2632
  bulkEditing: props.parameters.instance.bulkEditing,
2627
2633
  index: props.index
2628
2634
  });
@@ -2632,7 +2638,7 @@ function FetchingWrappedEntryCard(props) {
2632
2638
  props.onAction && props.onAction({
2633
2639
  entity: 'Entry',
2634
2640
  type: 'edit',
2635
- id: get(entry, 'sys.id'),
2641
+ id: props.entryId,
2636
2642
  contentTypeId: get(entry, 'sys.contentType.sys.id'),
2637
2643
  slide: slide
2638
2644
  });
@@ -2655,7 +2661,7 @@ function FetchingWrappedEntryCard(props) {
2655
2661
  props.onAction && props.onAction({
2656
2662
  entity: 'Entry',
2657
2663
  type: 'delete',
2658
- id: get(entry, 'sys.id'),
2664
+ id: props.entryId,
2659
2665
  contentTypeId: get(entry, 'sys.contentType.sys.id')
2660
2666
  });
2661
2667
  };
@@ -2713,11 +2719,15 @@ function FetchingWrappedEntryCard(props) {
2713
2719
  onMoveTop: props.onMoveTop,
2714
2720
  onMoveBottom: props.onMoveBottom
2715
2721
  };
2716
- var hasCardEditActions = props.hasCardEditActions;
2722
+ var hasCardEditActions = props.hasCardEditActions,
2723
+ hasCardMoveActions = props.hasCardMoveActions,
2724
+ hasCardRemoveActions = props.hasCardRemoveActions;
2717
2725
 
2718
2726
  function renderDefaultCard(props) {
2719
2727
  var builtinCardProps = _extends({}, sharedCardProps, props, {
2720
2728
  hasCardEditActions: hasCardEditActions,
2729
+ hasCardMoveActions: hasCardMoveActions,
2730
+ hasCardRemoveActions: hasCardRemoveActions,
2721
2731
  getAsset: getOrLoadAsset,
2722
2732
  getEntityScheduledActions: loadEntityScheduledActions,
2723
2733
  entry: (props == null ? void 0 : props.entity) || sharedCardProps.entity,
@@ -2749,6 +2759,7 @@ function SingleEntryReferenceEditor(props) {
2749
2759
  entityId = _ref.entityId,
2750
2760
  setValue = _ref.setValue,
2751
2761
  renderCustomCard = _ref.renderCustomCard,
2762
+ hasCardRemoveActions = _ref.hasCardRemoveActions,
2752
2763
  hasCardEditActions = _ref.hasCardEditActions;
2753
2764
  return React.createElement(FetchingWrappedEntryCard, Object.assign({}, props, {
2754
2765
  allContentTypes: allContentTypes,
@@ -2756,6 +2767,7 @@ function SingleEntryReferenceEditor(props) {
2756
2767
  entryId: entityId,
2757
2768
  renderCustomCard: renderCustomCard,
2758
2769
  hasCardEditActions: hasCardEditActions,
2770
+ hasCardRemoveActions: hasCardRemoveActions,
2759
2771
  onRemove: function onRemove() {
2760
2772
  setValue(null);
2761
2773
  }