@edifice.io/react 2.0.0-develop-rc.3 → 2.0.0-develop-rc.7

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.
Files changed (251) hide show
  1. package/README.md +17 -88
  2. package/dist/components/ActionBar/ActionBar.d.ts +1 -1
  3. package/dist/components/ActionBar/ActionBar.js +3 -2
  4. package/dist/components/ActionBar/index.d.ts +0 -1
  5. package/dist/components/Alert/Alert.d.ts +1 -1
  6. package/dist/components/Alert/Alert.js +7 -6
  7. package/dist/components/Alert/index.d.ts +0 -1
  8. package/dist/components/AppHeader/AppHeader.d.ts +1 -1
  9. package/dist/components/AppHeader/AppHeader.js +3 -2
  10. package/dist/components/AppHeader/index.d.ts +0 -1
  11. package/dist/components/AppIcon/AppIcon.js +1 -1
  12. package/dist/components/Attachment/Attachment.d.ts +1 -1
  13. package/dist/components/Attachment/Attachment.js +3 -2
  14. package/dist/components/Attachment/index.d.ts +0 -1
  15. package/dist/components/Avatar/Avatar.d.ts +1 -1
  16. package/dist/components/Avatar/Avatar.js +4 -3
  17. package/dist/components/Avatar/index.d.ts +0 -1
  18. package/dist/components/Badge/Badge.d.ts +1 -1
  19. package/dist/components/Badge/Badge.js +3 -2
  20. package/dist/components/Badge/index.d.ts +0 -1
  21. package/dist/components/Breadcrumb/Breadcrumb.js +1 -1
  22. package/dist/components/Button/Button.d.ts +1 -1
  23. package/dist/components/Button/Button.js +4 -3
  24. package/dist/components/Button/IconButton.d.ts +1 -1
  25. package/dist/components/Button/IconButton.js +4 -3
  26. package/dist/components/Button/SearchButton.d.ts +1 -1
  27. package/dist/components/Button/SearchButton.js +4 -3
  28. package/dist/components/Button/index.d.ts +0 -3
  29. package/dist/components/Card/Card.d.ts +1 -1
  30. package/dist/components/Card/Card.js +3 -2
  31. package/dist/components/Card/CardHeader.js +1 -1
  32. package/dist/components/Card/CardImage.js +1 -1
  33. package/dist/components/Card/CardUser.js +1 -1
  34. package/dist/components/Card/index.d.ts +0 -1
  35. package/dist/components/Checkbox/Checkbox.d.ts +1 -1
  36. package/dist/components/Checkbox/Checkbox.js +3 -2
  37. package/dist/components/Checkbox/index.d.ts +0 -1
  38. package/dist/components/ColorPicker/ColorPicker.d.ts +1 -1
  39. package/dist/components/ColorPicker/ColorPicker.js +5 -4
  40. package/dist/components/ColorPicker/ColorPickerItem.d.ts +1 -1
  41. package/dist/components/ColorPicker/ColorPickerItem.js +3 -2
  42. package/dist/components/ColorPicker/index.d.ts +1 -3
  43. package/dist/components/Combobox/Combobox.d.ts +1 -1
  44. package/dist/components/Combobox/Combobox.js +4 -4
  45. package/dist/components/Combobox/ComboboxTrigger.js +2 -2
  46. package/dist/components/Combobox/index.d.ts +0 -1
  47. package/dist/components/Dropdown/Dropdown.d.ts +1 -1
  48. package/dist/components/Dropdown/Dropdown.js +4 -3
  49. package/dist/components/Dropdown/DropdownCheckboxItem.js +1 -1
  50. package/dist/components/Dropdown/DropdownRadioItem.js +1 -1
  51. package/dist/components/Dropdown/index.d.ts +0 -1
  52. package/dist/components/Dropzone/Dropzone.d.ts +1 -1
  53. package/dist/components/Dropzone/Dropzone.js +2 -2
  54. package/dist/components/Dropzone/DropzoneFile.js +1 -1
  55. package/dist/components/Dropzone/DropzoneImport.js +1 -1
  56. package/dist/components/Dropzone/index.d.ts +0 -1
  57. package/dist/components/EmptyScreen/EmptyScreen.d.ts +1 -1
  58. package/dist/components/EmptyScreen/EmptyScreen.js +4 -3
  59. package/dist/components/EmptyScreen/index.d.ts +0 -1
  60. package/dist/components/FileCard/FileCard.d.ts +1 -1
  61. package/dist/components/FileCard/FileCard.js +4 -3
  62. package/dist/components/FileCard/index.d.ts +0 -1
  63. package/dist/components/Form/FormControl.d.ts +1 -1
  64. package/dist/components/Form/FormControl.js +6 -5
  65. package/dist/components/Form/FormText.d.ts +1 -1
  66. package/dist/components/Form/FormText.js +3 -2
  67. package/dist/components/Form/index.d.ts +1 -2
  68. package/dist/components/Heading/Heading.d.ts +1 -1
  69. package/dist/components/Heading/Heading.js +3 -2
  70. package/dist/components/Heading/index.d.ts +0 -1
  71. package/dist/components/Image/Image.d.ts +1 -1
  72. package/dist/components/Image/Image.js +3 -2
  73. package/dist/components/Image/index.d.ts +0 -1
  74. package/dist/components/ImagePicker/ImagePicker.js +4 -4
  75. package/dist/components/Input/Input.d.ts +1 -1
  76. package/dist/components/Input/Input.js +3 -2
  77. package/dist/components/Input/index.d.ts +0 -1
  78. package/dist/components/Label/Label.d.ts +1 -1
  79. package/dist/components/Label/Label.js +3 -2
  80. package/dist/components/Label/index.d.ts +0 -1
  81. package/dist/components/Loading/Loading.d.ts +1 -1
  82. package/dist/components/Loading/Loading.js +3 -2
  83. package/dist/components/Loading/index.d.ts +0 -1
  84. package/dist/components/LoadingScreen/LoadingScreen.d.ts +1 -1
  85. package/dist/components/LoadingScreen/LoadingScreen.js +3 -2
  86. package/dist/components/LoadingScreen/index.d.ts +1 -1
  87. package/dist/components/Logo/Logo.d.ts +1 -1
  88. package/dist/components/Logo/Logo.js +3 -2
  89. package/dist/components/Logo/index.d.ts +0 -1
  90. package/dist/components/Menu/MenuButton.js +1 -1
  91. package/dist/components/Modal/Modal.d.ts +1 -1
  92. package/dist/components/Modal/Modal.js +3 -2
  93. package/dist/components/Modal/ModalHeader.js +1 -1
  94. package/dist/components/Modal/index.d.ts +0 -1
  95. package/dist/components/Radio/Radio.d.ts +1 -1
  96. package/dist/components/Radio/Radio.js +3 -2
  97. package/dist/components/Radio/index.d.ts +0 -1
  98. package/dist/components/SearchBar/SearchBar.d.ts +1 -1
  99. package/dist/components/SearchBar/SearchBar.js +5 -4
  100. package/dist/components/SearchBar/index.d.ts +0 -1
  101. package/dist/components/Select/Select.d.ts +1 -1
  102. package/dist/components/Select/Select.js +4 -3
  103. package/dist/components/Select/SelectTrigger.js +1 -1
  104. package/dist/components/Select/index.d.ts +0 -1
  105. package/dist/components/Table/TableExplorer.d.ts +1 -1
  106. package/dist/components/Table/TableExplorer.js +4 -3
  107. package/dist/components/Table/index.d.ts +0 -1
  108. package/dist/components/Tabs/Tabs.d.ts +1 -1
  109. package/dist/components/Tabs/Tabs.js +2 -2
  110. package/dist/components/Tabs/TabsList.js +1 -1
  111. package/dist/components/Tabs/index.d.ts +0 -1
  112. package/dist/components/TextArea/TextArea.d.ts +1 -1
  113. package/dist/components/TextArea/TextArea.js +5 -4
  114. package/dist/components/TextArea/index.d.ts +0 -1
  115. package/dist/components/Toolbar/Toolbar.d.ts +1 -1
  116. package/dist/components/Toolbar/Toolbar.js +7 -6
  117. package/dist/components/Toolbar/index.d.ts +0 -1
  118. package/dist/components/Tooltip/Tooltip.d.ts +1 -1
  119. package/dist/components/Tooltip/Tooltip.js +3 -2
  120. package/dist/components/Tooltip/index.d.ts +0 -1
  121. package/dist/components/TreeView/TreeView.d.ts +1 -1
  122. package/dist/components/TreeView/TreeView.js +3 -2
  123. package/dist/components/TreeView/index.d.ts +0 -1
  124. package/dist/components/UploadCard/UploadCard.js +6 -6
  125. package/dist/components/VisuallyHidden/VisuallyHidden.d.ts +1 -1
  126. package/dist/components/VisuallyHidden/VisuallyHidden.js +3 -2
  127. package/dist/components/VisuallyHidden/index.d.ts +1 -1
  128. package/dist/core/useAvatar/useAvatar.js +1 -1
  129. package/dist/core/useConversation/useConversation.js +2 -2
  130. package/dist/core/useHasWorkflow/useHasWorkflow.js +1 -1
  131. package/dist/core/useHeader/useHeader.js +3 -3
  132. package/dist/core/useLibraryUrl/useLibraryUrl.js +2 -2
  133. package/dist/core/useMediaLibrary/useMediaLibrary.js +2 -2
  134. package/dist/core/useOdeIcons/useOdeIcons.d.ts +1 -1
  135. package/dist/core/useResource/useResource.d.ts +0 -1
  136. package/dist/core/useTrashedResource/useTrashedResource.js +2 -2
  137. package/dist/core/useUpload/useUpload.d.ts +4 -5
  138. package/dist/core/useUpload/useUpload.js +1 -1
  139. package/dist/core/useUploadFiles/useUploadFiles.d.ts +5 -5
  140. package/dist/core/useUploadFiles/useUploadFiles.js +3 -3
  141. package/dist/core/useWorkspaceFile/useWorkspaceFile.d.ts +4 -4
  142. package/dist/core/useWorkspaceFile/useWorkspaceFile.js +2 -2
  143. package/dist/core/useWorkspaceSearch/useWorkspaceSearch.d.ts +2 -2
  144. package/dist/core/useWorkspaceSearch/useWorkspaceSearch.js +1 -1
  145. package/dist/editor.js +3 -3
  146. package/dist/hooks/useBrowserInfo/useBrowserInfo.js +1 -1
  147. package/dist/hooks/useDropdown/useDropdown.d.ts +1 -1
  148. package/dist/hooks/useDropdown/useDropdown.js +2 -2
  149. package/dist/hooks/useDropzone/useDropzone.js +2 -2
  150. package/dist/hooks/useToast/useToast.js +1 -1
  151. package/dist/index.js +142 -142
  152. package/dist/modals.js +14 -16
  153. package/dist/modules/audience/ReactionChoice.js +5 -5
  154. package/dist/modules/audience/ReactionModal.Card.js +1 -1
  155. package/dist/modules/audience/ReactionModal.js +4 -5
  156. package/dist/modules/audience/ReactionSummary.js +3 -3
  157. package/dist/modules/audience/ViewsCounter.js +3 -3
  158. package/dist/modules/audience/ViewsModal.js +4 -4
  159. package/dist/modules/audience/hooks/useReactions.d.ts +3 -5
  160. package/dist/modules/audience/hooks/useViews.d.ts +3 -3
  161. package/dist/modules/editor/components/BubbleMenuEditImage/BubbleMenuEditImage.js +3 -3
  162. package/dist/modules/editor/components/Editor/Editor.js +4 -4
  163. package/dist/modules/editor/components/Editor/MathsModal.d.ts +0 -1
  164. package/dist/modules/editor/components/Editor/MathsModal.js +3 -3
  165. package/dist/modules/editor/components/EditorToolbar/EditorToolbar.DropdownMenu.js +3 -3
  166. package/dist/modules/editor/components/EditorToolbar/EditorToolbar.Emoji.js +3 -3
  167. package/dist/modules/editor/components/EditorToolbar/EditorToolbar.HighlightColor.js +4 -4
  168. package/dist/modules/editor/components/EditorToolbar/EditorToolbar.PlusMenu.js +1 -1
  169. package/dist/modules/editor/components/EditorToolbar/EditorToolbar.TextColor.js +4 -4
  170. package/dist/modules/editor/components/EditorToolbar/EditorToolbar.TextSize.js +3 -3
  171. package/dist/modules/editor/components/EditorToolbar/EditorToolbar.Typography.js +3 -3
  172. package/dist/modules/editor/components/EditorToolbar/EditorToolbar.js +1 -1
  173. package/dist/modules/editor/components/NodeView/AttachmentNodeView.js +2 -2
  174. package/dist/modules/editor/components/NodeView/AudioNodeView.js +2 -2
  175. package/dist/modules/editor/components/NodeView/ImageNodeView.js +2 -2
  176. package/dist/modules/editor/components/NodeView/LinkerNodeView.js +2 -2
  177. package/dist/modules/editor/components/NodeView/VideoNodeView.js +2 -2
  178. package/dist/modules/editor/components/Renderer/AttachmentRenderer.js +2 -2
  179. package/dist/modules/editor/components/Renderer/LinkerRenderer.js +2 -2
  180. package/dist/modules/editor/components/Renderer/MediaRenderer.js +2 -2
  181. package/dist/modules/editor/components/Toolbar/LinkToolbar.d.ts +1 -1
  182. package/dist/modules/editor/components/Toolbar/LinkToolbar.js +5 -5
  183. package/dist/modules/editor/components/Toolbar/TableToolbar.AddMenu.js +2 -2
  184. package/dist/modules/editor/components/Toolbar/TableToolbar.CellColor.js +4 -4
  185. package/dist/modules/editor/components/Toolbar/TableToolbar.DelMenu.js +2 -2
  186. package/dist/modules/editor/components/Toolbar/TableToolbar.d.ts +1 -1
  187. package/dist/modules/editor/components/Toolbar/TableToolbar.js +6 -6
  188. package/dist/modules/editor/hooks/useImageModal.d.ts +1 -2
  189. package/dist/modules/modals/OnboardingModal/OnboardingModal.d.ts +0 -1
  190. package/dist/modules/modals/OnboardingModal/OnboardingModal.js +5 -5
  191. package/dist/modules/modals/PublishModal/PublishModal.js +8 -8
  192. package/dist/modules/modals/PublishModal/components/ActivitiesDropdown.js +1 -1
  193. package/dist/modules/modals/PublishModal/components/AgeSelect.js +1 -1
  194. package/dist/modules/modals/PublishModal/components/LangSelect.js +1 -1
  195. package/dist/modules/modals/PublishModal/components/PublishModalFooter.js +1 -1
  196. package/dist/modules/modals/PublishModal/components/SubjectsDropdown.js +1 -1
  197. package/dist/modules/modals/ResourceModal/ResourceModal.d.ts +1 -1
  198. package/dist/modules/modals/ResourceModal/ResourceModal.js +12 -11
  199. package/dist/modules/modals/ResourceModal/apps/BlogPublic.d.ts +1 -1
  200. package/dist/modules/modals/ResourceModal/apps/BlogPublic.js +8 -7
  201. package/dist/modules/modals/ResourceModal/hooks/useUpdateMutation.d.ts +1 -1
  202. package/dist/modules/modals/ResourceModal/hooks/useUpdateMutation.js +3 -2
  203. package/dist/modules/modals/ResourceModal/index.d.ts +3 -3
  204. package/dist/modules/modals/ShareModal/ShareBookmarkLine.d.ts +1 -1
  205. package/dist/modules/modals/ShareModal/apps/ShareBlog.d.ts +2 -1
  206. package/dist/modules/modals/ShareModal/apps/ShareBlog.js +3 -2
  207. package/dist/modules/modals/ShareModal/hooks/useShare.d.ts +2 -2
  208. package/dist/modules/modals/ShareModal/hooks/useShareMutation.d.ts +1 -1
  209. package/dist/modules/modals/ShareModal/hooks/useShareMutation.js +3 -2
  210. package/dist/modules/modals/ShareModal/index.d.ts +3 -3
  211. package/dist/modules/modals/ShareModal/utils/hasRight.d.ts +0 -1
  212. package/dist/modules/modals/ShareModal/utils/showShareRightLine.d.ts +0 -1
  213. package/dist/modules/multimedia/AudioRecorder/AudioRecorder.js +5 -5
  214. package/dist/modules/multimedia/Embed/Embed.js +4 -4
  215. package/dist/modules/multimedia/ImageEditor/components/ImageEditor.js +8 -8
  216. package/dist/modules/multimedia/ImageEditor/components/ImageEditorToolbar.js +1 -1
  217. package/dist/modules/multimedia/ImageEditor/hooks/useHistoryTool.js +36 -38
  218. package/dist/modules/multimedia/ImagePickerWorkspace/ImagePickerWorkspace.js +2 -2
  219. package/dist/modules/multimedia/Linker/ExternalLinker.js +9 -9
  220. package/dist/modules/multimedia/Linker/InternalLinker.js +6 -6
  221. package/dist/modules/multimedia/LinkerCard/LinkerCard.d.ts +1 -1
  222. package/dist/modules/multimedia/LinkerCard/LinkerCard.js +5 -4
  223. package/dist/modules/multimedia/LinkerCard/index.d.ts +0 -1
  224. package/dist/modules/multimedia/MediaLibrary/MediaLibrary.js +5 -5
  225. package/dist/modules/multimedia/MediaLibrary/MediaLibraryContext.d.ts +3 -3
  226. package/dist/modules/multimedia/MediaLibrary/innertabs/InternalLink.js +1 -1
  227. package/dist/modules/multimedia/MediaLibrary/innertabs/Upload.js +1 -1
  228. package/dist/modules/multimedia/MediaLibrary/innertabs/Workspace.js +2 -2
  229. package/dist/modules/multimedia/UploadFiles/UploadFiles.d.ts +1 -1
  230. package/dist/modules/multimedia/VideoEmbed/VideoEmbed.js +7 -7
  231. package/dist/modules/multimedia/VideoRecorder/VideoRecorder.js +7 -7
  232. package/dist/modules/multimedia/Workspace/Workspace.js +10 -10
  233. package/dist/multimedia.js +18 -18
  234. package/dist/portal/Header/Header.js +3 -3
  235. package/dist/portal/Header/NavLink.js +1 -1
  236. package/dist/portal/Help/Help.d.ts +0 -1
  237. package/dist/portal/Help/Help.js +1 -1
  238. package/dist/portal/Help/hooks/useHelp.js +1 -1
  239. package/dist/portal/Layout/Layout.js +4 -4
  240. package/dist/portal/SearchEngine/SearchEngine.js +2 -2
  241. package/dist/utils/fileSize.js +1 -1
  242. package/dist/widgets/BookmarkedApps/BookmarkedApps.js +2 -2
  243. package/package.json +19 -28
  244. package/dist/modules/modals/ShareModal/ShareBookmark.js +0 -22
  245. package/dist/modules/modals/ShareModal/ShareBookmarkLine.js +0 -42
  246. package/dist/modules/modals/ShareModal/ShareModal.js +0 -128
  247. package/dist/modules/modals/ShareModal/hooks/useSearch.js +0 -178
  248. package/dist/modules/modals/ShareModal/hooks/useShare.js +0 -192
  249. package/dist/modules/modals/ShareModal/hooks/useShareBookmark.js +0 -67
  250. package/dist/modules/modals/ShareModal/utils/hasRight.js +0 -4
  251. package/dist/modules/modals/ShareModal/utils/showShareRightLine.js +0 -4
@@ -1,192 +0,0 @@
1
- import { useReducer, useEffect } from "react";
2
- import { odeServices } from "edifice-ts-client";
3
- import { useTranslation } from "react-i18next";
4
- import useUser from "../../../../core/useUser/useUser.js";
5
- import useToast from "../../../../hooks/useToast/useToast.js";
6
- import { useOdeClient } from "../../../../core/OdeClientProvider/OdeClientProvider.js";
7
- const initialState = {
8
- isSharing: !1,
9
- shareRights: {
10
- rights: [],
11
- visibleBookmarks: [],
12
- visibleGroups: [],
13
- visibleUsers: []
14
- },
15
- shareRightActions: []
16
- };
17
- function reducer(state, action) {
18
- switch (action.type) {
19
- case "init":
20
- return {
21
- ...state,
22
- ...action.payload
23
- };
24
- case "deleteRow":
25
- return {
26
- ...state,
27
- shareRights: action.payload
28
- };
29
- case "updateShareRights":
30
- return {
31
- ...state,
32
- shareRights: action.payload
33
- };
34
- case "toggleRight":
35
- return {
36
- ...state,
37
- shareRights: action.payload
38
- };
39
- case "isSharing":
40
- return {
41
- ...state,
42
- isSharing: action.payload
43
- };
44
- default:
45
- throw new Error("Unhandled action type");
46
- }
47
- }
48
- function useShare({
49
- resourceId,
50
- resourceRights,
51
- resourceCreatorId,
52
- shareResource,
53
- setIsLoading,
54
- onSuccess
55
- }) {
56
- const {
57
- appCode
58
- } = useOdeClient(), {
59
- user,
60
- avatar
61
- } = useUser(), toast = useToast(), {
62
- t
63
- } = useTranslation(), [state, dispatch] = useReducer(reducer, initialState);
64
- useEffect(() => {
65
- resourceId && (async () => {
66
- try {
67
- const [shareRightActions, shareRights] = await Promise.all([odeServices.share().getActionsForApp(appCode), odeServices.share().getRightsForResource(appCode, resourceId)]);
68
- dispatch({
69
- type: "init",
70
- payload: {
71
- shareRightActions,
72
- shareRights
73
- }
74
- });
75
- } catch (error) {
76
- console.error(error);
77
- }
78
- setIsLoading(!1);
79
- })();
80
- }, [resourceId]);
81
- const toggleRight = (shareRight, actionName) => {
82
- var _a, _b;
83
- const {
84
- rights,
85
- ...props
86
- } = state.shareRights, newShareRights = [...rights], index = newShareRights.findIndex((x) => x.id === shareRight.id), actionObject = state.shareRightActions.filter((shareRightAction) => shareRightAction.id === actionName)[0];
87
- if (newShareRights[index].actions.findIndex((action) => action.id === actionName) > -1) {
88
- let updatedActions = newShareRights[index].actions.filter((action) => action.id !== actionName);
89
- const requiredActions = state.shareRightActions.filter((shareRightAction) => {
90
- var _a2;
91
- return (_a2 = shareRightAction.requires) == null ? void 0 : _a2.includes(actionName);
92
- });
93
- updatedActions = updatedActions.filter((action) => !requiredActions.find((requiredAction) => requiredAction.id === action.id)), newShareRights[index] = {
94
- ...newShareRights[index],
95
- actions: updatedActions
96
- };
97
- } else {
98
- const requiredActions = state.shareRightActions.filter((shareRightAction) => {
99
- var _a2;
100
- return ((_a2 = actionObject.requires) == null ? void 0 : _a2.includes(shareRightAction.id)) && !newShareRights[index].actions.find((action) => action.id === shareRightAction.id);
101
- });
102
- newShareRights[index] = {
103
- ...newShareRights[index],
104
- actions: [...newShareRights[index].actions, actionObject, ...requiredActions]
105
- };
106
- }
107
- shareRight.type === "sharebookmark" && ((_a = newShareRights[index].users) == null || _a.forEach((user2) => {
108
- const userIndex = newShareRights.findIndex((item) => item.id === user2.id);
109
- newShareRights[userIndex] = {
110
- ...newShareRights[userIndex],
111
- actions: newShareRights[index].actions
112
- };
113
- }), (_b = newShareRights[index].groups) == null || _b.forEach((user2) => {
114
- const userIndex = newShareRights.findIndex((item) => item.id === user2.id);
115
- newShareRights[userIndex] = {
116
- ...newShareRights[userIndex],
117
- actions: newShareRights[index].actions
118
- };
119
- })), dispatch({
120
- type: "toggleRight",
121
- payload: {
122
- rights: newShareRights,
123
- ...props
124
- }
125
- });
126
- }, notifySuccess = (value) => {
127
- Object.keys(value)[0] === "error" ? (toast.error(t("explorer.shared.status.error")), console.error("Failed to save share", value)) : toast.success(t("explorer.shared.status.saved"));
128
- };
129
- return {
130
- state,
131
- dispatch,
132
- currentIsAuthor: () => resourceCreatorId === (user == null ? void 0 : user.userId),
133
- myAvatar: avatar,
134
- handleDeleteRow: (shareRight) => {
135
- dispatch({
136
- type: "deleteRow",
137
- payload: {
138
- ...state.shareRights,
139
- rights: state.shareRights.rights.filter((right) => {
140
- var _a, _b;
141
- return right.id !== shareRight.id && !((_a = shareRight.users) != null && _a.find((user2) => user2.id === right.id)) && !((_b = shareRight.groups) != null && _b.find((group) => group.id === right.id));
142
- })
143
- }
144
- });
145
- },
146
- handleShare: async () => {
147
- dispatch({
148
- type: "isSharing",
149
- payload: !0
150
- });
151
- try {
152
- const myRights = resourceRights.filter((right) => user && right.includes(`user:${user.userId}`)).map((right) => right.split(":")[2]).filter((right) => !!right), shares = [...state.shareRights.rights];
153
- if (myRights.length > 0) {
154
- const actions = myRights.map((right) => ({
155
- displayName: right,
156
- id: right
157
- }));
158
- shares.push({
159
- actions,
160
- avatarUrl: "",
161
- directoryUrl: "",
162
- displayName: user.username,
163
- id: user.userId,
164
- type: "user"
165
- });
166
- }
167
- if (shareResource) {
168
- const result = await shareResource.mutateAsync({
169
- resourceId,
170
- rights: shares
171
- });
172
- notifySuccess(result);
173
- } else {
174
- const result = await odeServices.share().saveRights(appCode, resourceId, shares);
175
- notifySuccess(result);
176
- }
177
- onSuccess();
178
- } catch (error) {
179
- typeof error == "string" && toast.error(t("explorer.shared.status.error")), console.error("Failed to save share", error);
180
- } finally {
181
- dispatch({
182
- type: "isSharing",
183
- payload: !1
184
- });
185
- }
186
- },
187
- toggleRight
188
- };
189
- }
190
- export {
191
- useShare as default
192
- };
@@ -1,67 +0,0 @@
1
- import { useRef, useState, useId } from "react";
2
- import { odeServices } from "edifice-ts-client";
3
- import { useTranslation } from "react-i18next";
4
- import useToast from "../../../../hooks/useToast/useToast.js";
5
- import useToggle from "../../../../hooks/useToggle/useToggle.js";
6
- const useShareBookmark = ({
7
- shareRights,
8
- shareDispatch
9
- }) => {
10
- const toast = useToast(), {
11
- t
12
- } = useTranslation(), refBookmark = useRef(null), [bookmark, setBookmark] = useState({
13
- name: "",
14
- id: useId()
15
- }), [showBookmark, setShowBookmark] = useToggle(!1), [showBookmarkInput, toggleBookmarkInput] = useState(!1), toggleBookmark = () => {
16
- setShowBookmark();
17
- }, handleBookmarkChange = () => {
18
- setBookmark((prev) => {
19
- var _a;
20
- return {
21
- ...prev,
22
- name: ((_a = refBookmark.current) == null ? void 0 : _a.value) || ""
23
- };
24
- });
25
- }, saveBookmark = async (name) => {
26
- try {
27
- const res = await odeServices.directory().saveBookmarks(name, {
28
- users: shareRights.rights.filter((right) => right.type === "user").map((u) => u.id),
29
- groups: shareRights.rights.filter((right) => right.type === "group").map((u) => u.id),
30
- bookmarks: shareRights.rights.filter((right) => right.type === "sharebookmark").map((u) => u.id)
31
- });
32
- toast.success(t("explorer.bookmarked.status.saved")), shareDispatch({
33
- type: "updateShareRights",
34
- payload: {
35
- ...shareRights,
36
- visibleBookmarks: [...shareRights.visibleBookmarks, {
37
- displayName: name,
38
- id: res.id
39
- }]
40
- }
41
- }), setBookmark((prev) => ({
42
- ...prev,
43
- bookmarkId: prev.id + (/* @__PURE__ */ new Date()).getTime().toString()
44
- })), toggleBookmarkInput(!1);
45
- } catch (e) {
46
- console.error("Failed to save bookmark", e), toast.error(t("explorer.bookmarked.status.error"));
47
- }
48
- };
49
- return {
50
- refBookmark,
51
- showBookmark,
52
- showBookmarkInput,
53
- bookmark,
54
- handleBookmarkChange,
55
- setBookmark,
56
- handleOnSave: () => {
57
- var _a;
58
- const inputValue = ((_a = refBookmark.current) == null ? void 0 : _a.value) || "";
59
- saveBookmark(inputValue);
60
- },
61
- toggleBookmark,
62
- toggleBookmarkInput
63
- };
64
- };
65
- export {
66
- useShareBookmark
67
- };
@@ -1,4 +0,0 @@
1
- const hasRight = (shareRight, shareAction) => shareRight.actions.filter((a) => shareAction.id === a.id).length > 0;
2
- export {
3
- hasRight
4
- };
@@ -1,4 +0,0 @@
1
- const showShareRightLine = (shareRight, showBookmarkMembers) => shareRight.isBookmarkMember && showBookmarkMembers || !shareRight.isBookmarkMember;
2
- export {
3
- showShareRightLine
4
- };