From 5ff1e8c006719fac8fa5358a42cf5dbe01d19f2e Mon Sep 17 00:00:00 2001 From: Oliver Kieselbach Date: Thu, 9 Jul 2026 14:15:19 +0200 Subject: [PATCH] added exact matches to tenant search --- .../components/TenantManagementSection.tsx | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/Web/autopilot-monitor-web/app/admin/components/TenantManagementSection.tsx b/src/Web/autopilot-monitor-web/app/admin/components/TenantManagementSection.tsx index f610736b..2e1ff48f 100644 --- a/src/Web/autopilot-monitor-web/app/admin/components/TenantManagementSection.tsx +++ b/src/Web/autopilot-monitor-web/app/admin/components/TenantManagementSection.tsx @@ -74,11 +74,21 @@ export function TenantManagementSection({ const [sendingWelcomeEmail, setSendingWelcomeEmail] = useState(false); const [notificationEmail, setNotificationEmail] = useState(""); - // Filter and sort tenants + // Filter and sort tenants. + // Quoted queries ("microsoft.com") do an exact, case-insensitive equality + // match against tenantId/domainName instead of a substring match. This lets + // you find a tenant like "microsoft.com" that would otherwise be swallowed by + // every "*.onmicrosoft.com" domain in a plain substring search. + const rawQuery = searchQuery.trim(); + const quotedMatch = rawQuery.match(/^"(.*)"$/); + const exactTerm = quotedMatch ? quotedMatch[1].toLowerCase() : null; + const substringTerm = searchQuery.toLowerCase(); const filteredTenants = tenants.filter(t => { - const matchesSearch = - t.tenantId.toLowerCase().includes(searchQuery.toLowerCase()) || - t.domainName.toLowerCase().includes(searchQuery.toLowerCase()); + const matchesSearch = exactTerm !== null + ? t.tenantId.toLowerCase() === exactTerm || + t.domainName.toLowerCase() === exactTerm + : t.tenantId.toLowerCase().includes(substringTerm) || + t.domainName.toLowerCase().includes(substringTerm); const matchesWaitlist = !showOnlyWaitlist || !previewApproved.has(t.tenantId); const matchesReady = !showOnlyReady || t.validateAutopilotDevice; return matchesSearch && matchesWaitlist && matchesReady; @@ -316,7 +326,7 @@ export function TenantManagementSection({ setSearchQuery(e.target.value)} className="w-full pl-10 pr-10 py-2 border border-gray-300 rounded-lg text-gray-900 placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition-colors"