118 lines
4.1 KiB
TypeScript
118 lines
4.1 KiB
TypeScript
"use client"
|
|
|
|
import { OrgSettingsSection } from "@/components/admin/settings/org-settings-form"
|
|
import { useOrgSettingsStore } from "@/lib/admin-settings/org-settings-store"
|
|
import { Input } from "@/components/ui/input"
|
|
import { Label } from "@/components/ui/label"
|
|
import { Switch } from "@/components/ui/switch"
|
|
import { Textarea } from "@/components/ui/textarea"
|
|
import {
|
|
Select,
|
|
SelectContent,
|
|
SelectItem,
|
|
SelectTrigger,
|
|
SelectValue,
|
|
} from "@/components/ui/select"
|
|
|
|
export function FilePoliciesSection() {
|
|
const filePolicies = useOrgSettingsStore((s) => s.filePolicies)
|
|
const setFilePolicies = useOrgSettingsStore((s) => s.setFilePolicies)
|
|
|
|
return (
|
|
<OrgSettingsSection
|
|
title="Politiques fichiers"
|
|
description="Règles d'upload, partage externe et rétention pour UltiDrive."
|
|
policySection="file_policies"
|
|
>
|
|
<div className="grid gap-4 sm:grid-cols-2">
|
|
<div>
|
|
<Label>Taille max upload (Mo)</Label>
|
|
<Input
|
|
className="mt-1 h-9"
|
|
type="number"
|
|
min={1}
|
|
value={filePolicies.max_upload_mib}
|
|
onChange={(e) =>
|
|
setFilePolicies({ max_upload_mib: Number(e.target.value) || 1 })
|
|
}
|
|
/>
|
|
</div>
|
|
<div>
|
|
<Label>Expiration liens par défaut (jours)</Label>
|
|
<Input
|
|
className="mt-1 h-9"
|
|
type="number"
|
|
min={1}
|
|
value={filePolicies.default_link_expiry_days}
|
|
onChange={(e) =>
|
|
setFilePolicies({
|
|
default_link_expiry_days: Number(e.target.value) || 1,
|
|
})
|
|
}
|
|
/>
|
|
</div>
|
|
<div>
|
|
<Label>Rétention corbeille (jours)</Label>
|
|
<Input
|
|
className="mt-1 h-9"
|
|
type="number"
|
|
min={1}
|
|
value={filePolicies.retention_trash_days}
|
|
onChange={(e) =>
|
|
setFilePolicies({ retention_trash_days: Number(e.target.value) || 1 })
|
|
}
|
|
/>
|
|
</div>
|
|
<div>
|
|
<Label>Partage externe</Label>
|
|
<Select
|
|
value={filePolicies.external_sharing}
|
|
onValueChange={(external_sharing) =>
|
|
setFilePolicies({
|
|
external_sharing: external_sharing as typeof filePolicies.external_sharing,
|
|
})
|
|
}
|
|
>
|
|
<SelectTrigger className="mt-1 h-9">
|
|
<SelectValue />
|
|
</SelectTrigger>
|
|
<SelectContent>
|
|
<SelectItem value="disabled">Désactivé</SelectItem>
|
|
<SelectItem value="authenticated">Utilisateurs authentifiés</SelectItem>
|
|
<SelectItem value="public_link">Liens publics autorisés</SelectItem>
|
|
</SelectContent>
|
|
</Select>
|
|
</div>
|
|
<div className="sm:col-span-2">
|
|
<Label>Extensions autorisées (vide = toutes)</Label>
|
|
<Textarea
|
|
className="mt-1 min-h-[80px] font-mono text-xs"
|
|
value={filePolicies.allowed_extensions}
|
|
onChange={(e) => setFilePolicies({ allowed_extensions: e.target.value })}
|
|
placeholder="pdf, docx, png, jpg"
|
|
/>
|
|
</div>
|
|
<label className="flex items-center justify-between gap-4 rounded-lg border p-3 sm:col-span-2">
|
|
<div>
|
|
<p className="text-sm font-medium">Bloquer les exécutables</p>
|
|
<p className="text-xs text-muted-foreground">exe, bat, sh, app, etc.</p>
|
|
</div>
|
|
<Switch
|
|
checked={filePolicies.block_executable}
|
|
onCheckedChange={(block_executable) => setFilePolicies({ block_executable })}
|
|
/>
|
|
</label>
|
|
<label className="flex items-center justify-between gap-4 rounded-lg border p-3 sm:col-span-2">
|
|
<div>
|
|
<p className="text-sm font-medium">Analyse antivirus à l'upload</p>
|
|
</div>
|
|
<Switch
|
|
checked={filePolicies.virus_scan_enabled}
|
|
onCheckedChange={(virus_scan_enabled) => setFilePolicies({ virus_scan_enabled })}
|
|
/>
|
|
</label>
|
|
</div>
|
|
</OrgSettingsSection>
|
|
)
|
|
}
|