maestro/ui/src/lib/owner.ts
oss-sync 2bab882d08
Some checks failed
CI / build-and-test (push) Has been cancelled
sync: update from private repo (e7c4a56)
2026-06-09 09:43:05 +00:00

20 lines
819 B
TypeScript

/**
* Resolve the display name for a task / scheduled-task owner.
*
* - A real user name (resolved from the users JOIN) is shown as-is.
* - No-auth single-user deployments own rows under 'local' (new rows) or NULL
* (legacy rows created before owner registration was fixed). Both render as
* 'local' so the lone local operator is shown consistently — instead of the
* misleading 'system' / 'user' labels the views used to fall back to.
* - An owner id with no matching user record (e.g. a deleted account in an auth
* deployment) falls back to 'system'.
*/
export function ownerDisplayName(
ownerId: string | null | undefined,
ownerName: string | null | undefined,
): string {
if (ownerName) return ownerName;
if (ownerId == null || ownerId === 'local') return 'local';
return 'system';
}