Add Drive folders: per request type, and managed from the Media page

Request files go in Requests/<type> (Chapters, Events...). Media →
Files shows a tab per folder under Media, up to three deep, and can
make, rename (files follow) and delete empty folders, move a file with
its Folder dropdown, and upload into the folder showing; Choose a file
has the same tabs. A folder made, or a file moved, in Drive by hand is
followed on the next look (migration 050 records each file's folder).

Deletes now move to Drive's trash: a shared drive's Content manager,
the service account's role, can't delete outright, so request and file
deletes would have failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-09-29 22:34:27 -05:00
parent 9854da965e
commit 7f05076a86
7 changed files with 479 additions and 38 deletions

View file

@ -63,8 +63,19 @@ export function cleanDetails(raw) {
return Object.keys(out).length ? out : null;
}
const MIN_MESSAGE = 10;
// Where in the shared drive the files go (googleService.js).
// Where in the shared drive the files go (googleService.js): a
// folder per type under Requests, eg. Requests/Chapters.
const DRIVE_FOLDER = "Requests";
const TYPE_FOLDERS = {
blog: "Blog posts",
event: "Events",
chapter: "Chapters",
region: "Regions",
partner: "Partners",
team: "Teams",
award: "Awards",
person: "People",
};
export const MAX_FILES = 3;
export const MAX_FILE_BYTES = 10 * 1024 * 1024;
@ -168,7 +179,7 @@ requests.post(
const stored = [];
try {
for (const file of uploads) {
stored.push({ ...file, driveId: (await driveUpload(DRIVE_FOLDER, `Request ${id} - ${file.name}`, file.mime, file.buffer)).id });
stored.push({ ...file, driveId: (await driveUpload(`${DRIVE_FOLDER}/${TYPE_FOLDERS[category]}`, `Request ${id} - ${file.name}`, file.mime, file.buffer)).id });
}
} catch (err) {
console.warn(`feedback #${id}: Drive upload failed: ${err.message}`);