Skip to content
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
29 changes: 19 additions & 10 deletions internal/dev_server/ui/src/Flags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,24 @@ function Flags({
const filteredFlags = useMemo(() => {
if (!flags) return [];
const flagEntries = Object.entries(flags);
const search = searchTerm.toLowerCase();
const filtered = fuzzysort
.go(search, flagEntries, { all: true, key: '0', threshold: 0.7 })
.map((result) => result.obj);
return filtered;
}, [flags, searchTerm]);
return flagEntries
.filter((entry) => {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored to be clearer filter entries. I assume we'll add another for tags in the future ;)

if (!searchTerm) return true;
const [flagKey] = entry;
const result = fuzzysort.single(searchTerm.toLowerCase(), flagKey);
return result && result.score > -5000; // Adjust threshold as needed
})
.filter((entry) => {
const [flagKey] = entry;
const hasOverride = flagKey in overrides;

if (onlyShowOverrides && !hasOverride) {
return false;
}

return true;
});
}, [flags, searchTerm, onlyShowOverrides]);

const paginatedFlags = useMemo(() => {
const startIndex = currentPage * flagsPerPage; // Adjust startIndex calculation
Expand Down Expand Up @@ -231,6 +243,7 @@ function Flags({
setSearchTerm(e.target.value);
setCurrentPage(0); // Reset pagination
}}
value={searchTerm}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously the input of the search box wasn't actually coupled to the display of the search... We were just relying on onChange events.

aria-label="Search flags input"
/>
<IconButton
Expand All @@ -249,10 +262,6 @@ function Flags({
const hasOverride = flagKey in overrides;
const currentValue = hasOverride ? overrideValue : flagValue;

if (onlyShowOverrides && !hasOverride) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was causing issues, because we need to not do any filter logic in the display logic for the pagination to work as expected.

return null;
}

return (
<li
key={flagKey}
Expand Down