@edifice.io/react 2.6.7-develop-integration.20261005091442 → 2.6.7-develop-b2school.20261005112514
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/components/Layout/Layout.js +21 -8
- package/dist/components/Tree/utilities/tree.js +1 -21
- package/dist/homepage.js +4 -0
- package/dist/hooks/index.d.ts +0 -2
- package/dist/hooks/useBackground/useBackground.d.ts +1 -0
- package/dist/hooks/useBackground/useBackground.js +2 -0
- package/dist/hooks/useZendeskGuide/useZendeskGuide.d.ts +3 -1
- package/dist/hooks/useZendeskGuide/useZendeskGuide.js +10 -3
- package/dist/icons.js +404 -402
- package/dist/index.js +182 -194
- package/dist/modules/homepage/components/UserSpace/UserSpace.d.ts +3 -1
- package/dist/modules/homepage/components/UserSpace/UserSpace.js +13 -7
- package/dist/modules/homepage/components/UserSpace/UserSpaceContainer.d.ts +4 -2
- package/dist/modules/homepage/components/UserSpace/UserSpaceContainer.js +3 -2
- package/dist/modules/homepage/components/WidgetsPersonalizationPanel/WidgetToggle.d.ts +16 -0
- package/dist/modules/homepage/components/WidgetsPersonalizationPanel/WidgetToggle.js +15 -0
- package/dist/modules/homepage/components/WidgetsPersonalizationPanel/WidgetsPersonalizationPanel.d.ts +21 -0
- package/dist/modules/homepage/components/WidgetsPersonalizationPanel/WidgetsPersonalizationPanel.js +47 -0
- package/dist/modules/homepage/components/WidgetsPersonalizationPanel/index.d.ts +2 -0
- package/dist/modules/homepage/components/index.d.ts +2 -1
- package/dist/modules/icons/components/IconAddWidget.d.ts +7 -0
- package/dist/modules/icons/components/IconAddWidget.js +12 -0
- package/dist/modules/icons/components/index.d.ts +1 -0
- package/dist/modules/multimedia/FileCard/index.d.ts +0 -4
- package/dist/modules/multimedia/Linker/InternalLinker/InternalLinker.d.ts +1 -7
- package/dist/modules/multimedia/Linker/InternalLinker/InternalLinker.js +0 -2
- package/dist/modules/multimedia/MediaLibrary/MediaLibrary.d.ts +2 -2
- package/dist/modules/multimedia/MediaLibrary/MediaLibrary.js +12 -48
- package/dist/modules/multimedia/MediaLibrary/innertabs/index.d.ts +0 -2
- package/dist/modules/multimedia/MediaLibrary/innertabs/index.js +0 -4
- package/dist/modules/multimedia/Workspace/Workspace.js +5 -8
- package/dist/modules/multimedia/index.d.ts +0 -2
- package/dist/multimedia.js +18 -26
- package/package.json +6 -6
- package/dist/hooks/useGoogleDriveSearch/index.d.ts +0 -1
- package/dist/hooks/useGoogleDriveSearch/useGoogleDriveSearch.d.ts +0 -14
- package/dist/hooks/useGoogleDriveSearch/useGoogleDriveSearch.js +0 -60
- package/dist/hooks/useNextcloudSearch/index.d.ts +0 -1
- package/dist/hooks/useNextcloudSearch/useNextcloudSearch.d.ts +0 -14
- package/dist/hooks/useNextcloudSearch/useNextcloudSearch.js +0 -64
- package/dist/modules/multimedia/FileCard/GoogleDriveFileCard.d.ts +0 -25
- package/dist/modules/multimedia/FileCard/GoogleDriveFileCard.js +0 -102
- package/dist/modules/multimedia/FileCard/NextcloudFileCard.d.ts +0 -25
- package/dist/modules/multimedia/FileCard/NextcloudFileCard.js +0 -102
- package/dist/modules/multimedia/GoogleDrive/GoogleDrive.d.ts +0 -24
- package/dist/modules/multimedia/GoogleDrive/GoogleDrive.js +0 -100
- package/dist/modules/multimedia/GoogleDrive/index.d.ts +0 -2
- package/dist/modules/multimedia/MediaLibrary/innertabs/GoogleDrive.d.ts +0 -1
- package/dist/modules/multimedia/MediaLibrary/innertabs/GoogleDrive.js +0 -61
- package/dist/modules/multimedia/MediaLibrary/innertabs/Nextcloud.d.ts +0 -1
- package/dist/modules/multimedia/MediaLibrary/innertabs/Nextcloud.js +0 -48
- package/dist/modules/multimedia/Nextcloud/Nextcloud.d.ts +0 -24
- package/dist/modules/multimedia/Nextcloud/Nextcloud.js +0 -124
- package/dist/modules/multimedia/Nextcloud/index.d.ts +0 -2
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { useState, useCallback } from "react";
|
|
2
|
-
import { odeServices } from "@edifice.io/client";
|
|
3
|
-
import { useQueryClient, useQuery } from "@tanstack/react-query";
|
|
4
|
-
import { findNodeById, modifyNode } from "../../components/Tree/utilities/tree.js";
|
|
5
|
-
function useNextcloudSearch(rootId, rootName, userId) {
|
|
6
|
-
var _a;
|
|
7
|
-
const [root, setRoot] = useState({
|
|
8
|
-
id: rootId,
|
|
9
|
-
name: rootName,
|
|
10
|
-
section: !0
|
|
11
|
-
}), updateFolder = useCallback((folderId, subfolders, files) => {
|
|
12
|
-
setRoot((prev) => {
|
|
13
|
-
const node = findNodeById(prev, folderId);
|
|
14
|
-
if (!node) return prev;
|
|
15
|
-
const children = subfolders.map((f) => {
|
|
16
|
-
var _a2;
|
|
17
|
-
const existing = (_a2 = node.children) == null ? void 0 : _a2.find((c) => c.id === f.path);
|
|
18
|
-
return existing ? {
|
|
19
|
-
...existing,
|
|
20
|
-
name: f.name
|
|
21
|
-
} : {
|
|
22
|
-
id: f.path,
|
|
23
|
-
name: f.name
|
|
24
|
-
};
|
|
25
|
-
});
|
|
26
|
-
return modifyNode(prev, (n) => n.id === node.id ? {
|
|
27
|
-
...n,
|
|
28
|
-
children,
|
|
29
|
-
files
|
|
30
|
-
} : n);
|
|
31
|
-
});
|
|
32
|
-
}, []), queryClient = useQueryClient(), oauth2StatusQuery = useQuery({
|
|
33
|
-
queryKey: ["nextcloud", "oauth2-status", userId],
|
|
34
|
-
queryFn: () => odeServices.nextcloud().getOauth2Status(userId),
|
|
35
|
-
enabled: !!userId
|
|
36
|
-
}), needsAuth = !((_a = oauth2StatusQuery.data) != null && _a.connected), [loadError, setLoadError] = useState(null), loadContent = useCallback(async (folderId) => {
|
|
37
|
-
if (!userId) return;
|
|
38
|
-
const path = folderId === rootId ? void 0 : folderId;
|
|
39
|
-
try {
|
|
40
|
-
const payload = await queryClient.fetchQuery({
|
|
41
|
-
queryKey: ["nextcloud", "documents", userId, path ?? "/"],
|
|
42
|
-
queryFn: () => odeServices.nextcloud().listDocuments(userId, path),
|
|
43
|
-
staleTime: 6e4
|
|
44
|
-
}), subfolders = [], files = [], currentPath = path ?? "/";
|
|
45
|
-
payload.filter((doc) => doc.path !== currentPath).forEach((doc) => {
|
|
46
|
-
doc.isFolder ? subfolders.push(doc) : files.push(doc);
|
|
47
|
-
}), setLoadError(null), updateFolder(folderId, subfolders, files);
|
|
48
|
-
} catch (error) {
|
|
49
|
-
setLoadError(error);
|
|
50
|
-
}
|
|
51
|
-
}, [rootId, userId, queryClient, updateFolder]);
|
|
52
|
-
return {
|
|
53
|
-
root,
|
|
54
|
-
needsAuth,
|
|
55
|
-
isCheckingAuth: oauth2StatusQuery.isLoading,
|
|
56
|
-
isAuthError: oauth2StatusQuery.isError,
|
|
57
|
-
refetchAuthStatus: oauth2StatusQuery.refetch,
|
|
58
|
-
loadContent,
|
|
59
|
-
loadError
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
export {
|
|
63
|
-
useNextcloudSearch as default
|
|
64
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { GoogleDriveDocument } from '@edifice.io/client';
|
|
3
|
-
import { CardProps } from '../../../components/Card';
|
|
4
|
-
export interface GoogleDriveFileCardProps extends CardProps {
|
|
5
|
-
doc: GoogleDriveDocument;
|
|
6
|
-
/**
|
|
7
|
-
* Id of the user who owns the Google Drive document, used to build the preview URL.
|
|
8
|
-
*/
|
|
9
|
-
userId: string;
|
|
10
|
-
/**
|
|
11
|
-
* Custom icon to override the default based on file type
|
|
12
|
-
* Can be a string or a React node
|
|
13
|
-
*/
|
|
14
|
-
customIcon?: ReactNode;
|
|
15
|
-
/**
|
|
16
|
-
* Custom color class to override the default based on file type
|
|
17
|
-
* Example: "bg-purple-300" or any valid CSS class
|
|
18
|
-
*/
|
|
19
|
-
customColor?: string;
|
|
20
|
-
}
|
|
21
|
-
declare const GoogleDriveFileCard: {
|
|
22
|
-
({ doc, userId, isClickable, isSelectable, isSelected, onClick, className, onSelect, isFocused, app, customIcon, customColor, }: GoogleDriveFileCardProps): import("react/jsx-runtime").JSX.Element;
|
|
23
|
-
displayName: string;
|
|
24
|
-
};
|
|
25
|
-
export default GoogleDriveFileCard;
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useRef } from "react";
|
|
3
|
-
import { DocumentHelper, odeServices } from "@edifice.io/client";
|
|
4
|
-
import clsx from "clsx";
|
|
5
|
-
import SvgIconLandscape from "../../icons/components/IconLandscape.js";
|
|
6
|
-
import SvgIconMic from "../../icons/components/IconMic.js";
|
|
7
|
-
import SvgIconTextPage from "../../icons/components/IconTextPage.js";
|
|
8
|
-
import SvgIconVideo from "../../icons/components/IconVideo.js";
|
|
9
|
-
import FileIcon from "./FileIcon.js";
|
|
10
|
-
import useThumbnail from "../../../hooks/useThumbnail/useThumbnail.js";
|
|
11
|
-
import Card from "../../../components/Card/Card.js";
|
|
12
|
-
const roleMappings = {
|
|
13
|
-
csv: {
|
|
14
|
-
icon: ".CSV",
|
|
15
|
-
color: "bg-orange-200"
|
|
16
|
-
},
|
|
17
|
-
xls: {
|
|
18
|
-
icon: ".XLS",
|
|
19
|
-
color: "bg-green-200"
|
|
20
|
-
},
|
|
21
|
-
doc: {
|
|
22
|
-
icon: ".DOC",
|
|
23
|
-
color: "bg-blue-200"
|
|
24
|
-
},
|
|
25
|
-
txt: {
|
|
26
|
-
icon: ".TXT",
|
|
27
|
-
color: "bg-blue-200"
|
|
28
|
-
},
|
|
29
|
-
pdf: {
|
|
30
|
-
icon: ".PDF",
|
|
31
|
-
color: "bg-red-200"
|
|
32
|
-
},
|
|
33
|
-
audio: {
|
|
34
|
-
icon: /* @__PURE__ */ jsx(SvgIconMic, { width: 22, height: 22 }),
|
|
35
|
-
color: "bg-red-200"
|
|
36
|
-
},
|
|
37
|
-
ppt: {
|
|
38
|
-
icon: ".PPT",
|
|
39
|
-
color: "bg-red-200"
|
|
40
|
-
},
|
|
41
|
-
img: {
|
|
42
|
-
icon: /* @__PURE__ */ jsx(SvgIconLandscape, { width: 22, height: 22 }),
|
|
43
|
-
color: "bg-green-200"
|
|
44
|
-
},
|
|
45
|
-
video: {
|
|
46
|
-
icon: /* @__PURE__ */ jsx(SvgIconVideo, { width: 22, height: 22 }),
|
|
47
|
-
color: "bg-purple-200"
|
|
48
|
-
},
|
|
49
|
-
zip: {
|
|
50
|
-
icon: ".ZIP",
|
|
51
|
-
color: "bg-gray-300"
|
|
52
|
-
},
|
|
53
|
-
md: {
|
|
54
|
-
icon: ".MD",
|
|
55
|
-
color: "bg-blue-200"
|
|
56
|
-
},
|
|
57
|
-
unknown: {
|
|
58
|
-
icon: /* @__PURE__ */ jsx(SvgIconTextPage, { width: 22, height: 22 }),
|
|
59
|
-
color: "bg-gray-300"
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
function getRoleMap(type, customIcon, customColor) {
|
|
63
|
-
return customIcon !== void 0 || customColor !== void 0 ? {
|
|
64
|
-
icon: customIcon || /* @__PURE__ */ jsx(SvgIconTextPage, { width: 22, height: 22 }),
|
|
65
|
-
color: customColor || "bg-gray-300",
|
|
66
|
-
hasShadow: !1
|
|
67
|
-
} : roleMappings[type] ?? roleMappings.unknown;
|
|
68
|
-
}
|
|
69
|
-
const GoogleDriveFileCard = ({
|
|
70
|
-
doc,
|
|
71
|
-
userId,
|
|
72
|
-
isClickable = !0,
|
|
73
|
-
isSelectable = !1,
|
|
74
|
-
isSelected = !1,
|
|
75
|
-
onClick,
|
|
76
|
-
className,
|
|
77
|
-
onSelect,
|
|
78
|
-
isFocused,
|
|
79
|
-
app,
|
|
80
|
-
customIcon,
|
|
81
|
-
customColor
|
|
82
|
-
}) => {
|
|
83
|
-
const ref = useRef(null), type = DocumentHelper.role(doc.contentType, !1), roleMap = getRoleMap(type ?? "unknown", customIcon, customColor), file = clsx("file position-relative rounded", (roleMap == null ? void 0 : roleMap.color) ?? "bg-yellow-200"), mediaSrc = type === "img" ? odeServices.googledrive().getFileUrl(userId, doc) : null, hasThumbnail = useThumbnail(mediaSrc, {
|
|
84
|
-
ref
|
|
85
|
-
}), imageStyles = hasThumbnail && {
|
|
86
|
-
backgroundImage: `url(${mediaSrc})`,
|
|
87
|
-
backgroundSize: "cover"
|
|
88
|
-
};
|
|
89
|
-
return /* @__PURE__ */ jsx(Card, { className: clsx("card-file", className), isClickable, isSelectable, isSelected, onClick, app, isFocused, onSelect, children: /* @__PURE__ */ jsxs(Card.Body, { space: "8", children: [
|
|
90
|
-
/* @__PURE__ */ jsx("div", { ref, className: file, style: {
|
|
91
|
-
aspectRatio: "16/10",
|
|
92
|
-
...imageStyles
|
|
93
|
-
}, children: type !== "img" || !hasThumbnail ? /* @__PURE__ */ jsx(FileIcon, { type, roleMap }) : null }),
|
|
94
|
-
/* @__PURE__ */ jsxs("div", { className: "mt-4", children: [
|
|
95
|
-
/* @__PURE__ */ jsx(Card.Text, { children: doc.name }),
|
|
96
|
-
/* @__PURE__ */ jsx(Card.Text, { className: "text-black-50", children: doc == null ? void 0 : doc.ownerDisplayName })
|
|
97
|
-
] })
|
|
98
|
-
] }) });
|
|
99
|
-
};
|
|
100
|
-
export {
|
|
101
|
-
GoogleDriveFileCard as default
|
|
102
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { NextcloudDocument } from '@edifice.io/client';
|
|
3
|
-
import { CardProps } from '../../../components/Card';
|
|
4
|
-
export interface NextcloudFileCardProps extends CardProps {
|
|
5
|
-
doc: NextcloudDocument;
|
|
6
|
-
/**
|
|
7
|
-
* Id of the user who owns the Nextcloud document, used to build the preview URL.
|
|
8
|
-
*/
|
|
9
|
-
userId: string;
|
|
10
|
-
/**
|
|
11
|
-
* Custom icon to override the default based on file type
|
|
12
|
-
* Can be a string or a React node
|
|
13
|
-
*/
|
|
14
|
-
customIcon?: ReactNode;
|
|
15
|
-
/**
|
|
16
|
-
* Custom color class to override the default based on file type
|
|
17
|
-
* Example: "bg-purple-300" or any valid CSS class
|
|
18
|
-
*/
|
|
19
|
-
customColor?: string;
|
|
20
|
-
}
|
|
21
|
-
declare const NextcloudFileCard: {
|
|
22
|
-
({ doc, userId, isClickable, isSelectable, isSelected, onClick, className, onSelect, isFocused, app, customIcon, customColor, }: NextcloudFileCardProps): import("react/jsx-runtime").JSX.Element;
|
|
23
|
-
displayName: string;
|
|
24
|
-
};
|
|
25
|
-
export default NextcloudFileCard;
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useRef } from "react";
|
|
3
|
-
import { DocumentHelper, odeServices } from "@edifice.io/client";
|
|
4
|
-
import clsx from "clsx";
|
|
5
|
-
import SvgIconLandscape from "../../icons/components/IconLandscape.js";
|
|
6
|
-
import SvgIconMic from "../../icons/components/IconMic.js";
|
|
7
|
-
import SvgIconTextPage from "../../icons/components/IconTextPage.js";
|
|
8
|
-
import SvgIconVideo from "../../icons/components/IconVideo.js";
|
|
9
|
-
import FileIcon from "./FileIcon.js";
|
|
10
|
-
import useThumbnail from "../../../hooks/useThumbnail/useThumbnail.js";
|
|
11
|
-
import Card from "../../../components/Card/Card.js";
|
|
12
|
-
const roleMappings = {
|
|
13
|
-
csv: {
|
|
14
|
-
icon: ".CSV",
|
|
15
|
-
color: "bg-orange-200"
|
|
16
|
-
},
|
|
17
|
-
xls: {
|
|
18
|
-
icon: ".XLS",
|
|
19
|
-
color: "bg-green-200"
|
|
20
|
-
},
|
|
21
|
-
doc: {
|
|
22
|
-
icon: ".DOC",
|
|
23
|
-
color: "bg-blue-200"
|
|
24
|
-
},
|
|
25
|
-
txt: {
|
|
26
|
-
icon: ".TXT",
|
|
27
|
-
color: "bg-blue-200"
|
|
28
|
-
},
|
|
29
|
-
pdf: {
|
|
30
|
-
icon: ".PDF",
|
|
31
|
-
color: "bg-red-200"
|
|
32
|
-
},
|
|
33
|
-
audio: {
|
|
34
|
-
icon: /* @__PURE__ */ jsx(SvgIconMic, { width: 22, height: 22 }),
|
|
35
|
-
color: "bg-red-200"
|
|
36
|
-
},
|
|
37
|
-
ppt: {
|
|
38
|
-
icon: ".PPT",
|
|
39
|
-
color: "bg-red-200"
|
|
40
|
-
},
|
|
41
|
-
img: {
|
|
42
|
-
icon: /* @__PURE__ */ jsx(SvgIconLandscape, { width: 22, height: 22 }),
|
|
43
|
-
color: "bg-green-200"
|
|
44
|
-
},
|
|
45
|
-
video: {
|
|
46
|
-
icon: /* @__PURE__ */ jsx(SvgIconVideo, { width: 22, height: 22 }),
|
|
47
|
-
color: "bg-purple-200"
|
|
48
|
-
},
|
|
49
|
-
zip: {
|
|
50
|
-
icon: ".ZIP",
|
|
51
|
-
color: "bg-gray-300"
|
|
52
|
-
},
|
|
53
|
-
md: {
|
|
54
|
-
icon: ".MD",
|
|
55
|
-
color: "bg-blue-200"
|
|
56
|
-
},
|
|
57
|
-
unknown: {
|
|
58
|
-
icon: /* @__PURE__ */ jsx(SvgIconTextPage, { width: 22, height: 22 }),
|
|
59
|
-
color: "bg-gray-300"
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
function getRoleMap(type, customIcon, customColor) {
|
|
63
|
-
return customIcon !== void 0 || customColor !== void 0 ? {
|
|
64
|
-
icon: customIcon || /* @__PURE__ */ jsx(SvgIconTextPage, { width: 22, height: 22 }),
|
|
65
|
-
color: customColor || "bg-gray-300",
|
|
66
|
-
hasShadow: !1
|
|
67
|
-
} : roleMappings[type] ?? roleMappings.unknown;
|
|
68
|
-
}
|
|
69
|
-
const NextcloudFileCard = ({
|
|
70
|
-
doc,
|
|
71
|
-
userId,
|
|
72
|
-
isClickable = !0,
|
|
73
|
-
isSelectable = !1,
|
|
74
|
-
isSelected = !1,
|
|
75
|
-
onClick,
|
|
76
|
-
className,
|
|
77
|
-
onSelect,
|
|
78
|
-
isFocused,
|
|
79
|
-
app,
|
|
80
|
-
customIcon,
|
|
81
|
-
customColor
|
|
82
|
-
}) => {
|
|
83
|
-
const ref = useRef(null), type = DocumentHelper.role(doc.contentType, !1), roleMap = getRoleMap(type ?? "unknown", customIcon, customColor), file = clsx("file position-relative rounded", (roleMap == null ? void 0 : roleMap.color) ?? "bg-yellow-200"), mediaSrc = type === "img" ? odeServices.nextcloud().getFileUrl(userId, doc) : null, hasThumbnail = useThumbnail(mediaSrc, {
|
|
84
|
-
ref
|
|
85
|
-
}), imageStyles = hasThumbnail && {
|
|
86
|
-
backgroundImage: `url(${mediaSrc})`,
|
|
87
|
-
backgroundSize: "cover"
|
|
88
|
-
};
|
|
89
|
-
return /* @__PURE__ */ jsx(Card, { className: clsx("card-file", className), isClickable, isSelectable, isSelected, onClick, app, isFocused, onSelect, children: /* @__PURE__ */ jsxs(Card.Body, { space: "8", children: [
|
|
90
|
-
/* @__PURE__ */ jsx("div", { ref, className: file, style: {
|
|
91
|
-
aspectRatio: "16/10",
|
|
92
|
-
...imageStyles
|
|
93
|
-
}, children: type !== "img" || !hasThumbnail ? /* @__PURE__ */ jsx(FileIcon, { type, roleMap }) : null }),
|
|
94
|
-
/* @__PURE__ */ jsxs("div", { className: "mt-4", children: [
|
|
95
|
-
/* @__PURE__ */ jsx(Card.Text, { children: doc.name }),
|
|
96
|
-
/* @__PURE__ */ jsx(Card.Text, { className: "text-black-50", children: doc == null ? void 0 : doc.ownerDisplayName })
|
|
97
|
-
] })
|
|
98
|
-
] }) });
|
|
99
|
-
};
|
|
100
|
-
export {
|
|
101
|
-
NextcloudFileCard as default
|
|
102
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { GoogleDriveDocument, Role } from '@edifice.io/client';
|
|
2
|
-
/**
|
|
3
|
-
* GoogleDrive component properties
|
|
4
|
-
*/
|
|
5
|
-
export interface GoogleDriveProps {
|
|
6
|
-
/**
|
|
7
|
-
* Notify parent when media elements are successfully selected.
|
|
8
|
-
*/
|
|
9
|
-
onSelect: (result: GoogleDriveDocument[]) => void;
|
|
10
|
-
/**
|
|
11
|
-
* Boolean to know if we can select 1 or many files.
|
|
12
|
-
*/
|
|
13
|
-
multiple?: boolean | undefined;
|
|
14
|
-
/**
|
|
15
|
-
* Document roles to filter files by; null (default) shows all roles.
|
|
16
|
-
*/
|
|
17
|
-
roles?: Role | Role[] | null;
|
|
18
|
-
/**
|
|
19
|
-
* Optional class for styling purpose
|
|
20
|
-
*/
|
|
21
|
-
className?: string;
|
|
22
|
-
}
|
|
23
|
-
declare const GoogleDrive: ({ onSelect, multiple, roles, className, }: GoogleDriveProps) => import("react/jsx-runtime").JSX.Element;
|
|
24
|
-
export default GoogleDrive;
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useState, useCallback, useEffect, useMemo } from "react";
|
|
3
|
-
import { DocumentHelper } from "@edifice.io/client";
|
|
4
|
-
import clsx from "clsx";
|
|
5
|
-
import { useTranslation } from "react-i18next";
|
|
6
|
-
import { findNodeById } from "../../../components/Tree/utilities/tree.js";
|
|
7
|
-
import SvgIconSortAscendingLetters from "../../icons/components/IconSortAscendingLetters.js";
|
|
8
|
-
import SvgIconSortDescendingLetters from "../../icons/components/IconSortDescendingLetters.js";
|
|
9
|
-
import SvgIconSortTime from "../../icons/components/IconSortTime.js";
|
|
10
|
-
import illuError from "@edifice.io/bootstrap/dist/images/emptyscreen/illu-error.svg";
|
|
11
|
-
import illuTrash from "@edifice.io/bootstrap/dist/images/emptyscreen/illu-trash.svg";
|
|
12
|
-
import useUser from "../../../hooks/useUser/useUser.js";
|
|
13
|
-
import useGoogleDriveSearch from "../../../hooks/useGoogleDriveSearch/useGoogleDriveSearch.js";
|
|
14
|
-
import { Grid } from "../../../components/Grid/Grid.js";
|
|
15
|
-
import Tree from "../../../components/Tree/components/Tree.js";
|
|
16
|
-
import SearchBar from "../../../components/SearchBar/SearchBar.js";
|
|
17
|
-
import Flex from "../../../components/Flex/Flex.js";
|
|
18
|
-
import Dropdown from "../../../components/Dropdown/Dropdown.js";
|
|
19
|
-
import EmptyScreen from "../../../components/EmptyScreen/EmptyScreen.js";
|
|
20
|
-
import Button from "../../../components/Button/Button.js";
|
|
21
|
-
import LoadingScreen from "../../../components/LoadingScreen/LoadingScreen.js";
|
|
22
|
-
import GoogleDriveFileCard from "../FileCard/GoogleDriveFileCard.js";
|
|
23
|
-
const ROOT_ID = "root";
|
|
24
|
-
function compare(a, b) {
|
|
25
|
-
return a === b ? 0 : a === void 0 ? -1 : b === void 0 ? 1 : a.localeCompare(b);
|
|
26
|
-
}
|
|
27
|
-
const GoogleDrive = ({
|
|
28
|
-
onSelect,
|
|
29
|
-
multiple = !0,
|
|
30
|
-
roles,
|
|
31
|
-
className
|
|
32
|
-
}) => {
|
|
33
|
-
const {
|
|
34
|
-
t
|
|
35
|
-
} = useTranslation(), {
|
|
36
|
-
user
|
|
37
|
-
} = useUser(), {
|
|
38
|
-
root,
|
|
39
|
-
loadContent,
|
|
40
|
-
loadError
|
|
41
|
-
} = useGoogleDriveSearch(ROOT_ID, t("google-drive.mydrive"), user == null ? void 0 : user.userId), [currentNodeId, setCurrentNodeId] = useState(ROOT_ID), currentNode = findNodeById(root, currentNodeId) ?? root, [searchTerm, setSearchTerm] = useState(void 0), [sortOrder, setSortOrder] = useState(["modified", "desc"]), [selectedDocuments, setSelectedDocuments] = useState([]), handleTreeItemChange = useCallback((nodeId) => {
|
|
42
|
-
setCurrentNodeId(nodeId), loadContent(nodeId);
|
|
43
|
-
}, [loadContent]);
|
|
44
|
-
useEffect(() => {
|
|
45
|
-
loadContent(ROOT_ID);
|
|
46
|
-
}, [loadContent]);
|
|
47
|
-
const documents = useMemo(() => {
|
|
48
|
-
if (!currentNode.files) return;
|
|
49
|
-
const matchesRole = (doc) => {
|
|
50
|
-
if (!roles) return !0;
|
|
51
|
-
const role = DocumentHelper.role(doc.contentType, !1);
|
|
52
|
-
return Array.isArray(roles) ? roles.includes(role) : roles === role;
|
|
53
|
-
}, normalizedSearchTerm = searchTerm == null ? void 0 : searchTerm.toLowerCase(), list = currentNode.files.filter((f) => (!normalizedSearchTerm || f.name.toLowerCase().includes(normalizedSearchTerm)) && matchesRole(f));
|
|
54
|
-
let sortFunction;
|
|
55
|
-
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
|
-
}, [currentNode, searchTerm, sortOrder, roles]), selectedIds = useMemo(() => new Set(selectedDocuments.map((d) => d.id)), [selectedDocuments]), handleSearchChange = useCallback((e) => {
|
|
57
|
-
setSearchTerm(e.target.value);
|
|
58
|
-
}, [setSearchTerm]);
|
|
59
|
-
function getSortOrderLabel() {
|
|
60
|
-
return sortOrder[0] === "name" ? sortOrder[1] === "asc" ? t("sort.order.alpha.asc") : t("sort.order.alpha.desc") : t("sort.order.modify.desc");
|
|
61
|
-
}
|
|
62
|
-
function handleSelectDoc(doc) {
|
|
63
|
-
let currentDocuments = [...selectedDocuments];
|
|
64
|
-
multiple ? currentDocuments.some((selectedDocument) => selectedDocument.id === doc.id) ? currentDocuments = currentDocuments.filter((selectedDocument) => selectedDocument.id !== doc.id) : currentDocuments = [...currentDocuments, doc] : currentDocuments = [doc], setSelectedDocuments(currentDocuments), onSelect(currentDocuments);
|
|
65
|
-
}
|
|
66
|
-
const googleDrive = clsx("workspace flex-grow-1 gap-0", className);
|
|
67
|
-
return /* @__PURE__ */ jsxs(Grid, { className: googleDrive, children: [
|
|
68
|
-
/* @__PURE__ */ jsx(Grid.Col, { sm: "12", md: "3", xl: "4", className: "workspace-folders p-12 pt-0 gap-12", children: /* @__PURE__ */ jsx("div", { style: {
|
|
69
|
-
position: "sticky",
|
|
70
|
-
top: 0,
|
|
71
|
-
paddingTop: "1.2rem"
|
|
72
|
-
}, children: /* @__PURE__ */ jsx(Tree, { nodes: root, selectedNodeId: currentNodeId, showIcon: !0, onTreeItemClick: handleTreeItemChange, onTreeItemUnfold: handleTreeItemChange }) }) }),
|
|
73
|
-
/* @__PURE__ */ jsx(Grid.Col, { sm: "12", md: "5", xl: "8", children: /* @__PURE__ */ jsxs(Grid, { className: "flex-grow-1 gap-0", children: [
|
|
74
|
-
/* @__PURE__ */ jsxs(Grid.Col, { sm: "4", md: "8", xl: "12", children: [
|
|
75
|
-
/* @__PURE__ */ jsx("div", { className: "workspace-search px-16 py-8 ", children: /* @__PURE__ */ jsx(SearchBar, { isVariant: !0, className: "gap-16", onChange: handleSearchChange }) }),
|
|
76
|
-
/* @__PURE__ */ jsxs(Flex, { className: "px-8 py-4", align: "center", justify: "end", children: [
|
|
77
|
-
/* @__PURE__ */ jsx("small", { className: "text-muted", children: t("workspace.search.order") }),
|
|
78
|
-
/* @__PURE__ */ jsxs(Dropdown, { children: [
|
|
79
|
-
/* @__PURE__ */ jsx(Dropdown.Trigger, { size: "sm", label: getSortOrderLabel(), variant: "ghost" }),
|
|
80
|
-
/* @__PURE__ */ jsxs(Dropdown.Menu, { children: [
|
|
81
|
-
/* @__PURE__ */ jsx(Dropdown.Item, { icon: /* @__PURE__ */ jsx(SvgIconSortTime, {}), onClick: () => setSortOrder(["modified", "desc"]), children: t("sort.order.modify.desc") }),
|
|
82
|
-
/* @__PURE__ */ jsx(Dropdown.Item, { icon: /* @__PURE__ */ jsx(SvgIconSortAscendingLetters, {}), onClick: () => setSortOrder(["name", "asc"]), children: t("sort.order.alpha.asc") }),
|
|
83
|
-
/* @__PURE__ */ jsx(Dropdown.Item, { icon: /* @__PURE__ */ jsx(SvgIconSortDescendingLetters, {}), onClick: () => setSortOrder(["name", "desc"]), children: t("sort.order.alpha.desc") })
|
|
84
|
-
] })
|
|
85
|
-
] })
|
|
86
|
-
] })
|
|
87
|
-
] }),
|
|
88
|
-
/* @__PURE__ */ jsx(Grid.Col, { sm: "4", md: "8", xl: "12", className: "p-8 gap-8", children: loadError ? /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: "12", className: "h-full w-100", justify: "center", align: "center", children: [
|
|
89
|
-
/* @__PURE__ */ jsx(EmptyScreen, { imageSrc: illuError, title: t("google-drive.error.title"), text: t("google-drive.error.description") }),
|
|
90
|
-
/* @__PURE__ */ jsx(Button, { onClick: () => loadContent(currentNodeId), children: t("retry") })
|
|
91
|
-
] }) : documents ? documents.length !== 0 ? /* @__PURE__ */ jsx("div", { className: "grid grid-workspace", children: documents.map((doc) => {
|
|
92
|
-
const isSelected = selectedIds.has(doc.id);
|
|
93
|
-
return /* @__PURE__ */ jsx(GoogleDriveFileCard, { doc, userId: user.userId, isSelected, onClick: () => handleSelectDoc(doc) }, doc.id);
|
|
94
|
-
}) }) : /* @__PURE__ */ jsx(EmptyScreen, { imageSrc: illuTrash, text: t("workspace.empty.docSpace"), title: t("explorer.emptyScreen.trash.title") }) : /* @__PURE__ */ jsx(LoadingScreen, {}) })
|
|
95
|
-
] }) })
|
|
96
|
-
] });
|
|
97
|
-
};
|
|
98
|
-
export {
|
|
99
|
-
GoogleDrive as default
|
|
100
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const GoogleDrive: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { odeServices, GoogleDriveCopyError } from "@edifice.io/client";
|
|
3
|
-
import { useTranslation } from "react-i18next";
|
|
4
|
-
import { useMediaLibraryContext } from "../MediaLibraryContext.js";
|
|
5
|
-
import useUser from "../../../../hooks/useUser/useUser.js";
|
|
6
|
-
import useToast from "../../../../hooks/useToast/useToast.js";
|
|
7
|
-
import GoogleDrive$1 from "../../GoogleDrive/GoogleDrive.js";
|
|
8
|
-
const GoogleDrive = () => {
|
|
9
|
-
const {
|
|
10
|
-
appCode,
|
|
11
|
-
visibility,
|
|
12
|
-
type,
|
|
13
|
-
setResultCounter,
|
|
14
|
-
setResult,
|
|
15
|
-
setPreSuccess,
|
|
16
|
-
multiple
|
|
17
|
-
} = useMediaLibraryContext(), {
|
|
18
|
-
user
|
|
19
|
-
} = useUser(), {
|
|
20
|
-
t
|
|
21
|
-
} = useTranslation(), toast = useToast();
|
|
22
|
-
function getDocumentRoleFilter() {
|
|
23
|
-
switch (type) {
|
|
24
|
-
case "image":
|
|
25
|
-
return "img";
|
|
26
|
-
case "audio":
|
|
27
|
-
return "audio";
|
|
28
|
-
case "video":
|
|
29
|
-
return "video";
|
|
30
|
-
default:
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
async function copyToWorkspace(userId, ids) {
|
|
35
|
-
try {
|
|
36
|
-
return await odeServices.googledrive().copyDocumentToWorkspace(
|
|
37
|
-
userId,
|
|
38
|
-
ids,
|
|
39
|
-
void 0,
|
|
40
|
-
// Copy the documents straight to their final place, the way an upload
|
|
41
|
-
// does, instead of leaving a copy in the user's own documents for the
|
|
42
|
-
// modal to transfer afterwards.
|
|
43
|
-
{
|
|
44
|
-
application: appCode,
|
|
45
|
-
visibility
|
|
46
|
-
}
|
|
47
|
-
);
|
|
48
|
-
} catch (error) {
|
|
49
|
-
if (error instanceof GoogleDriveCopyError && error.copied.length > 0)
|
|
50
|
-
return toast.warning(t("google-drive.transfer.error")), error.copied;
|
|
51
|
-
throw error;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
function handleSelect(result) {
|
|
55
|
-
setResultCounter(result.length), result.length ? (setResult(result), setPreSuccess(() => () => user != null && user.userId ? copyToWorkspace(user.userId, result.map((doc) => doc.id)) : Promise.resolve([]))) : (setResult(), setPreSuccess(void 0));
|
|
56
|
-
}
|
|
57
|
-
return /* @__PURE__ */ jsx(GoogleDrive$1, { roles: getDocumentRoleFilter(), onSelect: handleSelect, multiple, className: "border rounded overflow-y-auto" });
|
|
58
|
-
};
|
|
59
|
-
export {
|
|
60
|
-
GoogleDrive
|
|
61
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const Nextcloud: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { odeServices } from "@edifice.io/client";
|
|
3
|
-
import { useMediaLibraryContext } from "../MediaLibraryContext.js";
|
|
4
|
-
import useUser from "../../../../hooks/useUser/useUser.js";
|
|
5
|
-
import Nextcloud$1 from "../../Nextcloud/Nextcloud.js";
|
|
6
|
-
const Nextcloud = () => {
|
|
7
|
-
const {
|
|
8
|
-
appCode,
|
|
9
|
-
visibility,
|
|
10
|
-
type,
|
|
11
|
-
setResultCounter,
|
|
12
|
-
setResult,
|
|
13
|
-
setPreSuccess,
|
|
14
|
-
multiple
|
|
15
|
-
} = useMediaLibraryContext(), {
|
|
16
|
-
user
|
|
17
|
-
} = useUser();
|
|
18
|
-
function getDocumentRoleFilter() {
|
|
19
|
-
switch (type) {
|
|
20
|
-
case "image":
|
|
21
|
-
return "img";
|
|
22
|
-
case "audio":
|
|
23
|
-
return "audio";
|
|
24
|
-
case "video":
|
|
25
|
-
return "video";
|
|
26
|
-
default:
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
function handleSelect(result) {
|
|
31
|
-
setResultCounter(result.length), result.length ? (setResult(result), setPreSuccess(() => () => user != null && user.userId ? odeServices.nextcloud().copyDocumentToWorkspace(
|
|
32
|
-
user.userId,
|
|
33
|
-
result.map((doc) => doc.path),
|
|
34
|
-
void 0,
|
|
35
|
-
// Copy the documents straight to their final place, the way an
|
|
36
|
-
// upload does, instead of leaving a copy in the user's own
|
|
37
|
-
// documents for the modal to transfer afterwards.
|
|
38
|
-
{
|
|
39
|
-
application: appCode,
|
|
40
|
-
visibility
|
|
41
|
-
}
|
|
42
|
-
) : Promise.resolve([]))) : (setResult(), setPreSuccess(void 0));
|
|
43
|
-
}
|
|
44
|
-
return /* @__PURE__ */ jsx(Nextcloud$1, { roles: getDocumentRoleFilter(), onSelect: handleSelect, multiple, className: "border rounded overflow-y-auto" });
|
|
45
|
-
};
|
|
46
|
-
export {
|
|
47
|
-
Nextcloud
|
|
48
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { NextcloudDocument, Role } from '@edifice.io/client';
|
|
2
|
-
/**
|
|
3
|
-
* Nextcloud component properties
|
|
4
|
-
*/
|
|
5
|
-
export interface NextcloudProps {
|
|
6
|
-
/**
|
|
7
|
-
* Notify parent when media elements are successfully selected.
|
|
8
|
-
*/
|
|
9
|
-
onSelect: (result: NextcloudDocument[]) => void;
|
|
10
|
-
/**
|
|
11
|
-
* Boolean to know if we can select 1 or many files.
|
|
12
|
-
*/
|
|
13
|
-
multiple?: boolean | undefined;
|
|
14
|
-
/**
|
|
15
|
-
* Document roles to filter files by; null (default) shows all roles.
|
|
16
|
-
*/
|
|
17
|
-
roles?: Role | Role[] | null;
|
|
18
|
-
/**
|
|
19
|
-
* Optional class for styling purpose
|
|
20
|
-
*/
|
|
21
|
-
className?: string;
|
|
22
|
-
}
|
|
23
|
-
declare const Nextcloud: ({ onSelect, multiple, roles, className, }: NextcloudProps) => import("react/jsx-runtime").JSX.Element;
|
|
24
|
-
export default Nextcloud;
|