@brftech/filex-core 0.31.0 → 0.32.0
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/README.md +26 -2
- package/dist/filex-core.js +9289 -8103
- package/dist/filex-core.js.map +1 -1
- package/dist/filex-core.umd.cjs +49 -49
- package/dist/filex-core.umd.cjs.map +1 -1
- package/dist/index.d.ts +186 -8
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/FileExplorer.vue +510 -12
- package/src/components/CommandPalette.vue +18 -2
- package/src/components/E2eRecoveryUnlockModal.vue +29 -4
- package/src/components/FilterBar.vue +244 -0
- package/src/components/GalleryView.vue +11 -0
- package/src/components/GridView.vue +46 -3
- package/src/components/InspectorPanel.vue +231 -8
- package/src/components/ListView.vue +10 -1
- package/src/components/SecondaryPane.vue +15 -1
- package/src/components/SideNav.vue +161 -1
- package/src/components/Toolbar.vue +235 -49
- package/src/components/ViewSwitcher.vue +81 -0
- package/src/composables/useFileApi.ts +45 -0
- package/src/index.ts +6 -0
- package/src/lib/e2ecrypto.ts +191 -3
- package/src/lib/fileFilters.ts +143 -0
- package/src/lib/listing.ts +47 -0
- package/src/locales/en.ts +83 -0
- package/src/locales/tr.ts +83 -0
- package/src/modals/PermissionsModal.vue +18 -2
- package/src/styles/base.css +491 -0
- package/src/types/ExplorerConfig.ts +17 -1
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* The panel is mounted with v-if by the host — closed state leaves zero DOM.
|
|
25
25
|
*/
|
|
26
26
|
import { computed, ref, watch } from 'vue';
|
|
27
|
-
import type { FileApi, NodeVersion } from '../composables/useFileApi';
|
|
27
|
+
import type { FileApi, Grant, NodeVersion } from '../composables/useFileApi';
|
|
28
28
|
import type { FileNode, ShareInfo } from '../types/FileNode';
|
|
29
29
|
import type { LocaleCode } from '../types/ExplorerConfig';
|
|
30
30
|
import { useLocale } from '../composables/useLocale';
|
|
@@ -45,10 +45,28 @@ const props = defineProps<{
|
|
|
45
45
|
narrow?: boolean;
|
|
46
46
|
/** Authenticated thumbnail resolver (useThumbs.src). Optional. */
|
|
47
47
|
thumbSrc?: (n: FileNode) => string | null;
|
|
48
|
+
/* === surucu:d1 — the Drive shell's details panel ===================== */
|
|
49
|
+
/**
|
|
50
|
+
* Split the panel into **Details** and **Activity** tabs, and draw the two
|
|
51
|
+
* sections the mockups add: who has access, and the share link with a
|
|
52
|
+
* "Create link" button. `uiProfile: 'drive'` turns it on; absent/false is
|
|
53
|
+
* the flat scroll of sections this panel has always been, with no extra
|
|
54
|
+
* request made.
|
|
55
|
+
*
|
|
56
|
+
* ⚠ "Activity" is version history + comments, and nothing else, because
|
|
57
|
+
* nothing else exists: there is no per-file activity endpoint. The audit log
|
|
58
|
+
* is admin-only, has no path filter, and stores an EMPTY `target_id` for
|
|
59
|
+
* every file action (auth/audit_middleware.go) — so "Ayşe renamed this on
|
|
60
|
+
* Tuesday" cannot be answered by this server, and a timeline that made it up
|
|
61
|
+
* would be worse than the two real feeds.
|
|
62
|
+
*/
|
|
63
|
+
tabs?: boolean;
|
|
48
64
|
}>();
|
|
49
65
|
|
|
50
66
|
const emit = defineEmits<{
|
|
51
67
|
(e: 'close'): void;
|
|
68
|
+
/** surucu:d1 — a share link was minted from the panel. */
|
|
69
|
+
(e: 'share-created', payload: { path: string; url: string }): void;
|
|
52
70
|
(e: 'manage-permissions', node: FileNode): void;
|
|
53
71
|
(e: 'toast', message: string): void;
|
|
54
72
|
/** Fired after a successful restore/snapshot so the host can reload. */
|
|
@@ -239,6 +257,107 @@ async function takeSnapshot(): Promise<void> {
|
|
|
239
257
|
}
|
|
240
258
|
}
|
|
241
259
|
|
|
260
|
+
/* === surucu:d1 — tabs, people with access, the share-link row ==========
|
|
261
|
+
*
|
|
262
|
+
* The tab strip is presentation only: every section below is the same section,
|
|
263
|
+
* rendered under Details or under Activity. Nothing is fetched twice, and
|
|
264
|
+
* nothing new is fetched at all unless `tabs` is on.
|
|
265
|
+
*/
|
|
266
|
+
type InspectorTab = 'details' | 'activity';
|
|
267
|
+
const tab = ref<InspectorTab>('details');
|
|
268
|
+
|
|
269
|
+
/** People with access — `GET /api/files/permissions?path=…`.
|
|
270
|
+
*
|
|
271
|
+
* ⚠ Owner-gated on the server (handlers/grants.go `requireOwner`), so an
|
|
272
|
+
* editor or a viewer gets a 403 for a file they can perfectly well see. That
|
|
273
|
+
* is the server's call, not something to route around: the section hides,
|
|
274
|
+
* exactly the way the shares list already hides for the same class of caller.
|
|
275
|
+
* What it must NOT do is render an empty "People with access" and let the
|
|
276
|
+
* reader conclude that nobody has any.
|
|
277
|
+
*/
|
|
278
|
+
const peopleState = ref<SectionState>('hidden');
|
|
279
|
+
const people = ref<Grant[]>([]);
|
|
280
|
+
let peopleSeq = 0;
|
|
281
|
+
|
|
282
|
+
async function loadPeople(): Promise<void> {
|
|
283
|
+
const seq = ++peopleSeq;
|
|
284
|
+
const node = single.value;
|
|
285
|
+
if (!props.tabs || !node) {
|
|
286
|
+
peopleState.value = 'hidden';
|
|
287
|
+
people.value = [];
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
peopleState.value = 'loading';
|
|
291
|
+
try {
|
|
292
|
+
const r = await props.api.listPermissions(node.path);
|
|
293
|
+
if (seq !== peopleSeq) return;
|
|
294
|
+
// RBAC off on this storage → there are no grants, and a section reading
|
|
295
|
+
// "nobody" would misdescribe a drive where everyone can already read it.
|
|
296
|
+
if (!r.storage_rbac) {
|
|
297
|
+
peopleState.value = 'hidden';
|
|
298
|
+
people.value = [];
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
people.value = [...(r.direct ?? []), ...(r.inherited ?? [])];
|
|
302
|
+
peopleState.value = 'ok';
|
|
303
|
+
} catch {
|
|
304
|
+
if (seq !== peopleSeq) return;
|
|
305
|
+
people.value = [];
|
|
306
|
+
peopleState.value = 'hidden';
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function personName(g: Grant): string {
|
|
311
|
+
return g.user_display_name || g.user_email || `#${g.user_id}`;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
function personInitial(g: Grant): string {
|
|
315
|
+
const n = personName(g).trim();
|
|
316
|
+
return n ? n[0].toUpperCase() : '?';
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/** The share-link row: the first live link, or the Create button. */
|
|
320
|
+
const primaryShare = computed(() => (shares.value.length ? shares.value[0] : null));
|
|
321
|
+
const shareBusy = ref(false);
|
|
322
|
+
|
|
323
|
+
async function createLink(): Promise<void> {
|
|
324
|
+
const node = single.value;
|
|
325
|
+
if (!node || shareBusy.value) return;
|
|
326
|
+
shareBusy.value = true;
|
|
327
|
+
try {
|
|
328
|
+
const r = await props.api.createShare({ path: node.path });
|
|
329
|
+
const url = r.share?.url ?? '';
|
|
330
|
+
// Re-read the list rather than push the response into it: the LIST
|
|
331
|
+
// endpoint is what a later copy or revoke acts on, and its `uuid` is the
|
|
332
|
+
// numeric id the DELETE route wants — not the token the create response
|
|
333
|
+
// carries under that name.
|
|
334
|
+
const { shares: list } = await props.api.listShares(node.path);
|
|
335
|
+
shares.value = Array.isArray(list) ? list : [];
|
|
336
|
+
sharesState.value = 'ok';
|
|
337
|
+
if (url) {
|
|
338
|
+
emit('share-created', { path: node.path, url });
|
|
339
|
+
await copyText(url);
|
|
340
|
+
}
|
|
341
|
+
} catch (err) {
|
|
342
|
+
emit('toast', (err as Error).message);
|
|
343
|
+
} finally {
|
|
344
|
+
shareBusy.value = false;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
watch(
|
|
349
|
+
() => [props.nodes.map((n) => n.path).join('|'), props.tabs] as const,
|
|
350
|
+
() => void loadPeople(),
|
|
351
|
+
{ immediate: true },
|
|
352
|
+
);
|
|
353
|
+
|
|
354
|
+
/* Versions and comments are the two real feeds; when a selection has neither,
|
|
355
|
+
* the Activity tab says so instead of showing two empty headings. */
|
|
356
|
+
const activityUsable = computed(
|
|
357
|
+
() => versionsState.value !== 'hidden' || commentsState.value !== 'hidden',
|
|
358
|
+
);
|
|
359
|
+
/* === /surucu:d1 === */
|
|
360
|
+
|
|
242
361
|
watch(
|
|
243
362
|
() => props.nodes.map((n) => n.path).join(''),
|
|
244
363
|
() => void refresh(),
|
|
@@ -372,9 +491,32 @@ watch(
|
|
|
372
491
|
>×</button>
|
|
373
492
|
</header>
|
|
374
493
|
|
|
494
|
+
<!-- surucu:d1 — Details / Activity. Rendered only in the drive shell; the
|
|
495
|
+
classic panel keeps its single flat scroll of sections. -->
|
|
496
|
+
<div v-if="tabs" class="fe-inspector__tabs" role="tablist" :aria-label="t('inspector.title')">
|
|
497
|
+
<button
|
|
498
|
+
type="button"
|
|
499
|
+
class="fe-inspector__tab"
|
|
500
|
+
:class="{ 'is-active': tab === 'details' }"
|
|
501
|
+
role="tab"
|
|
502
|
+
:aria-selected="tab === 'details'"
|
|
503
|
+
data-testid="inspector-tab-details"
|
|
504
|
+
@click="tab = 'details'"
|
|
505
|
+
>{{ t('inspector.tab.details') }}</button>
|
|
506
|
+
<button
|
|
507
|
+
type="button"
|
|
508
|
+
class="fe-inspector__tab"
|
|
509
|
+
:class="{ 'is-active': tab === 'activity' }"
|
|
510
|
+
role="tab"
|
|
511
|
+
:aria-selected="tab === 'activity'"
|
|
512
|
+
data-testid="inspector-tab-activity"
|
|
513
|
+
@click="tab = 'activity'"
|
|
514
|
+
>{{ t('inspector.tab.activity') }}</button>
|
|
515
|
+
</div>
|
|
516
|
+
|
|
375
517
|
<div class="fe-inspector__scroll">
|
|
376
518
|
<!-- ══ Genel ══ -->
|
|
377
|
-
<section class="fe-inspector__section">
|
|
519
|
+
<section v-if="!tabs || tab === 'details'" class="fe-inspector__section">
|
|
378
520
|
<h3 class="fe-inspector__heading">{{ t('inspector.section.general') }}</h3>
|
|
379
521
|
|
|
380
522
|
<!-- Multi selection → summary -->
|
|
@@ -457,7 +599,7 @@ watch(
|
|
|
457
599
|
|
|
458
600
|
<!-- ══ Sürümler ══ -->
|
|
459
601
|
<section
|
|
460
|
-
v-if="versionsState === 'ok' || versionsState === 'error'"
|
|
602
|
+
v-if="(versionsState === 'ok' || versionsState === 'error') && (!tabs || tab === 'activity')"
|
|
461
603
|
class="fe-inspector__section"
|
|
462
604
|
>
|
|
463
605
|
<h3 class="fe-inspector__heading">{{ t('inspector.section.versions') }}</h3>
|
|
@@ -519,7 +661,21 @@ watch(
|
|
|
519
661
|
</section>
|
|
520
662
|
|
|
521
663
|
<!-- ══ İzinler ══ -->
|
|
522
|
-
|
|
664
|
+
<!-- ⚠ surucu:d1 — stands down when "People with access" is on screen. The
|
|
665
|
+
two say the same thing there (your own row is in the roster, with the
|
|
666
|
+
same level) and each carries its own button into the SAME modal —
|
|
667
|
+
two doors into one room, six lines apart. It stays for every other
|
|
668
|
+
case, which is exactly the case where People is hidden: RBAC off on
|
|
669
|
+
the storage, or the server refusing the grant list to a non-owner. -->
|
|
670
|
+
<section
|
|
671
|
+
v-if="
|
|
672
|
+
single &&
|
|
673
|
+
effectivePerm &&
|
|
674
|
+
(!tabs || tab === 'details') &&
|
|
675
|
+
!(tabs && peopleState === 'ok')
|
|
676
|
+
"
|
|
677
|
+
class="fe-inspector__section"
|
|
678
|
+
>
|
|
523
679
|
<h3 class="fe-inspector__heading">{{ t('inspector.section.permissions') }}</h3>
|
|
524
680
|
<div class="fe-inspector__permrow">
|
|
525
681
|
<span
|
|
@@ -535,10 +691,62 @@ watch(
|
|
|
535
691
|
</div>
|
|
536
692
|
</section>
|
|
537
693
|
|
|
694
|
+
<!-- ══ surucu:d1 — People with access ══
|
|
695
|
+
Real grants from `GET /api/files/permissions`; hidden entirely when
|
|
696
|
+
the caller is not an owner (403) or the storage has RBAC off, rather
|
|
697
|
+
than drawn empty. -->
|
|
698
|
+
<section
|
|
699
|
+
v-if="tabs && tab === 'details' && peopleState === 'ok'"
|
|
700
|
+
class="fe-inspector__section"
|
|
701
|
+
data-testid="inspector-people"
|
|
702
|
+
>
|
|
703
|
+
<h3 class="fe-inspector__heading">{{ t('inspector.people') }}</h3>
|
|
704
|
+
<p v-if="people.length === 0" class="fe-inspector__empty">
|
|
705
|
+
{{ t('inspector.people.empty') }}
|
|
706
|
+
</p>
|
|
707
|
+
<ul v-else class="fe-inspector__people">
|
|
708
|
+
<li v-for="g in people" :key="`${g.id}-${g.user_id}`" class="fe-inspector__person">
|
|
709
|
+
<span class="fe-inspector__avatar" aria-hidden="true">{{ personInitial(g) }}</span>
|
|
710
|
+
<span class="fe-inspector__person-main">
|
|
711
|
+
<span class="fe-inspector__person-name" :title="g.user_email">{{ personName(g) }}</span>
|
|
712
|
+
<span class="fe-inspector__person-sub">
|
|
713
|
+
{{ permLabel(g.level) }}<template v-if="g.inherited"> · {{ t('inspector.people.inherited') }}</template>
|
|
714
|
+
</span>
|
|
715
|
+
</span>
|
|
716
|
+
</li>
|
|
717
|
+
</ul>
|
|
718
|
+
<button
|
|
719
|
+
v-if="canManagePerms && single"
|
|
720
|
+
type="button"
|
|
721
|
+
class="fe-btn fe-btn--sm"
|
|
722
|
+
@click="emit('manage-permissions', single)"
|
|
723
|
+
>{{ t('inspector.people.manage') }}</button>
|
|
724
|
+
</section>
|
|
725
|
+
|
|
538
726
|
<!-- ══ Paylaşımlar ══ -->
|
|
539
|
-
<section
|
|
540
|
-
|
|
541
|
-
|
|
727
|
+
<section
|
|
728
|
+
v-if="sharesState === 'ok' && (!tabs || tab === 'details')"
|
|
729
|
+
class="fe-inspector__section"
|
|
730
|
+
data-testid="inspector-shares"
|
|
731
|
+
>
|
|
732
|
+
<h3 class="fe-inspector__heading">
|
|
733
|
+
{{ tabs ? t('inspector.link') : t('inspector.section.shares') }}
|
|
734
|
+
</h3>
|
|
735
|
+
<!-- surucu:d1 — the mockup's link row: what the state IS, and the one
|
|
736
|
+
button that changes it. Only when there is no link yet; the list
|
|
737
|
+
below is what an item that HAS links has always shown. -->
|
|
738
|
+
<div v-if="tabs && shares.length === 0" class="fe-inspector__linkrow">
|
|
739
|
+
<span class="fe-inspector__linkicon" aria-hidden="true">🔗</span>
|
|
740
|
+
<span class="fe-inspector__linknone">{{ t('inspector.link.none') }}</span>
|
|
741
|
+
<button
|
|
742
|
+
type="button"
|
|
743
|
+
class="fe-btn fe-btn--sm"
|
|
744
|
+
:disabled="shareBusy || !single"
|
|
745
|
+
data-testid="inspector-create-link"
|
|
746
|
+
@click="createLink"
|
|
747
|
+
>{{ t('inspector.link.create') }}</button>
|
|
748
|
+
</div>
|
|
749
|
+
<p v-else-if="shares.length === 0" class="fe-inspector__empty">
|
|
542
750
|
{{ t('inspector.shares.empty') }}
|
|
543
751
|
</p>
|
|
544
752
|
<ul v-else class="fe-inspector__shares">
|
|
@@ -561,7 +769,7 @@ watch(
|
|
|
561
769
|
|
|
562
770
|
<!-- ══ calisma:d3 — Yorumlar ══ -->
|
|
563
771
|
<section
|
|
564
|
-
v-if="commentsState === 'ok' || commentsState === 'error'"
|
|
772
|
+
v-if="(commentsState === 'ok' || commentsState === 'error') && (!tabs || tab === 'activity')"
|
|
565
773
|
class="fe-inspector__section"
|
|
566
774
|
>
|
|
567
775
|
<h3 class="fe-inspector__heading">
|
|
@@ -620,6 +828,21 @@ watch(
|
|
|
620
828
|
</template>
|
|
621
829
|
</section>
|
|
622
830
|
<!-- ══ /calisma:d3 ══ -->
|
|
831
|
+
|
|
832
|
+
<!-- surucu:d1 — the Activity tab with nothing behind it. It says which
|
|
833
|
+
two feeds fill it, because there is no third one to wait for: this
|
|
834
|
+
server keeps no per-file audit trail (target_id is empty for every
|
|
835
|
+
file action, and the log is admin-only). -->
|
|
836
|
+
<section
|
|
837
|
+
v-if="tabs && tab === 'activity' && !activityUsable"
|
|
838
|
+
class="fe-inspector__section"
|
|
839
|
+
data-testid="inspector-activity-empty"
|
|
840
|
+
>
|
|
841
|
+
<p class="fe-inspector__empty">
|
|
842
|
+
{{ single ? t('inspector.activity.empty') : t('inspector.activity.select') }}
|
|
843
|
+
</p>
|
|
844
|
+
<p v-if="single" class="fe-inspector__hint">{{ t('inspector.activity.hint') }}</p>
|
|
845
|
+
</section>
|
|
623
846
|
</div>
|
|
624
847
|
</aside>
|
|
625
848
|
</template>
|
|
@@ -33,6 +33,15 @@ const props = defineProps<{
|
|
|
33
33
|
/** Set of node IDs flagged starred by the user — render an inline
|
|
34
34
|
* filled star indicator and let the user toggle it from the row. */
|
|
35
35
|
starredIds?: Set<number>;
|
|
36
|
+
/**
|
|
37
|
+
* Offer the star affordance at all. Follows the Starred view: when the panel
|
|
38
|
+
* leaves that view out — a shared app token has no single person behind it,
|
|
39
|
+
* so "your starred files" is one list shown to strangers — offering to star
|
|
40
|
+
* something is offering to write into that same shared list. Owner's call,
|
|
41
|
+
* 2026-09-05: "yıldızlı yeri gözükmüyorsa o zaman yıldızla/yıldızı kaldır da
|
|
42
|
+
* gözükmemeli".
|
|
43
|
+
*/
|
|
44
|
+
starEnabled?: boolean;
|
|
36
45
|
/** Backend base URL + auth header builder forwarded to StarButton
|
|
37
46
|
* so it can POST /api/files/manager/star on click. Optional —
|
|
38
47
|
* embedders without auth wire-up pass nothing and the star column
|
|
@@ -390,7 +399,7 @@ const segments = computed<Segment[]>(() => {
|
|
|
390
399
|
>
|
|
391
400
|
<div class="fe-list__col fe-list__col--star" role="gridcell" @click.stop>
|
|
392
401
|
<StarButton
|
|
393
|
-
v-if="typeof n.id === 'number' && n.type === 'file'"
|
|
402
|
+
v-if="starEnabled !== false && typeof n.id === 'number' && n.type === 'file'"
|
|
394
403
|
:starred="!!starredIds?.has(n.id)"
|
|
395
404
|
:node-id="n.id"
|
|
396
405
|
:api-base="apiBase"
|
|
@@ -64,6 +64,13 @@ const props = defineProps<{
|
|
|
64
64
|
/** ui-fix — mirror the main panel's virtual `.trash` row at storage root
|
|
65
65
|
* so both split panes list identical rows (no row-offset). Defaults on. */
|
|
66
66
|
trashVisible?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* The navigation panel is already offering Trash, so neither pane draws the
|
|
69
|
+
* virtual row. Passed down rather than worked out here: the panel belongs to
|
|
70
|
+
* the host explorer, and a pane that guessed at it is how the two halves of a
|
|
71
|
+
* split end up listing different rows.
|
|
72
|
+
*/
|
|
73
|
+
navOffersTrash?: boolean;
|
|
67
74
|
}>();
|
|
68
75
|
|
|
69
76
|
const emit = defineEmits<{
|
|
@@ -114,7 +121,14 @@ async function loadPane(target?: string): Promise<void> {
|
|
|
114
121
|
// Same internal-entry filter + virtual `.trash` row as the main panel
|
|
115
122
|
// (shared helpers → both split panes list identical rows, no offset).
|
|
116
123
|
files.value = filterListing(resp.files);
|
|
117
|
-
if (
|
|
124
|
+
if (
|
|
125
|
+
injectTrashRow(files.value, resp.adapter, resp.dirname, props.trashVisible !== false, {
|
|
126
|
+
// ⚠ The panel is a sibling of BOTH panes. If it is offering Trash, this
|
|
127
|
+
// pane must drop the row too — otherwise the duplication is not removed,
|
|
128
|
+
// it just moves to the right-hand half of a split.
|
|
129
|
+
navOffersTrash: props.navOffersTrash,
|
|
130
|
+
})
|
|
131
|
+
) {
|
|
118
132
|
void hydrateTrashRow(files.value, resp.adapter, props.api);
|
|
119
133
|
}
|
|
120
134
|
path.value = props.toUser(resp.dirname);
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
*/
|
|
31
31
|
import { computed, ref } from 'vue';
|
|
32
32
|
import { useLocale } from '../composables/useLocale';
|
|
33
|
-
import type { LocaleCode } from '../types/ExplorerConfig';
|
|
33
|
+
import type { LocaleCode, ThemeMode } from '../types/ExplorerConfig';
|
|
34
|
+
import ContextMenu, { type ContextAction } from './ContextMenu.vue';
|
|
34
35
|
|
|
35
36
|
/** The virtual listings the panel can open. '' = an ordinary folder. */
|
|
36
37
|
export type NavView = '' | 'recent' | 'starred' | 'shared' | 'trash' | 'tag';
|
|
@@ -98,6 +99,37 @@ const props = defineProps<{
|
|
|
98
99
|
/** RBAC/root state — false hides the write affordances. */
|
|
99
100
|
canWrite?: boolean;
|
|
100
101
|
locale: LocaleCode;
|
|
102
|
+
/* === surucu:d1 — the Drive shell ==================================== */
|
|
103
|
+
/**
|
|
104
|
+
* Fold the primary actions into ONE "+ New" menu (`uiProfile: 'drive'`).
|
|
105
|
+
*
|
|
106
|
+
* Absent/false keeps the two-button block every other profile has had since
|
|
107
|
+
* v0.30.1 — Upload as the primary, New folder one step quieter — so this is
|
|
108
|
+
* additive and nothing that mounts the package today moves.
|
|
109
|
+
*
|
|
110
|
+
* ⚠ The menu holds what the explorer can ALREADY do: upload files, make a
|
|
111
|
+
* folder (the modal offers the encrypted variant from inside itself), and
|
|
112
|
+
* ask somebody else for files. There is deliberately no "Upload folder": the
|
|
113
|
+
* upload path takes a flat `File[]` and would have to create the intermediate
|
|
114
|
+
* directories itself, and an entry that quietly flattens someone's folder into
|
|
115
|
+
* one heap is worse than an entry that is not there.
|
|
116
|
+
*/
|
|
117
|
+
newMenu?: boolean;
|
|
118
|
+
/** Offer "Request files" in that menu — a folder we may write to and share. */
|
|
119
|
+
canRequestFiles?: boolean;
|
|
120
|
+
/**
|
|
121
|
+
* The signed-in person's storage line, from `GET /api/files/quota/me`. Null
|
|
122
|
+
* (the default) renders nothing at all.
|
|
123
|
+
*
|
|
124
|
+
* ⚠ It is a PER-USER figure, not this storage's — `quota.Snapshot` sums
|
|
125
|
+
* `nodes.size WHERE owner_id = me`, and there is no per-provider quota
|
|
126
|
+
* (internal/quota/service.go). The mockup labels it with the drive's name;
|
|
127
|
+
* that would be a lie about which number this is, so the label says
|
|
128
|
+
* "Storage" and the drive name stays out of it.
|
|
129
|
+
*/
|
|
130
|
+
quota?: { used: number; total: number; unlimited: boolean } | null;
|
|
131
|
+
/** Resolved theme — the teleported New menu leaves the `.fe` variable scope. */
|
|
132
|
+
theme?: ThemeMode;
|
|
101
133
|
}>();
|
|
102
134
|
|
|
103
135
|
const emit = defineEmits<{
|
|
@@ -110,6 +142,8 @@ const emit = defineEmits<{
|
|
|
110
142
|
(e: 'new-folder'): void;
|
|
111
143
|
(e: 'open-connections'): void;
|
|
112
144
|
(e: 'open-tokens'): void;
|
|
145
|
+
/* surucu:d1 — "Request files": the access modal on THIS folder, drop tab. */
|
|
146
|
+
(e: 'request-files'): void;
|
|
113
147
|
/** Drawer scrim / Esc — narrow mode only. */
|
|
114
148
|
(e: 'close'): void;
|
|
115
149
|
}>();
|
|
@@ -168,6 +202,74 @@ const hiddenTagCount = computed(() => Math.max(0, allTags.value.length - visible
|
|
|
168
202
|
* answer is still in flight. */
|
|
169
203
|
const showTags = computed(() => !!props.tagsLoaded || allTags.value.length > 0);
|
|
170
204
|
|
|
205
|
+
/* === surucu:d1 — the "+ New" menu ====================================
|
|
206
|
+
* One primary action instead of two buttons, the shape the reporter drew and
|
|
207
|
+
* the shape Drive/FileRun/Nextcloud share. It is the SAME ContextMenu the
|
|
208
|
+
* right-click menu uses — teleported to <body>, so the panel's own scroll
|
|
209
|
+
* container cannot clip it, and one keyboard/focus behaviour for both. */
|
|
210
|
+
const newBtnEl = ref<HTMLElement | null>(null);
|
|
211
|
+
const newMenuRef = ref<InstanceType<typeof ContextMenu> | null>(null);
|
|
212
|
+
|
|
213
|
+
const newActions = computed<ContextAction[]>(() => {
|
|
214
|
+
const list: ContextAction[] = [
|
|
215
|
+
{ key: 'upload', label: t('drive.new.upload'), icon: '⬆', disabled: !writable.value },
|
|
216
|
+
{ key: 'new-folder', label: t('drive.new.folder'), icon: '📁', disabled: !writable.value },
|
|
217
|
+
];
|
|
218
|
+
// Only when there is a real folder to hang a drop link on. Rendered as a
|
|
219
|
+
// disabled row rather than dropped, so the menu does not change height
|
|
220
|
+
// between folders — a menu whose items move is a menu people misclick.
|
|
221
|
+
list.push({ divider: true, key: 'new-sep', label: '' });
|
|
222
|
+
list.push({
|
|
223
|
+
key: 'request-files',
|
|
224
|
+
label: t('drive.new.request'),
|
|
225
|
+
icon: '🔗',
|
|
226
|
+
disabled: !props.canRequestFiles,
|
|
227
|
+
});
|
|
228
|
+
return list;
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
function openNewMenu() {
|
|
232
|
+
const r = newBtnEl.value?.getBoundingClientRect();
|
|
233
|
+
newMenuRef.value?.show(
|
|
234
|
+
{ clientX: r ? r.left : 0, clientY: r ? r.bottom + 6 : 0 } as MouseEvent,
|
|
235
|
+
[],
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function onNewSelect(a: ContextAction) {
|
|
240
|
+
if (a.key === 'upload') emit('upload');
|
|
241
|
+
else if (a.key === 'new-folder') emit('new-folder');
|
|
242
|
+
else if (a.key === 'request-files') emit('request-files');
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/* === surucu:d1 — the storage line =================================== */
|
|
246
|
+
function formatBytes(n: number): string {
|
|
247
|
+
if (!Number.isFinite(n) || n < 0) return '—';
|
|
248
|
+
const units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'];
|
|
249
|
+
let v = n;
|
|
250
|
+
let i = 0;
|
|
251
|
+
while (v >= 1024 && i < units.length - 1) {
|
|
252
|
+
v /= 1024;
|
|
253
|
+
i += 1;
|
|
254
|
+
}
|
|
255
|
+
const digits = v < 10 && i > 0 ? 1 : 0;
|
|
256
|
+
return `${v.toFixed(digits)} ${units[i]}`;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const quotaPercent = computed(() => {
|
|
260
|
+
const q = props.quota;
|
|
261
|
+
if (!q || q.unlimited || q.total <= 0) return 0;
|
|
262
|
+
return Math.max(0, Math.min(100, Math.round((q.used / q.total) * 100)));
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
const quotaText = computed(() => {
|
|
266
|
+
const q = props.quota;
|
|
267
|
+
if (!q) return '';
|
|
268
|
+
return q.unlimited || q.total <= 0
|
|
269
|
+
? t('drive.storage.used_unlimited', { used: formatBytes(q.used) })
|
|
270
|
+
: t('drive.storage.used', { used: formatBytes(q.used), total: formatBytes(q.total) });
|
|
271
|
+
});
|
|
272
|
+
|
|
171
273
|
const toggleLabel = computed(() =>
|
|
172
274
|
props.narrow
|
|
173
275
|
? t('sidenav.close')
|
|
@@ -238,7 +340,35 @@ const toggleLabel = computed(() =>
|
|
|
238
340
|
that appears and disappears makes every row below it jump by 90px each
|
|
239
341
|
time the user opens a view, which reads as the panel reloading. -->
|
|
240
342
|
<div class="fe-sidenav__primary">
|
|
343
|
+
<!-- surucu:d1 — one primary action, the shape #14's mockups draw. The
|
|
344
|
+
two-button block below is what every other profile still renders. -->
|
|
345
|
+
<button
|
|
346
|
+
v-if="newMenu"
|
|
347
|
+
ref="newBtnEl"
|
|
348
|
+
type="button"
|
|
349
|
+
class="fe-sidenav__new"
|
|
350
|
+
aria-haspopup="menu"
|
|
351
|
+
:title="t('drive.new')"
|
|
352
|
+
:aria-label="t('drive.new')"
|
|
353
|
+
data-testid="sidenav-new"
|
|
354
|
+
@click="openNewMenu"
|
|
355
|
+
>
|
|
356
|
+
<svg
|
|
357
|
+
class="fe-ficon"
|
|
358
|
+
viewBox="0 0 24 24"
|
|
359
|
+
fill="none"
|
|
360
|
+
stroke="currentColor"
|
|
361
|
+
stroke-width="2"
|
|
362
|
+
stroke-linecap="round"
|
|
363
|
+
aria-hidden="true"
|
|
364
|
+
focusable="false"
|
|
365
|
+
>
|
|
366
|
+
<path d="M12 5v14M5 12h14" />
|
|
367
|
+
</svg>
|
|
368
|
+
<span v-if="showLabels" class="fe-sidenav__text">{{ t('drive.new') }}</span>
|
|
369
|
+
</button>
|
|
241
370
|
<button
|
|
371
|
+
v-if="!newMenu"
|
|
242
372
|
type="button"
|
|
243
373
|
class="fe-sidenav__upload"
|
|
244
374
|
:disabled="!writable"
|
|
@@ -265,6 +395,7 @@ const toggleLabel = computed(() =>
|
|
|
265
395
|
<span v-if="showLabels" class="fe-sidenav__text">{{ t('toolbar.upload') }}</span>
|
|
266
396
|
</button>
|
|
267
397
|
<button
|
|
398
|
+
v-if="!newMenu"
|
|
268
399
|
type="button"
|
|
269
400
|
class="fe-sidenav__secondary"
|
|
270
401
|
:disabled="!writable"
|
|
@@ -568,5 +699,34 @@ const toggleLabel = computed(() =>
|
|
|
568
699
|
</ul>
|
|
569
700
|
</div>
|
|
570
701
|
</div>
|
|
702
|
+
|
|
703
|
+
<!-- surucu:d1 — the storage line. Under the navigation, above nothing:
|
|
704
|
+
it is the last thing in the panel because it is a status, not a
|
|
705
|
+
destination. Hidden entirely when the server did not answer (an app
|
|
706
|
+
token has no person to have a quota) rather than drawn empty. -->
|
|
707
|
+
<div v-if="quota" class="fe-sidenav__quota" data-testid="sidenav-quota">
|
|
708
|
+
<p v-if="showLabels" class="fe-sidenav__quota-label">{{ t('drive.storage.label') }}</p>
|
|
709
|
+
<div
|
|
710
|
+
class="fe-sidenav__quota-bar"
|
|
711
|
+
role="progressbar"
|
|
712
|
+
:aria-valuenow="quotaPercent"
|
|
713
|
+
aria-valuemin="0"
|
|
714
|
+
aria-valuemax="100"
|
|
715
|
+
:aria-label="quotaText"
|
|
716
|
+
:title="quotaText"
|
|
717
|
+
>
|
|
718
|
+
<span class="fe-sidenav__quota-fill" :style="{ width: quotaPercent + '%' }"></span>
|
|
719
|
+
</div>
|
|
720
|
+
<p v-if="showLabels" class="fe-sidenav__quota-text">{{ quotaText }}</p>
|
|
721
|
+
</div>
|
|
722
|
+
|
|
723
|
+
<ContextMenu
|
|
724
|
+
v-if="newMenu"
|
|
725
|
+
ref="newMenuRef"
|
|
726
|
+
:locale="locale"
|
|
727
|
+
:theme="theme"
|
|
728
|
+
:actions="newActions"
|
|
729
|
+
@select="onNewSelect"
|
|
730
|
+
/>
|
|
571
731
|
</nav>
|
|
572
732
|
</template>
|