-
Notifications
You must be signed in to change notification settings - Fork 11
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
Datagraph-search-filters #295
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
59e9ab0
fix bug with empty searchers
Southclaws 7a0eec8
add kind params to search
Southclaws 627f580
fix duplicate results by using two post searchers
Southclaws 3bd9c8b
implement datagraph search filters
Southclaws 0a66fab
remove search input from nav, fix required query param and tweak empt…
Southclaws 5b55611
oopsie
Southclaws 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 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
14 changes: 14 additions & 0 deletions
14
web/src/api/openapi-schema/requiredSearchQueryParameter.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,14 @@ | ||
/** | ||
* Generated by orval v7.2.0 🍺 | ||
* Do not edit manually. | ||
* storyden | ||
* Storyden social API for building community driven platforms. | ||
The Storyden API does not adhere to semantic versioning but instead applies a rolling strategy with deprecations and minimal breaking changes. This has been done mainly for a simpler development process and it may be changed to a more fixed versioning strategy in the future. Ultimately, the primary way Storyden tracks versions is dates, there are no set release tags currently. | ||
* OpenAPI spec version: rolling | ||
*/ | ||
|
||
/** | ||
* Search query string. | ||
*/ | ||
export type RequiredSearchQueryParameter = string; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { SearchIcon } from "@/components/ui/icons/Search"; | ||
import { LinkButtonStyleProps } from "@/components/ui/link-button"; | ||
|
||
import { Anchor, AnchorProps, MenuItem } from "./Anchor"; | ||
|
||
export const SearchID = "search"; | ||
export const SearchRoute = "/search"; | ||
export const SearchLabel = "Search"; | ||
|
||
type Props = AnchorProps & LinkButtonStyleProps; | ||
|
||
export function SearchAnchor(props: Props) { | ||
return ( | ||
<Anchor | ||
id={SearchID} | ||
route={SearchRoute} | ||
label={SearchLabel} | ||
icon={<SearchIcon />} | ||
{...props} | ||
/> | ||
); | ||
} | ||
|
||
export function SearchMenuItem() { | ||
return ( | ||
<MenuItem | ||
id={SearchID} | ||
route={SearchRoute} | ||
label={SearchLabel} | ||
icon={<SearchIcon />} | ||
/> | ||
); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { Portal, ToggleGroupValueChangeDetails } from "@ark-ui/react"; | ||
import { JSX } from "react"; | ||
import { Controller, ControllerProps, FieldValues } from "react-hook-form"; | ||
|
||
import * as ToggleGroup from "@/components/ui/toggle-group"; | ||
import * as Tooltip from "@/components/ui/tooltip"; | ||
import { HStack } from "@/styled-system/jsx"; | ||
|
||
type CollectionItem = { | ||
label: string; | ||
icon: JSX.Element; | ||
description: string; | ||
value: string; | ||
}; | ||
|
||
type Props<T extends FieldValues> = Omit<ControllerProps<T>, "render"> & { | ||
items: CollectionItem[]; | ||
}; | ||
|
||
export function DatagraphKindFilterField<T extends FieldValues>({ | ||
items, | ||
...props | ||
}: Props<T>) { | ||
return ( | ||
<Controller<T> | ||
{...props} | ||
render={({ formState, field }) => { | ||
function handleChangeFilter({ value }: ToggleGroupValueChangeDetails) { | ||
field.onChange(value); | ||
} | ||
Comment on lines
+27
to
+30
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add error handling for form state The component should handle and display form errors to provide feedback to users. render={({ formState, field }) => {
+ const error = formState.errors[props.name];
function handleChangeFilter({ value }: ToggleGroupValueChangeDetails) {
field.onChange(value);
}
+
+ return (
+ <div>
+ {/* Existing ToggleGroup implementation */}
+ {error && (
+ <div role="alert" style={{ color: 'red', marginTop: '4px' }}>
+ {error.message}
+ </div>
+ )}
+ </div>
+ );
|
||
|
||
return ( | ||
<ToggleGroup.Root | ||
multiple | ||
size="xs" | ||
onValueChange={handleChangeFilter} | ||
defaultValue={formState.defaultValues?.[props.name]} | ||
> | ||
{items.map((item) => ( | ||
<ToggleGroup.Item | ||
key={item.value} | ||
value={item.value} | ||
aria-label={item.description} | ||
> | ||
<Tooltip.Root | ||
lazyMount | ||
openDelay={0} | ||
positioning={{ | ||
slide: true, | ||
shift: -48, | ||
placement: "right-end", | ||
}} | ||
> | ||
<Tooltip.Trigger asChild> | ||
<HStack gap="1"> | ||
{item.icon} {item.label} | ||
</HStack> | ||
</Tooltip.Trigger> | ||
|
||
<Portal> | ||
<Tooltip.Positioner> | ||
<Tooltip.Arrow> | ||
<Tooltip.ArrowTip /> | ||
</Tooltip.Arrow> | ||
|
||
<Tooltip.Content>{item.description}</Tooltip.Content> | ||
</Tooltip.Positioner> | ||
</Portal> | ||
</Tooltip.Root> | ||
</ToggleGroup.Item> | ||
))} | ||
</ToggleGroup.Root> | ||
); | ||
}} | ||
/> | ||
); | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test coverage needed for the new search filters
The test is not verifying the new
kind
parameter functionality mentioned in the PR changes. Consider adding test cases that verify search results with differentkind
values to ensure the filter works correctly.Here's a suggested improvement:
Also add a test case for searching without the kind parameter to verify backward compatibility.