Files
ForgeBucket/frontend/src/api/queries/lfs.ts
T
erangel1 803672a610 Git LFS section is live with:
Enable LFS toggle — turns LFS on/off for the repo; all other controls dim when disabled
File locking toggle — enables the LFS locking protocol for binary assets
Maximum file size — optional per-file size cap in MB (blank = unlimited)
Info callout linking to the git-lfs client install page and noting the .gitattributes requirement
2026-05-07 16:12:25 +02:00

32 lines
1020 B
TypeScript

import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
import { z } from 'zod'
import { api } from '../client'
const lfsSettingsSchema = z.object({
enabled: z.boolean(),
lockingEnabled: z.boolean(),
maxFileSizeMB: z.number(),
})
export type LFSSettings = z.infer<typeof lfsSettingsSchema>
export function useLFSSettings(owner: string, repo: string) {
return useQuery({
queryKey: ['repos', owner, repo, 'lfs-settings'],
queryFn: () =>
api.get<LFSSettings>(`/api/v1/repos/${owner}/${repo}/lfs-settings`, lfsSettingsSchema),
enabled: Boolean(owner && repo),
})
}
export function useUpdateLFSSettings(owner: string, repo: string) {
const queryClient = useQueryClient()
return useMutation({
mutationFn: (body: Partial<LFSSettings>) =>
api.put<LFSSettings>(`/api/v1/repos/${owner}/${repo}/lfs-settings`, lfsSettingsSchema, body),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['repos', owner, repo, 'lfs-settings'] })
},
})
}