@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.
- package/README.md +17 -88
- package/dist/components/ActionBar/ActionBar.d.ts +1 -1
- package/dist/components/ActionBar/ActionBar.js +3 -2
- package/dist/components/ActionBar/index.d.ts +0 -1
- package/dist/components/Alert/Alert.d.ts +1 -1
- package/dist/components/Alert/Alert.js +7 -6
- package/dist/components/Alert/index.d.ts +0 -1
- package/dist/components/AppHeader/AppHeader.d.ts +1 -1
- package/dist/components/AppHeader/AppHeader.js +3 -2
- package/dist/components/AppHeader/index.d.ts +0 -1
- package/dist/components/AppIcon/AppIcon.js +1 -1
- package/dist/components/Attachment/Attachment.d.ts +1 -1
- package/dist/components/Attachment/Attachment.js +3 -2
- package/dist/components/Attachment/index.d.ts +0 -1
- package/dist/components/Avatar/Avatar.d.ts +1 -1
- package/dist/components/Avatar/Avatar.js +4 -3
- package/dist/components/Avatar/index.d.ts +0 -1
- package/dist/components/Badge/Badge.d.ts +1 -1
- package/dist/components/Badge/Badge.js +3 -2
- package/dist/components/Badge/index.d.ts +0 -1
- package/dist/components/Breadcrumb/Breadcrumb.js +1 -1
- package/dist/components/Button/Button.d.ts +1 -1
- package/dist/components/Button/Button.js +4 -3
- package/dist/components/Button/IconButton.d.ts +1 -1
- package/dist/components/Button/IconButton.js +4 -3
- package/dist/components/Button/SearchButton.d.ts +1 -1
- package/dist/components/Button/SearchButton.js +4 -3
- package/dist/components/Button/index.d.ts +0 -3
- package/dist/components/Card/Card.d.ts +1 -1
- package/dist/components/Card/Card.js +3 -2
- package/dist/components/Card/CardHeader.js +1 -1
- package/dist/components/Card/CardImage.js +1 -1
- package/dist/components/Card/CardUser.js +1 -1
- package/dist/components/Card/index.d.ts +0 -1
- package/dist/components/Checkbox/Checkbox.d.ts +1 -1
- package/dist/components/Checkbox/Checkbox.js +3 -2
- package/dist/components/Checkbox/index.d.ts +0 -1
- package/dist/components/ColorPicker/ColorPicker.d.ts +1 -1
- package/dist/components/ColorPicker/ColorPicker.js +5 -4
- package/dist/components/ColorPicker/ColorPickerItem.d.ts +1 -1
- package/dist/components/ColorPicker/ColorPickerItem.js +3 -2
- package/dist/components/ColorPicker/index.d.ts +1 -3
- package/dist/components/Combobox/Combobox.d.ts +1 -1
- package/dist/components/Combobox/Combobox.js +4 -4
- package/dist/components/Combobox/ComboboxTrigger.js +2 -2
- package/dist/components/Combobox/index.d.ts +0 -1
- package/dist/components/Dropdown/Dropdown.d.ts +1 -1
- package/dist/components/Dropdown/Dropdown.js +4 -3
- package/dist/components/Dropdown/DropdownCheckboxItem.js +1 -1
- package/dist/components/Dropdown/DropdownRadioItem.js +1 -1
- package/dist/components/Dropdown/index.d.ts +0 -1
- package/dist/components/Dropzone/Dropzone.d.ts +1 -1
- package/dist/components/Dropzone/Dropzone.js +2 -2
- package/dist/components/Dropzone/DropzoneFile.js +1 -1
- package/dist/components/Dropzone/DropzoneImport.js +1 -1
- package/dist/components/Dropzone/index.d.ts +0 -1
- package/dist/components/EmptyScreen/EmptyScreen.d.ts +1 -1
- package/dist/components/EmptyScreen/EmptyScreen.js +4 -3
- package/dist/components/EmptyScreen/index.d.ts +0 -1
- package/dist/components/FileCard/FileCard.d.ts +1 -1
- package/dist/components/FileCard/FileCard.js +4 -3
- package/dist/components/FileCard/index.d.ts +0 -1
- package/dist/components/Form/FormControl.d.ts +1 -1
- package/dist/components/Form/FormControl.js +6 -5
- package/dist/components/Form/FormText.d.ts +1 -1
- package/dist/components/Form/FormText.js +3 -2
- package/dist/components/Form/index.d.ts +1 -2
- package/dist/components/Heading/Heading.d.ts +1 -1
- package/dist/components/Heading/Heading.js +3 -2
- package/dist/components/Heading/index.d.ts +0 -1
- package/dist/components/Image/Image.d.ts +1 -1
- package/dist/components/Image/Image.js +3 -2
- package/dist/components/Image/index.d.ts +0 -1
- package/dist/components/ImagePicker/ImagePicker.js +4 -4
- package/dist/components/Input/Input.d.ts +1 -1
- package/dist/components/Input/Input.js +3 -2
- package/dist/components/Input/index.d.ts +0 -1
- package/dist/components/Label/Label.d.ts +1 -1
- package/dist/components/Label/Label.js +3 -2
- package/dist/components/Label/index.d.ts +0 -1
- package/dist/components/Loading/Loading.d.ts +1 -1
- package/dist/components/Loading/Loading.js +3 -2
- package/dist/components/Loading/index.d.ts +0 -1
- package/dist/components/LoadingScreen/LoadingScreen.d.ts +1 -1
- package/dist/components/LoadingScreen/LoadingScreen.js +3 -2
- package/dist/components/LoadingScreen/index.d.ts +1 -1
- package/dist/components/Logo/Logo.d.ts +1 -1
- package/dist/components/Logo/Logo.js +3 -2
- package/dist/components/Logo/index.d.ts +0 -1
- package/dist/components/Menu/MenuButton.js +1 -1
- package/dist/components/Modal/Modal.d.ts +1 -1
- package/dist/components/Modal/Modal.js +3 -2
- package/dist/components/Modal/ModalHeader.js +1 -1
- package/dist/components/Modal/index.d.ts +0 -1
- package/dist/components/Radio/Radio.d.ts +1 -1
- package/dist/components/Radio/Radio.js +3 -2
- package/dist/components/Radio/index.d.ts +0 -1
- package/dist/components/SearchBar/SearchBar.d.ts +1 -1
- package/dist/components/SearchBar/SearchBar.js +5 -4
- package/dist/components/SearchBar/index.d.ts +0 -1
- package/dist/components/Select/Select.d.ts +1 -1
- package/dist/components/Select/Select.js +4 -3
- package/dist/components/Select/SelectTrigger.js +1 -1
- package/dist/components/Select/index.d.ts +0 -1
- package/dist/components/Table/TableExplorer.d.ts +1 -1
- package/dist/components/Table/TableExplorer.js +4 -3
- package/dist/components/Table/index.d.ts +0 -1
- package/dist/components/Tabs/Tabs.d.ts +1 -1
- package/dist/components/Tabs/Tabs.js +2 -2
- package/dist/components/Tabs/TabsList.js +1 -1
- package/dist/components/Tabs/index.d.ts +0 -1
- package/dist/components/TextArea/TextArea.d.ts +1 -1
- package/dist/components/TextArea/TextArea.js +5 -4
- package/dist/components/TextArea/index.d.ts +0 -1
- package/dist/components/Toolbar/Toolbar.d.ts +1 -1
- package/dist/components/Toolbar/Toolbar.js +7 -6
- package/dist/components/Toolbar/index.d.ts +0 -1
- package/dist/components/Tooltip/Tooltip.d.ts +1 -1
- package/dist/components/Tooltip/Tooltip.js +3 -2
- package/dist/components/Tooltip/index.d.ts +0 -1
- package/dist/components/TreeView/TreeView.d.ts +1 -1
- package/dist/components/TreeView/TreeView.js +3 -2
- package/dist/components/TreeView/index.d.ts +0 -1
- package/dist/components/UploadCard/UploadCard.js +6 -6
- package/dist/components/VisuallyHidden/VisuallyHidden.d.ts +1 -1
- package/dist/components/VisuallyHidden/VisuallyHidden.js +3 -2
- package/dist/components/VisuallyHidden/index.d.ts +1 -1
- package/dist/core/useAvatar/useAvatar.js +1 -1
- package/dist/core/useConversation/useConversation.js +2 -2
- package/dist/core/useHasWorkflow/useHasWorkflow.js +1 -1
- package/dist/core/useHeader/useHeader.js +3 -3
- package/dist/core/useLibraryUrl/useLibraryUrl.js +2 -2
- package/dist/core/useMediaLibrary/useMediaLibrary.js +2 -2
- package/dist/core/useOdeIcons/useOdeIcons.d.ts +1 -1
- package/dist/core/useResource/useResource.d.ts +0 -1
- package/dist/core/useTrashedResource/useTrashedResource.js +2 -2
- package/dist/core/useUpload/useUpload.d.ts +4 -5
- package/dist/core/useUpload/useUpload.js +1 -1
- package/dist/core/useUploadFiles/useUploadFiles.d.ts +5 -5
- package/dist/core/useUploadFiles/useUploadFiles.js +3 -3
- package/dist/core/useWorkspaceFile/useWorkspaceFile.d.ts +4 -4
- package/dist/core/useWorkspaceFile/useWorkspaceFile.js +2 -2
- package/dist/core/useWorkspaceSearch/useWorkspaceSearch.d.ts +2 -2
- package/dist/core/useWorkspaceSearch/useWorkspaceSearch.js +1 -1
- package/dist/editor.js +3 -3
- package/dist/hooks/useBrowserInfo/useBrowserInfo.js +1 -1
- package/dist/hooks/useDropdown/useDropdown.d.ts +1 -1
- package/dist/hooks/useDropdown/useDropdown.js +2 -2
- package/dist/hooks/useDropzone/useDropzone.js +2 -2
- package/dist/hooks/useToast/useToast.js +1 -1
- package/dist/index.js +142 -142
- package/dist/modals.js +14 -16
- package/dist/modules/audience/ReactionChoice.js +5 -5
- package/dist/modules/audience/ReactionModal.Card.js +1 -1
- package/dist/modules/audience/ReactionModal.js +4 -5
- package/dist/modules/audience/ReactionSummary.js +3 -3
- package/dist/modules/audience/ViewsCounter.js +3 -3
- package/dist/modules/audience/ViewsModal.js +4 -4
- package/dist/modules/audience/hooks/useReactions.d.ts +3 -5
- package/dist/modules/audience/hooks/useViews.d.ts +3 -3
- package/dist/modules/editor/components/BubbleMenuEditImage/BubbleMenuEditImage.js +3 -3
- package/dist/modules/editor/components/Editor/Editor.js +4 -4
- package/dist/modules/editor/components/Editor/MathsModal.d.ts +0 -1
- package/dist/modules/editor/components/Editor/MathsModal.js +3 -3
- package/dist/modules/editor/components/EditorToolbar/EditorToolbar.DropdownMenu.js +3 -3
- package/dist/modules/editor/components/EditorToolbar/EditorToolbar.Emoji.js +3 -3
- package/dist/modules/editor/components/EditorToolbar/EditorToolbar.HighlightColor.js +4 -4
- package/dist/modules/editor/components/EditorToolbar/EditorToolbar.PlusMenu.js +1 -1
- package/dist/modules/editor/components/EditorToolbar/EditorToolbar.TextColor.js +4 -4
- package/dist/modules/editor/components/EditorToolbar/EditorToolbar.TextSize.js +3 -3
- package/dist/modules/editor/components/EditorToolbar/EditorToolbar.Typography.js +3 -3
- package/dist/modules/editor/components/EditorToolbar/EditorToolbar.js +1 -1
- package/dist/modules/editor/components/NodeView/AttachmentNodeView.js +2 -2
- package/dist/modules/editor/components/NodeView/AudioNodeView.js +2 -2
- package/dist/modules/editor/components/NodeView/ImageNodeView.js +2 -2
- package/dist/modules/editor/components/NodeView/LinkerNodeView.js +2 -2
- package/dist/modules/editor/components/NodeView/VideoNodeView.js +2 -2
- package/dist/modules/editor/components/Renderer/AttachmentRenderer.js +2 -2
- package/dist/modules/editor/components/Renderer/LinkerRenderer.js +2 -2
- package/dist/modules/editor/components/Renderer/MediaRenderer.js +2 -2
- package/dist/modules/editor/components/Toolbar/LinkToolbar.d.ts +1 -1
- package/dist/modules/editor/components/Toolbar/LinkToolbar.js +5 -5
- package/dist/modules/editor/components/Toolbar/TableToolbar.AddMenu.js +2 -2
- package/dist/modules/editor/components/Toolbar/TableToolbar.CellColor.js +4 -4
- package/dist/modules/editor/components/Toolbar/TableToolbar.DelMenu.js +2 -2
- package/dist/modules/editor/components/Toolbar/TableToolbar.d.ts +1 -1
- package/dist/modules/editor/components/Toolbar/TableToolbar.js +6 -6
- package/dist/modules/editor/hooks/useImageModal.d.ts +1 -2
- package/dist/modules/modals/OnboardingModal/OnboardingModal.d.ts +0 -1
- package/dist/modules/modals/OnboardingModal/OnboardingModal.js +5 -5
- package/dist/modules/modals/PublishModal/PublishModal.js +8 -8
- package/dist/modules/modals/PublishModal/components/ActivitiesDropdown.js +1 -1
- package/dist/modules/modals/PublishModal/components/AgeSelect.js +1 -1
- package/dist/modules/modals/PublishModal/components/LangSelect.js +1 -1
- package/dist/modules/modals/PublishModal/components/PublishModalFooter.js +1 -1
- package/dist/modules/modals/PublishModal/components/SubjectsDropdown.js +1 -1
- package/dist/modules/modals/ResourceModal/ResourceModal.d.ts +1 -1
- package/dist/modules/modals/ResourceModal/ResourceModal.js +12 -11
- package/dist/modules/modals/ResourceModal/apps/BlogPublic.d.ts +1 -1
- package/dist/modules/modals/ResourceModal/apps/BlogPublic.js +8 -7
- package/dist/modules/modals/ResourceModal/hooks/useUpdateMutation.d.ts +1 -1
- package/dist/modules/modals/ResourceModal/hooks/useUpdateMutation.js +3 -2
- package/dist/modules/modals/ResourceModal/index.d.ts +3 -3
- package/dist/modules/modals/ShareModal/ShareBookmarkLine.d.ts +1 -1
- package/dist/modules/modals/ShareModal/apps/ShareBlog.d.ts +2 -1
- package/dist/modules/modals/ShareModal/apps/ShareBlog.js +3 -2
- package/dist/modules/modals/ShareModal/hooks/useShare.d.ts +2 -2
- package/dist/modules/modals/ShareModal/hooks/useShareMutation.d.ts +1 -1
- package/dist/modules/modals/ShareModal/hooks/useShareMutation.js +3 -2
- package/dist/modules/modals/ShareModal/index.d.ts +3 -3
- package/dist/modules/modals/ShareModal/utils/hasRight.d.ts +0 -1
- package/dist/modules/modals/ShareModal/utils/showShareRightLine.d.ts +0 -1
- package/dist/modules/multimedia/AudioRecorder/AudioRecorder.js +5 -5
- package/dist/modules/multimedia/Embed/Embed.js +4 -4
- package/dist/modules/multimedia/ImageEditor/components/ImageEditor.js +8 -8
- package/dist/modules/multimedia/ImageEditor/components/ImageEditorToolbar.js +1 -1
- package/dist/modules/multimedia/ImageEditor/hooks/useHistoryTool.js +36 -38
- package/dist/modules/multimedia/ImagePickerWorkspace/ImagePickerWorkspace.js +2 -2
- package/dist/modules/multimedia/Linker/ExternalLinker.js +9 -9
- package/dist/modules/multimedia/Linker/InternalLinker.js +6 -6
- package/dist/modules/multimedia/LinkerCard/LinkerCard.d.ts +1 -1
- package/dist/modules/multimedia/LinkerCard/LinkerCard.js +5 -4
- package/dist/modules/multimedia/LinkerCard/index.d.ts +0 -1
- package/dist/modules/multimedia/MediaLibrary/MediaLibrary.js +5 -5
- package/dist/modules/multimedia/MediaLibrary/MediaLibraryContext.d.ts +3 -3
- package/dist/modules/multimedia/MediaLibrary/innertabs/InternalLink.js +1 -1
- package/dist/modules/multimedia/MediaLibrary/innertabs/Upload.js +1 -1
- package/dist/modules/multimedia/MediaLibrary/innertabs/Workspace.js +2 -2
- package/dist/modules/multimedia/UploadFiles/UploadFiles.d.ts +1 -1
- package/dist/modules/multimedia/VideoEmbed/VideoEmbed.js +7 -7
- package/dist/modules/multimedia/VideoRecorder/VideoRecorder.js +7 -7
- package/dist/modules/multimedia/Workspace/Workspace.js +10 -10
- package/dist/multimedia.js +18 -18
- package/dist/portal/Header/Header.js +3 -3
- package/dist/portal/Header/NavLink.js +1 -1
- package/dist/portal/Help/Help.d.ts +0 -1
- package/dist/portal/Help/Help.js +1 -1
- package/dist/portal/Help/hooks/useHelp.js +1 -1
- package/dist/portal/Layout/Layout.js +4 -4
- package/dist/portal/SearchEngine/SearchEngine.js +2 -2
- package/dist/utils/fileSize.js +1 -1
- package/dist/widgets/BookmarkedApps/BookmarkedApps.js +2 -2
- package/package.json +19 -28
- package/dist/modules/modals/ShareModal/ShareBookmark.js +0 -22
- package/dist/modules/modals/ShareModal/ShareBookmarkLine.js +0 -42
- package/dist/modules/modals/ShareModal/ShareModal.js +0 -128
- package/dist/modules/modals/ShareModal/hooks/useSearch.js +0 -178
- package/dist/modules/modals/ShareModal/hooks/useShare.js +0 -192
- package/dist/modules/modals/ShareModal/hooks/useShareBookmark.js +0 -67
- package/dist/modules/modals/ShareModal/utils/hasRight.js +0 -4
- 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
|
-
};
|