Centrale Refactor Big

This commit is contained in:
alma 2026-01-12 15:22:46 +01:00
parent 818a96d0a0
commit 2876806a3b

View File

@ -191,6 +191,23 @@ export default function MissionDetailPage() {
};
};
// Function to sanitize mission name (same logic as N8N)
const sanitizeMissionName = (name: string): string => {
if (!name || typeof name !== "string") return "unnamed-mission";
return name.toLowerCase()
.split("")
.map(c => {
if (c >= "a" && c <= "z") return c;
if (c >= "0" && c <= "9") return c;
if (c === " " || c === "-") return c;
return "";
})
.join("")
.split(" ")
.filter(Boolean)
.join("-");
};
// Handle delete mission
const handleDeleteMission = async () => {
@ -629,10 +646,17 @@ export default function MissionDetailPage() {
})()}
{mission.giteaRepositoryUrl && (() => {
// Gitea URL should already be a full URL, but handle both cases
const giteaUrl = mission.giteaRepositoryUrl.startsWith('http')
? mission.giteaRepositoryUrl
: `https://gite.slm-lab.net/${mission.giteaRepositoryUrl}`;
// Use mission name (sanitized) as repo name
const repoName = sanitizeMissionName(mission.name);
// Get Gitea owner from environment variable (default: "alma")
// Note: In Next.js client components, we need NEXT_PUBLIC_ prefix
const giteaOwner = typeof window !== 'undefined'
? (process.env.NEXT_PUBLIC_GITEA_OWNER || 'alma')
: 'alma';
// Build the correct Gitea URL: gite.slm-lab.net/owner/repo-name
const giteaUrl = `https://gite.slm-lab.net/${giteaOwner}/${repoName}`;
return (
<a