fix(ui): simplify model deprecation countdown

This commit is contained in:
ishaan-j-berri 2026-11-05 17:03:44 +08:00
parent 0ad5d750d4
commit a5e41df46f
2 changed files with 30 additions and 4 deletions

View file

@ -16,8 +16,26 @@ export function DeprecationModel({ alert }: { alert: DeprecationAlert }) {
);
}
export function DeprecationTiming({ alert }: { alert: DeprecationAlert }) {
export function DeprecationTiming({
alert,
format = "sentence",
}: {
alert: DeprecationAlert;
format?: "sentence" | "duration";
}) {
const days = alert.model.days_until_deprecation;
if (format === "duration") {
if (days === 0) return <span title={alert.model.deprecation_date}>Today</span>;
return (
<span title={alert.model.deprecation_date}>
{Math.abs(days)}{" "}
<span className="text-sm font-normal text-muted-foreground">
{Math.abs(days) === 1 ? "day" : "days"}
{days < 0 ? " ago" : ""}
</span>
</span>
);
}
let label = `Deprecates in ${days} ${days === 1 ? "day" : "days"}`;
if (days === 0) label = "Deprecates today";
if (days < 0) label = `Deprecated ${Math.abs(days)} ${days === -1 ? "day" : "days"} ago`;

View file

@ -25,6 +25,12 @@ import { affectedTeams } from "./migrationData";
const TABLE_STATE = { sortFields: [], defaultSort: { id: "", desc: false }, defaultPageSize: 50, filterColumns: [] };
type KeyRow = components["schemas"]["KeySpendActivityRow"];
function deprecationTimingLabel(days: number): string {
if (days < 0) return "Deprecated";
if (days === 0) return "Deprecation";
return "Deprecates in";
}
function migrationHeading(alert: DeprecationAlert, status: AlertStatus): string {
if (status === AlertStatus.Resolved) return "Migration marked resolved";
if (status === AlertStatus.Dismissed) return "Model deprecation dismissed";
@ -266,9 +272,11 @@ export default function MigrationDetail({
<p className="mt-1 text-xl font-semibold tabular-nums">{teamQuery.data?.length ?? "—"}</p>
</div>
<div className="p-3">
<p className="text-xs text-muted-foreground">Deprecation</p>
<p className="mt-1 text-lg font-semibold">
<DeprecationTiming alert={selected} />
<p className="text-xs text-muted-foreground">
{deprecationTimingLabel(selected.model.days_until_deprecation)}
</p>
<p className="mt-1 text-xl font-medium tabular-nums">
<DeprecationTiming alert={selected} format="duration" />
</p>
</div>
</div>