@edifice.io/react 2.6.9-develop-integration.20261014191834 → 2.6.9-develop-integration.20261014220706
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type Background = 'default' | 'pink-200' | 'yellow-200' | 'orange-200' | 'blue-200' | 'green-200';
|
|
1
|
+
export type Background = 'default' | 'pink-200' | 'yellow-200' | 'orange-200' | 'blue-200' | 'green-200' | 'crna';
|
|
2
2
|
declare const _default: () => {
|
|
3
3
|
betaEnabled: boolean | undefined;
|
|
4
4
|
background: Background;
|
|
@@ -2,8 +2,15 @@ import { GoogleDriveDocument, ID } from '@edifice.io/client';
|
|
|
2
2
|
import { TreeItem } from '../../components/Tree/types';
|
|
3
3
|
export type GoogleDriveFolderNode = TreeItem & {
|
|
4
4
|
files?: GoogleDriveDocument[];
|
|
5
|
+
/** False when the folder's content can't be copied to the workspace. */
|
|
6
|
+
canCopyToWorkspace?: boolean;
|
|
5
7
|
};
|
|
6
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Which documents a search browses from its root: the user's own Drive, or
|
|
10
|
+
* the documents other users shared with them.
|
|
11
|
+
*/
|
|
12
|
+
export type GoogleDriveSearchFilter = 'mydrive' | 'shared';
|
|
13
|
+
export default function useGoogleDriveSearch(rootId: string, rootName: string, userId?: string, filter?: GoogleDriveSearchFilter): {
|
|
7
14
|
root: GoogleDriveFolderNode;
|
|
8
15
|
needsAuth: boolean;
|
|
9
16
|
isCheckingAuth: boolean;
|
|
@@ -2,7 +2,7 @@ import { useState, useCallback } from "react";
|
|
|
2
2
|
import { odeServices } from "@edifice.io/client";
|
|
3
3
|
import { useQueryClient } from "@tanstack/react-query";
|
|
4
4
|
import { findNodeById, modifyNode } from "../../components/Tree/utilities/tree.js";
|
|
5
|
-
function useGoogleDriveSearch(rootId, rootName, userId) {
|
|
5
|
+
function useGoogleDriveSearch(rootId, rootName, userId, filter = "mydrive") {
|
|
6
6
|
const [root, setRoot] = useState({
|
|
7
7
|
id: rootId,
|
|
8
8
|
name: rootName,
|
|
@@ -11,30 +11,32 @@ function useGoogleDriveSearch(rootId, rootName, userId) {
|
|
|
11
11
|
setRoot((prev) => {
|
|
12
12
|
const node = findNodeById(prev, folderId);
|
|
13
13
|
if (!node) return prev;
|
|
14
|
-
const
|
|
14
|
+
const restrict = (doc) => node.canCopyToWorkspace === !1 ? {
|
|
15
|
+
...doc,
|
|
16
|
+
canCopyToWorkspace: !1
|
|
17
|
+
} : doc, children = subfolders.map(restrict).map((f) => {
|
|
15
18
|
var _a;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
...
|
|
19
|
-
name: f.name
|
|
20
|
-
} : {
|
|
19
|
+
return {
|
|
20
|
+
// Keep an already loaded subfolder's own content.
|
|
21
|
+
...(_a = node.children) == null ? void 0 : _a.find((c) => c.id === f.id),
|
|
21
22
|
id: f.id,
|
|
22
|
-
name: f.name
|
|
23
|
+
name: f.name,
|
|
24
|
+
canCopyToWorkspace: f.canCopyToWorkspace
|
|
23
25
|
};
|
|
24
26
|
});
|
|
25
27
|
return modifyNode(prev, (n) => n.id === node.id ? {
|
|
26
28
|
...n,
|
|
27
29
|
children,
|
|
28
|
-
files
|
|
30
|
+
files: files.map(restrict)
|
|
29
31
|
} : n);
|
|
30
32
|
});
|
|
31
33
|
}, []), queryClient = useQueryClient(), [loadError, setLoadError] = useState(null), loadContent = useCallback(async (folderId) => {
|
|
32
34
|
if (!userId) return;
|
|
33
|
-
const parentId = folderId === rootId ? void 0 : folderId;
|
|
35
|
+
const parentId = folderId === rootId ? void 0 : folderId, isSharedRoot = filter === "shared" && !parentId;
|
|
34
36
|
try {
|
|
35
37
|
const payload = await queryClient.fetchQuery({
|
|
36
|
-
queryKey: ["googledrive", "documents", userId, parentId ?? "root"],
|
|
37
|
-
queryFn: () => odeServices.googledrive().listDocuments(userId, parentId),
|
|
38
|
+
queryKey: ["googledrive", "documents", userId, isSharedRoot ? "shared" : parentId ?? "root"],
|
|
39
|
+
queryFn: () => isSharedRoot ? odeServices.googledrive().listSharedDocuments(userId) : odeServices.googledrive().listDocuments(userId, parentId),
|
|
38
40
|
staleTime: 6e4
|
|
39
41
|
}), subfolders = [], files = [];
|
|
40
42
|
payload.filter((doc) => doc.id !== parentId).forEach((doc) => {
|
|
@@ -43,7 +45,7 @@ function useGoogleDriveSearch(rootId, rootName, userId) {
|
|
|
43
45
|
} catch (error) {
|
|
44
46
|
setLoadError(error);
|
|
45
47
|
}
|
|
46
|
-
}, [rootId, userId, queryClient, updateFolder]);
|
|
48
|
+
}, [rootId, userId, filter, queryClient, updateFolder]);
|
|
47
49
|
return {
|
|
48
50
|
root,
|
|
49
51
|
needsAuth: !1,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useState,
|
|
2
|
+
import { useState, useEffect, useMemo, useCallback } from "react";
|
|
3
3
|
import { DocumentHelper } from "@edifice.io/client";
|
|
4
4
|
import clsx from "clsx";
|
|
5
5
|
import { useTranslation } from "react-i18next";
|
|
@@ -20,7 +20,7 @@ import EmptyScreen from "../../../components/EmptyScreen/EmptyScreen.js";
|
|
|
20
20
|
import Button from "../../../components/Button/Button.js";
|
|
21
21
|
import LoadingScreen from "../../../components/LoadingScreen/LoadingScreen.js";
|
|
22
22
|
import GoogleDriveFileCard from "../FileCard/GoogleDriveFileCard.js";
|
|
23
|
-
const ROOT_ID = "root";
|
|
23
|
+
const ROOT_ID = "root", SHARED_ROOT_ID = "shared";
|
|
24
24
|
function compare(a, b) {
|
|
25
25
|
return a === b ? 0 : a === void 0 ? -1 : b === void 0 ? 1 : a.localeCompare(b);
|
|
26
26
|
}
|
|
@@ -34,23 +34,26 @@ const GoogleDrive = ({
|
|
|
34
34
|
t
|
|
35
35
|
} = useTranslation(), {
|
|
36
36
|
user
|
|
37
|
-
} = useUser(), {
|
|
37
|
+
} = useUser(), myDrive = useGoogleDriveSearch(ROOT_ID, t("google-drive.mydrive"), user == null ? void 0 : user.userId), sharedWithMe = useGoogleDriveSearch(SHARED_ROOT_ID, t("workspace.tree.shared"), user == null ? void 0 : user.userId, "shared"), [currentNodeId, setCurrentNodeId] = useState(ROOT_ID), sectionOf = (nodeId) => findNodeById(sharedWithMe.root, nodeId) ? sharedWithMe : myDrive, {
|
|
38
38
|
root,
|
|
39
39
|
loadContent,
|
|
40
40
|
loadError
|
|
41
|
-
} =
|
|
42
|
-
setCurrentNodeId(nodeId), loadContent(nodeId);
|
|
43
|
-
},
|
|
41
|
+
} = sectionOf(currentNodeId), currentNode = findNodeById(root, currentNodeId) ?? root, [searchTerm, setSearchTerm] = useState(void 0), [sortOrder, setSortOrder] = useState(["modified", "desc"]), [selectedDocuments, setSelectedDocuments] = useState([]), handleTreeItemChange = (nodeId) => {
|
|
42
|
+
setCurrentNodeId(nodeId), sectionOf(nodeId).loadContent(nodeId);
|
|
43
|
+
}, loadMyDrive = myDrive.loadContent;
|
|
44
44
|
useEffect(() => {
|
|
45
|
-
|
|
46
|
-
}, [
|
|
45
|
+
loadMyDrive(ROOT_ID);
|
|
46
|
+
}, [loadMyDrive]);
|
|
47
47
|
const documents = useMemo(() => {
|
|
48
48
|
if (!currentNode.files) return;
|
|
49
49
|
const matchesRole = (doc) => {
|
|
50
50
|
if (!roles) return !0;
|
|
51
51
|
const role = DocumentHelper.role(doc.contentType, !1);
|
|
52
52
|
return Array.isArray(roles) ? roles.includes(role) : roles === role;
|
|
53
|
-
}, normalizedSearchTerm = searchTerm == null ? void 0 : searchTerm.toLowerCase(), list = currentNode.files.filter((f) => (
|
|
53
|
+
}, normalizedSearchTerm = searchTerm == null ? void 0 : searchTerm.toLowerCase(), list = currentNode.files.filter((f) => (
|
|
54
|
+
// A document that can't leave Google Drive could never be added.
|
|
55
|
+
f.canCopyToWorkspace && (!normalizedSearchTerm || f.name.toLowerCase().includes(normalizedSearchTerm)) && matchesRole(f)
|
|
56
|
+
));
|
|
54
57
|
let sortFunction;
|
|
55
58
|
return sortOrder[0] === "name" ? sortFunction = sortOrder[1] === "asc" ? (a, b) => compare(a.name, b.name) : (a, b) => compare(b.name, a.name) : sortFunction = (a, b) => compare(b.lastModified, a.lastModified), list.sort(sortFunction);
|
|
56
59
|
}, [currentNode, searchTerm, sortOrder, roles]), selectedIds = useMemo(() => new Set(selectedDocuments.map((d) => d.id)), [selectedDocuments]), handleSearchChange = useCallback((e) => {
|
|
@@ -69,7 +72,7 @@ const GoogleDrive = ({
|
|
|
69
72
|
position: "sticky",
|
|
70
73
|
top: 0,
|
|
71
74
|
paddingTop: "1.2rem"
|
|
72
|
-
}, children: /* @__PURE__ */ jsx(Tree, { nodes: root, selectedNodeId: currentNodeId, showIcon: !0, onTreeItemClick: handleTreeItemChange, onTreeItemUnfold: handleTreeItemChange }) }) }),
|
|
75
|
+
}, children: /* @__PURE__ */ jsx(Tree, { nodes: [myDrive.root, sharedWithMe.root], selectedNodeId: currentNodeId, showIcon: !0, onTreeItemClick: handleTreeItemChange, onTreeItemUnfold: handleTreeItemChange }) }) }),
|
|
73
76
|
/* @__PURE__ */ jsx(Grid.Col, { sm: "12", md: "5", xl: "8", children: /* @__PURE__ */ jsxs(Grid, { className: "flex-grow-1 gap-0", children: [
|
|
74
77
|
/* @__PURE__ */ jsxs(Grid.Col, { sm: "4", md: "8", xl: "12", children: [
|
|
75
78
|
/* @__PURE__ */ jsx("div", { className: "workspace-search px-16 py-8 ", children: /* @__PURE__ */ jsx(SearchBar, { isVariant: !0, className: "gap-16", onChange: handleSearchChange }) }),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edifice.io/react",
|
|
3
|
-
"version": "2.6.9-develop-integration.
|
|
3
|
+
"version": "2.6.9-develop-integration.20261014220706",
|
|
4
4
|
"description": "Edifice React Library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -140,9 +140,9 @@
|
|
|
140
140
|
"swiper": "10.1.0",
|
|
141
141
|
"ua-parser-js": "1.0.36",
|
|
142
142
|
"zustand": "4.5.7",
|
|
143
|
-
"@edifice.io/
|
|
144
|
-
"@edifice.io/utilities": "2.6.9-develop-integration.
|
|
145
|
-
"@edifice.io/
|
|
143
|
+
"@edifice.io/tiptap-extensions": "2.6.9-develop-integration.20261014220706",
|
|
144
|
+
"@edifice.io/utilities": "2.6.9-develop-integration.20261014220706",
|
|
145
|
+
"@edifice.io/bootstrap": "2.6.9-develop-integration.20261014220706"
|
|
146
146
|
},
|
|
147
147
|
"devDependencies": {
|
|
148
148
|
"@babel/plugin-transform-react-pure-annotations": "7.27.1",
|
|
@@ -173,8 +173,8 @@
|
|
|
173
173
|
"vite": "5.4.14",
|
|
174
174
|
"vite-plugin-dts": "4.5.4",
|
|
175
175
|
"vite-tsconfig-paths": "5.1.4",
|
|
176
|
-
"@edifice.io/
|
|
177
|
-
"@edifice.io/
|
|
176
|
+
"@edifice.io/config": "2.6.9-develop-integration.20261014220706",
|
|
177
|
+
"@edifice.io/client": "2.6.9-develop-integration.20261014220706"
|
|
178
178
|
},
|
|
179
179
|
"peerDependencies": {
|
|
180
180
|
"@react-spring/web": "9.7.5",
|