UI: Avoid duplicate Windows major version in machine OS label (e.g., 'Windows 11 Pro (26100)')
This commit is contained in:
parent
66bf0cd9e1
commit
904c2ef457
2 changed files with 48 additions and 5 deletions
|
|
@ -952,9 +952,29 @@ export function AdminCompaniesManager({ initialCompanies }: { initialCompanies:
|
||||||
</Badge>
|
</Badge>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-wrap items-center gap-2 text-xs text-neutral-500">
|
<div className="flex flex-wrap items-center gap-2 text-xs text-neutral-500">
|
||||||
<span>{machine.osName ?? "SO desconhecido"}</span>
|
{(() => {
|
||||||
{machine.osVersion ? <span className="text-neutral-400">•</span> : null}
|
const name = machine.osName ?? "SO desconhecido"
|
||||||
{machine.osVersion ? <span>{machine.osVersion}</span> : null}
|
const ver = ((): string => {
|
||||||
|
const n = machine.osName ?? null
|
||||||
|
const v = machine.osVersion ?? null
|
||||||
|
if (!v) return ""
|
||||||
|
const m = (n ?? "").match(/^windows\s+(\d+)\b/i)
|
||||||
|
if (m) {
|
||||||
|
const major = m[1]
|
||||||
|
const re = new RegExp(`^\\s*${major}(?:\\b|\\.|-_|\\s)+(.*)$`, "i")
|
||||||
|
const mm = v.match(re)
|
||||||
|
if (mm) return (mm[1] ?? "").trim()
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
})()
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<span>{name}</span>
|
||||||
|
{ver ? <span className="text-neutral-400">•</span> : null}
|
||||||
|
{ver ? <span>{ver}</span> : null}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
})()}
|
||||||
{machine.architecture ? (
|
{machine.architecture ? (
|
||||||
<span className="rounded-full bg-white px-2 py-0.5 text-[11px] font-medium text-neutral-600 shadow-sm">
|
<span className="rounded-full bg-white px-2 py-0.5 text-[11px] font-medium text-neutral-600 shadow-sm">
|
||||||
{machine.architecture.toUpperCase()}
|
{machine.architecture.toUpperCase()}
|
||||||
|
|
|
||||||
|
|
@ -353,6 +353,24 @@ type WindowsOsInfo = {
|
||||||
experience?: string
|
experience?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function formatOsVersionDisplay(osName: string | null | undefined, osVersion: string | null | undefined) {
|
||||||
|
const name = (osName ?? "").trim()
|
||||||
|
const version = (osVersion ?? "").trim()
|
||||||
|
if (!version) return ""
|
||||||
|
// If Windows and version redundantly starts with the same major (e.g., "11 (26100)"), drop leading major
|
||||||
|
const winMatch = name.match(/^windows\s+(\d+)\b/i)
|
||||||
|
if (winMatch) {
|
||||||
|
const major = winMatch[1]
|
||||||
|
const re = new RegExp(`^\\s*${major}(?:\\b|\\.|-_|\\s)+(.*)$`, "i")
|
||||||
|
const m = version.match(re)
|
||||||
|
if (m) {
|
||||||
|
const rest = (m[1] ?? "").trim()
|
||||||
|
return rest
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return version
|
||||||
|
}
|
||||||
|
|
||||||
function parseWindowsOsInfo(raw: unknown): WindowsOsInfo | null {
|
function parseWindowsOsInfo(raw: unknown): WindowsOsInfo | null {
|
||||||
if (!raw) return null
|
if (!raw) return null
|
||||||
const parseRecord = (value: Record<string, unknown>) => {
|
const parseRecord = (value: Record<string, unknown>) => {
|
||||||
|
|
@ -1581,7 +1599,8 @@ export function MachineDetails({ machine }: MachineDetailsProps) {
|
||||||
const summaryChips = useMemo(() => {
|
const summaryChips = useMemo(() => {
|
||||||
const chips: Array<{ key: string; label: string; value: string; icon: ReactNode; tone?: "warning" | "muted" }> = []
|
const chips: Array<{ key: string; label: string; value: string; icon: ReactNode; tone?: "warning" | "muted" }> = []
|
||||||
const osName = osNameDisplay || "Sistema desconhecido"
|
const osName = osNameDisplay || "Sistema desconhecido"
|
||||||
const osVersion = machine?.osVersion ?? windowsVersionLabel ?? ""
|
const osVersionRaw = machine?.osVersion ?? windowsVersionLabel ?? ""
|
||||||
|
const osVersion = formatOsVersionDisplay(osNameDisplay, osVersionRaw)
|
||||||
chips.push({
|
chips.push({
|
||||||
key: "os",
|
key: "os",
|
||||||
label: "Sistema",
|
label: "Sistema",
|
||||||
|
|
@ -3193,7 +3212,11 @@ function MachineCard({ machine, companyName }: { machine: MachinesQueryItem; com
|
||||||
<CardContent className="flex grow flex-col gap-3 text-sm">
|
<CardContent className="flex grow flex-col gap-3 text-sm">
|
||||||
<div className="flex flex-wrap items-center gap-2">
|
<div className="flex flex-wrap items-center gap-2">
|
||||||
<Badge variant="outline" className="border-slate-300 bg-slate-100 text-xs font-medium text-slate-700">
|
<Badge variant="outline" className="border-slate-300 bg-slate-100 text-xs font-medium text-slate-700">
|
||||||
{machine.osName ?? "SO"} {machine.osVersion ?? ""}
|
{(() => {
|
||||||
|
const name = machine.osName ?? "SO"
|
||||||
|
const ver = formatOsVersionDisplay(machine.osName, machine.osVersion)
|
||||||
|
return [name, ver].filter(Boolean).join(" ").trim()
|
||||||
|
})()}
|
||||||
</Badge>
|
</Badge>
|
||||||
{machine.architecture ? (
|
{machine.architecture ? (
|
||||||
<Badge variant="outline" className="border-slate-300 bg-slate-100 text-xs font-medium text-slate-700">
|
<Badge variant="outline" className="border-slate-300 bg-slate-100 text-xs font-medium text-slate-700">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue