@guillotinaweb/react-gmi 0.31.0 → 0.32.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.
@@ -7,7 +7,7 @@ interface ModalProps {
7
7
  }
8
8
  export declare function Modal(props: ModalProps): import("react/jsx-runtime").JSX.Element;
9
9
  interface ConfirmProps {
10
- message?: string;
10
+ message?: React.ReactNode;
11
11
  onCancel: () => void;
12
12
  onConfirm: () => void;
13
13
  loading?: boolean;
@@ -2,6 +2,7 @@ import { FolderCtx } from '../views/folder';
2
2
  import { BaseFormProps } from '../forms/base';
3
3
  import React from 'react';
4
4
  import { GuillotinaCommonObject, ItemColumn, RegistrySchema } from '../types/guillotina';
5
+ import { MessageDescriptor } from 'react-intl';
5
6
  export interface RegistrySortValue {
6
7
  direction: 'asc' | 'des';
7
8
  key: string;
@@ -52,6 +53,15 @@ export interface IRegistry {
52
53
  defaultSortValue: {
53
54
  [key: string]: RegistrySortValue;
54
55
  };
56
+ actionsList: {
57
+ [key: string]: (multiple: boolean) => {
58
+ [key: string]: {
59
+ text: MessageDescriptor;
60
+ perms: string[];
61
+ action: string;
62
+ };
63
+ };
64
+ };
55
65
  }
56
66
  export interface IManageRegistry {
57
67
  registry: IRegistry;
@@ -68,6 +78,13 @@ export interface IManageRegistry {
68
78
  getParsedSearchQueryParam: (query: string, type: string) => string;
69
79
  getDefaultSortValue: (type: string, fallback?: RegistrySortValue) => RegistrySortValue;
70
80
  getSearchEngineQueryParamsFunction: (type: string) => string;
81
+ getActionsList: (type: string, multiple: boolean) => {
82
+ [key: string]: {
83
+ text: MessageDescriptor;
84
+ perms: string[];
85
+ action: string;
86
+ };
87
+ };
71
88
  }
72
89
  export declare const defaultComponent: (context: GuillotinaCommonObject) => typeof FolderCtx;
73
90
  export declare function useRegistry(data: Partial<IRegistry>): IManageRegistry;
@@ -1,4 +1,4 @@
1
- import { IntlShape } from 'react-intl';
1
+ import { MessageDescriptor } from 'react-intl';
2
2
  import { IndexSignature } from '../types/global';
3
3
  export declare const classnames: (classNames: (string | boolean)[]) => string;
4
4
  export declare const noop: () => void;
@@ -7,9 +7,9 @@ export declare const toQueryString: (params: IndexSignature<string>) => string;
7
7
  export declare function base64ToArrayBuffer(base64: string): Uint8Array;
8
8
  export declare function stringToSlug(str: string): string;
9
9
  export declare function sleep(ms: number): Promise<void>;
10
- export declare const getActionsObject: (intl: IntlShape, multiple?: boolean) => {
10
+ export declare const getActionsObject: (multiple: boolean) => {
11
11
  [key: string]: {
12
- text: string;
12
+ text: MessageDescriptor;
13
13
  perms: string[];
14
14
  action: string;
15
15
  };
package/dist/react-gmi.js CHANGED
@@ -907,24 +907,20 @@ function sleep(ms) {
907
907
  }, ms);
908
908
  });
909
909
  }
910
- var getActionsObject = function getActionsObject(intl, multiple) {
911
- if (multiple === void 0) {
912
- multiple = false;
913
- }
914
-
910
+ var getActionsObject = function getActionsObject(multiple) {
915
911
  return {
916
912
  DELETE: {
917
- text: intl.formatMessage(genericMessages.delete),
913
+ text: genericMessages.delete,
918
914
  perms: ['guillotina.DeleteContent'],
919
915
  action: multiple ? 'removeItems' : 'removeItem'
920
916
  },
921
917
  MOVE: {
922
- text: intl.formatMessage(genericMessages.move_to),
918
+ text: genericMessages.move_to,
923
919
  perms: ['guillotina.MoveContent'],
924
920
  action: multiple ? 'moveItems' : 'moveItem'
925
921
  },
926
922
  COPY: {
927
- text: intl.formatMessage(genericMessages.copy_to),
923
+ text: genericMessages.copy_to,
928
924
  perms: ['guillotina.DuplicateContent'],
929
925
  action: multiple ? 'copyItems' : 'copyItem'
930
926
  }
@@ -6496,7 +6492,7 @@ function IWorkflow() {
6496
6492
  function PanelActions() {
6497
6493
  var traversal = useTraversal();
6498
6494
  var intl = reactIntl.useIntl();
6499
- var ACTIONS_OBJECT = getActionsObject(intl);
6495
+ var ACTIONS_OBJECT = traversal.registry.getActionsList(traversal.context['@type'], false);
6500
6496
 
6501
6497
  var hasPerm = function hasPerm(perms) {
6502
6498
  return perms.some(function (perm) {
@@ -6521,7 +6517,7 @@ function PanelActions() {
6521
6517
  onClick: function onClick() {
6522
6518
  onAction(actionKeyTyped);
6523
6519
  },
6524
- children: actionObject.text
6520
+ children: intl.formatMessage(actionObject.text)
6525
6521
  }, "panel_action_" + actionObject.text);
6526
6522
  }
6527
6523
  })
@@ -6872,9 +6868,8 @@ var ItemsActionsCtx = React.createContext({
6872
6868
  function ItemsActionsProvider(_ref) {
6873
6869
  var items = _ref.items,
6874
6870
  children = _ref.children;
6875
- var intl = reactIntl.useIntl();
6876
- var actions = getActionsObject(intl, true);
6877
6871
  var traversal = useTraversal();
6872
+ var actions = traversal.registry.getActionsList(traversal.context['@type'], true);
6878
6873
 
6879
6874
  var _useState = React.useState({
6880
6875
  all: false
@@ -6982,8 +6977,8 @@ function ItemCheckbox(_ref3) {
6982
6977
 
6983
6978
  function ItemsActionsDropdown() {
6984
6979
  var intl = reactIntl.useIntl();
6985
- var ACTIONS_OBJECT = getActionsObject(intl, true);
6986
6980
  var traversal = useTraversal();
6981
+ var ACTIONS_OBJECT = traversal.registry.getActionsList(traversal.context['@type'], true);
6987
6982
 
6988
6983
  var _useItemsActions3 = useItemsActions(),
6989
6984
  selected = _useItemsActions3.selected,
@@ -6994,7 +6989,7 @@ function ItemsActionsDropdown() {
6994
6989
  });
6995
6990
  var options = Object.keys(ACTIONS_OBJECT).map(function (action) {
6996
6991
  return {
6997
- text: ACTIONS_OBJECT[action].text,
6992
+ text: intl.formatMessage(ACTIONS_OBJECT[action].text),
6998
6993
  value: action
6999
6994
  };
7000
6995
  });
@@ -10923,7 +10918,8 @@ var registry = {
10923
10918
  UserManager: ['id', 'email', 'user_name']
10924
10919
  },
10925
10920
  parseSearchQueryParamFunction: {},
10926
- defaultSortValue: {}
10921
+ defaultSortValue: {},
10922
+ actionsList: {}
10927
10923
  };
10928
10924
 
10929
10925
  var getPathComponent = function getPathComponent(context, path, fallback) {
@@ -11024,6 +11020,16 @@ var getParsedSearchQueryParam = function getParsedSearchQueryParam(query, type)
11024
11020
  return parsedFunction(query, type);
11025
11021
  };
11026
11022
 
11023
+ var getActionsList = function getActionsList(type, multiple) {
11024
+ var funcActionsList = registry.actionsList[type];
11025
+
11026
+ if (funcActionsList) {
11027
+ return funcActionsList(multiple);
11028
+ }
11029
+
11030
+ return getActionsObject(multiple);
11031
+ };
11032
+
11027
11033
  var defaultComponent = function defaultComponent(context) {
11028
11034
  return context.is_folderish ? FolderCtx : ItemCtx;
11029
11035
  };
@@ -11053,7 +11059,8 @@ function useRegistry(data) {
11053
11059
  getDefaultSortValue: getDefaultSortValue,
11054
11060
  getSchemas: getSchemas,
11055
11061
  getView: getView,
11056
- getSearchEngineQueryParamsFunction: getSearchEngineQueryParamsFunction
11062
+ getSearchEngineQueryParamsFunction: getSearchEngineQueryParamsFunction,
11063
+ getActionsList: getActionsList
11057
11064
  };
11058
11065
  }
11059
11066
  /*