From 09ee3a1fe15a1f461f1486571390211b90eafc75 Mon Sep 17 00:00:00 2001 From: Troy Howard Date: Thu, 17 Oct 2024 13:47:58 -0700 Subject: [PATCH] Add special case to package search logic to include all packages tagged as native if the keyword "native" is in the filter text, even if the word isn't in the name/description text of the package. --- themes/default/theme/src/ts/packages.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/themes/default/theme/src/ts/packages.ts b/themes/default/theme/src/ts/packages.ts index 7289723ebd..e40e8459a0 100644 --- a/themes/default/theme/src/ts/packages.ts +++ b/themes/default/theme/src/ts/packages.ts @@ -22,7 +22,7 @@ const filterByTextAndTags = (filters, filterText) => { const packageType = el.attr("data-type"); const packageCategory = el.attr("data-category"); - const packageIsNative = packageType === "native-provider"; + let packageIsNative = packageType === "native-provider"; const packageHasSelectedType = !!filters.find(f => f.group === "type" && f.value === packageType) || (filters.find(f => f.group === "type" && f.value === "provider") && packageIsNative); @@ -30,10 +30,18 @@ const filterByTextAndTags = (filters, filterText) => { const packageTitle = el.attr("data-title"); const downcasedPackageTitle = packageTitle.toLowerCase(); - const downcasedFilterText = filterText?.trim().toLowerCase(); + let downcasedFilterText = filterText?.trim().toLowerCase(); + let packageIsAMatch; + // hack to include anything marked as native as responsive to a filter text including the word "native" + // see https://github.com/pulumi/registry/issues/5715 for reasoning + if (downcasedFilterText.includes("native")) { + downcasedFilterText = downcasedFilterText.replace(/native/g, ""); + packageIsNative = true; + } + if (downcasedFilterText === AMAZON_STRING || downcasedFilterText === AWS_STRING){ packageIsAMatch = downcasedPackageTitle.includes(AMAZON_STRING) || downcasedPackageTitle.includes(AWS_STRING); } else if (downcasedFilterText === GOOGLE_CLOUD_STRING || downcasedFilterText === GCP_STRING || downcasedFilterText === GOOGLE_STRING){