@hanzo/app 0.2.58 → 0.2.60
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/App.js +1 -4
- package/dist/Board.js +37 -121
- package/dist/Boxes.js +12 -16
- package/dist/CalScheduler.js +40 -81
- package/dist/Chat.js +87 -78
- package/dist/Chrome.d.ts +2 -14
- package/dist/Chrome.js +7 -44
- package/dist/Column.js +6 -2
- package/dist/Contents.d.ts +1 -1
- package/dist/Contents.js +2 -1
- package/dist/Drive.js +100 -121
- package/dist/Inbox.js +7 -7
- package/dist/Market.js +10 -15
- package/dist/Meet.js +48 -78
- package/dist/Orgs.js +10 -9
- package/dist/Palette.d.ts +1 -1
- package/dist/Palette.js +2 -1
- package/dist/Rail.d.ts +1 -1
- package/dist/Rail.js +4 -4
- package/dist/Schedule.js +11 -15
- package/dist/Settings.d.ts +1 -1
- package/dist/SettingsPane.js +2 -2
- package/dist/Shared.js +11 -16
- package/dist/Shell.js +1 -1
- package/dist/Talk.js +4 -4
- package/dist/Terminals.js +1 -3
- package/dist/Top.js +1 -1
- package/dist/Usage.js +3 -3
- package/dist/WindowControls.js +3 -5
- package/dist/Work.js +28 -51
- package/dist/bots/Bots.js +73 -129
- package/dist/bots/runtime.js +41 -103
- package/dist/cast.d.ts +1 -1
- package/dist/cast.js +1 -1
- package/dist/failure.d.ts +1 -1
- package/dist/failure.js +1 -1
- package/dist/ground.d.ts +21 -0
- package/dist/ground.js +21 -0
- package/dist/lib/limits.d.ts +1 -1
- package/dist/lib/limits.js +1 -1
- package/dist/lib/org.d.ts +3 -3
- package/dist/lib/org.js +5 -4
- package/dist/lib/orgname.d.ts +1 -1
- package/dist/lib/orgname.js +1 -1
- package/dist/lib/pay.d.ts +2 -6
- package/dist/lib/pay.js +2 -15
- package/dist/lib/plans.d.ts +1 -1
- package/dist/lib/plans.js +1 -1
- package/dist/lib/tier.d.ts +2 -2
- package/dist/lib/tier.js +6 -6
- package/dist/look.js +8 -10
- package/dist/recent.d.ts +1 -1
- package/dist/recent.js +2 -1
- package/dist/say.d.ts +4 -0
- package/dist/say.js +7 -0
- package/dist/thread.js +1 -1
- package/package.json +3 -3
- package/assets/memoji/art.svg +0 -22
- package/assets/memoji/cyber.svg +0 -22
- package/assets/memoji/data.svg +0 -22
- package/assets/memoji/des.svg +0 -22
- package/assets/memoji/dev.svg +0 -22
- package/assets/memoji/doc.svg +0 -22
- package/assets/memoji/edu.svg +0 -22
- package/assets/memoji/fin.svg +0 -22
- package/assets/memoji/gov.svg +0 -22
- package/assets/memoji/huma.svg +0 -22
- package/assets/memoji/lang.svg +0 -22
- package/assets/memoji/law.svg +0 -22
- package/assets/memoji/mana.svg +0 -22
- package/assets/memoji/mark.svg +0 -22
- package/assets/memoji/mu.svg +0 -22
- package/assets/memoji/opera.svg +0 -22
- package/assets/memoji/rev.svg +0 -22
- package/assets/memoji/sal.svg +0 -22
- package/assets/memoji/sci.svg +0 -22
- package/assets/memoji/su.svg +0 -22
- package/assets/memoji/vi.svg +0 -22
- package/dist/TeamPreview.d.ts +0 -9
- package/dist/TeamPreview.js +0 -305
- package/dist/TeamStory.d.ts +0 -49
- package/dist/TeamStory.js +0 -67
- package/dist/preview.d.ts +0 -84
- package/dist/preview.js +0 -120
- package/dist/workday.d.ts +0 -247
- package/dist/workday.js +0 -642
package/dist/Drive.js
CHANGED
|
@@ -4,7 +4,6 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
|
|
4
4
|
import { ArrowRight, ChevronDown, ChevronRight, Clock, 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';
|
|
5
5
|
import { Box, Button, Text, View, XStack, YStack } from '@hanzo/ui';
|
|
6
6
|
import { useIam, useOrganizations } from '@hanzo/iam/react';
|
|
7
|
-
import { useI18n } from '@hanzo/i18n/react';
|
|
8
7
|
import { useAi } from './lib/ai.js';
|
|
9
8
|
import { empty, useOpen } from './open.js';
|
|
10
9
|
import { attach, channel } from './pane.js';
|
|
@@ -17,14 +16,14 @@ import { weigh as size } from './lib/attach.js';
|
|
|
17
16
|
import { dropped, filesIn, forget, pool, register, search, settled, slug, upload, } from './lib/files.js';
|
|
18
17
|
import { checkoutUrl } from './lib/pay.js';
|
|
19
18
|
import { BAD, mix } from './lib/mix.js';
|
|
20
|
-
const blame = (e
|
|
19
|
+
const blame = (e) => {
|
|
21
20
|
const text = e instanceof Error ? e.message : String(e ?? '');
|
|
22
|
-
return text ||
|
|
21
|
+
return text || 'The store did not say what went wrong.';
|
|
23
22
|
};
|
|
24
23
|
/** A size as a row shows it; nothing is a dash. */
|
|
25
24
|
const weigh = (bytes) => (bytes ? size(bytes) : '—');
|
|
26
25
|
/** Format timestamp */
|
|
27
|
-
const when = (stamp
|
|
26
|
+
const when = (stamp) => {
|
|
28
27
|
if (!stamp)
|
|
29
28
|
return '';
|
|
30
29
|
const ms = stamp < 1e12 ? stamp * 1000 : stamp;
|
|
@@ -32,34 +31,34 @@ const when = (stamp, locale) => {
|
|
|
32
31
|
const now = new Date();
|
|
33
32
|
const sameDay = d.toDateString() === now.toDateString();
|
|
34
33
|
if (sameDay)
|
|
35
|
-
return d.toLocaleTimeString(
|
|
34
|
+
return d.toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' });
|
|
36
35
|
const sameYear = d.getFullYear() === now.getFullYear();
|
|
37
|
-
return d.toLocaleDateString(
|
|
36
|
+
return d.toLocaleDateString([], sameYear ? { month: 'short', day: 'numeric' } : { year: 'numeric', month: 'short', day: 'numeric' });
|
|
38
37
|
};
|
|
39
38
|
/** The store publishes a bucket's own display name; the slug is the fallback. */
|
|
40
|
-
const getBucketDisplayName = (b
|
|
39
|
+
const getBucketDisplayName = (b) => (typeof b === 'string' ? b : b?.displayName || b?.name) || 'Drive';
|
|
41
40
|
const wire = (key) => key.split('/').map(encodeURIComponent).join('/');
|
|
42
41
|
const objects = (bucket) => `/v1/s3/buckets/${encodeURIComponent(bucket)}/objects`;
|
|
43
|
-
async function putBytes(client, bucket, key, body,
|
|
42
|
+
async function putBytes(client, bucket, key, body, type) {
|
|
44
43
|
const grant = await client.http.json({
|
|
45
44
|
method: 'POST',
|
|
46
45
|
path: objects(bucket),
|
|
47
46
|
body: { bucket, key },
|
|
48
47
|
});
|
|
49
48
|
if (!grant?.url)
|
|
50
|
-
throw new Error(
|
|
49
|
+
throw new Error('The store issued no upload address.');
|
|
51
50
|
const sent = await fetch(grant.url, {
|
|
52
51
|
method: grant.method || 'PUT',
|
|
53
52
|
body,
|
|
54
53
|
headers: type ? { 'Content-Type': type } : undefined,
|
|
55
54
|
});
|
|
56
55
|
if (!sent.ok)
|
|
57
|
-
throw new Error(
|
|
56
|
+
throw new Error(`${key.split('/').pop()} did not upload (${sent.status}).`);
|
|
58
57
|
}
|
|
59
|
-
async function urlFor(client, bucket, key
|
|
58
|
+
async function urlFor(client, bucket, key) {
|
|
60
59
|
const grant = await client.http.json({ path: `${objects(bucket)}/${wire(key)}` });
|
|
61
60
|
if (!grant?.url)
|
|
62
|
-
throw new Error(
|
|
61
|
+
throw new Error('The store issued no download address.');
|
|
63
62
|
return grant.url;
|
|
64
63
|
}
|
|
65
64
|
async function remove(client, bucket, key) {
|
|
@@ -96,8 +95,7 @@ const CHIP = { fontSize: '$1', color: '$soft', bg: '$hover', px: 8, py: 2, round
|
|
|
96
95
|
const CELL = { fontSize: '$2', color: '$soft' };
|
|
97
96
|
/** A row's "more" control. */
|
|
98
97
|
function More({ onPress }) {
|
|
99
|
-
|
|
100
|
-
return (_jsx(Button, { variant: "ghost", size: "icon-sm", onClick: onPress, "aria-label": t('More'), title: t('More'), children: _jsx(MoreHorizontal, { size: 15 }) }));
|
|
98
|
+
return (_jsx(Button, { variant: "ghost", size: "icon-sm", onClick: onPress, "aria-label": "More", title: "More", children: _jsx(MoreHorizontal, { size: 15 }) }));
|
|
101
99
|
}
|
|
102
100
|
/** One line of a row's menu: a glyph and a word, the whole width. */
|
|
103
101
|
function Pick({ icon: Icon, label, tone, onPress, }) {
|
|
@@ -116,7 +114,6 @@ const NOTE = { display: 'block', px: 16, py: 24, fontSize: '$2', color: '$faint'
|
|
|
116
114
|
/** The drop target's veil: the page's own ground, nearly opaque. */
|
|
117
115
|
const VEIL = mix('var(--background)', 90, 'srgb');
|
|
118
116
|
export function Drive() {
|
|
119
|
-
const { t, locale } = useI18n();
|
|
120
117
|
const { client } = useAi();
|
|
121
118
|
const { user, isAuthenticated } = useIam();
|
|
122
119
|
const ready = Boolean(client && isAuthenticated);
|
|
@@ -167,8 +164,8 @@ export function Drive() {
|
|
|
167
164
|
: activeWs.path;
|
|
168
165
|
listLocalEntries(targetDir)
|
|
169
166
|
.then((items) => setLocalEntries(items))
|
|
170
|
-
.catch((e) => setFailed(blame(e
|
|
171
|
-
}, [activeWs, localPrefix
|
|
167
|
+
.catch((e) => setFailed(blame(e)));
|
|
168
|
+
}, [activeWs, localPrefix]);
|
|
172
169
|
useEffect(() => {
|
|
173
170
|
if (navSection === 'local') {
|
|
174
171
|
loadLocalEntries();
|
|
@@ -212,11 +209,11 @@ export function Drive() {
|
|
|
212
209
|
client.http
|
|
213
210
|
.json({ path: '/v1/s3/buckets' })
|
|
214
211
|
.then((out) => live && setBuckets(out?.buckets ?? []))
|
|
215
|
-
.catch((e) => live && setFailed(blame(e
|
|
212
|
+
.catch((e) => live && setFailed(blame(e)));
|
|
216
213
|
return () => {
|
|
217
214
|
live = false;
|
|
218
215
|
};
|
|
219
|
-
}, [ready, client, reload
|
|
216
|
+
}, [ready, client, reload]);
|
|
220
217
|
// THE DRIVE IS A BUCKET THE ORG OWNS. It used to fall back to the literal
|
|
221
218
|
// "my-drive", which is a nav label rather than a name the store answers to —
|
|
222
219
|
// so every read 404'd and every write went nowhere.
|
|
@@ -284,8 +281,8 @@ export function Drive() {
|
|
|
284
281
|
void client.http
|
|
285
282
|
.json({ path: `/v1/knowledge/files/${encodeURIComponent(id)}` })
|
|
286
283
|
.then((f) => setContents({ file: f, at }))
|
|
287
|
-
.catch((e) => setFailed(blame(e
|
|
288
|
-
}, [index, client
|
|
284
|
+
.catch((e) => setFailed(blame(e)));
|
|
285
|
+
}, [index, client]);
|
|
289
286
|
/** ASK IN CHAT: a new conversation with the file put into it, by reference. */
|
|
290
287
|
const askInChat = useCallback((f) => {
|
|
291
288
|
if (!client)
|
|
@@ -306,11 +303,11 @@ export function Drive() {
|
|
|
306
303
|
client.http
|
|
307
304
|
.collection('objects', { path: objects(activeBucket), query: { prefix } })
|
|
308
305
|
.then((found) => live && setEntries(found))
|
|
309
|
-
.catch((e) => live && setFailed(blame(e
|
|
306
|
+
.catch((e) => live && setFailed(blame(e)));
|
|
310
307
|
return () => {
|
|
311
308
|
live = false;
|
|
312
309
|
};
|
|
313
|
-
}, [ready, client, activeBucket, prefix
|
|
310
|
+
}, [ready, client, activeBucket, prefix]);
|
|
314
311
|
useEffect(() => {
|
|
315
312
|
loadEntries();
|
|
316
313
|
}, [loadEntries, reload]);
|
|
@@ -351,12 +348,12 @@ export function Drive() {
|
|
|
351
348
|
setReload((n) => n + 1);
|
|
352
349
|
}
|
|
353
350
|
catch (e) {
|
|
354
|
-
setFailed(blame(e
|
|
351
|
+
setFailed(blame(e));
|
|
355
352
|
}
|
|
356
353
|
finally {
|
|
357
354
|
setBusy(null);
|
|
358
355
|
}
|
|
359
|
-
}, [client, activeBucket, busy
|
|
356
|
+
}, [client, activeBucket, busy]);
|
|
360
357
|
// UPLOAD skips the platform: the bytes go straight to the store through
|
|
361
358
|
// presigned PUTs — one for a small file, one per 16 MB part for a large one,
|
|
362
359
|
// resumed from the parts the store holds when a connection drops — several
|
|
@@ -368,18 +365,10 @@ export function Drive() {
|
|
|
368
365
|
const list = Array.from(files);
|
|
369
366
|
if (!list.length || !client || !activeBucket)
|
|
370
367
|
return;
|
|
371
|
-
|
|
372
|
-
const uploading = (percent) => list.length === 1
|
|
373
|
-
? percent === undefined
|
|
374
|
-
? t('Uploading {name}', { name: list[0].name })
|
|
375
|
-
: t('Uploading {name} — {percent}%', { name: list[0].name, percent })
|
|
376
|
-
: percent === undefined
|
|
377
|
-
? t('Uploading {count} files', { count })
|
|
378
|
-
: t('Uploading {count} files — {percent}%', { count, percent });
|
|
379
|
-
void run(uploading(), async (say) => {
|
|
368
|
+
void run(`Uploading ${list.length === 1 ? list[0].name : `${list.length} files`}`, async (say) => {
|
|
380
369
|
const sent = new Map();
|
|
381
370
|
const total = list.reduce((n, f) => n + f.size, 0) || 1;
|
|
382
|
-
const tell = () => say(
|
|
371
|
+
const tell = () => say(`Uploading ${list.length === 1 ? list[0].name : `${list.length} files`} — ${Math.floor(([...sent.values()].reduce((a, b) => a + b, 0) / total) * 100)}%`);
|
|
383
372
|
await pool(list, 3, async (file) => {
|
|
384
373
|
const f = file;
|
|
385
374
|
const key = `${prefix}${f.relative || f.webkitRelativePath || file.name}`;
|
|
@@ -390,7 +379,7 @@ export function Drive() {
|
|
|
390
379
|
await register(client, activeBucket, key);
|
|
391
380
|
});
|
|
392
381
|
});
|
|
393
|
-
}, [client, activeBucket, prefix, run
|
|
382
|
+
}, [client, activeBucket, prefix, run]);
|
|
394
383
|
const handleCreateFolder = useCallback((folderName) => {
|
|
395
384
|
const clean = folderName.trim().replace(/^\/+|\/+$/g, '');
|
|
396
385
|
if (!clean)
|
|
@@ -406,14 +395,14 @@ export function Drive() {
|
|
|
406
395
|
setNaming(null);
|
|
407
396
|
loadLocalEntries();
|
|
408
397
|
})
|
|
409
|
-
.catch((e) => setFailed(blame(e
|
|
398
|
+
.catch((e) => setFailed(blame(e)));
|
|
410
399
|
return;
|
|
411
400
|
}
|
|
412
401
|
if (!client || !activeBucket)
|
|
413
402
|
return;
|
|
414
|
-
void run(
|
|
403
|
+
void run(`Creating ${clean}`, () => putBytes(client, activeBucket, `${prefix}${clean}/`, new Blob([])));
|
|
415
404
|
setNaming(null);
|
|
416
|
-
}, [client, activeBucket, prefix, run, navSection, activeWs, localPrefix, loadLocalEntries
|
|
405
|
+
}, [client, activeBucket, prefix, run, navSection, activeWs, localPrefix, loadLocalEntries]);
|
|
417
406
|
const handleCreateFile = useCallback((fileName) => {
|
|
418
407
|
const clean = fileName.trim().replace(/^\/+|\/+$/g, '');
|
|
419
408
|
if (!clean)
|
|
@@ -430,39 +419,39 @@ export function Drive() {
|
|
|
430
419
|
loadLocalEntries();
|
|
431
420
|
setEditingFile({ path: filePath, name: clean });
|
|
432
421
|
})
|
|
433
|
-
.catch((e) => setFailed(blame(e
|
|
422
|
+
.catch((e) => setFailed(blame(e)));
|
|
434
423
|
return;
|
|
435
424
|
}
|
|
436
425
|
if (!client || !activeBucket)
|
|
437
426
|
return;
|
|
438
|
-
void run(
|
|
427
|
+
void run(`Creating ${clean}`, () => putBytes(client, activeBucket, `${prefix}${clean}`, new Blob([''])));
|
|
439
428
|
setNaming(null);
|
|
440
|
-
}, [client, activeBucket, prefix, run, navSection, activeWs, localPrefix, loadLocalEntries
|
|
429
|
+
}, [client, activeBucket, prefix, run, navSection, activeWs, localPrefix, loadLocalEntries]);
|
|
441
430
|
const handleCloneRepo = useCallback((repoUrl) => {
|
|
442
431
|
const clean = repoUrl.trim();
|
|
443
432
|
if (!clean)
|
|
444
433
|
return;
|
|
445
434
|
setNaming(null);
|
|
446
|
-
void run(
|
|
435
|
+
void run(`Cloning ${clean}`, async () => {
|
|
447
436
|
const ws = await cloneRemoteRepo(clean);
|
|
448
437
|
setNavSection('local');
|
|
449
438
|
setActiveWorkspace(ws);
|
|
450
439
|
setLocalPrefix('');
|
|
451
440
|
loadLocalEntries();
|
|
452
441
|
});
|
|
453
|
-
}, [run, loadLocalEntries
|
|
442
|
+
}, [run, loadLocalEntries]);
|
|
454
443
|
const handleOpenLocalFile = useCallback(async () => {
|
|
455
444
|
try {
|
|
456
445
|
const selected = await pickLocalFile();
|
|
457
446
|
if (selected) {
|
|
458
|
-
const fileName = selected.split(/[/\\]/).pop() ||
|
|
447
|
+
const fileName = selected.split(/[/\\]/).pop() || 'file';
|
|
459
448
|
setEditingFile({ path: selected, name: fileName });
|
|
460
449
|
}
|
|
461
450
|
}
|
|
462
451
|
catch (e) {
|
|
463
|
-
setFailed(blame(e
|
|
452
|
+
setFailed(blame(e));
|
|
464
453
|
}
|
|
465
|
-
}, [
|
|
454
|
+
}, []);
|
|
466
455
|
const handleImportLocalFile = useCallback(async () => {
|
|
467
456
|
if (!activeWs)
|
|
468
457
|
return;
|
|
@@ -477,25 +466,25 @@ export function Drive() {
|
|
|
477
466
|
}
|
|
478
467
|
}
|
|
479
468
|
catch (e) {
|
|
480
|
-
setFailed(blame(e
|
|
469
|
+
setFailed(blame(e));
|
|
481
470
|
}
|
|
482
|
-
}, [activeWs, localPrefix, loadLocalEntries
|
|
471
|
+
}, [activeWs, localPrefix, loadLocalEntries]);
|
|
483
472
|
const handleRename = useCallback((entry, to) => {
|
|
484
473
|
const clean = to.trim().replace(/^\/+|\/+$/g, '');
|
|
485
474
|
if (!clean || !client || !activeBucket || entry.isDir)
|
|
486
475
|
return;
|
|
487
476
|
const from = `${prefix}${entry.key}`;
|
|
488
477
|
// The store has no copy, so a rename is the three verbs it does have.
|
|
489
|
-
void run(
|
|
490
|
-
const src = await fetch(await urlFor(client, activeBucket, from
|
|
478
|
+
void run(`Renaming ${entry.key}`, async () => {
|
|
479
|
+
const src = await fetch(await urlFor(client, activeBucket, from));
|
|
491
480
|
if (!src.ok)
|
|
492
|
-
throw new Error(
|
|
481
|
+
throw new Error(`${entry.key} could not be read (${src.status}).`);
|
|
493
482
|
const body = await src.blob();
|
|
494
|
-
await putBytes(client, activeBucket, `${prefix}${clean}`, body,
|
|
483
|
+
await putBytes(client, activeBucket, `${prefix}${clean}`, body, body.type || undefined);
|
|
495
484
|
await remove(client, activeBucket, from);
|
|
496
485
|
});
|
|
497
486
|
setNaming(null);
|
|
498
|
-
}, [client, activeBucket, prefix, run
|
|
487
|
+
}, [client, activeBucket, prefix, run]);
|
|
499
488
|
const handleDelete = useCallback((entry) => {
|
|
500
489
|
if (!client || !activeBucket)
|
|
501
490
|
return;
|
|
@@ -506,7 +495,7 @@ export function Drive() {
|
|
|
506
495
|
if (f)
|
|
507
496
|
await forget(client, f.id).catch(() => { });
|
|
508
497
|
};
|
|
509
|
-
void run(
|
|
498
|
+
void run(`Deleting ${entry.key}`, async (say) => {
|
|
510
499
|
if (!entry.isDir) {
|
|
511
500
|
await remove(client, activeBucket, key);
|
|
512
501
|
return unindex(key);
|
|
@@ -514,21 +503,21 @@ export function Drive() {
|
|
|
514
503
|
const root = key.endsWith('/') ? key : `${key}/`;
|
|
515
504
|
const out = await client.http.json({ path: objects(activeBucket), query: { prefix: root, recursive: 'true' } });
|
|
516
505
|
for (const e of (out?.objects ?? []).filter((x) => !x.isDir)) {
|
|
517
|
-
say(
|
|
506
|
+
say(`Deleting ${e.key}`);
|
|
518
507
|
await remove(client, activeBucket, root + e.key);
|
|
519
508
|
await unindex(root + e.key);
|
|
520
509
|
}
|
|
521
510
|
await remove(client, activeBucket, root).catch(() => { });
|
|
522
511
|
});
|
|
523
|
-
}, [client, activeBucket, prefix, run, index
|
|
512
|
+
}, [client, activeBucket, prefix, run, index]);
|
|
524
513
|
// DOWNLOAD follows a presigned GET. The object's platform address answers a
|
|
525
514
|
// signed URL, not the bytes, and it needs the caller's token — which an
|
|
526
515
|
// anchor href does not carry.
|
|
527
516
|
const handleDownload = useCallback((entry) => {
|
|
528
517
|
if (!client || !activeBucket || entry.isDir)
|
|
529
518
|
return;
|
|
530
|
-
void run(
|
|
531
|
-
const url = await urlFor(client, activeBucket, `${prefix}${entry.key}
|
|
519
|
+
void run(`Fetching ${entry.key}`, async () => {
|
|
520
|
+
const url = await urlFor(client, activeBucket, `${prefix}${entry.key}`);
|
|
532
521
|
const a = document.createElement('a');
|
|
533
522
|
a.href = url;
|
|
534
523
|
a.download = entry.key.split('/').pop() || 'download';
|
|
@@ -538,14 +527,14 @@ export function Drive() {
|
|
|
538
527
|
a.click();
|
|
539
528
|
document.body.removeChild(a);
|
|
540
529
|
});
|
|
541
|
-
}, [client, activeBucket, prefix, run
|
|
530
|
+
}, [client, activeBucket, prefix, run]);
|
|
542
531
|
const allProjects = useMemo(() => (projects ?? []).map((p) => ({
|
|
543
532
|
id: p.id || p.slug || p.name,
|
|
544
533
|
name: p.name || p.slug || p.id,
|
|
545
|
-
type: p.framework ||
|
|
546
|
-
updated: when(p.updatedAt || p.createdAt || 0
|
|
534
|
+
type: p.framework || 'Project',
|
|
535
|
+
updated: when(p.updatedAt || p.createdAt || 0),
|
|
547
536
|
size: '—',
|
|
548
|
-
})), [projects
|
|
537
|
+
})), [projects]);
|
|
549
538
|
const filteredProjects = useMemo(() => {
|
|
550
539
|
if (!searchQuery.trim())
|
|
551
540
|
return allProjects;
|
|
@@ -603,7 +592,7 @@ export function Drive() {
|
|
|
603
592
|
webkitdirectory: "true", directory: "true", multiple: true, hidden: true, onChange: (e) => {
|
|
604
593
|
handleUpload(e.target.files);
|
|
605
594
|
e.currentTarget.value = '';
|
|
606
|
-
} }), _jsxs(XStack, { height: 56, items: "center", justify: "space-between", px: "$5", borderBottomWidth: 1, borderColor: "$borderColor", shrink: 0, children: [_jsx(XStack, { width: 220, shrink: 1, children: _jsx(View, { display: "none", "$max-md": { display: 'flex' }, children: _jsx(Button, { variant: "ghost", size: "icon-sm", onClick: () => setMenu((v) => !v), "aria-label":
|
|
595
|
+
} }), _jsxs(XStack, { height: 56, items: "center", justify: "space-between", px: "$5", borderBottomWidth: 1, borderColor: "$borderColor", shrink: 0, children: [_jsx(XStack, { width: 220, shrink: 1, children: _jsx(View, { display: "none", "$max-md": { display: 'flex' }, children: _jsx(Button, { variant: "ghost", size: "icon-sm", onClick: () => setMenu((v) => !v), "aria-label": "Drive menu", "aria-expanded": menu, "aria-controls": "drive-menu", title: "Drive menu", children: _jsx(PanelLeft, { size: 16 }) }) }) }), _jsxs(XStack, { items: "center", gap: "$2", width: 460, maxW: "45%", height: 38, px: "$3", rounded: 8, bg: "$panel", borderWidth: 1, borderColor: "var(--border-control)", 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: "Search Drive", "aria-label": "Search Drive" }), ...BARE })] }), _jsxs(XStack, { items: "center", gap: "$3", children: [_jsx(Button, { size: "icon-sm", onClick: () => fileInputRef.current?.click(), "aria-label": "Upload", title: "Upload", children: _jsx(Upload, { size: 15 }) }), _jsx(Button, { size: "icon-sm", onClick: () => setNaming({ kind: 'folder', value: '' }), "aria-label": "Add Folder", title: "Add Folder", children: _jsx(Plus, { size: 16 }) }), _jsx(Text, { ...tip(userEmail), width: 32, height: 32, rounded: 9999, bg: "$raised", borderWidth: 1, borderColor: "$borderColor", display: "flex", 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
596
|
display: menu ? 'flex' : 'none',
|
|
608
597
|
position: 'absolute',
|
|
609
598
|
t: 0,
|
|
@@ -612,15 +601,15 @@ export function Drive() {
|
|
|
612
601
|
z: 'var(--z-drawer)',
|
|
613
602
|
overflowY: 'auto',
|
|
614
603
|
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:
|
|
604
|
+
}, 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: "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: "$borderColor", 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
605
|
setNewMenuOpen(false);
|
|
617
606
|
setMenu(false);
|
|
618
607
|
setNaming({ kind: 'file', value: '' });
|
|
619
|
-
}, children: [_jsx(FilePlus, { size: 14 }),
|
|
608
|
+
}, children: [_jsx(FilePlus, { size: 14 }), "New file"] }), _jsxs(Button, { ...ITEM, onClick: () => {
|
|
620
609
|
setNewMenuOpen(false);
|
|
621
610
|
setMenu(false);
|
|
622
611
|
setNaming({ kind: 'folder', value: '' });
|
|
623
|
-
}, children: [_jsx(FolderPlus, { size: 14 }),
|
|
612
|
+
}, children: [_jsx(FolderPlus, { size: 14 }), "New folder"] }), _jsx(View, { height: 1, bg: "$borderColor", my: 4 }), _jsxs(Button, { ...ITEM, onClick: () => {
|
|
624
613
|
setNewMenuOpen(false);
|
|
625
614
|
setMenu(false);
|
|
626
615
|
void pickLocalFolder().then((ws) => {
|
|
@@ -629,42 +618,42 @@ export function Drive() {
|
|
|
629
618
|
setLocalPrefix('');
|
|
630
619
|
}
|
|
631
620
|
});
|
|
632
|
-
}, children: [_jsx(FolderInput, { size: 14 }),
|
|
621
|
+
}, children: [_jsx(FolderInput, { size: 14 }), "Open local folder\u2026"] }), _jsxs(Button, { ...ITEM, onClick: () => {
|
|
633
622
|
setNewMenuOpen(false);
|
|
634
623
|
setMenu(false);
|
|
635
624
|
void handleOpenLocalFile();
|
|
636
|
-
}, children: [_jsx(FileText, { size: 14 }),
|
|
625
|
+
}, children: [_jsx(FileText, { size: 14 }), "Open local file\u2026"] }), _jsxs(Button, { ...ITEM, onClick: () => {
|
|
637
626
|
setNewMenuOpen(false);
|
|
638
627
|
setMenu(false);
|
|
639
628
|
void handleImportLocalFile();
|
|
640
|
-
}, children: [_jsx(Upload, { size: 14 }),
|
|
629
|
+
}, children: [_jsx(Upload, { size: 14 }), "Import local file\u2026"] }), _jsxs(Button, { ...ITEM, onClick: () => {
|
|
641
630
|
setNewMenuOpen(false);
|
|
642
631
|
setMenu(false);
|
|
643
632
|
setNaming({ kind: 'clone', value: '' });
|
|
644
|
-
}, children: [_jsx(FolderGit2, { size: 14 }),
|
|
633
|
+
}, children: [_jsx(FolderGit2, { size: 14 }), "Clone remote repo\u2026"] })] })) : (_jsxs(_Fragment, { children: [_jsxs(Button, { ...ITEM, onClick: () => {
|
|
645
634
|
setNewMenuOpen(false);
|
|
646
635
|
setMenu(false);
|
|
647
636
|
setNaming({ kind: 'file', value: '' });
|
|
648
|
-
}, children: [_jsx(FilePlus, { size: 14 }),
|
|
637
|
+
}, children: [_jsx(FilePlus, { size: 14 }), "New file"] }), _jsxs(Button, { ...ITEM, onClick: () => {
|
|
649
638
|
setNewMenuOpen(false);
|
|
650
639
|
setMenu(false);
|
|
651
640
|
setNaming({ kind: 'folder', value: '' });
|
|
652
|
-
}, children: [_jsx(FolderPlus, { size: 14 }),
|
|
641
|
+
}, children: [_jsx(FolderPlus, { size: 14 }), "New folder"] }), _jsx(View, { height: 1, bg: "$borderColor", my: 4 }), _jsxs(Button, { ...ITEM, onClick: () => {
|
|
653
642
|
setNewMenuOpen(false);
|
|
654
643
|
setMenu(false);
|
|
655
644
|
fileInputRef.current?.click();
|
|
656
|
-
}, children: [_jsx(Upload, { size: 14 }),
|
|
645
|
+
}, children: [_jsx(Upload, { size: 14 }), "File upload"] }), _jsxs(Button, { ...ITEM, onClick: () => {
|
|
657
646
|
setNewMenuOpen(false);
|
|
658
647
|
setMenu(false);
|
|
659
648
|
folderInputRef.current?.click();
|
|
660
|
-
}, children: [_jsx(FolderInput, { size: 14 }),
|
|
649
|
+
}, children: [_jsx(FolderInput, { size: 14 }), "Folder upload"] }), _jsx(View, { height: 1, bg: "$borderColor", my: 4 }), _jsxs(Button, { ...ITEM, onClick: () => {
|
|
661
650
|
setNewMenuOpen(false);
|
|
662
651
|
setMenu(false);
|
|
663
652
|
setNaming({ kind: 'clone', value: '' });
|
|
664
|
-
}, children: [_jsx(FolderGit2, { size: 14 }),
|
|
665
|
-
{ id: 'my-drive', label:
|
|
666
|
-
{ id: 'local', label:
|
|
667
|
-
{ id: 'recent', label:
|
|
653
|
+
}, children: [_jsx(FolderGit2, { size: 14 }), "Clone remote repo\u2026"] })] })) })) : null] }), _jsx(YStack, { gap: "$1", children: [
|
|
654
|
+
{ id: 'my-drive', label: 'My Drive', icon: HardDrive },
|
|
655
|
+
{ id: 'local', label: 'Local Folders', icon: Laptop },
|
|
656
|
+
{ id: 'recent', label: 'Recent', icon: Clock },
|
|
668
657
|
].map((item) => {
|
|
669
658
|
const isActive = navSection === item.id && !bucket && !prefix;
|
|
670
659
|
const Icon = item.icon;
|
|
@@ -674,7 +663,7 @@ export function Drive() {
|
|
|
674
663
|
setPrefix('');
|
|
675
664
|
setMenu(false);
|
|
676
665
|
}, children: [_jsx(Icon, { size: 16 }), item.label] }, item.id));
|
|
677
|
-
}) }), navSection === 'local' || localWorkspaces.length > 0 ? (_jsxs(YStack, { gap: "$1", pl: "$2", borderLeftWidth: 1, borderColor: "$borderColor", ml: "$3", children: [_jsx(Text, { fontSize: 11, fontWeight: "600", color: "$faint", letterSpacing: 0.5, mb: 2, children:
|
|
666
|
+
}) }), navSection === 'local' || localWorkspaces.length > 0 ? (_jsxs(YStack, { gap: "$1", pl: "$2", borderLeftWidth: 1, borderColor: "$borderColor", ml: "$3", children: [_jsx(Text, { fontSize: 11, fontWeight: "600", color: "$faint", letterSpacing: 0.5, mb: 2, children: "Workspaces" }), localWorkspaces.map((ws) => {
|
|
678
667
|
const isCur = navSection === 'local' && activeWs?.id === ws.id;
|
|
679
668
|
return (_jsxs(XStack, { items: "center", justify: "space-between", px: "$2", py: "$1", rounded: 6, bg: isCur ? '$hover' : 'transparent', hoverStyle: { bg: '$hover' }, cursor: "pointer", onPress: () => {
|
|
680
669
|
setActiveWorkspace(ws);
|
|
@@ -683,7 +672,7 @@ export function Drive() {
|
|
|
683
672
|
}, children: [_jsxs(XStack, { items: "center", gap: "$2", minW: 0, flex: 1, children: [_jsx(Folder, { size: 13, color: isCur ? 'var(--primary)' : '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", onClick: (e) => {
|
|
684
673
|
e.stopPropagation();
|
|
685
674
|
removeLocalWorkspace(ws.id);
|
|
686
|
-
}, title:
|
|
675
|
+
}, title: "Remove", children: _jsx(Trash2, { size: 11, color: "var(--muted-foreground)" }) })] }, ws.id));
|
|
687
676
|
}), _jsxs(Button, { variant: "ghost", size: "sm", justify: "flex-start", gap: 6, px: 8, py: 4, color: "$soft", onClick: () => {
|
|
688
677
|
void pickLocalFolder().then((ws) => {
|
|
689
678
|
if (ws) {
|
|
@@ -691,31 +680,21 @@ export function Drive() {
|
|
|
691
680
|
setLocalPrefix('');
|
|
692
681
|
}
|
|
693
682
|
});
|
|
694
|
-
}, children: [_jsx(Plus, { size: 13 }), _jsx(Text, { fontSize: "$1", color: "$soft", children:
|
|
695
|
-
? usage.capped
|
|
696
|
-
? t(usage.files === 1 ? 'over {size} in {count} file' : 'over {size} in {count} files', {
|
|
697
|
-
size: weigh(usage.bytes),
|
|
698
|
-
count: usage.files.toLocaleString(locale),
|
|
699
|
-
})
|
|
700
|
-
: t(usage.files === 1 ? '{size} in {count} file' : '{size} in {count} files', {
|
|
701
|
-
size: weigh(usage.bytes),
|
|
702
|
-
count: usage.files.toLocaleString(locale),
|
|
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: () => {
|
|
683
|
+
}, children: [_jsx(Plus, { size: 13 }), _jsx(Text, { fontSize: "$1", color: "$soft", children: "Open folder\u2026" })] })] })) : null, _jsxs(YStack, { gap: "$2", mt: "$2", px: "$2", children: [_jsx(Text, { fontSize: 11, fontWeight: "600", color: "$faint", letterSpacing: 0.6, children: "Storage" }), _jsx(Text, { fontSize: 12, color: "$quiet", children: usage ? `${usage.capped ? 'over ' : ''}${weigh(usage.bytes)} in ${usage.files.toLocaleString()} file${usage.files === 1 ? '' : 's'}` : 'Measuring…' }), _jsx(Button, { asChild: true, size: "sm", mt: 8, children: _jsx("a", { href: checkoutUrl(), target: "_blank", rel: "noreferrer", children: "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: "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: ["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: () => {
|
|
705
684
|
setLocalPrefix('');
|
|
706
|
-
}, children:
|
|
685
|
+
}, children: "Local Folders" }), _jsx(ChevronRight, { size: 13, color: "var(--muted-foreground)" }), _jsx(Button, { ...CRUMB, color: !localPrefix ? '$ink' : '$soft', onClick: () => setLocalPrefix(''), children: activeWs.name }), localPrefix
|
|
707
686
|
? 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
687
|
: null] })) : bucket || prefix ? (_jsxs(XStack, { items: "center", gap: "$2", pb: "$2", borderBottomWidth: 1, borderColor: "$borderColor", children: [_jsx(Button, { ...CRUMB, color: "$soft", onClick: () => {
|
|
709
688
|
openBucket(null);
|
|
710
689
|
setPrefix('');
|
|
711
|
-
}, children:
|
|
690
|
+
}, children: "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: 26, fontWeight: "700", color: "$ink", children: navSection === 'local' ? (activeWs ? activeWs.name : 'Local Folders') : 'Drive' }), _jsx(Text, { fontSize: 13, color: "$soft", children: navSection === 'local'
|
|
712
691
|
? activeWs
|
|
713
692
|
? activeWs.path
|
|
714
|
-
:
|
|
715
|
-
:
|
|
716
|
-
['list',
|
|
717
|
-
['grid',
|
|
718
|
-
['details',
|
|
693
|
+
: 'Edit local files, add files & folders, and code locally.'
|
|
694
|
+
: 'Secure. Private. Built for builders.' })] }), _jsx(XStack, { items: "center", bg: "$panel", rounded: 8, borderWidth: 1, borderColor: "$borderColor", p: 2, gap: 2, children: [
|
|
695
|
+
['list', 'List View', List],
|
|
696
|
+
['grid', 'Grid View', LayoutGrid],
|
|
697
|
+
['details', 'Details View', MoreHorizontal],
|
|
719
698
|
].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) => {
|
|
720
699
|
if (e.key === 'Escape')
|
|
721
700
|
setNaming(null);
|
|
@@ -728,34 +707,34 @@ export function Drive() {
|
|
|
728
707
|
handleCreateFolder(naming.value);
|
|
729
708
|
}
|
|
730
709
|
}, placeholder: naming.kind === 'file'
|
|
731
|
-
?
|
|
710
|
+
? 'File name (e.g. index.ts)'
|
|
732
711
|
: naming.kind === 'clone'
|
|
733
|
-
?
|
|
734
|
-
:
|
|
735
|
-
?
|
|
712
|
+
? 'owner/repo or Git URL (e.g. hanzoai/desktop)'
|
|
713
|
+
: 'Folder name', "aria-label": naming.kind === 'file'
|
|
714
|
+
? 'File name'
|
|
736
715
|
: naming.kind === 'clone'
|
|
737
|
-
?
|
|
738
|
-
:
|
|
716
|
+
? 'Clone remote repository'
|
|
717
|
+
: 'Folder name' }), ...BARE }), _jsx(Button, { variant: "primary", size: "sm", onClick: () => {
|
|
739
718
|
if (naming.kind === 'file')
|
|
740
719
|
handleCreateFile(naming.value);
|
|
741
720
|
else if (naming.kind === 'clone')
|
|
742
721
|
handleCloneRepo(naming.value);
|
|
743
722
|
else
|
|
744
723
|
handleCreateFolder(naming.value);
|
|
745
|
-
}, children:
|
|
724
|
+
}, children: naming.kind === 'clone' ? 'Clone' : 'Create' }), _jsx(Button, { variant: "ghost", size: "sm", color: "$soft", onClick: () => setNaming(null), children: "Cancel" })] })) : null, editingFile ? (_jsx(Editor, { filePath: editingFile.path, fileName: editingFile.name, onClose: () => {
|
|
746
725
|
setEditingFile(null);
|
|
747
726
|
loadLocalEntries();
|
|
748
727
|
}, onAskInChat: () => {
|
|
749
728
|
setEditingFile(null);
|
|
750
729
|
router.push('/chat');
|
|
751
|
-
} })) : null, busy ? (
|
|
730
|
+
} })) : null, busy ? (_jsxs(Text, { fontSize: "$2", color: "$soft", "data-slot": "drive-busy", children: [busy, "\u2026"] })) : 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: "$borderColor", rounded: 12, bg: "$panel", children: [_jsx(Laptop, { size: 40, color: "var(--primary)" }), _jsxs(YStack, { items: "center", gap: "$1", maxW: 460, children: [_jsx(Text, { fontSize: 18, fontWeight: "600", color: "$ink", text: "center", children: "No local folder opened" }), _jsx(Text, { fontSize: 13, color: "$soft", text: "center", children: "Open a local folder on your computer to browse, create, edit, and save files directly in Hanzo Desktop." })] }), _jsxs(XStack, { items: "center", gap: "$2", children: [_jsxs(Button, { onClick: () => {
|
|
752
731
|
void pickLocalFolder().then((ws) => {
|
|
753
732
|
if (ws) {
|
|
754
733
|
setNavSection('local');
|
|
755
734
|
setLocalPrefix('');
|
|
756
735
|
}
|
|
757
736
|
});
|
|
758
|
-
}, children: [_jsx(FolderPlus, { size: 16 }),
|
|
737
|
+
}, children: [_jsx(FolderPlus, { size: 16 }), "Open Local Folder\u2026"] }), _jsxs(Button, { variant: "outline", onClick: () => setNaming({ kind: 'clone', value: '' }), children: [_jsx(FolderGit2, { size: 16 }), "Clone Remote Repo\u2026"] })] })] })) : (_jsxs(YStack, { gap: "$2", children: [_jsxs(XStack, { items: "center", justify: "space-between", pb: "$1", children: [_jsx(Text, { fontSize: 12, fontWeight: "600", color: "$soft", children: localPrefix ? `Folder: ${localPrefix}` : 'Root Files & Directories' }), _jsxs(XStack, { items: "center", gap: "$2", children: [_jsxs(Button, { variant: "outline", size: "sm", onClick: () => setNaming({ kind: 'file', value: '' }), children: [_jsx(FilePlus, { size: 13 }), "New file"] }), _jsxs(Button, { variant: "outline", size: "sm", onClick: () => setNaming({ kind: 'folder', value: '' }), children: [_jsx(FolderPlus, { size: 13 }), "New folder"] }), _jsxs(Button, { variant: "outline", size: "sm", onClick: () => void handleImportLocalFile(), children: [_jsx(Upload, { size: 13 }), "Import file"] }), _jsxs(Button, { variant: "outline", size: "sm", onClick: () => setNaming({ kind: 'clone', value: '' }), children: [_jsx(FolderGit2, { size: 13 }), "Clone repo"] })] })] }), _jsxs(YStack, { borderWidth: 1, borderColor: "$borderColor", rounded: 8, overflowX: "auto", overflowY: "hidden", children: [_jsxs(View, { display: "grid", gridTemplateColumns: FILES, minW: "min-content", px: 16, py: 10, borderBottomWidth: 1, borderColor: "$borderColor", children: [_jsx(Text, { ...HEAD, children: "Name" }), _jsx(Text, { ...HEAD, children: "Type" }), _jsx(Text, { ...HEAD, children: "Updated" }), _jsx(Text, { ...HEAD, children: "Size" }), _jsx(View, {})] }), !localEntries || localEntries.length === 0 ? (_jsx(Text, { py: 36, px: 16, text: "center", fontSize: "$2", color: "$faint", children: "Empty folder" })) : (localEntries.map((e) => {
|
|
759
738
|
const ext = e.name.split('.').pop() || '';
|
|
760
739
|
return (_jsxs(View, { display: "grid", gridTemplateColumns: FILES, minW: "min-content", px: 16, py: 11, items: "center", cursor: "pointer", borderBottomWidth: 1, borderColor: "$borderColor", transition: "100ms", hoverStyle: { bg: '$hover' }, onClick: () => {
|
|
761
740
|
if (e.isDir) {
|
|
@@ -764,19 +743,19 @@ export function Drive() {
|
|
|
764
743
|
else {
|
|
765
744
|
setEditingFile({ path: e.path, name: e.name });
|
|
766
745
|
}
|
|
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(Text, { fontSize: "$2", color: "$soft", numberOfLines: 1, children: e.isDir ?
|
|
746
|
+
}, 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(Text, { fontSize: "$2", color: "$soft", numberOfLines: 1, children: e.isDir ? 'Folder' : ext.toUpperCase() || 'File' }), _jsx(Text, { ...CELL, children: e.lastModified ? when(e.lastModified) : '—' }), _jsx(Text, { ...CELL, children: e.isDir ? '—' : weigh(e.size) }), _jsxs(View, { position: "relative", onClick: (evt) => evt.stopPropagation(), children: [_jsx(More, { onPress: (evt) => {
|
|
768
747
|
evt.stopPropagation();
|
|
769
748
|
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: "$borderColor", rounded: 8, boxShadow: "var(--shadow-lg)", p: 4, gap: 2, children: [!e.isDir ? (_jsx(Pick, { icon: FileCode, label:
|
|
749
|
+
} }), itemMenuKey === e.path ? (_jsxs(YStack, { position: "absolute", r: 0, t: "100%", z: "var(--z-dropdown)", width: 160, bg: "var(--popover)", borderWidth: 1, borderColor: "$borderColor", rounded: 8, boxShadow: "var(--shadow-lg)", p: 4, gap: 2, children: [!e.isDir ? (_jsx(Pick, { icon: FileCode, label: "Edit file", onPress: () => {
|
|
771
750
|
setItemMenuKey(null);
|
|
772
751
|
setEditingFile({ path: e.path, name: e.name });
|
|
773
|
-
} })) : null, _jsx(Pick, { icon: Trash2, label:
|
|
752
|
+
} })) : null, _jsx(Pick, { icon: Trash2, label: "Delete", tone: BAD, onPress: () => {
|
|
774
753
|
setItemMenuKey(null);
|
|
775
754
|
deleteLocalPath(e.path)
|
|
776
755
|
.then(() => loadLocalEntries())
|
|
777
|
-
.catch((err) => setFailed(blame(err
|
|
756
|
+
.catch((err) => setFailed(blame(err)));
|
|
778
757
|
} })] })) : null] })] }, e.path));
|
|
779
|
-
}))] })] }))) : bucket || prefix ? (_jsx(YStack, { gap: "$2", children: _jsxs(YStack, { borderWidth: 1, borderColor: "$borderColor", rounded: 8, overflowX: "auto", overflowY: "hidden", children: [_jsxs(View, { display: "grid", gridTemplateColumns: FILES, minW: "min-content", px: 16, py: 10, borderBottomWidth: 1, borderColor: "$borderColor", children: [_jsx(Text, { ...HEAD, children:
|
|
758
|
+
}))] })] }))) : bucket || prefix ? (_jsx(YStack, { gap: "$2", children: _jsxs(YStack, { borderWidth: 1, borderColor: "$borderColor", rounded: 8, overflowX: "auto", overflowY: "hidden", children: [_jsxs(View, { display: "grid", gridTemplateColumns: FILES, minW: "min-content", px: 16, py: 10, borderBottomWidth: 1, borderColor: "$borderColor", children: [_jsx(Text, { ...HEAD, children: "NAME" }), _jsx(Text, { ...HEAD, children: "TYPE" }), _jsx(Text, { ...HEAD, children: "UPDATED \u2193" }), _jsx(Text, { ...HEAD, children: "SIZE" }), _jsx(View, {})] }), !filteredEntries || filteredEntries.length === 0 ? (_jsx(Text, { py: 36, px: 16, text: "center", fontSize: "$2", color: "$faint", children: "None" })) : (filteredEntries.map((e) => {
|
|
780
759
|
const isFolder = e.isDir || e.key.endsWith('/');
|
|
781
760
|
const cleanName = e.key.replace(/\/+$/, '');
|
|
782
761
|
return (_jsxs(View, { display: "grid", gridTemplateColumns: FILES, minW: "min-content", px: 16, py: 11, items: "center", cursor: "pointer", borderBottomWidth: 1, borderColor: "$borderColor", transition: "100ms", hoverStyle: { bg: '$hover' }, onClick: () => {
|
|
@@ -786,28 +765,28 @@ export function Drive() {
|
|
|
786
765
|
else {
|
|
787
766
|
handleDownload(e);
|
|
788
767
|
}
|
|
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 ?
|
|
768
|
+
}, 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 ? 'Folder' : cleanName.split('.').pop()?.toUpperCase() || 'File' }) }), _jsx(Text, { ...CELL, children: when(e.lastModified) }), _jsx(Text, { ...CELL, children: weigh(e.size) }), _jsxs(View, { position: "relative", items: "flex-start", children: [_jsx(More, { onPress: (ev) => {
|
|
790
769
|
ev.stopPropagation();
|
|
791
770
|
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: "$borderColor", rounded: 8, boxShadow: "var(--shadow-lg)", z: "var(--z-dropdown)", p: 4, minW: 140, onClick: (ev) => ev.stopPropagation(), children: [!isFolder && index.get(prefix + e.key) ? (_jsxs(_Fragment, { children: [_jsx(Pick, { icon: ListTree, label:
|
|
771
|
+
} }), itemMenuKey === e.key ? (_jsxs(YStack, { position: "absolute", r: 0, t: "100%", bg: "var(--popover)", borderWidth: 1, borderColor: "$borderColor", rounded: 8, boxShadow: "var(--shadow-lg)", z: "var(--z-dropdown)", p: 4, minW: 140, onClick: (ev) => ev.stopPropagation(), children: [!isFolder && index.get(prefix + e.key) ? (_jsxs(_Fragment, { children: [_jsx(Pick, { icon: ListTree, label: "Contents", onPress: () => {
|
|
793
772
|
setItemMenuKey(null);
|
|
794
773
|
setContents({ file: index.get(prefix + e.key) });
|
|
795
|
-
} }), _jsx(Pick, { icon: MessageSquare, label:
|
|
774
|
+
} }), _jsx(Pick, { icon: MessageSquare, label: "Ask in chat", onPress: () => {
|
|
796
775
|
setItemMenuKey(null);
|
|
797
776
|
askInChat(index.get(prefix + e.key));
|
|
798
|
-
} })] })) : null, !isFolder ? (_jsx(Pick, { icon: Download, label:
|
|
777
|
+
} })] })) : null, !isFolder ? (_jsx(Pick, { icon: Download, label: "Download", onPress: () => {
|
|
799
778
|
setItemMenuKey(null);
|
|
800
779
|
handleDownload(e);
|
|
801
|
-
} })) : null, _jsx(Pick, { icon: Trash2, label:
|
|
780
|
+
} })) : null, _jsx(Pick, { icon: Trash2, label: "Delete", tone: BAD, onPress: () => {
|
|
802
781
|
setItemMenuKey(null);
|
|
803
782
|
handleDelete(e);
|
|
804
783
|
} })] })) : null] })] }, e.key));
|
|
805
|
-
}))] }) })) : (_jsxs(_Fragment, { children: [_jsxs(YStack, { gap: "$2.5", children: [_jsx(Text, { fontSize: 12, fontWeight: "600", color: "$soft", children:
|
|
784
|
+
}))] }) })) : (_jsxs(_Fragment, { children: [_jsxs(YStack, { gap: "$2.5", children: [_jsx(Text, { fontSize: 12, fontWeight: "600", color: "$soft", children: "Storage Buckets" }), _jsx(YStack, { borderWidth: 1, borderColor: "$borderColor", rounded: 8, overflowX: "auto", overflowY: "hidden", children: failed ? (_jsxs(Text, { ...NOTE, children: [failed, _jsx(Button, { size: "sm", mx: "auto", mt: 10, onClick: () => {
|
|
806
785
|
setFailed(null);
|
|
807
786
|
setReload((n) => n + 1);
|
|
808
|
-
}, children:
|
|
787
|
+
}, children: "Try again" })] })) : !buckets ? (_jsx(Text, { ...NOTE, children: "Reading your storage\u2026" })) : buckets.length === 0 ? (_jsx(Text, { ...NOTE, children: "No buckets yet." })) : (buckets.map((b) => (_jsxs(XStack, { onClick: () => openBucket(b.name), items: "center", justify: "space-between", px: 16, py: 12, cursor: "pointer", bg: "transparent", transition: "100ms", hoverStyle: { bg: '$hover' }, children: [_jsxs(XStack, { items: "center", gap: "$2.5", children: [_jsx(Folder, { size: 17, color: "var(--foreground)" }), _jsx(Text, { fontSize: "$2", fontWeight: "500", color: "$ink", children: getBucketDisplayName(b) })] }), _jsxs(XStack, { items: "center", gap: "$4", children: [_jsx(Text, { fontSize: "$2", color: "$faint", children: when(b.createdAt) }), _jsx(More, { onPress: (e) => e.stopPropagation() })] })] }, b.name)))) })] }), _jsxs(YStack, { gap: "$2.5", children: [_jsx(Text, { fontSize: 12, fontWeight: "600", color: "$soft", children: "Projects (Unified VFS)" }), _jsxs(YStack, { borderWidth: 1, borderColor: "$borderColor", rounded: 8, overflowX: "auto", overflowY: "hidden", children: [_jsxs(View, { display: "grid", gridTemplateColumns: PROJECTS, minW: "min-content", px: 16, py: 10, borderBottomWidth: 1, borderColor: "$borderColor", children: [_jsx(Text, { ...HEAD, children: "NAME" }), _jsx(Text, { ...HEAD, children: "TYPE" }), _jsx(Text, { ...HEAD, children: "UPDATED \u2193" }), _jsx(Text, { ...HEAD, children: "SIZE" }), _jsx(View, {})] }), filteredProjects.length === 0 ? (_jsx(Text, { py: 36, px: 16, text: "center", fontSize: "$2", color: "$faint", children: "None" })) : (filteredProjects.map((p) => (_jsxs(View, { onClick: () => {
|
|
809
788
|
const targetBucket = buckets[0]?.name || 'hanzo';
|
|
810
789
|
openBucket(targetBucket);
|
|
811
790
|
setPrefix(`projects/${p.name || p.id}/`);
|
|
812
|
-
}, display: "grid", gridTemplateColumns: PROJECTS, minW: "min-content", px: 16, py: 11, items: "center", cursor: "pointer", borderBottomWidth: 1, borderColor: "$borderColor", transition: "100ms", hoverStyle: { bg: '$hover' }, 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(View, { items: "flex-start", children: _jsx(More, { onPress: (e) => e.stopPropagation() }) })] }, p.id))))] })] })] }))] })] }), 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: 1000, 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" }),
|
|
791
|
+
}, display: "grid", gridTemplateColumns: PROJECTS, minW: "min-content", px: 16, py: 11, items: "center", cursor: "pointer", borderBottomWidth: 1, borderColor: "$borderColor", transition: "100ms", hoverStyle: { bg: '$hover' }, 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(View, { items: "flex-start", children: _jsx(More, { onPress: (e) => e.stopPropagation() }) })] }, p.id))))] })] })] }))] })] }), 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: 1000, 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" }), _jsxs(Text, { fontSize: "$4", fontWeight: "600", color: "$ink", children: ["Drop files to upload to ", bucket || workspace] })] }) })) : null] }));
|
|
813
792
|
}
|