feat: add admin albums tab with access overview and bulk grants
New /admin/alben page: all Immich albums with per-album editorial grant chips (link + one-click revoke) and a bulk-grant form (multiple albums x multiple editorials, select-all, search). bulkGrantAlbums validates album existence once via listAlbums, skips already-active pairs, and commits each pair in its own transaction with full audit attribution.
This commit is contained in:
1 parent
0b65fbba16
commit
0931ffc777
12 files changed
+1245
-12
No files matched your search
@@ -0,0 +1,38 @@
|
||||
import { asc, isNull } from "drizzle-orm";
|
||||
|
||||
import { db } from "@/db/client";
|
||||
import { editorialAccounts } from "@/db/schema";
|
||||
import {
|
||||
AlbumGrantError,
|
||||
albumGrantService,
|
||||
type AlbumAccessOverviewAlbum,
|
||||
} from "@/modules/albums/grants";
|
||||
|
||||
export type EditorialOption = { id: string; name: string };
|
||||
|
||||
export async function loadAlbumAccess(
|
||||
service: Pick<typeof albumGrantService, "listAlbumAccessOverview"> = albumGrantService,
|
||||
): Promise<{ albums: AlbumAccessOverviewAlbum[]; unavailable: boolean }> {
|
||||
try {
|
||||
const albums = await service.listAlbumAccessOverview();
|
||||
return { albums, unavailable: false };
|
||||
} catch (error) {
|
||||
if (error instanceof AlbumGrantError && error.code === "IMMICH_UNAVAILABLE") {
|
||||
return { albums: [], unavailable: true };
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Bulk-grant targets: every non-archived editorial. Archived accounts cannot
|
||||
* log in anymore, so they stay out of the selection; grants they still hold
|
||||
* remain visible in the overview.
|
||||
*/
|
||||
export async function loadAssignableEditorials(): Promise<EditorialOption[]> {
|
||||
return db
|
||||
.select({ id: editorialAccounts.id, name: editorialAccounts.name })
|
||||
.from(editorialAccounts)
|
||||
.where(isNull(editorialAccounts.archivedAt))
|
||||
.orderBy(asc(editorialAccounts.name));
|
||||
}
|
||||
Reference in new issue
Block a user