feat: add environment badge to commit id column in ApkTable

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-05 14:46:05 +08:00
parent 0b86887680
commit 31bbebc2ab

View File

@@ -1,9 +1,11 @@
'use client';
import { formatFileSize, formatDateTime } from '@/lib/utils';
import { type ApkEnvironment } from '@/lib/apk-parser';
interface Apk {
name: string;
environment: ApkEnvironment;
commit: string | null;
size: number;
modifiedAt: string;
@@ -14,6 +16,22 @@ interface ApkTableProps {
apks: Apk[];
}
function getEnvironmentBadgeClass(env: ApkEnvironment): string {
switch (env) {
case 'product':
return 'bg-blue-100 text-blue-800';
case 'dev':
case 'sandbox':
return 'bg-green-100 text-green-800';
default:
return 'bg-gray-100 text-gray-800';
}
}
function formatEnvironment(env: ApkEnvironment): string {
return env;
}
export default function ApkTable({ apks }: ApkTableProps) {
if (!apks || apks.length === 0) {
return (
@@ -46,9 +64,14 @@ export default function ApkTable({ apks }: ApkTableProps) {
{apks.map((apk) => (
<tr key={apk.name} className="hover:bg-gray-50">
<td className="px-6 py-4 whitespace-nowrap">
<span className="font-mono text-sm text-gray-900">
{apk.commit || '-'}
</span>
<div className="flex items-center gap-2">
<span className="font-mono text-sm text-gray-900">
{apk.commit || '-'}
</span>
<span className={`px-2 py-0.5 text-xs font-medium rounded ${getEnvironmentBadgeClass(apk.environment)}`}>
{formatEnvironment(apk.environment)}
</span>
</div>
</td>
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
{formatFileSize(apk.size)}