@contentful/field-editor-reference 4.2.3 → 4.3.2

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.2](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@4.3.1...@contentful/field-editor-reference@4.3.2) (2022-04-29)
7
+
8
+ ### Bug Fixes
9
+
10
+ - use creatableContentTypes for create access check ([#1131](https://github.com/contentful/field-editors/issues/1131)) ([5fcf527](https://github.com/contentful/field-editors/commit/5fcf527609605140564eb0ba172c8877b882ebdc))
11
+
12
+ ## [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)
13
+
14
+ ### Bug Fixes
15
+
16
+ - 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))
17
+
18
+ # [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)
19
+
20
+ ### Features
21
+
22
+ - reference hide actions prop [DANTE-488] ([#1120](https://github.com/contentful/field-editors/issues/1120)) ([1f53844](https://github.com/contentful/field-editors/commit/1f538449ad07b36bed908d6e1b0e3744eafa079d))
23
+
6
24
  ## [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)
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 = creatableContentTypes.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
  }
@@ -2428,7 +2442,8 @@ function SingleReferenceEditor(props) {
2428
2442
  });
2429
2443
  }
2430
2444
  SingleReferenceEditor.defaultProps = {
2431
- hasCardEditActions: true
2445
+ hasCardEditActions: true,
2446
+ hasCardRemoveActions: true
2432
2447
  };
2433
2448
 
2434
2449
  var getEntryTitle = fieldEditorShared.entityHelpers.getEntryTitle,
@@ -2443,7 +2458,8 @@ var styles$1 = {
2443
2458
  var defaultProps = {
2444
2459
  isClickable: true,
2445
2460
  hasCardEditActions: true,
2446
- hasMoveOptions: true
2461
+ hasCardMoveActions: true,
2462
+ hasCardRemoveActions: true
2447
2463
  };
2448
2464
  function WrappedEntryCard(props) {
2449
2465
  var _props$entry;
@@ -2520,18 +2536,18 @@ function WrappedEntryCard(props) {
2520
2536
  onClick: function onClick() {
2521
2537
  props.onEdit && props.onEdit();
2522
2538
  }
2523
- }, "Edit") : null, props.onRemove ? React.createElement(f36Components.MenuItem, {
2539
+ }, "Edit") : null, props.hasCardRemoveActions && props.onRemove ? React.createElement(f36Components.MenuItem, {
2524
2540
  key: "delete",
2525
2541
  testId: "delete",
2526
2542
  onClick: function onClick() {
2527
2543
  props.onRemove && props.onRemove();
2528
2544
  }
2529
- }, "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, {
2530
2546
  onClick: function onClick() {
2531
2547
  return props.onMoveTop && props.onMoveTop();
2532
2548
  },
2533
2549
  testId: "move-top"
2534
- }, "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, {
2535
2551
  onClick: function onClick() {
2536
2552
  return props.onMoveBottom && props.onMoveBottom();
2537
2553
  },
@@ -2717,11 +2733,15 @@ function FetchingWrappedEntryCard(props) {
2717
2733
  onMoveTop: props.onMoveTop,
2718
2734
  onMoveBottom: props.onMoveBottom
2719
2735
  };
2720
- var hasCardEditActions = props.hasCardEditActions;
2736
+ var hasCardEditActions = props.hasCardEditActions,
2737
+ hasCardMoveActions = props.hasCardMoveActions,
2738
+ hasCardRemoveActions = props.hasCardRemoveActions;
2721
2739
 
2722
2740
  function renderDefaultCard(props) {
2723
2741
  var builtinCardProps = _extends({}, sharedCardProps, props, {
2724
2742
  hasCardEditActions: hasCardEditActions,
2743
+ hasCardMoveActions: hasCardMoveActions,
2744
+ hasCardRemoveActions: hasCardRemoveActions,
2725
2745
  getAsset: getOrLoadAsset,
2726
2746
  getEntityScheduledActions: loadEntityScheduledActions,
2727
2747
  entry: (props == null ? void 0 : props.entity) || sharedCardProps.entity,
@@ -2753,6 +2773,7 @@ function SingleEntryReferenceEditor(props) {
2753
2773
  entityId = _ref.entityId,
2754
2774
  setValue = _ref.setValue,
2755
2775
  renderCustomCard = _ref.renderCustomCard,
2776
+ hasCardRemoveActions = _ref.hasCardRemoveActions,
2756
2777
  hasCardEditActions = _ref.hasCardEditActions;
2757
2778
  return React.createElement(FetchingWrappedEntryCard, Object.assign({}, props, {
2758
2779
  allContentTypes: allContentTypes,
@@ -2760,6 +2781,7 @@ function SingleEntryReferenceEditor(props) {
2760
2781
  entryId: entityId,
2761
2782
  renderCustomCard: renderCustomCard,
2762
2783
  hasCardEditActions: hasCardEditActions,
2784
+ hasCardRemoveActions: hasCardRemoveActions,
2763
2785
  onRemove: function onRemove() {
2764
2786
  setValue(null);
2765
2787
  }