@hanzo/app 0.3.94 → 0.3.96
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/Account.d.ts +9 -3
- package/dist/Account.js +142 -141
- package/dist/App.js +71 -37
- package/dist/Bar.js +1 -1
- package/dist/Betas.d.ts +1 -1
- package/dist/Betas.js +16 -22
- package/dist/Board.js +114 -48
- package/dist/CalScheduler.d.ts +1 -0
- package/dist/CalScheduler.js +223 -57
- package/dist/Chat.js +432 -153
- package/dist/Contacts.js +35 -31
- package/dist/ContextMenu.js +126 -42
- package/dist/Directory.js +1 -1
- package/dist/Drawer.js +1 -1
- package/dist/Drive.js +351 -119
- package/dist/Gate.js +156 -13
- package/dist/Home.js +31 -53
- package/dist/Inbox.js +29 -15
- package/dist/InlineRename.d.ts +6 -0
- package/dist/InlineRename.js +41 -0
- package/dist/Learning.js +132 -13
- package/dist/Market.js +13 -9
- package/dist/Meet.d.ts +5 -0
- package/dist/Meet.js +75 -51
- package/dist/MoreMenu.d.ts +19 -0
- package/dist/MoreMenu.js +33 -0
- package/dist/NeedMoreUsage.js +2 -2
- package/dist/OrgSwitcher.js +6 -2
- package/dist/PreferencesDialog.js +5 -2
- package/dist/Rail.d.ts +73 -7
- package/dist/Rail.js +372 -111
- package/dist/Recents.js +77 -24
- package/dist/RightPane.js +2 -2
- package/dist/Search.d.ts +13 -1
- package/dist/Search.js +366 -50
- package/dist/Setup.js +34 -5
- package/dist/Shared.js +12 -12
- package/dist/Shell.d.ts +10 -0
- package/dist/Shell.js +258 -158
- package/dist/Sidebar.d.ts +14 -3
- package/dist/Sidebar.js +411 -129
- package/dist/SkipLink.d.ts +8 -0
- package/dist/SkipLink.js +11 -0
- package/dist/Start.js +51 -52
- package/dist/Terminals.js +159 -11
- package/dist/ToBottom.js +1 -1
- package/dist/Upgrade.d.ts +8 -3
- package/dist/Upgrade.js +194 -103
- package/dist/Usage.d.ts +1 -1
- package/dist/Usage.js +186 -82
- package/dist/WalletPill.js +8 -2
- package/dist/Work.js +162 -53
- package/dist/archive.d.ts +8 -0
- package/dist/archive.js +16 -0
- package/dist/bots/Bots.js +16 -1
- package/dist/bots/ComputerDialog.js +53 -26
- package/dist/bots/ConnectorsDialog.js +34 -15
- package/dist/bots/Make.js +5 -1
- package/dist/bots/Panel.js +37 -31
- package/dist/bots/Roster.d.ts +4 -1
- package/dist/bots/Roster.js +71 -25
- package/dist/bots/Thread.js +54 -27
- package/dist/bots/face.js +9 -3
- package/dist/bots/grid.d.ts +36 -0
- package/dist/bots/grid.js +91 -0
- package/dist/bots/ink.d.ts +1 -1
- package/dist/bots/ink.js +1 -1
- package/dist/bots/kit.d.ts +9 -4
- package/dist/bots/kit.js +3 -2
- package/dist/chord.d.ts +13 -0
- package/dist/chord.js +30 -1
- package/dist/crew.js +47 -4
- package/dist/ground.d.ts +2 -2
- package/dist/ground.js +3 -3
- package/dist/help.d.ts +7 -3
- package/dist/help.js +19 -14
- package/dist/keys.d.ts +28 -0
- package/dist/keys.js +58 -0
- package/dist/lib/arrival.d.ts +5 -0
- package/dist/lib/arrival.js +10 -0
- package/dist/lib/betas.d.ts +2 -0
- package/dist/lib/betas.js +10 -0
- package/dist/lib/branch.d.ts +11 -0
- package/dist/lib/branch.js +11 -0
- package/dist/lib/chatPreferences.d.ts +1 -1
- package/dist/lib/chatPreferences.js +1 -1
- package/dist/lib/dev-mode.d.ts +18 -0
- package/dist/lib/dev-mode.js +102 -0
- package/dist/lib/durable.d.ts +1 -1
- package/dist/lib/durable.js +1 -1
- package/dist/lib/info-hint.d.ts +7 -0
- package/dist/lib/info-hint.js +8 -0
- package/dist/lib/model-picker.d.ts +2 -0
- package/dist/lib/model-picker.js +12 -0
- package/dist/lib/owners.d.ts +5 -0
- package/dist/lib/owners.js +15 -0
- package/dist/lib/pay.d.ts +2 -0
- package/dist/lib/pay.js +4 -0
- package/dist/lib/todo.d.ts +7 -1
- package/dist/lib/todo.js +41 -29
- package/dist/look.js +39 -8
- package/dist/rail-open.d.ts +9 -0
- package/dist/rail-open.js +34 -0
- package/dist/renaming.d.ts +10 -0
- package/dist/renaming.js +25 -0
- package/dist/seek.d.ts +6 -1
- package/dist/seek.js +13 -0
- package/dist/thread.d.ts +2 -1
- package/dist/thread.js +85 -44
- package/package.json +11 -11
package/dist/Drive.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { arrival as arrive } from './lib/arrival.js';
|
|
3
4
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
4
|
-
import { ArrowRight, ChevronDown, ChevronRight,
|
|
5
|
-
import { Box, Button, Text, View, XStack, YStack } from '@hanzo/ui';
|
|
5
|
+
import { ArrowRight, ChevronDown, ChevronRight, Cloud, Download, File as FileIcon, FileArchive, FileAudio, FileCode, FileImage, FilePlus, FileText, FileVideo, Folder, FolderGit2, FolderInput, FolderPlus, HardDrive, Laptop, ListTree, MessageSquare, LayoutGrid, List, MoreHorizontal, PanelLeft, Plus, Search, Trash2, Upload, } from 'lucide-react';
|
|
6
|
+
import { Box, Button, Skeleton, Text, toast, View, XStack, YStack } from '@hanzo/ui';
|
|
6
7
|
import { useIam, useOrganizations } from '@hanzo/iam/react';
|
|
7
8
|
import { useI18n } from '@hanzo/i18n/react';
|
|
8
9
|
import { useAi } from './lib/ai.js';
|
|
@@ -16,10 +17,11 @@ import { cloneRemoteRepo, createLocalDir, createLocalFile, deleteLocalPath, getA
|
|
|
16
17
|
import { weigh as size } from './lib/attach.js';
|
|
17
18
|
import { dropped, filesIn, forget, pool, register, search, settled, slug, upload, } from './lib/files.js';
|
|
18
19
|
import { checkoutUrl } from './lib/pay.js';
|
|
19
|
-
import {
|
|
20
|
+
import { mix } from './lib/mix.js';
|
|
21
|
+
import { useDevMode } from './lib/dev-mode.js';
|
|
20
22
|
const blame = (e, t) => {
|
|
21
23
|
const text = e instanceof Error ? e.message : String(e ?? '');
|
|
22
|
-
return text || t('
|
|
24
|
+
return text || t('Something went wrong. Please try again.');
|
|
23
25
|
};
|
|
24
26
|
/** A size as a row shows it; nothing is a dash. */
|
|
25
27
|
const weigh = (bytes) => (bytes ? size(bytes) : '—');
|
|
@@ -47,7 +49,7 @@ async function putBytes(client, bucket, key, body, t, type) {
|
|
|
47
49
|
body: { bucket, key },
|
|
48
50
|
});
|
|
49
51
|
if (!grant?.url)
|
|
50
|
-
throw new Error(t('
|
|
52
|
+
throw new Error(t('Could not start upload.'));
|
|
51
53
|
const sent = await fetch(grant.url, {
|
|
52
54
|
method: grant.method || 'PUT',
|
|
53
55
|
body,
|
|
@@ -59,7 +61,7 @@ async function putBytes(client, bucket, key, body, t, type) {
|
|
|
59
61
|
async function urlFor(client, bucket, key, t) {
|
|
60
62
|
const grant = await client.http.json({ path: `${objects(bucket)}/${wire(key)}` });
|
|
61
63
|
if (!grant?.url)
|
|
62
|
-
throw new Error(t('
|
|
64
|
+
throw new Error(t('Could not start download.'));
|
|
63
65
|
return grant.url;
|
|
64
66
|
}
|
|
65
67
|
async function remove(client, bucket, key) {
|
|
@@ -87,21 +89,32 @@ function Glyph({ entry, size = 16 }) {
|
|
|
87
89
|
const FILES = 'minmax(200px, 2fr) 120px 140px 100px 48px';
|
|
88
90
|
const PROJECTS = 'minmax(220px, 2fr) 120px 140px 100px 48px';
|
|
89
91
|
/** A column heading. */
|
|
90
|
-
const HEAD = { fontSize: '$1', fontWeight: '
|
|
92
|
+
const HEAD = { fontSize: '$1', fontWeight: '500', color: '$soft' };
|
|
91
93
|
/** A row's name: one line, cut with an ellipsis. */
|
|
92
94
|
const NAME = { fontSize: '$2', fontWeight: '500', color: '$ink', numberOfLines: 1 };
|
|
93
95
|
/** A row's kind, set as a tag. */
|
|
94
|
-
const CHIP = { fontSize: '$1', color: '$soft', bg: '$hover', px: 8, py: 2, rounded: 4 };
|
|
96
|
+
const CHIP = { fontFamily: '$mono', fontSize: '$1', color: '$soft', bg: '$hover', px: 8, py: 2, rounded: 4 };
|
|
95
97
|
/** A quiet cell: the date and the size. */
|
|
96
98
|
const CELL = { fontSize: '$2', color: '$soft' };
|
|
97
99
|
/** A row's "more" control. */
|
|
98
100
|
function More({ onPress }) {
|
|
99
|
-
const { t
|
|
100
|
-
return (_jsx(Button, { variant: "ghost", size: "icon-sm", onClick: onPress, "aria-label": t('More'), title: t('More'), children: _jsx(MoreHorizontal, { size: 15 }) }));
|
|
101
|
+
const { t } = useI18n();
|
|
102
|
+
return (_jsx(Button, { variant: "ghost", size: "icon-sm", focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, "$max-sm": { minW: 44, minH: 44 }, onClick: onPress, "aria-label": t('More'), title: t('More'), children: _jsx(MoreHorizontal, { size: 15 }) }));
|
|
101
103
|
}
|
|
102
104
|
/** One line of a row's menu: a glyph and a word, the whole width. */
|
|
103
105
|
function Pick({ icon: Icon, label, tone, onPress, }) {
|
|
104
|
-
return (_jsxs(Button, { variant: "ghost", size: "sm", width: "100%", justify: "flex-start", ...(tone ? { color: tone } : null), onClick: onPress, children: [_jsx(Icon, { size: 13 }), label] }));
|
|
106
|
+
return (_jsxs(Button, { variant: "ghost", size: "sm", width: "100%", justify: "flex-start", focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, "$max-sm": { minH: 44 }, ...(tone ? { color: tone } : null), onClick: onPress, children: [_jsx(Icon, { size: 13 }), label] }));
|
|
107
|
+
}
|
|
108
|
+
/** Calm monochrome layout-matched skeleton for bucket rows at Drive root. */
|
|
109
|
+
function DriveBucketSkeleton({ label }) {
|
|
110
|
+
return (_jsx(YStack, { role: "status", "aria-busy": true, "aria-label": label, children: [0, 1, 2].map((i) => (_jsxs(XStack, { items: "center", justify: "space-between", px: 16, py: 13, borderBottomWidth: i === 2 ? 0 : 1, borderColor: "$edge", gap: "$3", children: [_jsxs(XStack, { items: "center", gap: "$2.5", flex: 1, minW: 0, children: [_jsx(Skeleton, { layout: "block", width: 17, height: 17, rounded: "$2", shrink: 0 }), _jsx(Skeleton, { layout: "block", width: i === 0 ? 156 : i === 1 ? 128 : 142, height: 13, rounded: "$2" })] }), _jsx(Skeleton, { layout: "block", width: 64, height: 12, rounded: "$2", shrink: 0 })] }, i))) }));
|
|
111
|
+
}
|
|
112
|
+
/** Calm monochrome layout-matched skeleton for Drive file rows or grid cards. */
|
|
113
|
+
function DriveEntriesSkeleton({ grid = false, label }) {
|
|
114
|
+
if (grid) {
|
|
115
|
+
return (_jsx(View, { role: "status", "aria-busy": true, "aria-label": label, display: "grid", gridTemplateColumns: "repeat(auto-fill, minmax(180px, 1fr))", "$max-sm": { gridTemplateColumns: '1fr' }, gap: "$3", children: [0, 1, 2, 3, 4, 5].map((i) => (_jsxs(YStack, { p: "$3.5", rounded: "$4", bg: "$panel", borderWidth: 1, borderColor: "$edge", gap: "$2.5", children: [_jsxs(XStack, { items: "center", justify: "space-between", width: "100%", children: [_jsx(Skeleton, { layout: "block", width: 18, height: 18, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: 40, height: 16, rounded: "$2" })] }), _jsx(Skeleton, { layout: "block", width: i % 2 === 0 ? '82%' : '68%', height: 13, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: 54, height: 11, rounded: "$2" })] }, i))) }));
|
|
116
|
+
}
|
|
117
|
+
return (_jsx(YStack, { role: "status", "aria-busy": true, "aria-label": label, children: [0, 1, 2, 3, 4].map((i) => (_jsxs(View, { display: "grid", gridTemplateColumns: FILES, minW: "min-content", px: 16, py: 12, items: "center", borderBottomWidth: i === 4 ? 0 : 1, borderColor: "$edge", children: [_jsxs(XStack, { items: "center", gap: "$2.5", minW: 0, pr: "$2", children: [_jsx(Skeleton, { layout: "block", width: 16, height: 16, rounded: "$2", shrink: 0 }), _jsx(Skeleton, { layout: "block", width: i % 2 === 0 ? 180 : 140, height: 13, rounded: "$2" })] }), _jsx(Skeleton, { layout: "block", width: 46, height: 18, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: 74, height: 12, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: 48, height: 12, rounded: "$2" }), _jsx(View, {})] }, i))) }));
|
|
105
118
|
}
|
|
106
119
|
/** A tooltip on a gui element: `title` is a DOM attribute gui passes through and does not type. */
|
|
107
120
|
const tip = (title) => ({ title });
|
|
@@ -117,6 +130,7 @@ const NOTE = { display: 'block', px: 16, py: 24, fontSize: '$2', color: '$faint'
|
|
|
117
130
|
const VEIL = mix('var(--background)', 90, 'srgb');
|
|
118
131
|
export function Drive() {
|
|
119
132
|
const { t, locale } = useI18n();
|
|
133
|
+
const [devMode] = useDevMode();
|
|
120
134
|
const { client } = useAi();
|
|
121
135
|
const { user, isAuthenticated } = useIam();
|
|
122
136
|
const ready = Boolean(client && isAuthenticated);
|
|
@@ -146,6 +160,16 @@ export function Drive() {
|
|
|
146
160
|
const [itemMenuKey, setItemMenuKey] = useState(null);
|
|
147
161
|
const [naming, setNaming] = useState(null);
|
|
148
162
|
const [projects, setProjects] = useState(null);
|
|
163
|
+
const [pendingDeletes, setPendingDeletes] = useState(() => new Set());
|
|
164
|
+
const deleteTimersRef = useRef(new Map());
|
|
165
|
+
useEffect(() => {
|
|
166
|
+
const timers = deleteTimersRef.current;
|
|
167
|
+
return () => {
|
|
168
|
+
for (const timer of timers.values())
|
|
169
|
+
clearTimeout(timer);
|
|
170
|
+
timers.clear();
|
|
171
|
+
};
|
|
172
|
+
}, []);
|
|
149
173
|
const [localWorkspaces, setLocalWorkspaces] = useState(getLocalWorkspaces);
|
|
150
174
|
const [activeWs, setActiveWs] = useState(getActiveWorkspace);
|
|
151
175
|
const [localEntries, setLocalEntries] = useState(null);
|
|
@@ -157,6 +181,30 @@ export function Drive() {
|
|
|
157
181
|
setActiveWs(getActiveWorkspace());
|
|
158
182
|
});
|
|
159
183
|
}, []);
|
|
184
|
+
useEffect(() => {
|
|
185
|
+
if (!newMenuOpen && !itemMenuKey && !menu)
|
|
186
|
+
return;
|
|
187
|
+
const onKey = (e) => {
|
|
188
|
+
if (e.key === 'Escape') {
|
|
189
|
+
setNewMenuOpen(false);
|
|
190
|
+
setItemMenuKey(null);
|
|
191
|
+
setMenu(false);
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
const onDown = (e) => {
|
|
195
|
+
const target = e.target;
|
|
196
|
+
if (!target?.closest?.('[data-drive-menu]')) {
|
|
197
|
+
setNewMenuOpen(false);
|
|
198
|
+
setItemMenuKey(null);
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
window.addEventListener('keydown', onKey);
|
|
202
|
+
window.addEventListener('mousedown', onDown);
|
|
203
|
+
return () => {
|
|
204
|
+
window.removeEventListener('keydown', onKey);
|
|
205
|
+
window.removeEventListener('mousedown', onDown);
|
|
206
|
+
};
|
|
207
|
+
}, [newMenuOpen, itemMenuKey, menu]);
|
|
160
208
|
const loadLocalEntries = useCallback(() => {
|
|
161
209
|
if (!activeWs) {
|
|
162
210
|
setLocalEntries(null);
|
|
@@ -226,9 +274,12 @@ export function Drive() {
|
|
|
226
274
|
// projects, and the toolbar's verbs all act on an OPEN bucket — so opening
|
|
227
275
|
// the org's first one is what makes New, upload and the listing agree about
|
|
228
276
|
// where they are. It is also what a drive does: the files, on arrival.
|
|
277
|
+
const didAutoOpenRef = useRef(false);
|
|
229
278
|
useEffect(() => {
|
|
230
|
-
|
|
231
|
-
|
|
279
|
+
const step = arrive(didAutoOpenRef.current, bucket, landing);
|
|
280
|
+
didAutoOpenRef.current = step.done;
|
|
281
|
+
if (step.open)
|
|
282
|
+
openBucket(step.open);
|
|
232
283
|
}, [bucket, landing, openBucket]);
|
|
233
284
|
// THE INDEX'S WORD on this bucket's files, read again every few seconds while
|
|
234
285
|
// any of them is still moving through its stages.
|
|
@@ -438,19 +489,27 @@ export function Drive() {
|
|
|
438
489
|
void run(t('Creating {name}', { name: clean }), () => putBytes(client, activeBucket, `${prefix}${clean}`, new Blob(['']), t));
|
|
439
490
|
setNaming(null);
|
|
440
491
|
}, [client, activeBucket, prefix, run, navSection, activeWs, localPrefix, loadLocalEntries, t]);
|
|
441
|
-
const handleCloneRepo = useCallback((repoUrl) => {
|
|
492
|
+
const handleCloneRepo = useCallback(async (repoUrl) => {
|
|
442
493
|
const clean = repoUrl.trim();
|
|
443
|
-
if (!clean)
|
|
494
|
+
if (!clean || busy)
|
|
444
495
|
return;
|
|
445
496
|
setNaming(null);
|
|
446
|
-
|
|
497
|
+
setBusy(t('Cloning {name}', { name: clean }));
|
|
498
|
+
setFailed(null);
|
|
499
|
+
try {
|
|
447
500
|
const ws = await cloneRemoteRepo(clean);
|
|
448
501
|
setNavSection('local');
|
|
449
502
|
setActiveWorkspace(ws);
|
|
450
503
|
setLocalPrefix('');
|
|
451
504
|
loadLocalEntries();
|
|
452
|
-
}
|
|
453
|
-
|
|
505
|
+
}
|
|
506
|
+
catch (e) {
|
|
507
|
+
setFailed(blame(e, t));
|
|
508
|
+
}
|
|
509
|
+
finally {
|
|
510
|
+
setBusy(null);
|
|
511
|
+
}
|
|
512
|
+
}, [busy, loadLocalEntries, t]);
|
|
454
513
|
const handleOpenLocalFile = useCallback(async () => {
|
|
455
514
|
try {
|
|
456
515
|
const selected = await pickLocalFile();
|
|
@@ -485,14 +544,37 @@ export function Drive() {
|
|
|
485
544
|
if (!clean || !client || !activeBucket || entry.isDir)
|
|
486
545
|
return;
|
|
487
546
|
const from = `${prefix}${entry.key}`;
|
|
488
|
-
|
|
489
|
-
|
|
547
|
+
const toKey = clean.includes('/') ? clean : `${prefix}${clean}`;
|
|
548
|
+
if (toKey === from) {
|
|
549
|
+
setNaming(null);
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
const fromName = entry.key.replace(/\/+$/, '');
|
|
553
|
+
// The store has no copy, so a rename/move is the three verbs it does have.
|
|
554
|
+
void run(t('Moving {name}', { name: fromName }), async () => {
|
|
490
555
|
const src = await fetch(await urlFor(client, activeBucket, from, t));
|
|
491
556
|
if (!src.ok)
|
|
492
|
-
throw new Error(t('{name} could not be read ({status}).', { name:
|
|
557
|
+
throw new Error(t('{name} could not be read ({status}).', { name: fromName, status: src.status }));
|
|
493
558
|
const body = await src.blob();
|
|
494
|
-
await putBytes(client, activeBucket,
|
|
559
|
+
await putBytes(client, activeBucket, toKey, body, t, body.type || undefined);
|
|
495
560
|
await remove(client, activeBucket, from);
|
|
561
|
+
toast(t('Moved {name} to {target}', { name: fromName, target: clean }), {
|
|
562
|
+
duration: 5000,
|
|
563
|
+
action: {
|
|
564
|
+
label: t('Undo'),
|
|
565
|
+
onClick: () => {
|
|
566
|
+
void run(t('Restoring {name}', { name: fromName }), async () => {
|
|
567
|
+
const moved = await fetch(await urlFor(client, activeBucket, toKey, t));
|
|
568
|
+
if (!moved.ok)
|
|
569
|
+
throw new Error(t('{name} could not be read ({status}).', { name: clean, status: moved.status }));
|
|
570
|
+
const movedBody = await moved.blob();
|
|
571
|
+
await putBytes(client, activeBucket, from, movedBody, t, movedBody.type || undefined);
|
|
572
|
+
await remove(client, activeBucket, toKey);
|
|
573
|
+
toast.success(t('Restored {name}', { name: fromName }));
|
|
574
|
+
});
|
|
575
|
+
},
|
|
576
|
+
},
|
|
577
|
+
});
|
|
496
578
|
});
|
|
497
579
|
setNaming(null);
|
|
498
580
|
}, [client, activeBucket, prefix, run, t]);
|
|
@@ -500,27 +582,115 @@ export function Drive() {
|
|
|
500
582
|
if (!client || !activeBucket)
|
|
501
583
|
return;
|
|
502
584
|
const key = `${prefix}${entry.key}`;
|
|
585
|
+
const deleteId = `cloud:${activeBucket}:${key}`;
|
|
586
|
+
const cleanName = entry.key.replace(/\/+$/, '');
|
|
587
|
+
const existing = deleteTimersRef.current.get(deleteId);
|
|
588
|
+
if (existing)
|
|
589
|
+
clearTimeout(existing);
|
|
590
|
+
setPendingDeletes((prev) => {
|
|
591
|
+
const next = new Set(prev);
|
|
592
|
+
next.add(deleteId);
|
|
593
|
+
return next;
|
|
594
|
+
});
|
|
503
595
|
// A deleted file leaves the index too, so search and chat stop citing it.
|
|
504
596
|
const unindex = async (k) => {
|
|
505
597
|
const f = index.get(k);
|
|
506
598
|
if (f)
|
|
507
599
|
await forget(client, f.id).catch(() => { });
|
|
508
600
|
};
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
601
|
+
const timer = setTimeout(() => {
|
|
602
|
+
deleteTimersRef.current.delete(deleteId);
|
|
603
|
+
void run(t('Deleting {name}', { name: cleanName }), async (say) => {
|
|
604
|
+
try {
|
|
605
|
+
if (!entry.isDir) {
|
|
606
|
+
await remove(client, activeBucket, key);
|
|
607
|
+
await unindex(key);
|
|
608
|
+
}
|
|
609
|
+
else {
|
|
610
|
+
const root = key.endsWith('/') ? key : `${key}/`;
|
|
611
|
+
const out = await client.http.json({ path: objects(activeBucket), query: { prefix: root, recursive: 'true' } });
|
|
612
|
+
for (const e of (out?.objects ?? []).filter((x) => !x.isDir)) {
|
|
613
|
+
say(t('Deleting {name}', { name: e.key }));
|
|
614
|
+
await remove(client, activeBucket, root + e.key);
|
|
615
|
+
await unindex(root + e.key);
|
|
616
|
+
}
|
|
617
|
+
await remove(client, activeBucket, root).catch(() => { });
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
finally {
|
|
621
|
+
setPendingDeletes((prev) => {
|
|
622
|
+
const next = new Set(prev);
|
|
623
|
+
next.delete(deleteId);
|
|
624
|
+
return next;
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
});
|
|
628
|
+
}, 5000);
|
|
629
|
+
deleteTimersRef.current.set(deleteId, timer);
|
|
630
|
+
toast(t('Deleted {name}', { name: cleanName }), {
|
|
631
|
+
duration: 5000,
|
|
632
|
+
action: {
|
|
633
|
+
label: t('Undo'),
|
|
634
|
+
onClick: () => {
|
|
635
|
+
const pending = deleteTimersRef.current.get(deleteId);
|
|
636
|
+
if (pending) {
|
|
637
|
+
clearTimeout(pending);
|
|
638
|
+
deleteTimersRef.current.delete(deleteId);
|
|
639
|
+
}
|
|
640
|
+
setPendingDeletes((prev) => {
|
|
641
|
+
const next = new Set(prev);
|
|
642
|
+
next.delete(deleteId);
|
|
643
|
+
return next;
|
|
644
|
+
});
|
|
645
|
+
toast.success(t('Restored {name}', { name: cleanName }));
|
|
646
|
+
},
|
|
647
|
+
},
|
|
522
648
|
});
|
|
523
649
|
}, [client, activeBucket, prefix, run, index, t]);
|
|
650
|
+
const handleDeleteLocal = useCallback((entry) => {
|
|
651
|
+
const deleteId = `local:${entry.path}`;
|
|
652
|
+
const existing = deleteTimersRef.current.get(deleteId);
|
|
653
|
+
if (existing)
|
|
654
|
+
clearTimeout(existing);
|
|
655
|
+
setPendingDeletes((prev) => {
|
|
656
|
+
const next = new Set(prev);
|
|
657
|
+
next.add(deleteId);
|
|
658
|
+
return next;
|
|
659
|
+
});
|
|
660
|
+
const timer = setTimeout(() => {
|
|
661
|
+
deleteTimersRef.current.delete(deleteId);
|
|
662
|
+
deleteLocalPath(entry.path)
|
|
663
|
+
.then(() => loadLocalEntries())
|
|
664
|
+
.catch((err) => setFailed(blame(err, t)))
|
|
665
|
+
.finally(() => {
|
|
666
|
+
setPendingDeletes((prev) => {
|
|
667
|
+
const next = new Set(prev);
|
|
668
|
+
next.delete(deleteId);
|
|
669
|
+
return next;
|
|
670
|
+
});
|
|
671
|
+
});
|
|
672
|
+
}, 5000);
|
|
673
|
+
deleteTimersRef.current.set(deleteId, timer);
|
|
674
|
+
toast(t('Deleted {name}', { name: entry.name }), {
|
|
675
|
+
duration: 5000,
|
|
676
|
+
action: {
|
|
677
|
+
label: t('Undo'),
|
|
678
|
+
onClick: () => {
|
|
679
|
+
const pending = deleteTimersRef.current.get(deleteId);
|
|
680
|
+
if (pending) {
|
|
681
|
+
clearTimeout(pending);
|
|
682
|
+
deleteTimersRef.current.delete(deleteId);
|
|
683
|
+
}
|
|
684
|
+
setPendingDeletes((prev) => {
|
|
685
|
+
const next = new Set(prev);
|
|
686
|
+
next.delete(deleteId);
|
|
687
|
+
return next;
|
|
688
|
+
});
|
|
689
|
+
toast.success(t('Restored {name}', { name: entry.name }));
|
|
690
|
+
},
|
|
691
|
+
},
|
|
692
|
+
});
|
|
693
|
+
}, [loadLocalEntries, t]);
|
|
524
694
|
// DOWNLOAD follows a presigned GET. The object's platform address answers a
|
|
525
695
|
// signed URL, not the bytes, and it needs the caller's token — which an
|
|
526
696
|
// anchor href does not carry.
|
|
@@ -555,11 +725,17 @@ export function Drive() {
|
|
|
555
725
|
const filteredEntries = useMemo(() => {
|
|
556
726
|
if (!entries)
|
|
557
727
|
return null;
|
|
728
|
+
const live = entries.filter((e) => !pendingDeletes.has(`cloud:${activeBucket ?? ''}:${prefix}${e.key}`));
|
|
558
729
|
if (!searchQuery.trim())
|
|
559
|
-
return
|
|
730
|
+
return live;
|
|
560
731
|
const q = searchQuery.toLowerCase();
|
|
561
|
-
return
|
|
562
|
-
}, [entries, searchQuery]);
|
|
732
|
+
return live.filter((e) => e.key.toLowerCase().includes(q));
|
|
733
|
+
}, [entries, searchQuery, pendingDeletes, activeBucket, prefix]);
|
|
734
|
+
const visibleLocalEntries = useMemo(() => {
|
|
735
|
+
if (!localEntries)
|
|
736
|
+
return null;
|
|
737
|
+
return localEntries.filter((e) => !pendingDeletes.has(`local:${e.path}`));
|
|
738
|
+
}, [localEntries, pendingDeletes]);
|
|
563
739
|
// Breadcrumbs
|
|
564
740
|
const crumbs = useMemo(() => {
|
|
565
741
|
if (!prefix)
|
|
@@ -603,7 +779,7 @@ export function Drive() {
|
|
|
603
779
|
webkitdirectory: "true", directory: "true", multiple: true, hidden: true, onChange: (e) => {
|
|
604
780
|
handleUpload(e.target.files);
|
|
605
781
|
e.currentTarget.value = '';
|
|
606
|
-
} }), _jsxs(XStack, {
|
|
782
|
+
} }), _jsxs(XStack, { minH: 56, items: "center", justify: "space-between", gap: "$3", px: "$5", py: "$2", "$max-md": { px: '$3', gap: '$2' }, borderBottomWidth: 1, borderColor: "$edge", shrink: 0, children: [_jsx(XStack, { width: 220, shrink: 1, "$max-md": { width: 'auto', shrink: 0 }, children: _jsx(View, { display: "none", "$max-md": { display: 'flex' }, children: _jsx(Button, { variant: "ghost", size: "icon-sm", focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, "$max-sm": { minW: 44, minH: 44 }, onClick: () => setMenu((v) => !v), "aria-label": t('Drive menu'), "aria-expanded": menu, "aria-controls": "drive-menu", title: t('Drive menu'), children: _jsx(PanelLeft, { size: 16 }) }) }) }), _jsxs(XStack, { items: "center", gap: "$2", width: 460, maxW: "45%", "$max-md": { flex: 1, width: 'auto', maxW: '100%', minW: 0 }, height: 38, "$max-sm": { minH: 44 }, px: "$3", rounded: 8, bg: "$panel", borderWidth: 1, borderColor: "var(--border-strong)", focusWithinStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, children: [_jsx(Search, { size: 15, color: "var(--muted-foreground)", "aria-hidden": true }), _jsx(Text, { render: _jsx("input", { value: searchQuery, onChange: (e) => setSearchQuery(e.target.value), placeholder: t('Search Drive'), "aria-label": t('Search Drive') }), ...BARE, minW: 0 })] }), _jsxs(XStack, { items: "center", gap: "$2", shrink: 0, children: [_jsx(Button, { size: "icon-sm", variant: "outline", borderColor: "var(--border-strong)", focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, "$max-sm": { minW: 44, minH: 44 }, onClick: () => fileInputRef.current?.click(), "aria-label": t('Upload'), title: t('Upload'), children: _jsx(Upload, { size: 15 }) }), _jsx(Button, { size: "icon-sm", variant: "outline", borderColor: "var(--border-strong)", focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, "$max-sm": { minW: 44, minH: 44 }, onClick: () => setNaming({ kind: 'folder', value: '' }), "aria-label": t('New folder'), title: t('New folder'), children: _jsx(Plus, { size: 16 }) }), _jsx(Text, { ...tip(userEmail), width: 32, height: 32, rounded: 9999, bg: "$raised", borderWidth: 1, borderColor: "$edge", display: "flex", "$max-sm": { display: 'none' }, items: "center", justify: "center", fontSize: "$2", fontWeight: "600", color: "$ink", children: userInitials })] })] }), _jsxs(XStack, { flex: 1, minH: 0, overflow: "hidden", position: "relative", children: [_jsx(View, { display: "none", "$max-md": { display: menu ? 'flex' : 'none' }, position: "absolute", t: 0, r: 0, b: 0, l: 0, z: "var(--z-scrim)", bg: "var(--surface-scrim)", onPress: () => setMenu(false), "aria-hidden": true }), _jsxs(YStack, { id: "drive-menu", width: 240, minW: 240, bg: "$background", borderRightWidth: 1, borderColor: "$borderColor", px: "$3", py: "$4", justify: "space-between", "$max-md": {
|
|
607
783
|
display: menu ? 'flex' : 'none',
|
|
608
784
|
position: 'absolute',
|
|
609
785
|
t: 0,
|
|
@@ -612,7 +788,7 @@ export function Drive() {
|
|
|
612
788
|
z: 'var(--z-drawer)',
|
|
613
789
|
overflowY: 'auto',
|
|
614
790
|
boxShadow: 'var(--shadow-lg)',
|
|
615
|
-
}, children: [_jsxs(YStack, { gap: "$4", children: [_jsxs(View, { position: "relative", children: [_jsxs(Button, { size: "lg", width: "100%", justify: "space-between", onClick: () => setNewMenuOpen((v) => !v), "aria-expanded": newMenuOpen, children: [_jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(Plus, { size: 16 }), _jsx(Text, { fontSize: "$3", fontWeight: "500", color: "$ink", children: t('New') })] }), _jsx(ChevronDown, { size: 14, opacity: 0.65 })] }), newMenuOpen ? (_jsx(YStack, { position: "absolute", t: "100%", mt: 6, l: 0, width: "100%", bg: "var(--popover)", borderWidth: 1, borderColor: "
|
|
791
|
+
}, children: [_jsxs(YStack, { gap: "$4", children: [_jsxs(View, { position: "relative", "data-drive-menu": "new", children: [_jsxs(Button, { size: "lg", variant: "outline", width: "100%", justify: "space-between", borderColor: "var(--border-strong)", focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, "$max-sm": { minH: 44 }, onClick: () => setNewMenuOpen((v) => !v), "aria-expanded": newMenuOpen, children: [_jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(Plus, { size: 16 }), _jsx(Text, { fontSize: "$3", fontWeight: "500", color: "$ink", children: t('New') })] }), _jsx(ChevronDown, { size: 14, opacity: 0.65 })] }), newMenuOpen ? (_jsx(YStack, { position: "absolute", t: "100%", mt: 6, l: 0, width: "100%", bg: "var(--popover)", borderWidth: 1, borderColor: "var(--border-strong)", rounded: 10, boxShadow: "var(--shadow-lg)", z: "var(--z-dropdown)", p: 6, gap: 2, children: navSection === 'local' ? (_jsxs(_Fragment, { children: [_jsxs(Button, { ...ITEM, onClick: () => {
|
|
616
792
|
setNewMenuOpen(false);
|
|
617
793
|
setMenu(false);
|
|
618
794
|
setNaming({ kind: 'file', value: '' });
|
|
@@ -637,11 +813,11 @@ export function Drive() {
|
|
|
637
813
|
setNewMenuOpen(false);
|
|
638
814
|
setMenu(false);
|
|
639
815
|
void handleImportLocalFile();
|
|
640
|
-
}, children: [_jsx(Upload, { size: 14 }), t('Import local file…')] }), _jsxs(Button, { ...ITEM, onClick: () => {
|
|
816
|
+
}, children: [_jsx(Upload, { size: 14 }), t('Import local file…')] }), devMode ? (_jsxs(Button, { ...ITEM, onClick: () => {
|
|
641
817
|
setNewMenuOpen(false);
|
|
642
818
|
setMenu(false);
|
|
643
819
|
setNaming({ kind: 'clone', value: '' });
|
|
644
|
-
}, children: [_jsx(FolderGit2, { size: 14 }), t('Clone remote repo…')] })] })) : (_jsxs(_Fragment, { children: [_jsxs(Button, { ...ITEM, onClick: () => {
|
|
820
|
+
}, children: [_jsx(FolderGit2, { size: 14 }), t('Clone remote repo…')] })) : null] })) : (_jsxs(_Fragment, { children: [_jsxs(Button, { ...ITEM, onClick: () => {
|
|
645
821
|
setNewMenuOpen(false);
|
|
646
822
|
setMenu(false);
|
|
647
823
|
setNaming({ kind: 'file', value: '' });
|
|
@@ -657,66 +833,62 @@ export function Drive() {
|
|
|
657
833
|
setNewMenuOpen(false);
|
|
658
834
|
setMenu(false);
|
|
659
835
|
folderInputRef.current?.click();
|
|
660
|
-
}, children: [_jsx(FolderInput, { size: 14 }), t('Folder upload')] }), _jsx(View, { height: 1, bg: "$borderColor", my: 4 }), _jsxs(Button, { ...ITEM, onClick: () => {
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
{ id: 'my-drive', label: t('My
|
|
666
|
-
{ id: 'local', label: t('Local
|
|
667
|
-
{ id: 'recent', label: t('Recent'), icon: Clock },
|
|
836
|
+
}, children: [_jsx(FolderInput, { size: 14 }), t('Folder upload')] }), devMode ? (_jsxs(_Fragment, { children: [_jsx(View, { height: 1, bg: "$borderColor", my: 4 }), _jsxs(Button, { ...ITEM, onClick: () => {
|
|
837
|
+
setNewMenuOpen(false);
|
|
838
|
+
setMenu(false);
|
|
839
|
+
setNaming({ kind: 'clone', value: '' });
|
|
840
|
+
}, children: [_jsx(FolderGit2, { size: 14 }), t('Clone remote repo…')] })] })) : null] })) })) : null] }), _jsx(YStack, { gap: "$1", children: [
|
|
841
|
+
{ id: 'my-drive', label: t('My drive'), icon: HardDrive },
|
|
842
|
+
{ id: 'local', label: t('Local folders'), icon: Laptop },
|
|
668
843
|
].map((item) => {
|
|
669
844
|
const isActive = navSection === item.id && !bucket && !prefix;
|
|
670
845
|
const Icon = item.icon;
|
|
671
|
-
return (_jsxs(Button, { variant: isActive ? 'secondary' : 'ghost', width: "100%", justify: "flex-start", gap: 12, px: 12, color: isActive ? '$ink' : '$soft', fontWeight: isActive ? '600' : '500', onClick: () => {
|
|
846
|
+
return (_jsxs(Button, { variant: isActive ? 'secondary' : 'ghost', width: "100%", justify: "flex-start", gap: 12, px: 12, color: isActive ? '$ink' : '$soft', fontWeight: isActive ? '600' : '500', focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, "$max-sm": { minH: 44 }, onClick: () => {
|
|
672
847
|
setNavSection(item.id);
|
|
673
848
|
openBucket(null);
|
|
674
849
|
setPrefix('');
|
|
675
850
|
setMenu(false);
|
|
676
851
|
}, children: [_jsx(Icon, { size: 16 }), item.label] }, item.id));
|
|
677
|
-
}) }), navSection === 'local' || localWorkspaces.length > 0 ? (_jsxs(YStack, { gap: "$1", pl: "$2", borderLeftWidth: 1, borderColor: "$
|
|
852
|
+
}) }), navSection === 'local' || localWorkspaces.length > 0 ? (_jsxs(YStack, { gap: "$1", pl: "$2", borderLeftWidth: 1, borderColor: "$edge", ml: "$3", children: [_jsx(Text, { fontSize: 11, fontWeight: "500", color: "$soft", mb: 2, children: t('Workspaces') }), localWorkspaces.map((ws) => {
|
|
678
853
|
const isCur = navSection === 'local' && activeWs?.id === ws.id;
|
|
679
|
-
return (_jsxs(XStack, { items: "center", justify: "space-between", px: "$2", py: "$1", rounded: 6, bg: isCur ? '$hover' : 'transparent', hoverStyle: { bg: '$hover' }, cursor: "pointer", onPress: () => {
|
|
854
|
+
return (_jsxs(XStack, { items: "center", justify: "space-between", px: "$2", py: "$1", "$max-sm": { minH: 44 }, rounded: 6, bg: isCur ? '$hover' : 'transparent', transition: "quickest", hoverStyle: { bg: '$hover' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, cursor: "pointer", onPress: () => {
|
|
680
855
|
setActiveWorkspace(ws);
|
|
681
856
|
setNavSection('local');
|
|
682
857
|
setLocalPrefix('');
|
|
683
|
-
}, children: [_jsxs(XStack, { items: "center", gap: "$2", minW: 0, flex: 1, children: [_jsx(Folder, { size: 13, color: isCur ? 'var(--
|
|
858
|
+
}, children: [_jsxs(XStack, { items: "center", gap: "$2", minW: 0, flex: 1, children: [_jsx(Folder, { size: 13, color: isCur ? 'var(--foreground)' : 'var(--muted-foreground)' }), _jsx(Text, { fontSize: "$2", fontWeight: isCur ? '600' : '400', color: isCur ? '$ink' : '$soft', numberOfLines: 1, children: ws.name })] }), _jsx(Button, { variant: "ghost", size: "icon-sm", focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, onClick: (e) => {
|
|
684
859
|
e.stopPropagation();
|
|
685
860
|
removeLocalWorkspace(ws.id);
|
|
686
|
-
}, title: t('Remove'), children: _jsx(Trash2, { size: 11, color: "var(--muted-foreground)" }) })] }, ws.id));
|
|
687
|
-
}), _jsxs(Button, { variant: "ghost", size: "sm", justify: "flex-start", gap: 6, px: 8, py: 4, color: "$soft", onClick: () => {
|
|
861
|
+
}, "aria-label": t('Remove {name}', { name: ws.name }), title: t('Remove'), children: _jsx(Trash2, { size: 11, color: "var(--muted-foreground)" }) })] }, ws.id));
|
|
862
|
+
}), _jsxs(Button, { variant: "ghost", size: "sm", justify: "flex-start", gap: 6, px: 8, py: 4, color: "$soft", focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, "$max-sm": { minH: 44 }, onClick: () => {
|
|
688
863
|
void pickLocalFolder().then((ws) => {
|
|
689
864
|
if (ws) {
|
|
690
865
|
setNavSection('local');
|
|
691
866
|
setLocalPrefix('');
|
|
692
867
|
}
|
|
693
868
|
});
|
|
694
|
-
}, children: [_jsx(Plus, { size: 13 }), _jsx(Text, { fontSize: "$1", color: "$soft", children: t('Open folder…') })] })] })) : null, _jsxs(YStack, { gap: "$2", mt: "$2", px: "$2", children: [_jsx(Text, { fontSize: 11, fontWeight: "
|
|
695
|
-
? usage.
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
:
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
})
|
|
704
|
-
: t('Measuring…') }), _jsx(Button, { asChild: true, size: "sm", mt: 8, children: _jsx("a", { href: checkoutUrl(), target: "_blank", rel: "noreferrer", children: t('Manage storage') }) })] })] }), _jsxs(YStack, { px: 14, py: 12, rounded: 10, borderWidth: 1, borderColor: "$borderColor", bg: "$panel", gap: 6, children: [_jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(Cloud, { size: 16, color: "var(--foreground)" }), _jsx(Text, { fontSize: "$2", fontWeight: "600", color: "$ink", children: t('Hanzo Drive') })] }), _jsx(Text, { fontSize: "$1", color: "$soft", children: [userEmail, activeBucket].filter(Boolean).join(' · ') }), _jsx(Button, { asChild: true, variant: "link", size: "sm", px: 0, mt: 4, justify: "flex-start", children: _jsxs("a", { href: "https://docs.hanzo.ai/docs/openapi/s3/", target: "_blank", rel: "noreferrer", children: [t('Documentation'), _jsx(ArrowRight, { size: 12 })] }) })] })] }), _jsxs(YStack, { flex: 1, minH: 0, px: "$6", py: "$5", overflowY: "auto", overflowX: "hidden", gap: "$5", children: [navSection === 'local' && activeWs ? (_jsxs(XStack, { items: "center", gap: "$2", pb: "$2", borderBottomWidth: 1, borderColor: "$borderColor", children: [_jsx(Button, { ...CRUMB, color: "$soft", onClick: () => {
|
|
869
|
+
}, children: [_jsx(Plus, { size: 13 }), _jsx(Text, { fontSize: "$1", color: "$soft", children: t('Open folder…') })] })] })) : null, _jsxs(YStack, { gap: "$2", mt: "$2", px: "$2", children: [_jsx(Text, { fontSize: 11, fontWeight: "500", color: "$soft", children: t('Storage') }), usage ? (_jsx(Text, { fontSize: 12, color: "$quiet", children: usage.capped
|
|
870
|
+
? t(usage.files === 1 ? 'over {size} in {count} file' : 'over {size} in {count} files', {
|
|
871
|
+
size: weigh(usage.bytes),
|
|
872
|
+
count: usage.files.toLocaleString(locale),
|
|
873
|
+
})
|
|
874
|
+
: t(usage.files === 1 ? '{size} in {count} file' : '{size} in {count} files', {
|
|
875
|
+
size: weigh(usage.bytes),
|
|
876
|
+
count: usage.files.toLocaleString(locale),
|
|
877
|
+
}) })) : (_jsx(Skeleton, { layout: "block", width: 112, height: 14, rounded: "$2" })), _jsx(Button, { asChild: true, size: "sm", mt: 8, children: _jsx("a", { href: checkoutUrl(), target: "_blank", rel: "noreferrer", children: t('Manage storage') }) })] })] }), _jsxs(YStack, { px: 14, py: 12, rounded: 10, borderWidth: 1, borderColor: "$borderColor", bg: "$panel", gap: 6, children: [_jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(Cloud, { size: 16, color: "var(--foreground)" }), _jsx(Text, { fontSize: "$2", fontWeight: "600", color: "$ink", children: t('Hanzo Drive') })] }), _jsx(Text, { fontSize: "$1", color: "$soft", children: (devMode ? [userEmail, activeBucket] : [userEmail]).filter(Boolean).join(' · ') }), devMode ? (_jsx(Button, { asChild: true, variant: "link", size: "sm", px: 0, mt: 4, justify: "flex-start", children: _jsxs("a", { href: "https://docs.hanzo.ai/docs/openapi/s3/", target: "_blank", rel: "noreferrer", children: [t('S3 API docs'), _jsx(ArrowRight, { size: 12 })] }) })) : null] })] }), _jsxs(YStack, { flex: 1, minH: 0, minW: 0, px: "$6", py: "$5", "$max-sm": { px: '$3', py: '$4' }, overflowY: "auto", overflowX: "hidden", gap: "$5", children: [navSection === 'local' && activeWs ? (_jsxs(XStack, { items: "center", gap: "$2", pb: "$2", flexWrap: "wrap", borderBottomWidth: 1, borderColor: "$edge", children: [_jsx(Button, { ...CRUMB, color: "$soft", onClick: () => {
|
|
705
878
|
setLocalPrefix('');
|
|
706
|
-
}, children: t('Local
|
|
879
|
+
}, children: t('Local folders') }), _jsx(ChevronRight, { size: 13, color: "var(--muted-foreground)" }), _jsx(Button, { ...CRUMB, color: !localPrefix ? '$ink' : '$soft', onClick: () => setLocalPrefix(''), children: activeWs.name }), localPrefix
|
|
707
880
|
? localPrefix.split('/').map((c, i, arr) => (_jsxs(React.Fragment, { children: [_jsx(ChevronRight, { size: 13, color: "var(--muted-foreground)" }), _jsx(Button, { ...CRUMB, color: i === arr.length - 1 ? '$ink' : '$soft', onClick: () => setLocalPrefix(arr.slice(0, i + 1).join('/')), children: c })] }, `${i}-${c}`)))
|
|
708
|
-
: null] })) : bucket || prefix ? (_jsxs(XStack, { items: "center", gap: "$2", pb: "$2", borderBottomWidth: 1, borderColor: "$
|
|
881
|
+
: null] })) : bucket || prefix ? (_jsxs(XStack, { items: "center", gap: "$2", pb: "$2", flexWrap: "wrap", borderBottomWidth: 1, borderColor: "$edge", children: [_jsx(Button, { ...CRUMB, color: "$soft", onClick: () => {
|
|
709
882
|
openBucket(null);
|
|
710
883
|
setPrefix('');
|
|
711
|
-
}, children: t('Drive') }), _jsx(ChevronRight, { size: 13, color: "var(--muted-foreground)" }), _jsx(Button, { ...CRUMB, color: crumbs.length === 0 ? '$ink' : '$soft', onClick: () => setPrefix(''), children: bucket || 'hanzo' }), crumbs.map((c, i) => (_jsxs(React.Fragment, { children: [_jsx(ChevronRight, { size: 13, color: "var(--muted-foreground)" }), _jsx(Button, { ...CRUMB, color: i === crumbs.length - 1 ? '$ink' : '$soft', onClick: () => setPrefix(crumbs.slice(0, i + 1).map((x) => `${x}/`).join('')), children: c })] }, `${i}-${c}`)))] })) : null, _jsxs(XStack, { items: "center", justify: "space-between", children: [_jsxs(YStack, { gap: "$1", children: [_jsx(Text, { render: "h1", fontSize:
|
|
884
|
+
}, children: t('Drive') }), _jsx(ChevronRight, { size: 13, color: "var(--muted-foreground)" }), _jsx(Button, { ...CRUMB, color: crumbs.length === 0 ? '$ink' : '$soft', onClick: () => setPrefix(''), children: bucket || 'hanzo' }), crumbs.map((c, i) => (_jsxs(React.Fragment, { children: [_jsx(ChevronRight, { size: 13, color: "var(--muted-foreground)" }), _jsx(Button, { ...CRUMB, color: i === crumbs.length - 1 ? '$ink' : '$soft', onClick: () => setPrefix(crumbs.slice(0, i + 1).map((x) => `${x}/`).join('')), children: c })] }, `${i}-${c}`)))] })) : null, _jsxs(XStack, { items: "center", justify: "space-between", flexWrap: "wrap", gap: "$3", children: [_jsxs(YStack, { gap: "$1", minW: 0, flex: 1, children: [_jsx(Text, { render: "h1", fontSize: "$7", fontWeight: "700", color: "$ink", numberOfLines: 1, children: navSection === 'local' ? (activeWs ? activeWs.name : t('Local folders')) : t('Drive') }), _jsx(Text, { fontSize: "$2", color: "$soft", children: navSection === 'local'
|
|
712
885
|
? activeWs
|
|
713
886
|
? activeWs.path
|
|
714
|
-
: t('
|
|
715
|
-
: t('
|
|
716
|
-
['list', t('List
|
|
717
|
-
['grid', t('Grid
|
|
718
|
-
|
|
719
|
-
].map(([mode, label, Icon]) => (_jsx(Button, { variant: viewMode === mode ? 'secondary' : 'ghost', size: "icon-sm", color: viewMode === mode ? '$ink' : '$soft', onClick: () => setViewMode(mode), "aria-label": label, "aria-pressed": viewMode === mode, title: label, children: _jsx(Icon, { size: 14 }) }, mode))) })] }), naming ? (_jsxs(XStack, { items: "center", gap: "$3", py: 10, px: 14, rounded: 8, borderWidth: 1, borderColor: "var(--border-control)", bg: "$panel", children: [naming.kind === 'file' ? (_jsx(FileCode, { size: 16, color: "var(--primary)" })) : naming.kind === 'clone' ? (_jsx(FolderGit2, { size: 16, color: "var(--primary)" })) : (_jsx(Folder, { size: 16, color: "var(--foreground)" })), _jsx(Text, { render: _jsx("input", { autoFocus: true, value: naming.value, onChange: (e) => setNaming({ ...naming, value: e.target.value }), onKeyDown: (e) => {
|
|
887
|
+
: t('Browse and edit files directly in folders on your computer.')
|
|
888
|
+
: t('Your cloud files and local folders in one place.') })] }), _jsx(XStack, { items: "center", bg: "$panel", rounded: 8, borderWidth: 1, borderColor: "var(--border-strong)", p: 2, gap: 2, shrink: 0, children: [
|
|
889
|
+
['list', t('List view'), List],
|
|
890
|
+
['grid', t('Grid view'), LayoutGrid],
|
|
891
|
+
].map(([mode, label, Icon]) => (_jsx(Button, { variant: viewMode === mode ? 'secondary' : 'ghost', size: "icon-sm", color: viewMode === mode ? '$ink' : '$soft', focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, "$max-sm": { minW: 44, minH: 44 }, onClick: () => setViewMode(mode), "aria-label": label, "aria-pressed": viewMode === mode, title: label, children: _jsx(Icon, { size: 14 }) }, mode))) })] }), naming ? (_jsxs(XStack, { items: "center", flexWrap: "wrap", gap: "$3", py: 10, px: 14, rounded: 8, borderWidth: 1, borderColor: "var(--border-strong)", bg: "$panel", focusWithinStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, children: [naming.kind === 'file' ? (_jsx(FileCode, { size: 16, color: "var(--foreground)" })) : naming.kind === 'clone' ? (_jsx(FolderGit2, { size: 16, color: "var(--foreground)" })) : naming.kind === 'rename' ? (_jsx(FolderInput, { size: 16, color: "var(--foreground)" })) : (_jsx(Folder, { size: 16, color: "var(--foreground)" })), _jsx(Text, { render: _jsx("input", { autoFocus: true, value: naming.value, onChange: (e) => setNaming({ ...naming, value: e.target.value }), onKeyDown: (e) => {
|
|
720
892
|
if (e.key === 'Escape')
|
|
721
893
|
setNaming(null);
|
|
722
894
|
if (e.key === 'Enter') {
|
|
@@ -724,6 +896,8 @@ export function Drive() {
|
|
|
724
896
|
handleCreateFile(naming.value);
|
|
725
897
|
else if (naming.kind === 'clone')
|
|
726
898
|
handleCloneRepo(naming.value);
|
|
899
|
+
else if (naming.kind === 'rename' && naming.entry)
|
|
900
|
+
handleRename(naming.entry, naming.value);
|
|
727
901
|
else
|
|
728
902
|
handleCreateFolder(naming.value);
|
|
729
903
|
}
|
|
@@ -731,83 +905,141 @@ export function Drive() {
|
|
|
731
905
|
? t('File name (e.g. {example})', { example: 'index.ts' })
|
|
732
906
|
: naming.kind === 'clone'
|
|
733
907
|
? t('owner/repo or Git URL (e.g. {example})', { example: 'hanzoai/desktop' })
|
|
734
|
-
:
|
|
908
|
+
: naming.kind === 'rename'
|
|
909
|
+
? t('New name or path (e.g. folder/file.md)')
|
|
910
|
+
: t('Folder name'), "aria-label": naming.kind === 'file'
|
|
735
911
|
? t('File name')
|
|
736
912
|
: naming.kind === 'clone'
|
|
737
913
|
? t('Clone remote repository')
|
|
738
|
-
:
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
914
|
+
: naming.kind === 'rename'
|
|
915
|
+
? t('Move or rename file')
|
|
916
|
+
: t('Folder name') }), ...BARE, minW: 140 }), _jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(Button, { variant: "primary", size: "sm", "$max-sm": { minH: 44 }, onClick: () => {
|
|
917
|
+
if (naming.kind === 'file')
|
|
918
|
+
handleCreateFile(naming.value);
|
|
919
|
+
else if (naming.kind === 'clone')
|
|
920
|
+
handleCloneRepo(naming.value);
|
|
921
|
+
else if (naming.kind === 'rename' && naming.entry)
|
|
922
|
+
handleRename(naming.entry, naming.value);
|
|
923
|
+
else
|
|
924
|
+
handleCreateFolder(naming.value);
|
|
925
|
+
}, children: t(naming.kind === 'clone' ? 'Clone' : naming.kind === 'rename' ? 'Move' : 'Create') }), _jsx(Button, { variant: "ghost", size: "sm", color: "$soft", "$max-sm": { minH: 44 }, onClick: () => setNaming(null), children: t('Cancel') })] })] })) : null, editingFile ? (_jsx(Editor, { filePath: editingFile.path, fileName: editingFile.name, onClose: () => {
|
|
746
926
|
setEditingFile(null);
|
|
747
927
|
loadLocalEntries();
|
|
748
928
|
}, onAskInChat: () => {
|
|
749
929
|
setEditingFile(null);
|
|
750
930
|
router.push('/chat');
|
|
751
|
-
} })) : null, busy ? (_jsx(Text, { fontSize: "$2", color: "$soft", "data-slot": "drive-busy", children: t('{status}…', { status: busy }) })) : null,
|
|
931
|
+
} })) : null, busy ? (_jsx(Text, { fontSize: "$2", color: "$soft", "data-slot": "drive-busy", children: t('{status}…', { status: busy }) })) : null, failed ? (_jsxs(XStack, { role: "alert", items: "center", justify: "space-between", flexWrap: "wrap", gap: "$3", px: 16, py: 12, rounded: "$4", borderWidth: 1, borderColor: "var(--border-strong)", bg: "var(--surface-card)", children: [_jsx(Text, { fontSize: "$2", color: "var(--state-error)", flex: 1, minW: 0, children: failed }), _jsx(Button, { size: "sm", variant: "outline", borderColor: "var(--border-strong)", focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, "$max-sm": { minH: 44 }, onClick: () => {
|
|
932
|
+
setFailed(null);
|
|
933
|
+
setReload((n) => n + 1);
|
|
934
|
+
}, children: t('Try again') })] })) : null, hits && hits.length ? _jsx(Hits, { hits: hits, onOpen: (p) => showContents(p.file.id, p.section.id) }) : null, navSection === 'local' ? (!activeWs ? (_jsxs(YStack, { py: 60, px: 24, items: "center", justify: "center", gap: "$4", borderWidth: 1, borderStyle: "dashed", borderColor: "$edge", rounded: 12, bg: "$panel", children: [_jsx(Laptop, { size: 40, color: "var(--foreground)" }), _jsxs(YStack, { items: "center", gap: "$1", maxW: 460, children: [_jsx(Text, { fontSize: 18, fontWeight: "600", color: "$ink", text: "center", children: t('No local folder opened') }), _jsx(Text, { fontSize: 13, color: "$soft", text: "center", children: t('Open a local folder on your computer to browse, create, edit, and save files directly in Hanzo Desktop.') })] }), _jsxs(XStack, { items: "center", justify: "center", flexWrap: "wrap", gap: "$2", children: [_jsxs(Button, { focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, "$max-sm": { minH: 44 }, onClick: () => {
|
|
752
935
|
void pickLocalFolder().then((ws) => {
|
|
753
936
|
if (ws) {
|
|
754
937
|
setNavSection('local');
|
|
755
938
|
setLocalPrefix('');
|
|
756
939
|
}
|
|
757
940
|
});
|
|
758
|
-
}, children: [_jsx(FolderPlus, { size: 16 }), t('Open
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
941
|
+
}, children: [_jsx(FolderPlus, { size: 16 }), t('Open local folder…')] }), devMode ? (_jsxs(Button, { variant: "outline", borderColor: "var(--border-strong)", focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, "$max-sm": { minH: 44 }, onClick: () => setNaming({ kind: 'clone', value: '' }), children: [_jsx(FolderGit2, { size: 16 }), t('Clone remote repo…')] })) : null] })] })) : (_jsxs(YStack, { gap: "$2.5", children: [_jsxs(XStack, { items: "center", justify: "space-between", flexWrap: "wrap", gap: "$2", pb: "$1", children: [_jsx(Text, { fontSize: 12, fontWeight: "600", color: "$soft", children: localPrefix ? t('Folder: {path}', { path: localPrefix }) : t('Files and folders') }), _jsxs(XStack, { items: "center", flexWrap: "wrap", gap: "$2", children: [_jsxs(Button, { variant: "outline", size: "sm", borderColor: "var(--border-strong)", focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, "$max-sm": { minH: 44 }, onClick: () => setNaming({ kind: 'file', value: '' }), children: [_jsx(FilePlus, { size: 13 }), t('New file')] }), _jsxs(Button, { variant: "outline", size: "sm", borderColor: "var(--border-strong)", focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, "$max-sm": { minH: 44 }, onClick: () => setNaming({ kind: 'folder', value: '' }), children: [_jsx(FolderPlus, { size: 13 }), t('New folder')] }), _jsxs(Button, { variant: "outline", size: "sm", borderColor: "var(--border-strong)", focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, "$max-sm": { minH: 44 }, onClick: () => void handleImportLocalFile(), children: [_jsx(Upload, { size: 13 }), t('Import file')] }), devMode ? (_jsxs(Button, { variant: "outline", size: "sm", borderColor: "var(--border-strong)", focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, "$max-sm": { minH: 44 }, onClick: () => setNaming({ kind: 'clone', value: '' }), children: [_jsx(FolderGit2, { size: 13 }), t('Clone repo')] })) : null] })] }), viewMode === 'grid' && visibleLocalEntries === null ? (_jsx(DriveEntriesSkeleton, { grid: true, label: t('Loading files') })) : viewMode === 'grid' && visibleLocalEntries && visibleLocalEntries.length > 0 ? (_jsx(View, { display: "grid", gridTemplateColumns: "repeat(auto-fill, minmax(180px, 1fr))", "$max-sm": { gridTemplateColumns: '1fr' }, gap: "$3", children: visibleLocalEntries.map((e) => {
|
|
942
|
+
const ext = e.name.includes('.') ? e.name.split('.').pop()?.toLowerCase() || '' : '';
|
|
943
|
+
return (_jsxs(YStack, { render: "button", ...{ type: 'button' }, p: "$3.5", rounded: "$4", bg: "$panel", borderWidth: 1, borderColor: "$edge", gap: "$2", items: "flex-start", cursor: "pointer", transition: "quickest", hoverStyle: { bg: '$hover', borderColor: 'var(--border-strong)' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, onClick: () => {
|
|
944
|
+
if (e.isDir) {
|
|
945
|
+
setLocalPrefix(localPrefix ? `${localPrefix}/${e.name}` : e.name);
|
|
946
|
+
}
|
|
947
|
+
else {
|
|
948
|
+
setEditingFile({ path: e.path, name: e.name });
|
|
949
|
+
}
|
|
950
|
+
}, children: [_jsxs(XStack, { items: "center", justify: "space-between", width: "100%", children: [e.isDir ? (_jsx(Folder, { size: 18, color: "var(--foreground)" })) : (_jsx(FileCode, { size: 18, color: "var(--muted-foreground)" })), _jsx(Text, { ...CHIP, children: e.isDir ? t('Folder') : ext || t('File') })] }), _jsx(Text, { ...NAME, text: "start", width: "100%", children: e.name }), _jsx(Text, { fontSize: "$1", color: "$soft", children: e.isDir ? t('Folder') : weigh(e.size) })] }, e.path));
|
|
951
|
+
}) })) : (_jsxs(YStack, { borderWidth: 1, borderColor: "$edge", rounded: 8, overflowX: "auto", overflowY: "hidden", children: [_jsxs(View, { display: "grid", gridTemplateColumns: FILES, minW: "min-content", px: 16, py: 10, borderBottomWidth: 1, borderColor: "$edge", children: [_jsx(Text, { ...HEAD, children: t('Name') }), _jsx(Text, { ...HEAD, children: t('Type') }), _jsx(Text, { ...HEAD, children: t('Updated') }), _jsx(Text, { ...HEAD, children: t('Size') }), _jsx(View, {})] }), visibleLocalEntries === null ? (_jsx(DriveEntriesSkeleton, { label: t('Loading files') })) : visibleLocalEntries.length === 0 ? (_jsx(YStack, { py: 40, px: 16, items: "center", gap: "$2", children: _jsx(Text, { fontSize: "$2", color: "$soft", text: "center", children: t('This folder is empty.') }) })) : (visibleLocalEntries.map((e) => {
|
|
952
|
+
const ext = e.name.includes('.') ? e.name.split('.').pop()?.toLowerCase() || '' : '';
|
|
953
|
+
const openLocal = () => {
|
|
954
|
+
if (e.isDir) {
|
|
955
|
+
setLocalPrefix(localPrefix ? `${localPrefix}/${e.name}` : e.name);
|
|
956
|
+
}
|
|
957
|
+
else {
|
|
958
|
+
setEditingFile({ path: e.path, name: e.name });
|
|
959
|
+
}
|
|
960
|
+
};
|
|
961
|
+
return (_jsxs(View, { role: "button", tabIndex: 0, display: "grid", gridTemplateColumns: FILES, minW: "min-content", px: 16, py: 11, items: "center", cursor: "pointer", borderBottomWidth: 1, borderColor: "$edge", transition: "100ms", hoverStyle: { bg: '$hover' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)', outlineOffset: -2 }, onClick: openLocal, onKeyDown: (ev) => {
|
|
962
|
+
if (ev.target !== ev.currentTarget)
|
|
963
|
+
return;
|
|
964
|
+
if (ev.key === 'Enter' || ev.key === ' ') {
|
|
965
|
+
ev.preventDefault?.();
|
|
966
|
+
openLocal();
|
|
766
967
|
}
|
|
767
|
-
}, children: [_jsxs(XStack, { items: "center", gap: "$3", minW: 0, pr: "$2", children: [e.isDir ? (_jsx(Folder, { size: 16, color: "var(--foreground)" })) : (_jsx(FileCode, { size: 16, color: "var(--muted-foreground)" })), _jsx(Text, { ...NAME, children: e.name })] }), _jsx(
|
|
968
|
+
}, children: [_jsxs(XStack, { items: "center", gap: "$3", minW: 0, pr: "$2", children: [e.isDir ? (_jsx(Folder, { size: 16, color: "var(--foreground)" })) : (_jsx(FileCode, { size: 16, color: "var(--muted-foreground)" })), _jsx(Text, { ...NAME, children: e.name })] }), _jsx(View, { items: "flex-start", children: _jsx(Text, { ...CHIP, children: e.isDir ? t('Folder') : ext || t('File') }) }), _jsx(Text, { ...CELL, children: e.lastModified ? when(e.lastModified, locale) : '—' }), _jsx(Text, { ...CELL, children: e.isDir ? '—' : weigh(e.size) }), _jsxs(View, { position: "relative", "data-drive-menu": e.path, onClick: (evt) => evt.stopPropagation(), children: [_jsx(More, { onPress: (evt) => {
|
|
768
969
|
evt.stopPropagation();
|
|
769
970
|
setItemMenuKey(itemMenuKey === e.path ? null : e.path);
|
|
770
|
-
} }), itemMenuKey === e.path ? (_jsxs(YStack, { position: "absolute", r: 0, t: "100%", z: "var(--z-dropdown)", width: 160, bg: "var(--popover)", borderWidth: 1, borderColor: "
|
|
971
|
+
} }), itemMenuKey === e.path ? (_jsxs(YStack, { position: "absolute", r: 0, t: "100%", z: "var(--z-dropdown)", width: 160, bg: "var(--popover)", borderWidth: 1, borderColor: "var(--border-strong)", rounded: 8, boxShadow: "var(--shadow-lg)", p: 4, gap: 2, children: [!e.isDir ? (_jsx(Pick, { icon: FileCode, label: t('Edit file'), onPress: () => {
|
|
771
972
|
setItemMenuKey(null);
|
|
772
973
|
setEditingFile({ path: e.path, name: e.name });
|
|
773
|
-
} })) : null, _jsx(Pick, { icon: Trash2, label: t('Delete'), tone:
|
|
974
|
+
} })) : null, _jsx(Pick, { icon: Trash2, label: t('Delete'), tone: "var(--state-error)", onPress: () => {
|
|
774
975
|
setItemMenuKey(null);
|
|
775
|
-
|
|
776
|
-
.then(() => loadLocalEntries())
|
|
777
|
-
.catch((err) => setFailed(blame(err, t)));
|
|
976
|
+
handleDeleteLocal(e);
|
|
778
977
|
} })] })) : null] })] }, e.path));
|
|
779
|
-
}))] })] }))) : bucket || prefix ? (_jsx(YStack, { gap: "$2", children:
|
|
978
|
+
}))] }))] }))) : bucket || prefix ? (_jsx(YStack, { gap: "$2", children: viewMode === 'grid' && filteredEntries === null && !failed ? (_jsx(DriveEntriesSkeleton, { grid: true, label: t('Loading files') })) : viewMode === 'grid' && filteredEntries && filteredEntries.length > 0 ? (_jsx(View, { display: "grid", gridTemplateColumns: "repeat(auto-fill, minmax(180px, 1fr))", "$max-sm": { gridTemplateColumns: '1fr' }, gap: "$3", children: filteredEntries.map((e) => {
|
|
979
|
+
const isFolder = e.isDir || e.key.endsWith('/');
|
|
980
|
+
const cleanName = e.key.replace(/\/+$/, '');
|
|
981
|
+
const ext = cleanName.includes('.') ? cleanName.split('.').pop()?.toLowerCase() || '' : '';
|
|
982
|
+
return (_jsxs(YStack, { render: "button", ...{ type: 'button' }, p: "$3.5", rounded: "$4", bg: "$panel", borderWidth: 1, borderColor: "$edge", gap: "$2", items: "flex-start", cursor: "pointer", transition: "quickest", hoverStyle: { bg: '$hover', borderColor: 'var(--border-strong)' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, onClick: () => {
|
|
983
|
+
if (isFolder)
|
|
984
|
+
setPrefix(`${prefix}${cleanName}/`);
|
|
985
|
+
else
|
|
986
|
+
handleDownload(e);
|
|
987
|
+
}, children: [_jsxs(XStack, { items: "center", justify: "space-between", width: "100%", children: [_jsx(Glyph, { entry: e, size: 18 }), _jsx(Text, { ...CHIP, children: isFolder ? t('Folder') : ext || t('File') })] }), _jsx(Text, { ...NAME, text: "start", width: "100%", children: cleanName }), _jsx(Text, { fontSize: "$1", color: "$soft", children: isFolder ? t('Folder') : weigh(e.size) })] }, e.key));
|
|
988
|
+
}) })) : (_jsxs(YStack, { borderWidth: 1, borderColor: "$edge", rounded: 8, overflowX: "auto", overflowY: "hidden", children: [_jsxs(View, { display: "grid", gridTemplateColumns: FILES, minW: "min-content", px: 16, py: 10, borderBottomWidth: 1, borderColor: "$edge", children: [_jsx(Text, { ...HEAD, children: t('Name') }), _jsx(Text, { ...HEAD, children: t('Type') }), _jsx(Text, { ...HEAD, children: t('Updated ↓') }), _jsx(Text, { ...HEAD, children: t('Size') }), _jsx(View, {})] }), filteredEntries === null && !failed ? (_jsx(DriveEntriesSkeleton, { label: t('Loading files') })) : !filteredEntries || filteredEntries.length === 0 ? (_jsxs(YStack, { py: 44, px: 16, items: "center", gap: "$3", children: [_jsx(Text, { text: "center", fontSize: "$2", color: "$soft", children: searchQuery.trim()
|
|
989
|
+
? t('No files match “{query}”.', { query: searchQuery.trim() })
|
|
990
|
+
: t('No files in this folder yet.') }), !searchQuery.trim() ? (_jsxs(XStack, { gap: "$2", flexWrap: "wrap", justify: "center", children: [_jsxs(Button, { size: "sm", rounded: 999, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, "$max-sm": { minH: 44 }, onClick: () => fileInputRef.current?.click(), children: [_jsx(Upload, { size: 13 }), t('Upload files')] }), _jsxs(Button, { size: "sm", variant: "outline", rounded: 999, borderColor: "var(--border-strong)", focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' }, "$max-sm": { minH: 44 }, onClick: () => setNaming({ kind: 'folder', value: '' }), children: [_jsx(FolderPlus, { size: 13 }), t('New folder')] })] })) : null] })) : (filteredEntries.map((e) => {
|
|
780
991
|
const isFolder = e.isDir || e.key.endsWith('/');
|
|
781
992
|
const cleanName = e.key.replace(/\/+$/, '');
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
|
|
993
|
+
const ext = cleanName.includes('.') ? cleanName.split('.').pop()?.toLowerCase() || '' : '';
|
|
994
|
+
const openEntry = () => {
|
|
995
|
+
if (isFolder) {
|
|
996
|
+
setPrefix(`${prefix}${cleanName}/`);
|
|
997
|
+
}
|
|
998
|
+
else {
|
|
999
|
+
handleDownload(e);
|
|
1000
|
+
}
|
|
1001
|
+
};
|
|
1002
|
+
return (_jsxs(View, { role: "button", tabIndex: 0, display: "grid", gridTemplateColumns: FILES, minW: "min-content", px: 16, py: 11, items: "center", cursor: "pointer", borderBottomWidth: 1, borderColor: "$edge", transition: "100ms", hoverStyle: { bg: '$hover' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)', outlineOffset: -2 }, onClick: openEntry, onKeyDown: (ev) => {
|
|
1003
|
+
if (ev.target !== ev.currentTarget)
|
|
1004
|
+
return;
|
|
1005
|
+
if (ev.key === 'Enter' || ev.key === ' ') {
|
|
1006
|
+
ev.preventDefault?.();
|
|
1007
|
+
openEntry();
|
|
788
1008
|
}
|
|
789
|
-
}, children: [_jsxs(XStack, { items: "center", gap: "$2.5", minW: 0, children: [_jsx(Glyph, { entry: e, size: 16 }), _jsxs(YStack, { minW: 0, children: [_jsx(Text, { ...NAME, children: cleanName }), !isFolder && index.get(prefix + e.key) ? _jsx(Badge, { f: index.get(prefix + e.key) }) : null] })] }), _jsx(View, { items: "flex-start", children: _jsx(Text, { ...CHIP, children: isFolder ? t('Folder') :
|
|
1009
|
+
}, children: [_jsxs(XStack, { items: "center", gap: "$2.5", minW: 0, children: [_jsx(Glyph, { entry: e, size: 16 }), _jsxs(YStack, { minW: 0, children: [_jsx(Text, { ...NAME, children: cleanName }), !isFolder && index.get(prefix + e.key) ? _jsx(Badge, { f: index.get(prefix + e.key) }) : null] })] }), _jsx(View, { items: "flex-start", children: _jsx(Text, { ...CHIP, children: isFolder ? t('Folder') : ext || t('File') }) }), _jsx(Text, { ...CELL, children: when(e.lastModified, locale) }), _jsx(Text, { ...CELL, children: weigh(e.size) }), _jsxs(View, { position: "relative", items: "flex-start", "data-drive-menu": e.key, children: [_jsx(More, { onPress: (ev) => {
|
|
790
1010
|
ev.stopPropagation();
|
|
791
1011
|
setItemMenuKey(itemMenuKey === e.key ? null : e.key);
|
|
792
|
-
} }), itemMenuKey === e.key ? (_jsxs(YStack, { position: "absolute", r: 0, t: "100%", bg: "var(--popover)", borderWidth: 1, borderColor: "
|
|
1012
|
+
} }), itemMenuKey === e.key ? (_jsxs(YStack, { position: "absolute", r: 0, t: "100%", bg: "var(--popover)", borderWidth: 1, borderColor: "var(--border-strong)", rounded: 8, boxShadow: "var(--shadow-lg)", z: "var(--z-dropdown)", p: 4, minW: 148, onClick: (ev) => ev.stopPropagation(), children: [!isFolder && index.get(prefix + e.key) ? (_jsxs(_Fragment, { children: [_jsx(Pick, { icon: ListTree, label: t('Contents'), onPress: () => {
|
|
793
1013
|
setItemMenuKey(null);
|
|
794
1014
|
setContents({ file: index.get(prefix + e.key) });
|
|
795
1015
|
} }), _jsx(Pick, { icon: MessageSquare, label: t('Ask in chat'), onPress: () => {
|
|
796
1016
|
setItemMenuKey(null);
|
|
797
1017
|
askInChat(index.get(prefix + e.key));
|
|
798
|
-
} })] })) : null, !isFolder ? (_jsx(Pick, { icon:
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
1018
|
+
} })] })) : null, !isFolder ? (_jsxs(_Fragment, { children: [_jsx(Pick, { icon: FolderInput, label: t('Move or rename'), onPress: () => {
|
|
1019
|
+
setItemMenuKey(null);
|
|
1020
|
+
setNaming({ kind: 'rename', entry: e, value: `${prefix}${cleanName}` });
|
|
1021
|
+
} }), _jsx(Pick, { icon: Download, label: t('Download'), onPress: () => {
|
|
1022
|
+
setItemMenuKey(null);
|
|
1023
|
+
handleDownload(e);
|
|
1024
|
+
} })] })) : null, _jsx(Pick, { icon: Trash2, label: t('Delete'), tone: "var(--state-error)", onPress: () => {
|
|
802
1025
|
setItemMenuKey(null);
|
|
803
1026
|
handleDelete(e);
|
|
804
1027
|
} })] })) : null] })] }, e.key));
|
|
805
|
-
}))] }) })) : (_jsxs(_Fragment, { children: [_jsxs(YStack, { gap: "$2.5", children: [_jsx(Text, { fontSize:
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
const targetBucket = buckets[0]?.name || 'hanzo';
|
|
1028
|
+
}))] })) })) : (_jsxs(_Fragment, { children: [_jsxs(YStack, { gap: "$2.5", children: [_jsx(Text, { fontSize: "$1", fontWeight: "600", color: "$soft", children: devMode ? t('Storage buckets') : t('Cloud storage') }), _jsx(YStack, { borderWidth: 1, borderColor: "$edge", rounded: 8, overflowX: "auto", overflowY: "hidden", children: !buckets && !failed ? (_jsx(DriveBucketSkeleton, { label: t('Loading your files') })) : !buckets || buckets.length === 0 ? (_jsx(Text, { ...NOTE, children: devMode ? t('No buckets yet.') : t('No cloud folders yet.') })) : (buckets.map((b) => (_jsxs(XStack, { render: "button", ...{ type: 'button' }, onClick: () => openBucket(b.name), width: "100%", items: "center", justify: "space-between", px: 16, py: 12, "$max-sm": { minH: 48 }, cursor: "pointer", bg: "transparent", borderWidth: 0, borderBottomWidth: 1, borderColor: "$edge", transition: "100ms", hoverStyle: { bg: '$hover' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)', outlineOffset: -2 }, children: [_jsxs(XStack, { items: "center", gap: "$2.5", minW: 0, flex: 1, children: [_jsx(Folder, { size: 17, color: "var(--foreground)" }), _jsx(Text, { fontSize: "$2", fontWeight: "500", color: "$ink", numberOfLines: 1, children: getBucketDisplayName(b, t) })] }), _jsxs(XStack, { items: "center", gap: "$3", shrink: 0, children: [_jsx(Text, { fontSize: "$2", color: "$soft", children: when(b.createdAt, locale) }), _jsx(ChevronRight, { size: 14, color: "var(--muted-foreground)", "aria-hidden": true })] })] }, b.name)))) })] }), _jsxs(YStack, { gap: "$2.5", children: [_jsx(Text, { fontSize: "$1", fontWeight: "600", color: "$soft", children: devMode ? t('Projects (unified VFS)') : t('Projects') }), _jsxs(YStack, { borderWidth: 1, borderColor: "$edge", rounded: 8, overflowX: "auto", overflowY: "hidden", children: [_jsxs(View, { display: "grid", gridTemplateColumns: PROJECTS, minW: "min-content", px: 16, py: 10, borderBottomWidth: 1, borderColor: "$edge", children: [_jsx(Text, { ...HEAD, children: t('Name') }), _jsx(Text, { ...HEAD, children: t('Type') }), _jsx(Text, { ...HEAD, children: t('Updated ↓') }), _jsx(Text, { ...HEAD, children: t('Size') }), _jsx(View, {})] }), filteredProjects.length === 0 ? (_jsx(Text, { py: 36, px: 16, text: "center", fontSize: "$2", color: "$soft", children: searchQuery.trim()
|
|
1029
|
+
? t('No projects match “{query}”.', { query: searchQuery.trim() })
|
|
1030
|
+
: t('No projects yet.') })) : (filteredProjects.map((p) => {
|
|
1031
|
+
const openProject = () => {
|
|
1032
|
+
const targetBucket = buckets?.[0]?.name || 'hanzo';
|
|
810
1033
|
openBucket(targetBucket);
|
|
811
1034
|
setPrefix(`projects/${p.name || p.id}/`);
|
|
812
|
-
}
|
|
1035
|
+
};
|
|
1036
|
+
return (_jsxs(View, { role: "button", tabIndex: 0, onClick: openProject, onKeyDown: (ev) => {
|
|
1037
|
+
if (ev.target !== ev.currentTarget)
|
|
1038
|
+
return;
|
|
1039
|
+
if (ev.key === 'Enter' || ev.key === ' ') {
|
|
1040
|
+
ev.preventDefault?.();
|
|
1041
|
+
openProject();
|
|
1042
|
+
}
|
|
1043
|
+
}, display: "grid", gridTemplateColumns: PROJECTS, minW: "min-content", px: 16, py: 11, items: "center", cursor: "pointer", borderBottomWidth: 1, borderColor: "$edge", transition: "100ms", hoverStyle: { bg: '$hover' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)', outlineOffset: -2 }, children: [_jsxs(XStack, { items: "center", gap: "$2.5", minW: 0, children: [_jsx(Folder, { size: 16, color: "var(--foreground)" }), _jsx(Text, { ...NAME, children: p.name })] }), _jsx(View, { items: "flex-start", children: _jsx(Text, { ...CHIP, children: p.type }) }), _jsx(Text, { ...CELL, children: p.updated }), _jsx(Text, { ...CELL, children: p.size }), _jsx(XStack, { items: "center", justify: "flex-end", children: _jsx(ChevronRight, { size: 14, color: "var(--muted-foreground)", "aria-hidden": true }) })] }, p.id));
|
|
1044
|
+
}))] })] })] }))] })] }), contents && client ? (_jsx(Contents, { api: client, file: contents.file, at: contents.at, onClose: () => setContents(null), onAsk: askInChat, onFollow: (id, at) => showContents(id, at) })) : null, over ? (_jsx(Box, { position: "absolute", t: 0, l: 0, r: 0, b: 0, z: "var(--z-modal)", bg: VEIL, borderWidth: 2, borderStyle: "dashed", borderColor: "var(--ring)", rounded: "$3", display: "flex", items: "center", justify: "center", pointerEvents: "none", children: _jsxs(YStack, { items: "center", gap: "$2", children: [_jsx(Upload, { size: 36, color: "currentColor" }), _jsx(Text, { fontSize: "$4", fontWeight: "600", color: "$ink", children: t('Drop files to upload to {name}', { name: bucket || workspace }) })] }) })) : null] }));
|
|
813
1045
|
}
|