Centrale Refactor Big
This commit is contained in:
parent
84bc21e37e
commit
06f5560d27
@ -191,59 +191,6 @@ export default function MissionDetailPage() {
|
||||
};
|
||||
};
|
||||
|
||||
// Function to convert application URL to iframe URL
|
||||
// Example: parole.slm-lab.net/channel/xxx -> hub.slm-lab.net/parole/channel/xxx
|
||||
const convertToIframeUrl = (appUrl: string | null | undefined): string | null => {
|
||||
if (!appUrl) return null;
|
||||
|
||||
try {
|
||||
// If it's already a full URL, parse it
|
||||
if (appUrl.startsWith('http://') || appUrl.startsWith('https://')) {
|
||||
const url = new URL(appUrl);
|
||||
const hostname = url.hostname;
|
||||
const pathname = url.pathname;
|
||||
const search = url.search;
|
||||
|
||||
// Extract subdomain (e.g., "parole" from "parole.slm-lab.net")
|
||||
const subdomainMatch = hostname.match(/^([^.]+)\.slm-lab\.net$/);
|
||||
if (!subdomainMatch) {
|
||||
// If URL doesn't match expected pattern, return original
|
||||
return appUrl;
|
||||
}
|
||||
|
||||
const subdomain = subdomainMatch[1];
|
||||
// Remove leading slash from pathname if present
|
||||
const cleanPath = pathname.startsWith('/') ? pathname.substring(1) : pathname;
|
||||
|
||||
// Build iframe URL: hub.slm-lab.net/[subdomain]/[path][search]
|
||||
const iframeUrl = `https://hub.slm-lab.net/${subdomain}/${cleanPath}${search}`;
|
||||
return iframeUrl;
|
||||
} else {
|
||||
// If it's not a full URL, assume it's a relative path and return as is
|
||||
// (This shouldn't happen for these fields, but handle it gracefully)
|
||||
return appUrl;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error converting URL to iframe URL:', error);
|
||||
return appUrl; // Return original URL if conversion fails
|
||||
}
|
||||
};
|
||||
|
||||
// Function to build Leantime URL from project ID
|
||||
// If leantimeProjectId is a URL, convert it; if it's just an ID, build the URL
|
||||
const getLeantimeUrl = (projectId: string | null | undefined): string | null => {
|
||||
if (!projectId) return null;
|
||||
|
||||
// If it's already a full URL, convert it
|
||||
if (projectId.startsWith('http://') || projectId.startsWith('https://')) {
|
||||
return convertToIframeUrl(projectId);
|
||||
}
|
||||
|
||||
// Otherwise, it's just an ID - build the full URL
|
||||
// Format: agilite.slm-lab.net/projects/showProject/[id]
|
||||
const appUrl = `https://agilite.slm-lab.net/projects/showProject/${projectId}`;
|
||||
return convertToIframeUrl(appUrl);
|
||||
};
|
||||
|
||||
// Handle delete mission
|
||||
const handleDeleteMission = async () => {
|
||||
@ -626,97 +573,77 @@ export default function MissionDetailPage() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Liens d'intégration */}
|
||||
{/* Ressources Métiers */}
|
||||
{(mission.rocketChatChannelId || mission.outlineCollectionId || mission.giteaRepositoryUrl || mission.leantimeProjectId) && (
|
||||
<div className="bg-white rounded-lg shadow-sm border border-gray-100 p-6">
|
||||
<h2 className="text-xl font-semibold text-gray-800 mb-4">Liens d'intégration</h2>
|
||||
<h2 className="text-xl font-semibold text-gray-800 mb-4">Ressources Métiers</h2>
|
||||
<div className="space-y-3">
|
||||
{mission.rocketChatChannelId && (
|
||||
<div className="flex items-center justify-between p-3 bg-blue-50 rounded-lg border border-blue-100">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="w-10 h-10 bg-blue-100 rounded-full flex items-center justify-center">
|
||||
<Users className="h-5 w-5 text-blue-600" />
|
||||
</div>
|
||||
<div>
|
||||
<p className="font-medium text-gray-900">Tenant de Parole</p>
|
||||
<p className="text-sm text-gray-500">RocketChat</p>
|
||||
</div>
|
||||
<a
|
||||
href={mission.rocketChatChannelId}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="flex items-center gap-3 p-3 bg-blue-50 rounded-lg border border-blue-100 hover:bg-blue-100 transition-colors cursor-pointer"
|
||||
>
|
||||
<div className="w-10 h-10 bg-blue-100 rounded-full flex items-center justify-center">
|
||||
<Users className="h-5 w-5 text-blue-600" />
|
||||
</div>
|
||||
<a
|
||||
href={convertToIframeUrl(mission.rocketChatChannelId) || mission.rocketChatChannelId}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors text-sm font-medium"
|
||||
>
|
||||
Ouvrir
|
||||
</a>
|
||||
</div>
|
||||
<div className="flex-1">
|
||||
<p className="font-medium text-gray-900">Espace de discussion</p>
|
||||
<p className="text-sm text-gray-500">RocketChat</p>
|
||||
</div>
|
||||
</a>
|
||||
)}
|
||||
|
||||
{mission.outlineCollectionId && (
|
||||
<div className="flex items-center justify-between p-3 bg-purple-50 rounded-lg border border-purple-100">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="w-10 h-10 bg-purple-100 rounded-full flex items-center justify-center">
|
||||
<FileText className="h-5 w-5 text-purple-600" />
|
||||
</div>
|
||||
<div>
|
||||
<p className="font-medium text-gray-900">Tenant du Chapitre</p>
|
||||
<p className="text-sm text-gray-500">Outline</p>
|
||||
</div>
|
||||
<a
|
||||
href={mission.outlineCollectionId}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="flex items-center gap-3 p-3 bg-purple-50 rounded-lg border border-purple-100 hover:bg-purple-100 transition-colors cursor-pointer"
|
||||
>
|
||||
<div className="w-10 h-10 bg-purple-100 rounded-full flex items-center justify-center">
|
||||
<FileText className="h-5 w-5 text-purple-600" />
|
||||
</div>
|
||||
<a
|
||||
href={convertToIframeUrl(mission.outlineCollectionId) || mission.outlineCollectionId}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="px-4 py-2 bg-purple-600 text-white rounded-md hover:bg-purple-700 transition-colors text-sm font-medium"
|
||||
>
|
||||
Ouvrir
|
||||
</a>
|
||||
</div>
|
||||
<div className="flex-1">
|
||||
<p className="font-medium text-gray-900">Espace de documentation</p>
|
||||
<p className="text-sm text-gray-500">Outline</p>
|
||||
</div>
|
||||
</a>
|
||||
)}
|
||||
|
||||
{mission.giteaRepositoryUrl && (
|
||||
<div className="flex items-center justify-between p-3 bg-green-50 rounded-lg border border-green-100">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="w-10 h-10 bg-green-100 rounded-full flex items-center justify-center">
|
||||
<FileIcon className="h-5 w-5 text-green-600" />
|
||||
</div>
|
||||
<div>
|
||||
<p className="font-medium text-gray-900">Tenant du Code</p>
|
||||
<p className="text-sm text-gray-500">Gitea</p>
|
||||
</div>
|
||||
<a
|
||||
href={mission.giteaRepositoryUrl}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="flex items-center gap-3 p-3 bg-green-50 rounded-lg border border-green-100 hover:bg-green-100 transition-colors cursor-pointer"
|
||||
>
|
||||
<div className="w-10 h-10 bg-green-100 rounded-full flex items-center justify-center">
|
||||
<FileIcon className="h-5 w-5 text-green-600" />
|
||||
</div>
|
||||
<a
|
||||
href={convertToIframeUrl(mission.giteaRepositoryUrl) || mission.giteaRepositoryUrl}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="px-4 py-2 bg-green-600 text-white rounded-md hover:bg-green-700 transition-colors text-sm font-medium"
|
||||
>
|
||||
Ouvrir
|
||||
</a>
|
||||
</div>
|
||||
<div className="flex-1">
|
||||
<p className="font-medium text-gray-900">Espace pour les codes sources</p>
|
||||
<p className="text-sm text-gray-500">Gitea</p>
|
||||
</div>
|
||||
</a>
|
||||
)}
|
||||
|
||||
{mission.leantimeProjectId && (
|
||||
<div className="flex items-center justify-between p-3 bg-amber-50 rounded-lg border border-amber-100">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="w-10 h-10 bg-amber-100 rounded-full flex items-center justify-center">
|
||||
<Calendar className="h-5 w-5 text-amber-600" />
|
||||
</div>
|
||||
<div>
|
||||
<p className="font-medium text-gray-900">Tenant des Devoirs</p>
|
||||
<p className="text-sm text-gray-500">Leantime</p>
|
||||
</div>
|
||||
<a
|
||||
href={mission.leantimeProjectId.startsWith('http') ? mission.leantimeProjectId : `https://agilite.slm-lab.net/projects/showProject/${mission.leantimeProjectId}`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="flex items-center gap-3 p-3 bg-amber-50 rounded-lg border border-amber-100 hover:bg-amber-100 transition-colors cursor-pointer"
|
||||
>
|
||||
<div className="w-10 h-10 bg-amber-100 rounded-full flex items-center justify-center">
|
||||
<Calendar className="h-5 w-5 text-amber-600" />
|
||||
</div>
|
||||
<a
|
||||
href={getLeantimeUrl(mission.leantimeProjectId) || mission.leantimeProjectId}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="px-4 py-2 bg-amber-600 text-white rounded-md hover:bg-amber-700 transition-colors text-sm font-medium"
|
||||
>
|
||||
Ouvrir
|
||||
</a>
|
||||
</div>
|
||||
<div className="flex-1">
|
||||
<p className="font-medium text-gray-900">Espace d'organisation</p>
|
||||
<p className="text-sm text-gray-500">Leantime</p>
|
||||
</div>
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user