@burdenoff/microfe-files 2026.1113.1 → 2026.1115.1
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/files/components/ShareAccessParts.d.ts +57 -0
- package/dist/files/components/ShareAccessParts.js +141 -0
- package/dist/files/components/ShareAccessParts.js.map +1 -0
- package/dist/files/components/SharedFolderView.d.ts +18 -0
- package/dist/files/components/SharedFolderView.js +80 -0
- package/dist/files/components/SharedFolderView.js.map +1 -0
- package/dist/files/hooks/usePublicShare.d.ts +21 -0
- package/dist/files/hooks/usePublicShare.js +45 -0
- package/dist/files/hooks/usePublicShare.js.map +1 -0
- package/dist/files/hooks/useSharedFolderFileUrl.d.ts +20 -0
- package/dist/files/hooks/useSharedFolderFileUrl.js +32 -0
- package/dist/files/hooks/useSharedFolderFileUrl.js.map +1 -0
- package/dist/files/pages/ShareAccessPage.js +128 -160
- package/dist/files/pages/ShareAccessPage.js.map +1 -1
- package/dist/files/utils/publicShare.d.ts +62 -0
- package/dist/files/utils/publicShare.js +44 -0
- package/dist/files/utils/publicShare.js.map +1 -0
- package/dist/generated/global-types.d.ts +294 -123
- package/dist/generated/wspace-operations.d.ts +48 -0
- package/dist/generated/wspace-operations.js +372 -36
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/generated/wspace-types.d.ts +6493 -695
- package/dist/generated/wspace-types.js.map +1 -1
- package/dist/translations/en.d.ts +11 -0
- package/dist/translations/en.js +11 -0
- package/dist/translations/en.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { FormEvent } from 'react';
|
|
2
|
+
import { ShareAccessFailure } from '../utils/shareAccess';
|
|
3
|
+
import { PublicShareResult, SharedFolderFile } from '../utils/publicShare';
|
|
4
|
+
/** The page title and purpose line, worded for a file or a folder link. */
|
|
5
|
+
export declare function ShareAccessHeader({ isFolder }: {
|
|
6
|
+
isFolder: boolean;
|
|
7
|
+
}): import('react').JSX.Element;
|
|
8
|
+
/** Shown while the link is being checked. */
|
|
9
|
+
export declare function ShareAccessVerifying(): import('react').JSX.Element;
|
|
10
|
+
/** A shared file, with Open preview and (when allowed) Download. */
|
|
11
|
+
export declare function SharedFileSummary({ file, canDownload, onPreview, onDownload, }: {
|
|
12
|
+
file: {
|
|
13
|
+
name: string;
|
|
14
|
+
size: number;
|
|
15
|
+
};
|
|
16
|
+
canDownload: boolean;
|
|
17
|
+
onPreview: () => void;
|
|
18
|
+
onDownload: () => void;
|
|
19
|
+
}): import('react').JSX.Element;
|
|
20
|
+
/** Asks for the link's password; says so plainly when it was wrong. */
|
|
21
|
+
export declare function SharePasswordForm({ isFolder, invalid, password, onPasswordChange, onSubmit, }: {
|
|
22
|
+
isFolder: boolean;
|
|
23
|
+
invalid: boolean;
|
|
24
|
+
password: string;
|
|
25
|
+
onPasswordChange: (value: string) => void;
|
|
26
|
+
onSubmit: (event: FormEvent<HTMLFormElement>) => void;
|
|
27
|
+
}): import('react').JSX.Element;
|
|
28
|
+
/** One plain sentence when the link can't be opened, and a retry button. */
|
|
29
|
+
export declare function ShareUnavailable({ unavailable, onRetry, }: {
|
|
30
|
+
unavailable: boolean;
|
|
31
|
+
onRetry: () => void;
|
|
32
|
+
}): import('react').JSX.Element;
|
|
33
|
+
export interface ShareAccessBodyProps {
|
|
34
|
+
loading: boolean;
|
|
35
|
+
share: PublicShareResult | null;
|
|
36
|
+
/** The shared file, once a file link opened. */
|
|
37
|
+
sharedFile: {
|
|
38
|
+
name: string;
|
|
39
|
+
size: number;
|
|
40
|
+
downloadUrl?: string;
|
|
41
|
+
url: string;
|
|
42
|
+
} | null;
|
|
43
|
+
failure: ShareAccessFailure | null;
|
|
44
|
+
isFolder: boolean;
|
|
45
|
+
password: string;
|
|
46
|
+
busyFileId: string | null;
|
|
47
|
+
failedFileId: string | null;
|
|
48
|
+
onPasswordChange: (value: string) => void;
|
|
49
|
+
onPasswordSubmit: (event: FormEvent<HTMLFormElement>) => void;
|
|
50
|
+
onRetry: () => void;
|
|
51
|
+
onOpenPreview: () => void;
|
|
52
|
+
onDownload: () => void;
|
|
53
|
+
onFolderPreview: (file: SharedFolderFile) => void;
|
|
54
|
+
onFolderDownload: (file: SharedFolderFile) => void;
|
|
55
|
+
}
|
|
56
|
+
/** Picks what the share card shows: checking, folder, file, password or error. */
|
|
57
|
+
export declare function ShareAccessBody(props: ShareAccessBodyProps): import('react').JSX.Element;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { tWithFallback as e } from "../utils/i18n.js";
|
|
2
|
+
import { formatFileSize as t } from "../utils/index.js";
|
|
3
|
+
import { SharedFolderView as n } from "./SharedFolderView.js";
|
|
4
|
+
import { Download as r, Eye as i, FileText as a, Loader2 as o, Lock as s } from "lucide-react";
|
|
5
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
6
|
+
import { useI18n as u } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
7
|
+
import { Button as d, PagePurpose as f } from "@burdenoff/fe-libs/ui";
|
|
8
|
+
// src/files/components/ShareAccessParts.tsx
|
|
9
|
+
function p({ isFolder: t }) {
|
|
10
|
+
let { t: n } = u();
|
|
11
|
+
return /* @__PURE__ */ l("div", {
|
|
12
|
+
className: "mb-6",
|
|
13
|
+
children: [/* @__PURE__ */ c("h1", {
|
|
14
|
+
className: "text-xl font-semibold text-text-primary",
|
|
15
|
+
children: t ? e(n, "files.share.folder.title", "Shared folder") : e(n, "files.share.title", "Shared file access")
|
|
16
|
+
}), /* @__PURE__ */ c(f, {
|
|
17
|
+
className: "mt-2",
|
|
18
|
+
children: t ? e(n, "files.share.folder.subtitle", "Someone shared a folder with you via a link. Preview and download its files here — if the link is password-protected, enter the password the sender gave you to unlock it.") : e(n, "files.share.subtitle", "Someone shared a file with you via a link. Preview and download it here — if the link is password-protected, enter the password the sender gave you to unlock it.")
|
|
19
|
+
})]
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function m() {
|
|
23
|
+
let { t } = u();
|
|
24
|
+
return /* @__PURE__ */ l("div", {
|
|
25
|
+
role: "status",
|
|
26
|
+
className: "flex items-center gap-3 rounded-lg border border-border-seam bg-bg-sunken px-4 py-3 text-sm text-text-secondary",
|
|
27
|
+
children: [/* @__PURE__ */ c(o, { className: "size-4 animate-spin text-action-primary-bg" }), e(t, "files.share.verifying", "Verifying share access…")]
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function h({ file: n, canDownload: o, onPreview: s, onDownload: f }) {
|
|
31
|
+
let { t: p } = u();
|
|
32
|
+
return /* @__PURE__ */ l("div", {
|
|
33
|
+
className: "space-y-4",
|
|
34
|
+
children: [/* @__PURE__ */ l("div", {
|
|
35
|
+
className: "flex items-center gap-3 rounded-lg border border-border-seam bg-bg-sunken px-4 py-3",
|
|
36
|
+
children: [/* @__PURE__ */ c(a, { className: "size-5 shrink-0 text-text-tertiary" }), /* @__PURE__ */ l("div", {
|
|
37
|
+
className: "min-w-0",
|
|
38
|
+
children: [/* @__PURE__ */ c("p", {
|
|
39
|
+
className: "truncate text-sm font-medium text-text-primary",
|
|
40
|
+
children: n.name
|
|
41
|
+
}), /* @__PURE__ */ c("p", {
|
|
42
|
+
className: "text-xs text-text-secondary",
|
|
43
|
+
children: t(n.size)
|
|
44
|
+
})]
|
|
45
|
+
})]
|
|
46
|
+
}), /* @__PURE__ */ l("div", {
|
|
47
|
+
className: "flex flex-col gap-2 sm:flex-row",
|
|
48
|
+
children: [/* @__PURE__ */ l(d, {
|
|
49
|
+
type: "button",
|
|
50
|
+
variant: "outline",
|
|
51
|
+
className: "flex-1",
|
|
52
|
+
onClick: s,
|
|
53
|
+
children: [/* @__PURE__ */ c(i, { className: "size-4" }), e(p, "files.share.openPreview", "Open preview")]
|
|
54
|
+
}), o && /* @__PURE__ */ l(d, {
|
|
55
|
+
type: "button",
|
|
56
|
+
className: "flex-1",
|
|
57
|
+
onClick: f,
|
|
58
|
+
children: [/* @__PURE__ */ c(r, { className: "size-4" }), e(p, "files.share.download", "Download")]
|
|
59
|
+
})]
|
|
60
|
+
})]
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function g({ isFolder: t, invalid: n, password: r, onPasswordChange: i, onSubmit: a }) {
|
|
64
|
+
let { t: o } = u();
|
|
65
|
+
return /* @__PURE__ */ l("form", {
|
|
66
|
+
className: "space-y-4",
|
|
67
|
+
onSubmit: a,
|
|
68
|
+
children: [
|
|
69
|
+
/* @__PURE__ */ l("label", {
|
|
70
|
+
className: "block text-sm font-medium text-text-primary",
|
|
71
|
+
children: [e(o, "files.share.password.label", "Share password"), /* @__PURE__ */ l("div", {
|
|
72
|
+
className: "mt-2 flex items-center gap-2 rounded-lg border border-border-seam px-3 py-2",
|
|
73
|
+
children: [/* @__PURE__ */ c(s, { className: "size-4 text-text-tertiary" }), /* @__PURE__ */ c("input", {
|
|
74
|
+
type: "password",
|
|
75
|
+
value: r,
|
|
76
|
+
onChange: (e) => i(e.target.value),
|
|
77
|
+
"aria-label": e(o, "files.share.password.label", "Share password"),
|
|
78
|
+
className: "w-full bg-transparent text-sm text-text-primary outline-none",
|
|
79
|
+
placeholder: e(o, "files.share.password.placeholder", "Enter the share password")
|
|
80
|
+
})]
|
|
81
|
+
})]
|
|
82
|
+
}),
|
|
83
|
+
n && /* @__PURE__ */ c("div", {
|
|
84
|
+
role: "alert",
|
|
85
|
+
className: "rounded-lg border border-status-error-border bg-status-error-bg-subtle px-3 py-2 text-sm text-status-error-text",
|
|
86
|
+
children: e(o, "files.share.errors.wrongPassword", "That password didn't work. Check it with the person who shared the link and try again.")
|
|
87
|
+
}),
|
|
88
|
+
/* @__PURE__ */ c("button", {
|
|
89
|
+
type: "submit",
|
|
90
|
+
disabled: !r.trim(),
|
|
91
|
+
className: "inline-flex w-full items-center justify-center gap-2 rounded-lg bg-action-primary-bg px-4 py-2.5 text-sm font-medium text-text-inverse transition-colors hover:bg-action-primary-bg-hover disabled:cursor-not-allowed disabled:bg-bg-sunken disabled:text-text-tertiary",
|
|
92
|
+
children: t ? e(o, "files.share.folder.unlock", "Unlock shared folder") : e(o, "files.share.unlock", "Unlock shared file")
|
|
93
|
+
})
|
|
94
|
+
]
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
function _({ unavailable: t, onRetry: n }) {
|
|
98
|
+
let { t: r } = u();
|
|
99
|
+
return /* @__PURE__ */ l("div", {
|
|
100
|
+
className: "space-y-4",
|
|
101
|
+
children: [t && /* @__PURE__ */ c("div", {
|
|
102
|
+
role: "alert",
|
|
103
|
+
className: "rounded-lg border border-status-error-border bg-status-error-bg-subtle px-3 py-2 text-sm text-status-error-text",
|
|
104
|
+
children: e(r, "files.share.errors.unavailable", "This link has expired or is no longer available.")
|
|
105
|
+
}), /* @__PURE__ */ c("button", {
|
|
106
|
+
type: "button",
|
|
107
|
+
onClick: n,
|
|
108
|
+
className: "inline-flex w-full items-center justify-center gap-2 rounded-lg bg-action-primary-bg px-4 py-2.5 text-sm font-medium text-text-inverse transition-colors hover:bg-action-primary-bg-hover",
|
|
109
|
+
children: e(r, "files.share.retry", "Retry shared file access")
|
|
110
|
+
})]
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
function v(e) {
|
|
114
|
+
let { loading: t, share: r, sharedFile: i, failure: a } = e;
|
|
115
|
+
return t ? /* @__PURE__ */ c(m, {}) : r?.kind === "folder" ? /* @__PURE__ */ c(n, {
|
|
116
|
+
folderName: r.folder.name,
|
|
117
|
+
files: r.files,
|
|
118
|
+
truncated: r.truncated,
|
|
119
|
+
busyFileId: e.busyFileId,
|
|
120
|
+
failedFileId: e.failedFileId,
|
|
121
|
+
onPreview: e.onFolderPreview,
|
|
122
|
+
onDownload: e.onFolderDownload
|
|
123
|
+
}) : i ? /* @__PURE__ */ c(h, {
|
|
124
|
+
file: i,
|
|
125
|
+
canDownload: !!(i.downloadUrl || i.url),
|
|
126
|
+
onPreview: e.onOpenPreview,
|
|
127
|
+
onDownload: e.onDownload
|
|
128
|
+
}) : a === "password-required" || a === "password-invalid" ? /* @__PURE__ */ c(g, {
|
|
129
|
+
isFolder: e.isFolder,
|
|
130
|
+
invalid: a === "password-invalid",
|
|
131
|
+
password: e.password,
|
|
132
|
+
onPasswordChange: e.onPasswordChange,
|
|
133
|
+
onSubmit: e.onPasswordSubmit
|
|
134
|
+
}) : /* @__PURE__ */ c(_, {
|
|
135
|
+
unavailable: a === "unavailable",
|
|
136
|
+
onRetry: e.onRetry
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
export { v as ShareAccessBody, p as ShareAccessHeader, m as ShareAccessVerifying, g as SharePasswordForm, _ as ShareUnavailable, h as SharedFileSummary };
|
|
140
|
+
|
|
141
|
+
//# sourceMappingURL=ShareAccessParts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShareAccessParts.js","names":["ShareAccessHeader","useI18n","isFolder","tWithFallback","t","PagePurpose","ShareAccessVerifying","Loader2","SharedFileSummary","FileText","file","formatFileSize","Button","onPreview","Eye","canDownload","onDownload","Download","SharePasswordForm","Lock","password","onPasswordChange","event","invalid","ShareUnavailable","unavailable","onRetry","ShareAccessBody","props","loading","share","SharedFolderView","sharedFile","failure"],"sources":["../../../src/files/components/ShareAccessParts.tsx"],"sourcesContent":["/**\n * Pieces of the public share page (`/files/share/:token`, BOFF-11865), split\n * out so the page itself only decides which one to show.\n */\nimport type { FormEvent } from \"react\";\nimport { Download, Eye, FileText, Loader2, Lock } from \"lucide-react\";\nimport { useI18n } from \"@burdenoff/fe-libs/shared/providers/shell/I18nProvider\";\nimport { Button, PagePurpose } from \"@burdenoff/fe-libs/ui\";\nimport { tWithFallback } from \"../utils/i18n\";\nimport { formatFileSize } from \"../utils\";\nimport type { ShareAccessFailure } from \"../utils/shareAccess\";\nimport type { PublicShareResult, SharedFolderFile } from \"../utils/publicShare\";\nimport { SharedFolderView } from \"./SharedFolderView\";\n\n/** The page title and purpose line, worded for a file or a folder link. */\nexport function ShareAccessHeader({ isFolder }: { isFolder: boolean }) {\n const { t } = useI18n();\n return (\n <div className=\"mb-6\">\n <h1 className=\"text-xl font-semibold text-text-primary\">\n {isFolder\n ? tWithFallback(t, \"files.share.folder.title\", \"Shared folder\")\n : tWithFallback(t, \"files.share.title\", \"Shared file access\")}\n </h1>\n <PagePurpose className=\"mt-2\">\n {isFolder\n ? tWithFallback(\n t,\n \"files.share.folder.subtitle\",\n \"Someone shared a folder with you via a link. Preview and download its files here — if the link is password-protected, enter the password the sender gave you to unlock it.\",\n )\n : tWithFallback(\n t,\n \"files.share.subtitle\",\n \"Someone shared a file with you via a link. Preview and download it here — if the link is password-protected, enter the password the sender gave you to unlock it.\",\n )}\n </PagePurpose>\n </div>\n );\n}\n\n/** Shown while the link is being checked. */\nexport function ShareAccessVerifying() {\n const { t } = useI18n();\n return (\n <div\n role=\"status\"\n className=\"flex items-center gap-3 rounded-lg border border-border-seam bg-bg-sunken px-4 py-3 text-sm text-text-secondary\"\n >\n <Loader2 className=\"size-4 animate-spin text-action-primary-bg\" />\n {tWithFallback(t, \"files.share.verifying\", \"Verifying share access…\")}\n </div>\n );\n}\n\n/** A shared file, with Open preview and (when allowed) Download. */\nexport function SharedFileSummary({\n file,\n canDownload,\n onPreview,\n onDownload,\n}: {\n file: { name: string; size: number };\n canDownload: boolean;\n onPreview: () => void;\n onDownload: () => void;\n}) {\n const { t } = useI18n();\n return (\n <div className=\"space-y-4\">\n <div className=\"flex items-center gap-3 rounded-lg border border-border-seam bg-bg-sunken px-4 py-3\">\n <FileText className=\"size-5 shrink-0 text-text-tertiary\" />\n <div className=\"min-w-0\">\n <p className=\"truncate text-sm font-medium text-text-primary\">\n {file.name}\n </p>\n <p className=\"text-xs text-text-secondary\">\n {formatFileSize(file.size)}\n </p>\n </div>\n </div>\n <div className=\"flex flex-col gap-2 sm:flex-row\">\n <Button\n type=\"button\"\n variant=\"outline\"\n className=\"flex-1\"\n onClick={onPreview}\n >\n <Eye className=\"size-4\" />\n {tWithFallback(t, \"files.share.openPreview\", \"Open preview\")}\n </Button>\n {canDownload && (\n <Button type=\"button\" className=\"flex-1\" onClick={onDownload}>\n <Download className=\"size-4\" />\n {tWithFallback(t, \"files.share.download\", \"Download\")}\n </Button>\n )}\n </div>\n </div>\n );\n}\n\n/** Asks for the link's password; says so plainly when it was wrong. */\nexport function SharePasswordForm({\n isFolder,\n invalid,\n password,\n onPasswordChange,\n onSubmit,\n}: {\n isFolder: boolean;\n invalid: boolean;\n password: string;\n onPasswordChange: (value: string) => void;\n onSubmit: (event: FormEvent<HTMLFormElement>) => void;\n}) {\n const { t } = useI18n();\n return (\n <form className=\"space-y-4\" onSubmit={onSubmit}>\n <label className=\"block text-sm font-medium text-text-primary\">\n {tWithFallback(t, \"files.share.password.label\", \"Share password\")}\n <div className=\"mt-2 flex items-center gap-2 rounded-lg border border-border-seam px-3 py-2\">\n <Lock className=\"size-4 text-text-tertiary\" />\n <input\n type=\"password\"\n value={password}\n onChange={(event) => onPasswordChange(event.target.value)}\n aria-label={tWithFallback(\n t,\n \"files.share.password.label\",\n \"Share password\",\n )}\n className=\"w-full bg-transparent text-sm text-text-primary outline-none\"\n placeholder={tWithFallback(\n t,\n \"files.share.password.placeholder\",\n \"Enter the share password\",\n )}\n />\n </div>\n </label>\n\n {invalid && (\n <div\n role=\"alert\"\n className=\"rounded-lg border border-status-error-border bg-status-error-bg-subtle px-3 py-2 text-sm text-status-error-text\"\n >\n {tWithFallback(\n t,\n \"files.share.errors.wrongPassword\",\n \"That password didn't work. Check it with the person who shared the link and try again.\",\n )}\n </div>\n )}\n\n <button\n type=\"submit\"\n disabled={!password.trim()}\n className=\"inline-flex w-full items-center justify-center gap-2 rounded-lg bg-action-primary-bg px-4 py-2.5 text-sm font-medium text-text-inverse transition-colors hover:bg-action-primary-bg-hover disabled:cursor-not-allowed disabled:bg-bg-sunken disabled:text-text-tertiary\"\n >\n {isFolder\n ? tWithFallback(\n t,\n \"files.share.folder.unlock\",\n \"Unlock shared folder\",\n )\n : tWithFallback(t, \"files.share.unlock\", \"Unlock shared file\")}\n </button>\n </form>\n );\n}\n\n/** One plain sentence when the link can't be opened, and a retry button. */\nexport function ShareUnavailable({\n unavailable,\n onRetry,\n}: {\n unavailable: boolean;\n onRetry: () => void;\n}) {\n const { t } = useI18n();\n return (\n <div className=\"space-y-4\">\n {unavailable && (\n <div\n role=\"alert\"\n className=\"rounded-lg border border-status-error-border bg-status-error-bg-subtle px-3 py-2 text-sm text-status-error-text\"\n >\n {tWithFallback(\n t,\n \"files.share.errors.unavailable\",\n \"This link has expired or is no longer available.\",\n )}\n </div>\n )}\n <button\n type=\"button\"\n onClick={onRetry}\n className=\"inline-flex w-full items-center justify-center gap-2 rounded-lg bg-action-primary-bg px-4 py-2.5 text-sm font-medium text-text-inverse transition-colors hover:bg-action-primary-bg-hover\"\n >\n {tWithFallback(t, \"files.share.retry\", \"Retry shared file access\")}\n </button>\n </div>\n );\n}\n\nexport interface ShareAccessBodyProps {\n loading: boolean;\n share: PublicShareResult | null;\n /** The shared file, once a file link opened. */\n sharedFile: {\n name: string;\n size: number;\n downloadUrl?: string;\n url: string;\n } | null;\n failure: ShareAccessFailure | null;\n isFolder: boolean;\n password: string;\n busyFileId: string | null;\n failedFileId: string | null;\n onPasswordChange: (value: string) => void;\n onPasswordSubmit: (event: FormEvent<HTMLFormElement>) => void;\n onRetry: () => void;\n onOpenPreview: () => void;\n onDownload: () => void;\n onFolderPreview: (file: SharedFolderFile) => void;\n onFolderDownload: (file: SharedFolderFile) => void;\n}\n\n/** Picks what the share card shows: checking, folder, file, password or error. */\nexport function ShareAccessBody(props: ShareAccessBodyProps) {\n const { loading, share, sharedFile, failure } = props;\n if (loading) return <ShareAccessVerifying />;\n if (share?.kind === \"folder\") {\n return (\n <SharedFolderView\n folderName={share.folder.name}\n files={share.files}\n truncated={share.truncated}\n busyFileId={props.busyFileId}\n failedFileId={props.failedFileId}\n onPreview={props.onFolderPreview}\n onDownload={props.onFolderDownload}\n />\n );\n }\n if (sharedFile) {\n return (\n <SharedFileSummary\n file={sharedFile}\n canDownload={Boolean(sharedFile.downloadUrl || sharedFile.url)}\n onPreview={props.onOpenPreview}\n onDownload={props.onDownload}\n />\n );\n }\n if (failure === \"password-required\" || failure === \"password-invalid\") {\n return (\n <SharePasswordForm\n isFolder={props.isFolder}\n invalid={failure === \"password-invalid\"}\n password={props.password}\n onPasswordChange={props.onPasswordChange}\n onSubmit={props.onPasswordSubmit}\n />\n );\n }\n return (\n <ShareUnavailable\n unavailable={failure === \"unavailable\"}\n onRetry={props.onRetry}\n />\n );\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SharedFolderFile } from '../utils/publicShare';
|
|
2
|
+
export interface SharedFolderViewProps {
|
|
3
|
+
folderName: string;
|
|
4
|
+
files: SharedFolderFile[];
|
|
5
|
+
/** True when the folder holds more files than the link lists. */
|
|
6
|
+
truncated: boolean;
|
|
7
|
+
/** The file whose download link is being fetched, if any. */
|
|
8
|
+
busyFileId?: string | null;
|
|
9
|
+
/** The file whose download link could not be fetched, if any. */
|
|
10
|
+
failedFileId?: string | null;
|
|
11
|
+
onPreview: (file: SharedFolderFile) => void;
|
|
12
|
+
onDownload: (file: SharedFolderFile) => void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The files of a folder opened through its public share link (BOFF-11865).
|
|
16
|
+
* Each file can be previewed or downloaded; the folder itself is read-only.
|
|
17
|
+
*/
|
|
18
|
+
export declare function SharedFolderView({ folderName, files, truncated, busyFileId, failedFileId, onPreview, onDownload, }: SharedFolderViewProps): import('react').JSX.Element;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { tWithFallback as e } from "../utils/i18n.js";
|
|
2
|
+
import { formatFileSize as t } from "../utils/index.js";
|
|
3
|
+
import { Download as n, Eye as r, FileText as i, Folder as a, Loader2 as o } from "lucide-react";
|
|
4
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
5
|
+
import { useI18n as l } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
6
|
+
import { Button as u } from "@burdenoff/fe-libs/ui";
|
|
7
|
+
// src/files/components/SharedFolderView.tsx
|
|
8
|
+
function d({ folderName: d, files: f, truncated: p, busyFileId: m, failedFileId: h, onPreview: g, onDownload: _ }) {
|
|
9
|
+
let { t: v } = l();
|
|
10
|
+
return /* @__PURE__ */ c("div", {
|
|
11
|
+
className: "space-y-4",
|
|
12
|
+
children: [
|
|
13
|
+
/* @__PURE__ */ c("div", {
|
|
14
|
+
className: "flex items-center gap-3 rounded-lg border border-border-seam bg-bg-sunken px-4 py-3",
|
|
15
|
+
children: [/* @__PURE__ */ s(a, { className: "size-5 shrink-0 text-text-tertiary" }), /* @__PURE__ */ s("p", {
|
|
16
|
+
className: "truncate text-sm font-medium text-text-primary",
|
|
17
|
+
children: d
|
|
18
|
+
})]
|
|
19
|
+
}),
|
|
20
|
+
f.length === 0 ? /* @__PURE__ */ s("p", {
|
|
21
|
+
className: "text-sm text-text-secondary",
|
|
22
|
+
children: e(v, "files.share.folder.empty", "This folder has no files yet.")
|
|
23
|
+
}) : /* @__PURE__ */ s("ul", {
|
|
24
|
+
className: "divide-y divide-border-seam rounded-lg border border-border-seam",
|
|
25
|
+
"aria-label": e(v, "files.share.folder.listLabel", "Files in this folder"),
|
|
26
|
+
children: f.map((a) => {
|
|
27
|
+
let l = m === a.id;
|
|
28
|
+
return /* @__PURE__ */ c("li", {
|
|
29
|
+
className: "px-3 py-2",
|
|
30
|
+
children: [/* @__PURE__ */ c("div", {
|
|
31
|
+
className: "flex items-center gap-3",
|
|
32
|
+
children: [
|
|
33
|
+
/* @__PURE__ */ s(i, { className: "size-4 shrink-0 text-text-tertiary" }),
|
|
34
|
+
/* @__PURE__ */ c("div", {
|
|
35
|
+
className: "min-w-0 flex-1",
|
|
36
|
+
children: [/* @__PURE__ */ s("p", {
|
|
37
|
+
className: "truncate text-sm font-medium text-text-primary",
|
|
38
|
+
children: a.name
|
|
39
|
+
}), /* @__PURE__ */ s("p", {
|
|
40
|
+
className: "text-xs text-text-secondary",
|
|
41
|
+
children: t(Number(a.size))
|
|
42
|
+
})]
|
|
43
|
+
}),
|
|
44
|
+
/* @__PURE__ */ s(u, {
|
|
45
|
+
type: "button",
|
|
46
|
+
variant: "ghost",
|
|
47
|
+
size: "icon-sm",
|
|
48
|
+
disabled: l,
|
|
49
|
+
"aria-label": e(v, "files.share.folder.previewFile", "Preview {{name}}", { name: a.name }),
|
|
50
|
+
onClick: () => g(a),
|
|
51
|
+
children: /* @__PURE__ */ s(r, { className: "size-4" })
|
|
52
|
+
}),
|
|
53
|
+
/* @__PURE__ */ s(u, {
|
|
54
|
+
type: "button",
|
|
55
|
+
variant: "ghost",
|
|
56
|
+
size: "icon-sm",
|
|
57
|
+
disabled: l,
|
|
58
|
+
"aria-label": e(v, "files.share.folder.downloadFile", "Download {{name}}", { name: a.name }),
|
|
59
|
+
onClick: () => _(a),
|
|
60
|
+
children: l ? /* @__PURE__ */ s(o, { className: "size-4 animate-spin" }) : /* @__PURE__ */ s(n, { className: "size-4" })
|
|
61
|
+
})
|
|
62
|
+
]
|
|
63
|
+
}), h === a.id && /* @__PURE__ */ s("p", {
|
|
64
|
+
role: "alert",
|
|
65
|
+
className: "mt-1 text-xs text-status-error-text",
|
|
66
|
+
children: e(v, "files.share.folder.fileFailed", "Couldn't open this file. Try again.")
|
|
67
|
+
})]
|
|
68
|
+
}, a.id);
|
|
69
|
+
})
|
|
70
|
+
}),
|
|
71
|
+
p && /* @__PURE__ */ s("p", {
|
|
72
|
+
className: "text-xs text-text-secondary",
|
|
73
|
+
children: e(v, "files.share.folder.truncated", "This folder has more files than this link shows.")
|
|
74
|
+
})
|
|
75
|
+
]
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
export { d as SharedFolderView };
|
|
79
|
+
|
|
80
|
+
//# sourceMappingURL=SharedFolderView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SharedFolderView.js","names":["SharedFolderView","useI18n","Folder","folderName","files","tWithFallback","t","busy","busyFileId","file","FileText","formatFileSize","Button","onPreview","Eye","onDownload","Loader2","Download","failedFileId","truncated"],"sources":["../../../src/files/components/SharedFolderView.tsx"],"sourcesContent":["import { Download, Eye, FileText, Folder, Loader2 } from \"lucide-react\";\nimport { useI18n } from \"@burdenoff/fe-libs/shared/providers/shell/I18nProvider\";\nimport { Button } from \"@burdenoff/fe-libs/ui\";\nimport { tWithFallback } from \"../utils/i18n\";\nimport { formatFileSize } from \"../utils\";\nimport type { SharedFolderFile } from \"../utils/publicShare\";\n\nexport interface SharedFolderViewProps {\n folderName: string;\n files: SharedFolderFile[];\n /** True when the folder holds more files than the link lists. */\n truncated: boolean;\n /** The file whose download link is being fetched, if any. */\n busyFileId?: string | null;\n /** The file whose download link could not be fetched, if any. */\n failedFileId?: string | null;\n onPreview: (file: SharedFolderFile) => void;\n onDownload: (file: SharedFolderFile) => void;\n}\n\n/**\n * The files of a folder opened through its public share link (BOFF-11865).\n * Each file can be previewed or downloaded; the folder itself is read-only.\n */\nexport function SharedFolderView({\n folderName,\n files,\n truncated,\n busyFileId,\n failedFileId,\n onPreview,\n onDownload,\n}: SharedFolderViewProps) {\n const { t } = useI18n();\n\n return (\n <div className=\"space-y-4\">\n <div className=\"flex items-center gap-3 rounded-lg border border-border-seam bg-bg-sunken px-4 py-3\">\n <Folder className=\"size-5 shrink-0 text-text-tertiary\" />\n <p className=\"truncate text-sm font-medium text-text-primary\">\n {folderName}\n </p>\n </div>\n\n {files.length === 0 ? (\n <p className=\"text-sm text-text-secondary\">\n {tWithFallback(\n t,\n \"files.share.folder.empty\",\n \"This folder has no files yet.\",\n )}\n </p>\n ) : (\n <ul\n className=\"divide-y divide-border-seam rounded-lg border border-border-seam\"\n aria-label={tWithFallback(\n t,\n \"files.share.folder.listLabel\",\n \"Files in this folder\",\n )}\n >\n {files.map((file) => {\n const busy = busyFileId === file.id;\n return (\n <li key={file.id} className=\"px-3 py-2\">\n <div className=\"flex items-center gap-3\">\n <FileText className=\"size-4 shrink-0 text-text-tertiary\" />\n <div className=\"min-w-0 flex-1\">\n <p className=\"truncate text-sm font-medium text-text-primary\">\n {file.name}\n </p>\n <p className=\"text-xs text-text-secondary\">\n {formatFileSize(Number(file.size))}\n </p>\n </div>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-sm\"\n disabled={busy}\n aria-label={tWithFallback(\n t,\n \"files.share.folder.previewFile\",\n \"Preview {{name}}\",\n { name: file.name },\n )}\n onClick={() => onPreview(file)}\n >\n <Eye className=\"size-4\" />\n </Button>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-sm\"\n disabled={busy}\n aria-label={tWithFallback(\n t,\n \"files.share.folder.downloadFile\",\n \"Download {{name}}\",\n { name: file.name },\n )}\n onClick={() => onDownload(file)}\n >\n {busy ? (\n <Loader2 className=\"size-4 animate-spin\" />\n ) : (\n <Download className=\"size-4\" />\n )}\n </Button>\n </div>\n {failedFileId === file.id && (\n <p\n role=\"alert\"\n className=\"mt-1 text-xs text-status-error-text\"\n >\n {tWithFallback(\n t,\n \"files.share.folder.fileFailed\",\n \"Couldn't open this file. Try again.\",\n )}\n </p>\n )}\n </li>\n );\n })}\n </ul>\n )}\n\n {truncated && (\n <p className=\"text-xs text-text-secondary\">\n {tWithFallback(\n t,\n \"files.share.folder.truncated\",\n \"This folder has more files than this link shows.\",\n )}\n </p>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;AAwBA,SAAgBA,EAAiB,EAC/B,eACA,UACA,cACA,eACA,iBACA,cACA,iBACwB;CACxB,IAAM,EAAE,SAAMC,EAAQ;CAEtB,OACE,kBAAC,OAAD;EAAK,WAAU;EAAf,UAAA;GACE,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,kBAACC,GAAD,EAAQ,WAAU,qCAAsC,CAAA,GACxD,kBAAC,KAAD;KAAG,WAAU;KACV,UAAAC;IACA,CAAA,CACA;;GAEJC,EAAM,WAAW,IAChB,kBAAC,KAAD;IAAG,WAAU;IACV,UAAAC,EACCC,GACA,4BACA,+BACF;GACC,CAAA,IAEH,kBAAC,MAAD;IACE,WAAU;IACV,cAAYD,EACVC,GACA,gCACA,sBACF;IAEC,UAAAF,EAAM,KAAK,MAAS;KACnB,IAAMG,IAAOC,MAAeC,EAAK;KACjC,OACE,kBAAC,MAAD;MAAkB,WAAU;MAA5B,UAAA,CACE,kBAAC,OAAD;OAAK,WAAU;OAAf,UAAA;QACE,kBAACC,GAAD,EAAU,WAAU,qCAAsC,CAAA;QAC1D,kBAAC,OAAD;SAAK,WAAU;SAAf,UAAA,CACE,kBAAC,KAAD;UAAG,WAAU;UACV,UAAAD,EAAK;SACL,CAAA,GACH,kBAAC,KAAD;UAAG,WAAU;UACV,UAAAE,EAAe,OAAOF,EAAK,IAAI,CAAC;SAChC,CAAA,CACA;;QACL,kBAACG,GAAD;SACE,MAAK;SACL,SAAQ;SACR,MAAK;SACL,UAAUL;SACV,cAAYF,EACVC,GACA,kCACA,oBACA,EAAE,MAAMG,EAAK,KAAK,CACpB;SACA,eAAeI,EAAUJ,CAAI;SAE7B,UAAA,kBAACK,GAAD,EAAK,WAAU,SAAU,CAAA;QACnB,CAAA;QACR,kBAACF,GAAD;SACE,MAAK;SACL,SAAQ;SACR,MAAK;SACL,UAAUL;SACV,cAAYF,EACVC,GACA,mCACA,qBACA,EAAE,MAAMG,EAAK,KAAK,CACpB;SACA,eAAeM,EAAWN,CAAI;SAE7B,UAAAF,IACC,kBAACS,GAAD,EAAS,WAAU,sBAAuB,CAAA,IAE1C,kBAACC,GAAD,EAAU,WAAU,SAAU,CAAA;QAE1B,CAAA;OACL;MACJ,CAAA,GAAAC,MAAiBT,EAAK,MACrB,kBAAC,KAAD;OACE,MAAK;OACL,WAAU;OAET,UAAAJ,EACCC,GACA,iCACA,qCACF;MACC,CAAA,CAEH;KA1DK,GAAAG,EAAK,EA0DV;IAER,CAAC;GACC,CAAA;GAGLU,KACC,kBAAC,KAAD;IAAG,WAAU;IACV,UAAAd,EACCC,GACA,gCACA,kDACF;GACC,CAAA;EAEF;;AAET"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { PublicShareDocuments, PublicShareRequest, PublicShareResult, ShareResourceKind } from '../utils/publicShare';
|
|
2
|
+
import { ShareAccessFailure } from '../utils/shareAccess';
|
|
3
|
+
/**
|
|
4
|
+
* Opens a public share link (file or folder, BOFF-11865) when the page mounts
|
|
5
|
+
* and on retry or password entry. Failures are reduced to what the visitor
|
|
6
|
+
* can act on; the raw error only goes to `onError` for support logs.
|
|
7
|
+
*/
|
|
8
|
+
export declare function usePublicShare(options: {
|
|
9
|
+
request: PublicShareRequest;
|
|
10
|
+
documents: PublicShareDocuments;
|
|
11
|
+
token: string;
|
|
12
|
+
onLoaded: (result: PublicShareResult) => void;
|
|
13
|
+
onError: (error: unknown, kind: ShareResourceKind | undefined) => void;
|
|
14
|
+
}): {
|
|
15
|
+
loading: boolean;
|
|
16
|
+
failure: ShareAccessFailure | null;
|
|
17
|
+
share: PublicShareResult | null;
|
|
18
|
+
kind: ShareResourceKind | null;
|
|
19
|
+
acceptedPasswordRef: import('react').RefObject<string | undefined>;
|
|
20
|
+
loadShare: (sharePassword?: string) => Promise<void>;
|
|
21
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { loadPublicShare as e } from "../utils/publicShare.js";
|
|
2
|
+
import { classifyShareAccessError as t } from "../utils/shareAccess.js";
|
|
3
|
+
import { useCallback as n, useEffect as r, useRef as i, useState as a } from "react";
|
|
4
|
+
// src/files/hooks/usePublicShare.ts
|
|
5
|
+
function o(o) {
|
|
6
|
+
let { request: s, documents: c, token: l } = o, u = i(o);
|
|
7
|
+
r(() => {
|
|
8
|
+
u.current = o;
|
|
9
|
+
});
|
|
10
|
+
let [d, f] = a(!1), [p, m] = a(null), [h, g] = a(null), [_, v] = a(null), y = i(void 0), b = i(void 0), x = n(async (n) => {
|
|
11
|
+
f(!0);
|
|
12
|
+
try {
|
|
13
|
+
let t = await e(s, c, {
|
|
14
|
+
token: l,
|
|
15
|
+
password: n,
|
|
16
|
+
kind: y.current,
|
|
17
|
+
onKind: (e) => {
|
|
18
|
+
y.current = e, v(e);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
b.current = n || void 0, g(t), m(null), u.current.onLoaded(t);
|
|
22
|
+
} catch (e) {
|
|
23
|
+
u.current.onError(e, y.current), m(t(e));
|
|
24
|
+
} finally {
|
|
25
|
+
f(!1);
|
|
26
|
+
}
|
|
27
|
+
}, [
|
|
28
|
+
c,
|
|
29
|
+
s,
|
|
30
|
+
l
|
|
31
|
+
]);
|
|
32
|
+
return r(() => {
|
|
33
|
+
x();
|
|
34
|
+
}, [x]), {
|
|
35
|
+
loading: d,
|
|
36
|
+
failure: p,
|
|
37
|
+
share: h,
|
|
38
|
+
kind: _,
|
|
39
|
+
acceptedPasswordRef: b,
|
|
40
|
+
loadShare: x
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export { o as usePublicShare };
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=usePublicShare.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePublicShare.js","names":["usePublicShare","options","callbacksRef","useRef","loading","setLoading","useState","failure","setFailure","share","setShare","kind","setKind","kindRef","acceptedPasswordRef","loadShare","useCallback","result","loadPublicShare","request","documents","sharePassword","resolved","error","classifyShareAccessError","token","useEffect"],"sources":["../../../src/files/hooks/usePublicShare.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from \"react\";\nimport {\n type PublicShareDocuments,\n type PublicShareRequest,\n type PublicShareResult,\n type ShareResourceKind,\n loadPublicShare,\n} from \"../utils/publicShare\";\nimport {\n type ShareAccessFailure,\n classifyShareAccessError,\n} from \"../utils/shareAccess\";\n\n/**\n * Opens a public share link (file or folder, BOFF-11865) when the page mounts\n * and on retry or password entry. Failures are reduced to what the visitor\n * can act on; the raw error only goes to `onError` for support logs.\n */\nexport function usePublicShare(options: {\n request: PublicShareRequest;\n documents: PublicShareDocuments;\n token: string;\n onLoaded: (result: PublicShareResult) => void;\n onError: (error: unknown, kind: ShareResourceKind | undefined) => void;\n}) {\n const { request, documents, token } = options;\n // Read through refs so new callbacks never re-run the lookup (each lookup\n // counts a view on the link).\n const callbacksRef = useRef(options);\n useEffect(() => {\n callbacksRef.current = options;\n });\n\n const [loading, setLoading] = useState(false);\n const [failure, setFailure] = useState<ShareAccessFailure | null>(null);\n const [share, setShare] = useState<PublicShareResult | null>(null);\n const [kind, setKind] = useState<ShareResourceKind | null>(null);\n // Once the token's kind is known, retries skip the lookup.\n const kindRef = useRef<ShareResourceKind | undefined>(undefined);\n // The password that unlocked the link; folder file downloads need it again.\n const acceptedPasswordRef = useRef<string | undefined>(undefined);\n\n const loadShare = useCallback(\n async (sharePassword?: string) => {\n setLoading(true);\n try {\n const result = await loadPublicShare(request, documents, {\n token,\n password: sharePassword,\n kind: kindRef.current,\n onKind: (resolved) => {\n kindRef.current = resolved;\n setKind(resolved);\n },\n });\n acceptedPasswordRef.current = sharePassword || undefined;\n setShare(result);\n setFailure(null);\n callbacksRef.current.onLoaded(result);\n } catch (error) {\n callbacksRef.current.onError(error, kindRef.current);\n setFailure(classifyShareAccessError(error));\n } finally {\n setLoading(false);\n }\n },\n [documents, request, token],\n );\n\n useEffect(() => {\n void loadShare();\n }, [loadShare]);\n\n return { loading, failure, share, kind, acceptedPasswordRef, loadShare };\n}\n"],"mappings":";;;;AAkBA,SAAgBA,EAAe,GAM5B;CACD,IAAM,EAAE,YAAS,cAAW,aAAUC,GAGhCC,IAAeC,EAAOF,CAAO;CACnC,QAAgB;EACd,EAAa,UAAUA;CACzB,CAAC;CAED,IAAM,CAACG,GAASC,KAAcC,EAAS,EAAK,GACtC,CAACC,GAASC,KAAcF,EAAoC,IAAI,GAChE,CAACG,GAAOC,KAAYJ,EAAmC,IAAI,GAC3D,CAACK,GAAMC,KAAWN,EAAmC,IAAI,GAEzDO,IAAUV,EAAsC,KAAA,CAAS,GAEzDW,IAAsBX,EAA2B,KAAA,CAAS,GAE1DY,IAAYC,EAChB,OAAO,MAA2B;EAChC,EAAW,EAAI;EACf,IAAI;GACF,IAAMC,IAAS,MAAMC,EAAgBC,GAASC,GAAW;IACvD;IACA,UAAUC;IACV,MAAMR,EAAQ;IACd,SAAS,MAAa;KAEpB,AADA,EAAQ,UAAUS,GAClBV,EAAQU,CAAQ;IAClB;GACF,CAAC;GAID,AAHA,EAAoB,UAAUD,KAAiB,KAAA,GAC/CX,EAASO,CAAM,GACfT,EAAW,IAAI,GACfN,EAAa,QAAQ,SAASe,CAAM;EACtC,SAASM,GAAO;GAEd,AADArB,EAAa,QAAQ,QAAQqB,GAAOV,EAAQ,OAAO,GACnDL,EAAWgB,EAAyBD,CAAK,CAAC;EAC5C,UAAU;GACR,EAAW,EAAK;EAClB;CACF,GACA;EAACH;EAAWD;EAASM;CAAK,CAC5B;CAMA,OAJAC,QAAgB;EACd,EAAe;CACjB,GAAG,CAACX,CAAS,CAAC,GAEP;EAAE;EAAS;EAAS;EAAO;EAAM;EAAqB;CAAU;AACzE"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { PublicShareRequest, SharedFolderFile } from '../utils/publicShare';
|
|
3
|
+
/**
|
|
4
|
+
* Fetches a short-lived URL for one file of a folder opened through its
|
|
5
|
+
* public share link (BOFF-11865), and tracks which file is loading or failed.
|
|
6
|
+
*/
|
|
7
|
+
export declare function useSharedFolderFileUrl(options: {
|
|
8
|
+
request: PublicShareRequest;
|
|
9
|
+
/** The printed DownloadFolderShareFile mutation. */
|
|
10
|
+
document: string;
|
|
11
|
+
token: string;
|
|
12
|
+
/** The password that unlocked the link, when it has one. */
|
|
13
|
+
passwordRef: RefObject<string | undefined>;
|
|
14
|
+
/** Called with the raw error for support logs; never shown to the visitor. */
|
|
15
|
+
onError: (error: unknown) => void;
|
|
16
|
+
}): {
|
|
17
|
+
busyFileId: string | null;
|
|
18
|
+
failedFileId: string | null;
|
|
19
|
+
fetchUrl: (file: SharedFolderFile) => Promise<string | null>;
|
|
20
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useCallback as e, useState as t } from "react";
|
|
2
|
+
// src/files/hooks/useSharedFolderFileUrl.ts
|
|
3
|
+
function n(n) {
|
|
4
|
+
let { request: r, document: i, token: a, passwordRef: o, onError: s } = n, [c, l] = t(null), [u, d] = t(null);
|
|
5
|
+
return {
|
|
6
|
+
busyFileId: c,
|
|
7
|
+
failedFileId: u,
|
|
8
|
+
fetchUrl: e(async (e) => {
|
|
9
|
+
l(e.id), d(null);
|
|
10
|
+
try {
|
|
11
|
+
return (await r(i, { input: {
|
|
12
|
+
token: a,
|
|
13
|
+
fileId: e.id,
|
|
14
|
+
password: o.current
|
|
15
|
+
} })).downloadFolderShareFile.downloadUrl;
|
|
16
|
+
} catch (t) {
|
|
17
|
+
return s(t), d(e.id), null;
|
|
18
|
+
} finally {
|
|
19
|
+
l(null);
|
|
20
|
+
}
|
|
21
|
+
}, [
|
|
22
|
+
i,
|
|
23
|
+
s,
|
|
24
|
+
o,
|
|
25
|
+
r,
|
|
26
|
+
a
|
|
27
|
+
])
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export { n as useSharedFolderFileUrl };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=useSharedFolderFileUrl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSharedFolderFileUrl.js","names":["useSharedFolderFileUrl","options","busyFileId","setBusyFileId","useState","failedFileId","setFailedFileId","useCallback","file","request","document","passwordRef","error","onError","token"],"sources":["../../../src/files/hooks/useSharedFolderFileUrl.ts"],"sourcesContent":["import { type RefObject, useCallback, useState } from \"react\";\nimport type {\n DownloadFolderShareFileMutation,\n DownloadFolderShareFileMutationVariables,\n} from \"../../generated/wspace-operations\";\nimport type {\n PublicShareRequest,\n SharedFolderFile,\n} from \"../utils/publicShare\";\n\n/**\n * Fetches a short-lived URL for one file of a folder opened through its\n * public share link (BOFF-11865), and tracks which file is loading or failed.\n */\nexport function useSharedFolderFileUrl(options: {\n request: PublicShareRequest;\n /** The printed DownloadFolderShareFile mutation. */\n document: string;\n token: string;\n /** The password that unlocked the link, when it has one. */\n passwordRef: RefObject<string | undefined>;\n /** Called with the raw error for support logs; never shown to the visitor. */\n onError: (error: unknown) => void;\n}) {\n const { request, document, token, passwordRef, onError } = options;\n const [busyFileId, setBusyFileId] = useState<string | null>(null);\n const [failedFileId, setFailedFileId] = useState<string | null>(null);\n\n /** The file's URL, or null when it could not be fetched. */\n const fetchUrl = useCallback(\n async (file: SharedFolderFile): Promise<string | null> => {\n setBusyFileId(file.id);\n setFailedFileId(null);\n try {\n const data = await request<\n DownloadFolderShareFileMutation,\n DownloadFolderShareFileMutationVariables\n >(document, {\n input: { token, fileId: file.id, password: passwordRef.current },\n });\n return data.downloadFolderShareFile.downloadUrl;\n } catch (error) {\n onError(error);\n setFailedFileId(file.id);\n return null;\n } finally {\n setBusyFileId(null);\n }\n },\n [document, onError, passwordRef, request, token],\n );\n\n return { busyFileId, failedFileId, fetchUrl };\n}\n"],"mappings":";;AAcA,SAAgBA,EAAuB,GASpC;CACD,IAAM,EAAE,YAAS,aAAU,UAAO,gBAAa,eAAYC,GACrD,CAACC,GAAYC,KAAiBC,EAAwB,IAAI,GAC1D,CAACC,GAAcC,KAAmBF,EAAwB,IAAI;CA0BpE,OAAO;EAAE;EAAY;EAAc,UAvBlBG,EACf,OAAO,MAAmD;GAExD,AADAJ,EAAcK,EAAK,EAAE,GACrBF,EAAgB,IAAI;GACpB,IAAI;IAOF,QAAO,MANYG,EAGjBC,GAAU,EACV,OAAO;KAAE;KAAO,QAAQF,EAAK;KAAI,UAAUG,EAAY;IAAQ,EACjE,CAAC,EAAA,CACW,wBAAwB;GACtC,SAASC,GAAO;IAGd,OAFAC,EAAQD,CAAK,GACbN,EAAgBE,EAAK,EAAE,GAChB;GACT,UAAU;IACR,EAAc,IAAI;GACpB;EACF,GACA;GAACE;GAAUG;GAASF;GAAaF;GAASK;EAAK,CAGd;CAAS;AAC9C"}
|