-
Notifications
You must be signed in to change notification settings - Fork 604
feat: logs v2 search #2812
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
Merged
Merged
feat: logs v2 search #2812
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
7c49bd1
feat: new filter logic
ogzhanolguncu 23b7393
fix: remove ununused hook
ogzhanolguncu feaa801
Merge branch 'main' into logs-v2-filter-cloud
ogzhanolguncu 92c1c99
fix: parsing logic
ogzhanolguncu 61c8abb
Merge branch 'logs-v2-filter-cloud' of github.com:unkeyed/unkey into …
ogzhanolguncu fd36900
[autofix.ci] apply automated fixes
autofix-ci[bot] 1cd7e17
chore: remove log
ogzhanolguncu 89281b2
Merge branch 'logs-v2-filter-cloud' of github.com:unkeyed/unkey into …
ogzhanolguncu 723738f
chore: revert flag
ogzhanolguncu 0c1b297
feat: add ui for logs search
ogzhanolguncu e9afe8e
fix: input for search
ogzhanolguncu 2dac542
feat: add structured query parsing
ogzhanolguncu 33116a9
feat: allow parsing multiple search
ogzhanolguncu 6beefba
chore: run formatter
ogzhanolguncu 964a99f
Merge branch 'main' of github.com:unkeyed/unkey into logs-v2-search
ogzhanolguncu df0903a
[autofix.ci] apply automated fixes
autofix-ci[bot] 5182ba5
chore: fix build issue
ogzhanolguncu 48b3bec
Merge branch 'logs-v2-search' of github.com:unkeyed/unkey into logs-v…
ogzhanolguncu bd6d6cb
fix: build issue
ogzhanolguncu 55f8301
fix: build error
ogzhanolguncu e0e4884
Merge branch 'main' into logs-v2-search
ogzhanolguncu bc967e3
feat: give preselected ai queries for users
ogzhanolguncu ffbd76a
refactor: common functions into a hook
ogzhanolguncu 1a6120e
refactor: checkbox component and selection logic
ogzhanolguncu cff30d0
refactor: allow easier filter navigation
ogzhanolguncu 8d4c067
refactor: add full keyboard navigation for selected filters
ogzhanolguncu 48881ec
fix: import path
ogzhanolguncu 39e2e62
Merge branch 'main' into logs-v2-search
ogzhanolguncu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
121 changes: 121 additions & 0 deletions
121
.../(app)/logs-v2/components/controls/components/logs-filters/components/filter-checkbox.tsx
This file contains hidden or 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,121 @@ | ||
| import type { FilterValue } from "@/app/(app)/logs-v2/filters.type"; | ||
| import { useFilters } from "@/app/(app)/logs-v2/hooks/use-filters"; | ||
| import { Checkbox } from "@/components/ui/checkbox"; | ||
| import { cn } from "@/lib/utils"; | ||
| import { Button } from "@unkey/ui"; | ||
| import { useCallback } from "react"; | ||
| import { useCheckboxState } from "./hooks/use-checkbox-state"; | ||
|
|
||
| export type BaseCheckboxOption = { | ||
| id: number; | ||
| checked: boolean; | ||
| [key: string]: any; | ||
| }; | ||
|
|
||
| interface BaseCheckboxFilterProps<TCheckbox extends BaseCheckboxOption> { | ||
| options: TCheckbox[]; | ||
| filterField: "methods" | "paths" | "status"; | ||
| checkPath: string; | ||
| className?: string; | ||
| showScroll?: boolean; | ||
| scrollContainerRef?: React.RefObject<HTMLDivElement>; | ||
| renderBottomGradient?: () => React.ReactNode; | ||
| renderOptionContent?: (option: TCheckbox) => React.ReactNode; | ||
| createFilterValue: (option: TCheckbox) => Pick<FilterValue, "value" | "metadata">; | ||
| } | ||
|
|
||
| export const FilterCheckbox = <TCheckbox extends BaseCheckboxOption>({ | ||
| options, | ||
| filterField, | ||
| checkPath, | ||
| className, | ||
| showScroll = false, | ||
| renderOptionContent, | ||
| createFilterValue, | ||
| scrollContainerRef, | ||
| renderBottomGradient, | ||
| }: BaseCheckboxFilterProps<TCheckbox>) => { | ||
| const { filters, updateFilters } = useFilters(); | ||
| const { checkboxes, handleCheckboxChange, handleSelectAll, handleKeyDown } = useCheckboxState({ | ||
| options, | ||
| filters, | ||
| filterField, | ||
| checkPath, | ||
| }); | ||
|
|
||
| const handleApplyFilter = useCallback(() => { | ||
| const selectedValues = checkboxes.filter((c) => c.checked).map((c) => createFilterValue(c)); | ||
|
|
||
| const otherFilters = filters.filter((f) => f.field !== filterField); | ||
| const newFilters: FilterValue[] = selectedValues.map((filterValue) => ({ | ||
| id: crypto.randomUUID(), | ||
| field: filterField, | ||
| operator: "is", | ||
| ...filterValue, | ||
| })); | ||
|
|
||
| updateFilters([...otherFilters, ...newFilters]); | ||
| }, [checkboxes, filterField, filters, updateFilters, createFilterValue]); | ||
|
|
||
| return ( | ||
| <div className={cn("flex flex-col p-2", className)}> | ||
| <div | ||
| className={cn( | ||
| "flex flex-col gap-2 font-mono px-2 py-2", | ||
| showScroll && | ||
| "max-h-64 overflow-auto [&::-webkit-scrollbar]:hidden [-ms-overflow-style:none] [scrollbar-width:none]", | ||
| )} | ||
| ref={scrollContainerRef} | ||
| > | ||
| <div className="flex justify-between items-center"> | ||
| <label | ||
| className="flex items-center gap-2 cursor-pointer" | ||
| // biome-ignore lint/a11y/noNoninteractiveElementToInteractiveRole: its okay | ||
| role="checkbox" | ||
| aria-checked={checkboxes.every((checkbox) => checkbox.checked)} | ||
| onKeyDown={handleKeyDown} | ||
| > | ||
| <Checkbox | ||
| tabIndex={0} | ||
| checked={checkboxes.every((checkbox) => checkbox.checked)} | ||
| className="size-[14px] rounded border-gray-4 [&_svg]:size-3" | ||
| onClick={handleSelectAll} | ||
| /> | ||
| <span className="text-xs text-accent-12 ml-2"> | ||
| {checkboxes.every((checkbox) => checkbox.checked) ? "Unselect All" : "Select All"} | ||
| </span> | ||
| </label> | ||
| </div> | ||
| {checkboxes.map((checkbox, index) => ( | ||
| <label | ||
| key={checkbox.id} | ||
| className="flex gap-4 items-center py-1 cursor-pointer" | ||
| // biome-ignore lint/a11y/noNoninteractiveElementToInteractiveRole: its okay | ||
| role="checkbox" | ||
| aria-checked={checkbox.checked} | ||
| onKeyDown={(e) => handleKeyDown(e, index)} | ||
| > | ||
| <Checkbox | ||
| tabIndex={0} | ||
| checked={checkbox.checked} | ||
| className="size-[14px] rounded border-gray-4 [&_svg]:size-3" | ||
| onClick={() => handleCheckboxChange(index)} | ||
| /> | ||
| {renderOptionContent ? renderOptionContent(checkbox) : null} | ||
| </label> | ||
| ))} | ||
| </div> | ||
|
|
||
| {renderBottomGradient?.()} | ||
|
|
||
| {renderBottomGradient && <div className="border-t border-gray-4" />} | ||
| <Button | ||
| variant="primary" | ||
| className="font-sans mt-2 w-full h-9 rounded-md" | ||
| onClick={handleApplyFilter} | ||
| > | ||
| Apply Filter | ||
| </Button> | ||
| </div> | ||
| ); | ||
| }; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.