@edifice.io/react 2.2.3-develop-b2school.20250423112933 → 2.2.3-develop-b2school.20250425104325
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/dist/hooks/useWorkspaceFolders/useWorkspaceFolders.js +11 -5
- package/dist/modules/multimedia/WorkspaceFolders/WorkspaceFolders.js +15 -10
- package/dist/modules/multimedia/WorkspaceFolders/components/NewFolderForm.d.ts +5 -1
- package/dist/modules/multimedia/WorkspaceFolders/components/NewFolderForm.js +5 -4
- package/package.json +6 -6
- package/dist/hooks/useWorkspaceFolders/useWorkspaceFolders.d.ts +0 -10
|
@@ -2,10 +2,14 @@ import { odeServices } from "@edifice.io/client";
|
|
|
2
2
|
import { useQueryClient, useQuery, useMutation } from "@tanstack/react-query";
|
|
3
3
|
import { useMemo, useCallback } from "react";
|
|
4
4
|
import { useEdificeClient } from "../../providers/EdificeClientProvider/EdificeClientProvider.hook.js";
|
|
5
|
+
import { useTranslation } from "react-i18next";
|
|
6
|
+
import useToast from "../useToast/useToast.js";
|
|
5
7
|
function useWorkspaceFolders() {
|
|
6
8
|
const queryClient = useQueryClient(), {
|
|
7
9
|
user
|
|
8
|
-
} = useEdificeClient(), {
|
|
10
|
+
} = useEdificeClient(), toast = useToast(), {
|
|
11
|
+
t
|
|
12
|
+
} = useTranslation(), {
|
|
9
13
|
data: ownerWorkspaceData = [],
|
|
10
14
|
isLoading: isLoadingOwner
|
|
11
15
|
} = useQuery({
|
|
@@ -22,10 +26,12 @@ function useWorkspaceFolders() {
|
|
|
22
26
|
folderName,
|
|
23
27
|
folderParentId
|
|
24
28
|
}) => odeServices.workspace().createFolder(folderName, folderParentId),
|
|
25
|
-
onSuccess: () => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
onSuccess: (newFolder) => {
|
|
30
|
+
const queryKey = ["workspace", "folders", newFolder.isShared ? "shared" : "owner"];
|
|
31
|
+
queryClient.setQueryData(queryKey, (oldFolders) => [...oldFolders, newFolder]);
|
|
32
|
+
},
|
|
33
|
+
onError: () => {
|
|
34
|
+
toast.error(t("e400"));
|
|
29
35
|
}
|
|
30
36
|
}), folders = useMemo(() => [...ownerWorkspaceData, ...sharedWorkspaceData], [ownerWorkspaceData, sharedWorkspaceData]), canCopyFileIntoFolder = useCallback((folderId) => {
|
|
31
37
|
var _a;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useState } from "react";
|
|
2
|
+
import { useState, useEffect } from "react";
|
|
3
3
|
import { useTranslation } from "react-i18next";
|
|
4
4
|
import SvgIconFolderAdd from "../../icons/components/IconFolderAdd.js";
|
|
5
5
|
import NewFolderForm from "./components/NewFolderForm.js";
|
|
@@ -21,27 +21,32 @@ function WorkspaceFolders({
|
|
|
21
21
|
} = useWorkspaceFolders(), {
|
|
22
22
|
foldersTree,
|
|
23
23
|
filterTree
|
|
24
|
-
} = useWorkspaceFoldersTree(folders), [
|
|
24
|
+
} = useWorkspaceFoldersTree(folders), [searchValue, setSearchValue] = useState(""), [selectedFolderId, setSelectedFolderId] = useState(void 0), [showNewFolderForm, setShowNewFolderForm] = useState(!1), [canCreateFolderIntoSelectedFolder, setCanCreateFolderIntoSelectedFolder] = useState(!1), selectedFolderIdForAPI = selectedFolderId === WORKSPACE_USER_FOLDER_ID || !selectedFolderId ? "" : selectedFolderId;
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (selectedFolderId) {
|
|
27
|
+
const canCopyFileInto = selectedFolderId === WORKSPACE_USER_FOLDER_ID || canCopyFileIntoFolder(selectedFolderId) && selectedFolderId !== WORKSPACE_SHARED_FOLDER_ID;
|
|
28
|
+
setCanCreateFolderIntoSelectedFolder(canCopyFileInto), onFolderSelected(selectedFolderIdForAPI, canCopyFileInto);
|
|
29
|
+
}
|
|
30
|
+
}, [selectedFolderId]);
|
|
31
|
+
const handleSearchChange = (e) => {
|
|
25
32
|
setSearchValue(e.target.value);
|
|
26
33
|
}, handleSearchSubmit = () => {
|
|
27
|
-
filterTree(searchValue)
|
|
34
|
+
filterTree(searchValue);
|
|
28
35
|
}, handleFolderSelected = (folderId) => {
|
|
29
|
-
setShowNewFolderForm(!1);
|
|
30
|
-
const newSelectedFolderId = folderId === WORKSPACE_USER_FOLDER_ID ? "" : folderId;
|
|
31
|
-
setSelectedFolderId(newSelectedFolderId);
|
|
32
|
-
const canCopyFileInto = folderId === WORKSPACE_USER_FOLDER_ID || canCopyFileIntoFolder(folderId) && folderId !== WORKSPACE_SHARED_FOLDER_ID;
|
|
33
|
-
setCanCreateFolderIntoSelectedFolder(canCopyFileInto), onFolderSelected(newSelectedFolderId, canCopyFileInto);
|
|
36
|
+
setShowNewFolderForm(!1), setSelectedFolderId(folderId);
|
|
34
37
|
}, handleNewFolderClick = () => {
|
|
35
38
|
setShowNewFolderForm(!0);
|
|
39
|
+
}, handleNewFolderCreated = (folderId) => {
|
|
40
|
+
handleFolderSelected(folderId);
|
|
36
41
|
};
|
|
37
42
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "d-flex flex-column gap-12", children: [
|
|
38
43
|
/* @__PURE__ */ jsx("p", { children: t("attachments.add.to.folder.modal.description") }),
|
|
39
44
|
/* @__PURE__ */ jsx(SearchBar, { onChange: handleSearchChange, isVariant: !1, placeholder: t("search"), onClick: handleSearchSubmit }),
|
|
40
45
|
/* @__PURE__ */ jsxs("div", { className: "border border-gray-400 rounded", children: [
|
|
41
|
-
/* @__PURE__ */ jsx("div", { className: "p-12", children: isLoading ? /* @__PURE__ */ jsx(Loading, { isLoading: !0, className: "justify-content-center" }) : /* @__PURE__ */ jsx(Tree, { nodes: foldersTree, onTreeItemClick: handleFolderSelected,
|
|
46
|
+
/* @__PURE__ */ jsx("div", { className: "p-12", children: isLoading ? /* @__PURE__ */ jsx(Loading, { isLoading: !0, className: "justify-content-center" }) : /* @__PURE__ */ jsx(Tree, { nodes: foldersTree, onTreeItemClick: handleFolderSelected, selectedNodeId: selectedFolderId }) }),
|
|
42
47
|
/* @__PURE__ */ jsxs("div", { className: "d-flex justify-content-end border-top border-gray-400 px-8 py-4 ", children: [
|
|
43
48
|
!showNewFolderForm && /* @__PURE__ */ jsx(Button, { color: "primary", variant: "ghost", leftIcon: /* @__PURE__ */ jsx(SvgIconFolderAdd, {}), onClick: handleNewFolderClick, disabled: !canCreateFolderIntoSelectedFolder, children: t("workspace.folder.create") }),
|
|
44
|
-
showNewFolderForm && selectedFolderId !== void 0 && /* @__PURE__ */ jsx(NewFolderForm, { onClose: () => setShowNewFolderForm(!1), folderParentId:
|
|
49
|
+
showNewFolderForm && selectedFolderId !== void 0 && /* @__PURE__ */ jsx(NewFolderForm, { onClose: () => setShowNewFolderForm(!1), folderParentId: selectedFolderIdForAPI, onFolderCreated: handleNewFolderCreated })
|
|
45
50
|
] })
|
|
46
51
|
] })
|
|
47
52
|
] }) });
|
|
@@ -7,6 +7,10 @@ type Props = {
|
|
|
7
7
|
* Parent folder ID where the new folder will be created
|
|
8
8
|
*/
|
|
9
9
|
folderParentId: string;
|
|
10
|
+
/**
|
|
11
|
+
* Function called when the new folder is created
|
|
12
|
+
*/
|
|
13
|
+
onFolderCreated: (folderId: string) => void;
|
|
10
14
|
};
|
|
11
|
-
export default function NewFolderForm({ onClose, folderParentId }: Props): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export default function NewFolderForm({ onClose, folderParentId, onFolderCreated, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
12
16
|
export {};
|
|
@@ -7,7 +7,8 @@ import FormControl from "../../../../components/Form/FormControl.js";
|
|
|
7
7
|
import Button from "../../../../components/Button/Button.js";
|
|
8
8
|
function NewFolderForm({
|
|
9
9
|
onClose,
|
|
10
|
-
folderParentId
|
|
10
|
+
folderParentId,
|
|
11
|
+
onFolderCreated
|
|
11
12
|
}) {
|
|
12
13
|
const {
|
|
13
14
|
t
|
|
@@ -24,13 +25,13 @@ function NewFolderForm({
|
|
|
24
25
|
folderName,
|
|
25
26
|
folderParentId
|
|
26
27
|
}, {
|
|
27
|
-
onSuccess: () => {
|
|
28
|
-
onClose();
|
|
28
|
+
onSuccess: (newFolder) => {
|
|
29
|
+
newFolder._id && onFolderCreated(newFolder._id), onClose();
|
|
29
30
|
}
|
|
30
31
|
});
|
|
31
32
|
}, children: /* @__PURE__ */ jsxs("div", { className: "d-flex gap-4 flex-row", children: [
|
|
32
33
|
/* @__PURE__ */ jsx(FormControl, { id: "modalWorkspaceNewFolderForm", isRequired: !0, children: /* @__PURE__ */ jsx(FormControl.Input, { ref: refInputName, size: "md", type: "text", placeholder: t("folder.new.name.label") }) }),
|
|
33
|
-
/* @__PURE__ */ jsx(Button, { type: "submit", color: "primary", variant: "ghost", isLoading: createFolderMutation.isPending, leftIcon: /* @__PURE__ */ jsx(SvgIconSave, {}) })
|
|
34
|
+
/* @__PURE__ */ jsx(Button, { type: "submit", color: "primary", variant: "ghost", disabled: createFolderMutation.isPending, isLoading: createFolderMutation.isPending, leftIcon: /* @__PURE__ */ jsx(SvgIconSave, {}) })
|
|
34
35
|
] }) });
|
|
35
36
|
}
|
|
36
37
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edifice.io/react",
|
|
3
|
-
"version": "2.2.3-develop-b2school.
|
|
3
|
+
"version": "2.2.3-develop-b2school.20250425104325",
|
|
4
4
|
"description": "Edifice React Library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -118,9 +118,9 @@
|
|
|
118
118
|
"react-slugify": "^3.0.3",
|
|
119
119
|
"swiper": "^10.1.0",
|
|
120
120
|
"ua-parser-js": "^1.0.36",
|
|
121
|
-
"@edifice.io/bootstrap": "2.2.3-develop-b2school.
|
|
122
|
-
"@edifice.io/
|
|
123
|
-
"@edifice.io/
|
|
121
|
+
"@edifice.io/bootstrap": "2.2.3-develop-b2school.20250425104325",
|
|
122
|
+
"@edifice.io/tiptap-extensions": "2.2.3-develop-b2school.20250425104325",
|
|
123
|
+
"@edifice.io/utilities": "2.2.3-develop-b2school.20250425104325"
|
|
124
124
|
},
|
|
125
125
|
"devDependencies": {
|
|
126
126
|
"@babel/plugin-transform-react-pure-annotations": "^7.23.3",
|
|
@@ -151,8 +151,8 @@
|
|
|
151
151
|
"vite": "^5.4.11",
|
|
152
152
|
"vite-plugin-dts": "^4.1.0",
|
|
153
153
|
"vite-tsconfig-paths": "^5.0.1",
|
|
154
|
-
"@edifice.io/client": "2.2.3-develop-b2school.
|
|
155
|
-
"@edifice.io/config": "2.2.3-develop-b2school.
|
|
154
|
+
"@edifice.io/client": "2.2.3-develop-b2school.20250425104325",
|
|
155
|
+
"@edifice.io/config": "2.2.3-develop-b2school.20250425104325"
|
|
156
156
|
},
|
|
157
157
|
"peerDependencies": {
|
|
158
158
|
"@react-spring/web": "^9.7.5",
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
declare function useWorkspaceFolders(): {
|
|
2
|
-
folders: import('@edifice.io/client').WorkspaceElement[];
|
|
3
|
-
createFolderMutation: import('../../node_modules/@tanstack/react-query').UseMutationResult<any, Error, {
|
|
4
|
-
folderName: string;
|
|
5
|
-
folderParentId?: string;
|
|
6
|
-
}, unknown>;
|
|
7
|
-
canCopyFileIntoFolder: (folderId: string) => boolean;
|
|
8
|
-
isLoading: boolean;
|
|
9
|
-
};
|
|
10
|
-
export default useWorkspaceFolders;
|