Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add special case to package search logic for native providers. #5732

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions themes/default/theme/src/ts/packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,26 @@ 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);
const packageHasSelectedCategory = !!filters.find(f => f.group === "category" && f.value === packageCategory);

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){
Expand Down
Loading