rename API endpoints for backups and notifications

This commit is contained in:
Jakub Trávník 2025-12-01 16:24:15 +01:00
parent 07f7c5e025
commit a9ac6eec20
6 changed files with 19 additions and 19 deletions

View file

@ -79,7 +79,7 @@ async function exportFromApi(endpoint: string, filename: string, options: Export
downloadAsJson(data, filename);
}
export type ExportEntityType = "volumes" | "repositories" | "notifications" | "backups" | "full";
export type ExportEntityType = "volumes" | "repositories" | "notification-destinations" | "backup-schedules" | "full";
type ExportConfig = {
endpoint: string;
@ -107,17 +107,17 @@ const exportConfigs: Record<ExportEntityType, ExportConfig> = {
return identifier ? `repository-${identifier}-config` : "repositories-config";
},
},
notifications: {
endpoint: "/api/v1/config/export/notifications",
label: "Notification",
labelPlural: "Notifications",
"notification-destinations": {
endpoint: "/api/v1/config/export/notification-destinations",
label: "Notification Destination",
labelPlural: "Notification Destinations",
getFilename: (opts) => {
const identifier = opts.id ?? opts.name;
return identifier ? `notification-${identifier}-config` : "notifications-config";
return identifier ? `notification-destination-${identifier}-config` : "notification-destinations-config";
},
},
backups: {
endpoint: "/api/v1/config/export/backups",
"backup-schedules": {
endpoint: "/api/v1/config/export/backup-schedules",
label: "Backup Schedule",
labelPlural: "Backup Schedules",
getFilename: (opts) => (opts.id ? `backup-schedule-${opts.id}-config` : "backup-schedules-config"),
@ -176,7 +176,7 @@ export function ExportDialog({
const isSingleItem = !!(name || id);
const isFullExport = entityType === "full";
// TODO: Volumes will have encrypted secrets (e.g., SMB/NFS credentials) in a future PR
const hasSecrets = entityType !== "backups" && entityType !== "volumes";
const hasSecrets = entityType !== "backup-schedules" && entityType !== "volumes";
const entityLabel = isSingleItem ? config.label : config.labelPlural;
const requiresPassword = includeRecoveryKey || secretsMode === "cleartext";

View file

@ -126,7 +126,7 @@ export const ScheduleSummary = (props: Props) => {
<Pencil className="h-4 w-4 mr-2" />
<span className="sm:inline">Edit schedule</span>
</Button>
<ExportDialog entityType="backups" id={schedule.id} size="sm" triggerLabel="Export config" />
<ExportDialog entityType="backup-schedules" id={schedule.id} size="sm" triggerLabel="Export config" />
<Button
variant="outline"
size="sm"

View file

@ -122,7 +122,7 @@ export default function Backups({ loaderData }: Route.ComponentProps) {
</Link>
<Card className="flex flex-col items-center justify-center h-full hover:bg-muted/50 transition-colors cursor-pointer">
<CardContent className="flex flex-col items-center justify-center gap-2 h-full w-full">
<ExportDialog entityType="backups" variant="card" />
<ExportDialog entityType="backup-schedules" variant="card" />
</CardContent>
</Card>
</div>

View file

@ -143,7 +143,7 @@ export default function NotificationDetailsPage({ loaderData }: Route.ComponentP
<TestTube2 className="h-4 w-4 mr-2" />
Test
</Button>
<ExportDialog entityType="notifications" name={data.name} triggerLabel="Export config" />
<ExportDialog entityType="notification-destinations" name={data.name} triggerLabel="Export config" />
<Button
onClick={() => setShowDeleteConfirm(true)}
variant="destructive"

View file

@ -124,7 +124,7 @@ export default function Notifications({ loaderData }: Route.ComponentProps) {
)}
</span>
<div className="flex gap-2">
<ExportDialog entityType="notifications" />
<ExportDialog entityType="notification-destinations" />
<Button onClick={() => navigate("/notifications/create")}>
<Plus size={16} className="mr-2" />
Create Destination

View file

@ -319,18 +319,18 @@ export const configExportController = new Hono()
return c.json({ error: "Failed to export repositories" }, 500);
}
})
.get("/export/notifications", async (c) => {
.get("/export/notification-destinations", async (c) => {
try {
const params = parseExportParams(c);
const result = await fetchNotifications(getFilterOptions(c));
if ("error" in result) return c.json({ error: result.error }, result.status);
return c.json({ notificationDestinations: await exportEntities(result.data, params) });
} catch (err) {
logger.error(`Notifications export failed: ${err instanceof Error ? err.message : String(err)}`);
return c.json({ error: "Failed to export notifications" }, 500);
logger.error(`Notification destinations export failed: ${err instanceof Error ? err.message : String(err)}`);
return c.json({ error: "Failed to export notification destinations" }, 500);
}
})
.get("/export/backups", async (c) => {
.get("/export/backup-schedules", async (c) => {
try {
const params = parseExportParams(c);
@ -354,8 +354,8 @@ export const configExportController = new Hono()
return c.json({ backupSchedules });
} catch (err) {
logger.error(`Backups export failed: ${err instanceof Error ? err.message : String(err)}`);
return c.json({ error: "Failed to export backups" }, 500);
logger.error(`Backup schedules export failed: ${err instanceof Error ? err.message : String(err)}`);
return c.json({ error: "Failed to export backup schedules" }, 500);
}
});