Fix cluster service page.
This commit is contained in:
@@ -24,6 +24,7 @@ export function ClusterServicesComponent() {
|
|||||||
switch (status) {
|
switch (status) {
|
||||||
case 'running':
|
case 'running':
|
||||||
case 'ready':
|
case 'ready':
|
||||||
|
case 'deployed':
|
||||||
return <CheckCircle className="h-5 w-5 text-green-500" />;
|
return <CheckCircle className="h-5 w-5 text-green-500" />;
|
||||||
case 'error':
|
case 'error':
|
||||||
return <AlertCircle className="h-5 w-5 text-red-500" />;
|
return <AlertCircle className="h-5 w-5 text-red-500" />;
|
||||||
@@ -36,19 +37,23 @@ export function ClusterServicesComponent() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getStatusBadge = (service: Service) => {
|
const getStatusBadge = (service: Service) => {
|
||||||
const status = service.status?.status || (service.deployed ? 'deployed' : 'available');
|
// Handle both old format (status as string) and new format (status as object)
|
||||||
|
const status = typeof service.status === 'string' ? service.status :
|
||||||
|
service.status?.status || (service.deployed ? 'deployed' : 'available');
|
||||||
|
|
||||||
const variants: Record<string, 'secondary' | 'default' | 'success' | 'destructive' | 'outline'> = {
|
const variants: Record<string, 'secondary' | 'default' | 'success' | 'destructive' | 'outline'> = {
|
||||||
|
'not-deployed': 'secondary',
|
||||||
available: 'secondary',
|
available: 'secondary',
|
||||||
deploying: 'default',
|
deploying: 'default',
|
||||||
installing: 'default',
|
installing: 'default',
|
||||||
running: 'success',
|
running: 'success',
|
||||||
ready: 'success',
|
ready: 'success',
|
||||||
|
deployed: 'success',
|
||||||
error: 'destructive',
|
error: 'destructive',
|
||||||
deployed: 'outline',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const labels: Record<string, string> = {
|
const labels: Record<string, string> = {
|
||||||
|
'not-deployed': 'Not Deployed',
|
||||||
available: 'Available',
|
available: 'Available',
|
||||||
deploying: 'Deploying',
|
deploying: 'Deploying',
|
||||||
installing: 'Installing',
|
installing: 'Installing',
|
||||||
@@ -59,7 +64,7 @@ export function ClusterServicesComponent() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Badge variant={variants[status]}>
|
<Badge variant={variants[status] || 'secondary'}>
|
||||||
{labels[status] || status}
|
{labels[status] || status}
|
||||||
</Badge>
|
</Badge>
|
||||||
);
|
);
|
||||||
@@ -210,16 +215,18 @@ export function ClusterServicesComponent() {
|
|||||||
{service.version}
|
{service.version}
|
||||||
</Badge>
|
</Badge>
|
||||||
)}
|
)}
|
||||||
{getStatusIcon(service.status?.status)}
|
{getStatusIcon(typeof service.status === 'string' ? service.status : service.status?.status)}
|
||||||
</div>
|
</div>
|
||||||
<p className="text-sm text-muted-foreground">{service.description}</p>
|
<p className="text-sm text-muted-foreground">{service.description}</p>
|
||||||
{service.status?.message && (
|
{typeof service.status === 'object' && service.status?.message && (
|
||||||
<p className="text-xs text-muted-foreground mt-1">{service.status.message}</p>
|
<p className="text-xs text-muted-foreground mt-1">{service.status.message}</p>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
{getStatusBadge(service)}
|
{getStatusBadge(service)}
|
||||||
{!service.deployed && (
|
{((typeof service.status === 'string' && service.status === 'not-deployed') ||
|
||||||
|
(!service.status || service.status === 'not-deployed') ||
|
||||||
|
(typeof service.status === 'object' && service.status?.status === 'not-deployed')) && (
|
||||||
<Button
|
<Button
|
||||||
size="sm"
|
size="sm"
|
||||||
onClick={() => handleInstallService(service.name)}
|
onClick={() => handleInstallService(service.name)}
|
||||||
@@ -228,7 +235,8 @@ export function ClusterServicesComponent() {
|
|||||||
{isInstalling ? <Loader2 className="h-4 w-4 animate-spin" /> : 'Install'}
|
{isInstalling ? <Loader2 className="h-4 w-4 animate-spin" /> : 'Install'}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
{service.deployed && (
|
{((typeof service.status === 'string' && service.status === 'deployed') ||
|
||||||
|
(typeof service.status === 'object' && service.status?.status === 'deployed')) && (
|
||||||
<Button
|
<Button
|
||||||
size="sm"
|
size="sm"
|
||||||
variant="destructive"
|
variant="destructive"
|
||||||
|
|||||||
@@ -2,8 +2,9 @@ export interface Service {
|
|||||||
name: string;
|
name: string;
|
||||||
description: string;
|
description: string;
|
||||||
version?: string;
|
version?: string;
|
||||||
status?: ServiceStatus;
|
status?: ServiceStatus | string; // Can be either an object or a string like 'deployed', 'not-deployed'
|
||||||
deployed?: boolean;
|
deployed?: boolean;
|
||||||
|
namespace?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ServiceStatus {
|
export interface ServiceStatus {
|
||||||
|
|||||||
Reference in New Issue
Block a user