-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38124 from appsmithorg/release
12/12 Daily Promotion
- Loading branch information
Showing
16 changed files
with
149 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,4 +27,6 @@ export const PropsToBeCssPrefixPrepended = [ | |
"px", | ||
"py", | ||
"gap", | ||
"rowGap", | ||
"columnGap", | ||
]; |
31 changes: 31 additions & 0 deletions
31
app/client/src/IDE/utils/filterEntityGroupsBySearchTerm.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { filterEntityGroupsBySearchTerm } from "."; | ||
|
||
const groups = [ | ||
{ | ||
name: "Group 1", | ||
items: [{ title: "file1" }, { title: "file2" }], | ||
}, | ||
{ | ||
title: "Group 2", | ||
items: [{ title: "file3" }, { title: "file4" }], | ||
}, | ||
]; | ||
|
||
describe("filterEntityGroupsBySearchTerm", () => { | ||
test.each([ | ||
["", groups], | ||
[ | ||
"file1", | ||
[ | ||
{ | ||
name: "Group 1", | ||
items: [{ title: "file1" }], | ||
}, | ||
], | ||
], | ||
["notfound", []], | ||
["file", groups], | ||
])("%s -> %j", (searchTerm, output) => { | ||
expect(filterEntityGroupsBySearchTerm(searchTerm, groups)).toEqual(output); | ||
}); | ||
}); |
43 changes: 43 additions & 0 deletions
43
app/client/src/IDE/utils/filterEntityGroupsBySearchTerm.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import Fuse, { type FuseOptions } from "fuse.js"; | ||
|
||
/** Searchable properties. Must be defined in this way to be able to derive union type and satisfy FuseOptions */ | ||
const keys: ["title"] = ["title"]; | ||
|
||
/** Union type to make sure these particular keys are present in collection that's being passed in for search. */ | ||
type Keys = (typeof keys)[number]; | ||
|
||
type BaseGroup = Record<PropertyKey, unknown>; | ||
type BaseItem = Record<Keys, string | number>; | ||
type Group<G extends BaseGroup, T extends BaseItem> = G & { | ||
items: T[]; | ||
}; | ||
|
||
const FUSE_OPTIONS: FuseOptions<BaseItem> = { | ||
shouldSort: true, | ||
threshold: 0.1, | ||
keys, | ||
}; | ||
|
||
/** Filter entity groups by search term using fuse.js */ | ||
export const filterEntityGroupsBySearchTerm = < | ||
G extends BaseGroup, | ||
T extends BaseItem, | ||
>( | ||
searchTerm: string, | ||
groups: Array<Group<G, T>>, | ||
): Array<Group<G, T>> => { | ||
if (!searchTerm) { | ||
return groups; | ||
} | ||
|
||
return groups.reduce((result: Array<Group<G, T>>, group) => { | ||
const { items, ...rest } = group; | ||
const searchResults = new Fuse(items, FUSE_OPTIONS).search(searchTerm); | ||
|
||
if (searchResults.length) { | ||
result.push({ ...rest, items: searchResults } as Group<G, T>); | ||
} | ||
|
||
return result; | ||
}, []); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { filterEntityGroupsBySearchTerm } from "./filterEntityGroupsBySearchTerm"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 0 additions & 51 deletions
51
app/client/src/pages/Editor/IDE/EditorPane/fuzzySearchInFiles.test.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.