fix: add edit buttons to resource table rows

This commit is contained in:
loveuer
2025-11-13 10:31:55 +08:00
parent 529a90b80d
commit 08be388322

View File

@@ -363,6 +363,33 @@ export default function K8sResourceList() {
<TableCell>{metadata.namespace || '-'}</TableCell> <TableCell>{metadata.namespace || '-'}</TableCell>
<TableCell>{`${status.readyReplicas || 0}/${spec.replicas || 0}`}</TableCell> <TableCell>{`${status.readyReplicas || 0}/${spec.replicas || 0}`}</TableCell>
<TableCell>{getAge(metadata.creationTimestamp)}</TableCell> <TableCell>{getAge(metadata.creationTimestamp)}</TableCell>
<TableCell>
<Tooltip title="编辑">
<IconButton
size="small"
onClick={() => handleEditResource(metadata.name, metadata.namespace, selectedKind.label)}
>
<EditIcon fontSize="small" />
</IconButton>
</Tooltip>
<Tooltip title="查看日志">
<IconButton
size="small"
onClick={() => handleViewLogs(metadata.name, metadata.namespace)}
>
<VisibilityIcon fontSize="small" />
</IconButton>
</Tooltip>
<Tooltip title="删除">
<IconButton
size="small"
color="error"
onClick={() => openDeleteDialog(metadata.name, metadata.namespace)}
>
<DeleteIcon fontSize="small" />
</IconButton>
</Tooltip>
</TableCell>
</TableRow> </TableRow>
) )
case 'service': case 'service':
@@ -375,6 +402,25 @@ export default function K8sResourceList() {
<TableCell>{spec.externalIPs?.join(', ') || status.loadBalancer?.ingress?.map((i: any) => i.ip || i.hostname).join(', ') || '-'}</TableCell> <TableCell>{spec.externalIPs?.join(', ') || status.loadBalancer?.ingress?.map((i: any) => i.ip || i.hostname).join(', ') || '-'}</TableCell>
<TableCell>{spec.ports?.map((p: any) => `${p.port}/${p.protocol}`).join(', ') || '-'}</TableCell> <TableCell>{spec.ports?.map((p: any) => `${p.port}/${p.protocol}`).join(', ') || '-'}</TableCell>
<TableCell>{getAge(metadata.creationTimestamp)}</TableCell> <TableCell>{getAge(metadata.creationTimestamp)}</TableCell>
<TableCell>
<Tooltip title="编辑">
<IconButton
size="small"
onClick={() => handleEditResource(metadata.name, metadata.namespace, selectedKind.label)}
>
<EditIcon fontSize="small" />
</IconButton>
</Tooltip>
<Tooltip title="删除">
<IconButton
size="small"
color="error"
onClick={() => openDeleteDialog(metadata.name, metadata.namespace)}
>
<DeleteIcon fontSize="small" />
</IconButton>
</Tooltip>
</TableCell>
</TableRow> </TableRow>
) )
case 'configmap': case 'configmap':
@@ -384,6 +430,25 @@ export default function K8sResourceList() {
<TableCell>{metadata.namespace || '-'}</TableCell> <TableCell>{metadata.namespace || '-'}</TableCell>
<TableCell>{Object.keys(resource.data || {}).length}</TableCell> <TableCell>{Object.keys(resource.data || {}).length}</TableCell>
<TableCell>{getAge(metadata.creationTimestamp)}</TableCell> <TableCell>{getAge(metadata.creationTimestamp)}</TableCell>
<TableCell>
<Tooltip title="编辑">
<IconButton
size="small"
onClick={() => handleEditResource(metadata.name, metadata.namespace, selectedKind.label)}
>
<EditIcon fontSize="small" />
</IconButton>
</Tooltip>
<Tooltip title="删除">
<IconButton
size="small"
color="error"
onClick={() => openDeleteDialog(metadata.name, metadata.namespace)}
>
<DeleteIcon fontSize="small" />
</IconButton>
</Tooltip>
</TableCell>
</TableRow> </TableRow>
) )
case 'pod': case 'pod':