Centrale Refactor Big
This commit is contained in:
parent
be3f4cf508
commit
84bc21e37e
@ -61,6 +61,10 @@ interface Mission {
|
|||||||
createdAt: string;
|
createdAt: string;
|
||||||
creator: User;
|
creator: User;
|
||||||
missionUsers: any[];
|
missionUsers: any[];
|
||||||
|
rocketChatChannelId?: string | null;
|
||||||
|
outlineCollectionId?: string | null;
|
||||||
|
giteaRepositoryUrl?: string | null;
|
||||||
|
leantimeProjectId?: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function MissionDetailPage() {
|
export default function MissionDetailPage() {
|
||||||
@ -186,6 +190,60 @@ export default function MissionDetailPage() {
|
|||||||
iconPath: oddNumber ? `/F SDG Icons 2019 WEB/F-WEB-Goal-${oddNumber.padStart(2, '0')}.png` : ""
|
iconPath: oddNumber ? `/F SDG Icons 2019 WEB/F-WEB-Goal-${oddNumber.padStart(2, '0')}.png` : ""
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 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
|
// Handle delete mission
|
||||||
const handleDeleteMission = async () => {
|
const handleDeleteMission = async () => {
|
||||||
@ -568,6 +626,102 @@ export default function MissionDetailPage() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* Liens d'intégration */}
|
||||||
|
{(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>
|
||||||
|
<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>
|
||||||
|
</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>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{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>
|
||||||
|
</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>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{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>
|
||||||
|
</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>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{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>
|
||||||
|
</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>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Mission Status & Action Buttons */}
|
{/* Mission Status & Action Buttons */}
|
||||||
<div className="flex justify-between items-center">
|
<div className="flex justify-between items-center">
|
||||||
{/* Closed Status */}
|
{/* Closed Status */}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user