fix(usage): format Last Active as local time on GPU & Storage tabs

The Last Active column had no renderer, so it dumped the raw ISO timestamp
(gpustack/gpustack#5523). It's a UTC instant (max bucket hour), so format it
to the user's local time with dayjs — matching the Resource Events time
column and the rest of the product. (Token Last Active is a daily date, not
an instant, so it stays a plain date with no timezone shift.)
This commit is contained in:
michelia
2026-06-09 11:54:28 +08:00
committed by michela feng
parent 878bdaa5a7
commit 7ce1faaf6c
2 changed files with 19 additions and 25 deletions
@@ -328,6 +328,13 @@ const GpuInstancesTab: React.FC = () => {
/>
)
};
// Last Active is a UTC instant (max bucket hour) → show formatted local time.
const lastActiveCol = {
title: intl.formatMessage({ id: 'usage.table.lastActive' }),
dataIndex: 'last_active',
key: 'last_active',
render: (v?: string) => (v ? dayjs(v).format('YYYY-MM-DD HH:mm:ss') : '-')
};
if (activeTableTab === 'gpu_type') {
return [
instanceTypeColType,
@@ -337,11 +344,7 @@ const GpuInstancesTab: React.FC = () => {
dataIndex: 'active_instances',
key: 'active_instances'
},
{
title: intl.formatMessage({ id: 'usage.table.lastActive' }),
dataIndex: 'last_active',
key: 'last_active'
}
lastActiveCol
];
}
if (activeTableTab === 'instance') {
@@ -353,11 +356,7 @@ const GpuInstancesTab: React.FC = () => {
},
instanceTypeColInstance,
...baseValueCols,
{
title: intl.formatMessage({ id: 'usage.table.lastActive' }),
dataIndex: 'last_active',
key: 'last_active'
}
lastActiveCol
];
}
// user tab
@@ -368,11 +367,7 @@ const GpuInstancesTab: React.FC = () => {
key: 'user_name'
},
...baseValueCols,
{
title: intl.formatMessage({ id: 'usage.table.lastActive' }),
dataIndex: 'last_active',
key: 'last_active'
}
lastActiveCol
];
}, [activeTableTab, tableSort, intl]);
+9 -10
View File
@@ -293,6 +293,13 @@ const StorageTab: React.FC = () => {
render: (v: number) => (v ?? 0).toFixed(2)
}
];
// Last Active is a UTC instant (max bucket hour) → show formatted local time.
const lastActiveCol = {
title: intl.formatMessage({ id: 'usage.table.lastActive' }),
dataIndex: 'last_active',
key: 'last_active',
render: (v?: string) => (v ? dayjs(v).format('YYYY-MM-DD HH:mm:ss') : '-')
};
if (activeTableTab === 'volume') {
return [
{
@@ -314,11 +321,7 @@ const StorageTab: React.FC = () => {
render: (v?: number) => (v ? `${Math.round(v / 1024)}GB` : '-')
},
...valueCols,
{
title: intl.formatMessage({ id: 'usage.table.lastActive' }),
dataIndex: 'last_active',
key: 'last_active'
}
lastActiveCol
];
}
return [
@@ -333,11 +336,7 @@ const StorageTab: React.FC = () => {
dataIndex: 'active_volumes',
key: 'active_volumes'
},
{
title: intl.formatMessage({ id: 'usage.table.lastActive' }),
dataIndex: 'last_active',
key: 'last_active'
}
lastActiveCol
];
}, [activeTableTab, tableSort, intl]);