feat(myshares): new version of myshares sections, supporting grants Users + Tokens

This commit is contained in:
Edouard Vanbelle
2026-05-29 02:16:15 +02:00
parent 8800353900
commit 63722c868e
43 changed files with 2676 additions and 243 deletions
+27 -1
View File
@@ -1,5 +1,5 @@
/**
* @import {Grant, ResourceTypeEnum, SharedWithMeResponse} from '../core/types.js'
* @import {Grant, ResourceTypeEnum, SharedWithMeResponse, OutgoingResourcesResponse} from '../core/types.js'
*/
import { getCsrfHeaders } from '../core/csrf.js';
@@ -110,6 +110,32 @@ const grants = {
return response.json();
},
/**
* Fetch a cursor-paginated list of resources the current user has shared
* with others, with full file / folder metadata resolved server-side.
*
* @param {object} [opts]
* @param {number} [opts.limit] - Max items per page (1–200, default 50).
* @param {string} [opts.cursor] - Opaque cursor from a previous call.
* @param {string} [opts.orderBy] - Sort: 'first_shared_at' | 'name' | 'type' | 'subject'.
* @param {boolean} [opts.reverse] - Reverse sort order.
* @returns {Promise<OutgoingResourcesResponse>}
*/
async fetchMySharesPage({ limit = 50, cursor, orderBy, reverse = false } = {}) {
const params = new URLSearchParams({ limit: String(limit) });
if (cursor) params.set('cursor', cursor);
if (orderBy) params.set('sort_by', orderBy);
if (reverse) params.set('reverse', 'true');
const response = await fetch(`/api/grants/outgoing/resources?${params}`);
if (!response.ok) {
throw new Error(`Failed to fetch my shares: HTTP ${response.status}`);
}
return response.json();
},
/**
* Fetch all grants on a specific resource (for the "Manage sharing" panel).
* Refreshes the outgoingGrants cache for this resource.