fix: show actual environment name for 'other' category
- Add rawEnvironment field to preserve extracted environment name - Display rawEnvironment (e.g., 'timeshift') instead of 'other' in badge Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -24,6 +24,7 @@ export async function GET(request: Request) {
|
|||||||
name: apk.name,
|
name: apk.name,
|
||||||
size: apk.size,
|
size: apk.size,
|
||||||
environment: parsed.environment,
|
environment: parsed.environment,
|
||||||
|
rawEnvironment: parsed.rawEnvironment,
|
||||||
commit: parsed.commit,
|
commit: parsed.commit,
|
||||||
modifiedAt: apk.modifiedAt.toISOString(),
|
modifiedAt: apk.modifiedAt.toISOString(),
|
||||||
downloadUrl: `/api/download?project=${encodeURIComponent(project)}&version=${encodeURIComponent(version)}&filename=${encodeURIComponent(apk.name)}`,
|
downloadUrl: `/api/download?project=${encodeURIComponent(project)}&version=${encodeURIComponent(version)}&filename=${encodeURIComponent(apk.name)}`,
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ const fetcher = (url: string) => fetch(url).then((res) => res.json());
|
|||||||
interface Apk {
|
interface Apk {
|
||||||
name: string;
|
name: string;
|
||||||
environment: ApkEnvironment;
|
environment: ApkEnvironment;
|
||||||
|
rawEnvironment: string;
|
||||||
commit: string | null;
|
commit: string | null;
|
||||||
size: number;
|
size: number;
|
||||||
modifiedAt: string;
|
modifiedAt: string;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { type ApkEnvironment } from '@/lib/apk-parser';
|
|||||||
interface Apk {
|
interface Apk {
|
||||||
name: string;
|
name: string;
|
||||||
environment: ApkEnvironment;
|
environment: ApkEnvironment;
|
||||||
|
rawEnvironment: string;
|
||||||
commit: string | null;
|
commit: string | null;
|
||||||
size: number;
|
size: number;
|
||||||
modifiedAt: string;
|
modifiedAt: string;
|
||||||
@@ -28,10 +29,6 @@ function getEnvironmentBadgeClass(env: ApkEnvironment): string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatEnvironment(env: ApkEnvironment): string {
|
|
||||||
return env;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function ApkTable({ apks }: ApkTableProps) {
|
export default function ApkTable({ apks }: ApkTableProps) {
|
||||||
if (!apks || apks.length === 0) {
|
if (!apks || apks.length === 0) {
|
||||||
return (
|
return (
|
||||||
@@ -69,7 +66,7 @@ export default function ApkTable({ apks }: ApkTableProps) {
|
|||||||
{apk.commit || '-'}
|
{apk.commit || '-'}
|
||||||
</span>
|
</span>
|
||||||
<span className={`px-2 py-0.5 text-xs font-medium rounded ${getEnvironmentBadgeClass(apk.environment)}`}>
|
<span className={`px-2 py-0.5 text-xs font-medium rounded ${getEnvironmentBadgeClass(apk.environment)}`}>
|
||||||
{formatEnvironment(apk.environment)}
|
{apk.rawEnvironment}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ export type ApkEnvironment = 'product' | 'dev' | 'sandbox' | 'other';
|
|||||||
|
|
||||||
export interface ParsedApkMetadata {
|
export interface ParsedApkMetadata {
|
||||||
environment: ApkEnvironment;
|
environment: ApkEnvironment;
|
||||||
|
rawEnvironment: string;
|
||||||
commit: string | null;
|
commit: string | null;
|
||||||
isValid: boolean;
|
isValid: boolean;
|
||||||
}
|
}
|
||||||
@@ -12,27 +13,27 @@ export function getApkTabs(): string[] {
|
|||||||
return APK_TABS;
|
return APK_TABS;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function detectEnvironment(prefix: string, configuredTabs: string[]): ApkEnvironment {
|
export function detectEnvironment(prefix: string, configuredTabs: string[]): { environment: ApkEnvironment; rawEnvironment: string } {
|
||||||
// Empty prefix → other
|
// Empty prefix → other
|
||||||
if (!prefix) {
|
if (!prefix) {
|
||||||
return 'other';
|
return { environment: 'other', rawEnvironment: 'other' };
|
||||||
}
|
}
|
||||||
|
|
||||||
// No underscore means product (e.g., "ft")
|
// No underscore means product (e.g., "ft")
|
||||||
if (!prefix.includes('_')) {
|
if (!prefix.includes('_')) {
|
||||||
return 'product';
|
return { environment: 'product', rawEnvironment: 'product' };
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract environment from last segment after underscore
|
// Extract environment from last segment after underscore
|
||||||
const lastUnderscoreIndex = prefix.lastIndexOf('_');
|
const lastUnderscoreIndex = prefix.lastIndexOf('_');
|
||||||
const env = prefix.substring(lastUnderscoreIndex + 1);
|
const rawEnv = prefix.substring(lastUnderscoreIndex + 1);
|
||||||
|
|
||||||
// Check if environment is configured
|
// Check if environment is configured
|
||||||
if (configuredTabs.includes(env)) {
|
if (configuredTabs.includes(rawEnv)) {
|
||||||
return env as ApkEnvironment;
|
return { environment: rawEnv as ApkEnvironment, rawEnvironment: rawEnv };
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'other';
|
return { environment: 'other', rawEnvironment: rawEnv };
|
||||||
}
|
}
|
||||||
|
|
||||||
export function parseApkFilename(filename: string, version: string): ParsedApkMetadata {
|
export function parseApkFilename(filename: string, version: string): ParsedApkMetadata {
|
||||||
@@ -48,7 +49,7 @@ export function parseApkFilename(filename: string, version: string): ParsedApkMe
|
|||||||
prefix = '';
|
prefix = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
const environment = detectEnvironment(prefix, APK_TABS);
|
const { environment, rawEnvironment } = detectEnvironment(prefix, APK_TABS);
|
||||||
|
|
||||||
// Extract commit ID
|
// Extract commit ID
|
||||||
const commitMatch = filename.match(/([a-f0-9]{7,})\.apk$/);
|
const commitMatch = filename.match(/([a-f0-9]{7,})\.apk$/);
|
||||||
@@ -56,6 +57,7 @@ export function parseApkFilename(filename: string, version: string): ParsedApkMe
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
environment,
|
environment,
|
||||||
|
rawEnvironment,
|
||||||
commit,
|
commit,
|
||||||
isValid: commit !== null,
|
isValid: commit !== null,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user