-
Notifications
You must be signed in to change notification settings - Fork 190
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 a component for filtering repositories based on their results #2343
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d30ca71
Add FilterKey type
robertbrignull 563720b
Rename SortableResult => FilterAndSortableResult
robertbrignull 18d7c89
Split out FilterAndSortableResultWithIds to mirror RepositoriesFilter…
robertbrignull 049b4c2
Change matchesFilter to accept a FilterAndSortableResult
robertbrignull 72c07a3
Implement support for new filterKey
robertbrignull 0685218
Clarify some behaviour in filterAndSortRepositoriesWithResults
robertbrignull 2701cd4
Add tests of the new filter key
robertbrignull 7fb9975
Add UI for repository filter component
robertbrignull ec35293
Add storybook for repository filter component
robertbrignull a8a84a6
Add changelog entry
robertbrignull dd630bf
Split tests up into describe blocks
robertbrignull 93acb76
Use punctuation to make test names clearer
robertbrignull 2844fed
Merge branch 'main' into robertbrignull/results_filter
robertbrignull 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
25 changes: 25 additions & 0 deletions
25
extensions/ql-vscode/src/stories/variant-analysis/RepositoriesFilter.stories.tsx
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,25 @@ | ||
import * as React from "react"; | ||
import { useState } from "react"; | ||
|
||
import { ComponentMeta } from "@storybook/react"; | ||
|
||
import { RepositoriesFilter as RepositoriesFilterComponent } from "../../view/variant-analysis/RepositoriesFilter"; | ||
import { FilterKey } from "../../pure/variant-analysis-filter-sort"; | ||
|
||
export default { | ||
title: "Variant Analysis/Repositories Filter", | ||
component: RepositoriesFilterComponent, | ||
argTypes: { | ||
value: { | ||
control: { | ||
disable: true, | ||
}, | ||
}, | ||
}, | ||
} as ComponentMeta<typeof RepositoriesFilterComponent>; | ||
|
||
export const RepositoriesFilter = () => { | ||
const [value, setValue] = useState(FilterKey.All); | ||
|
||
return <RepositoriesFilterComponent value={value} onChange={setValue} />; | ||
}; |
36 changes: 36 additions & 0 deletions
36
extensions/ql-vscode/src/view/variant-analysis/RepositoriesFilter.tsx
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,36 @@ | ||
import * as React from "react"; | ||
import { useCallback } from "react"; | ||
import styled from "styled-components"; | ||
import { VSCodeDropdown, VSCodeOption } from "@vscode/webview-ui-toolkit/react"; | ||
import { Codicon } from "../common"; | ||
import { FilterKey } from "../../pure/variant-analysis-filter-sort"; | ||
|
||
const Dropdown = styled(VSCodeDropdown)` | ||
width: 100%; | ||
`; | ||
|
||
type Props = { | ||
value: FilterKey; | ||
onChange: (value: FilterKey) => void; | ||
|
||
className?: string; | ||
}; | ||
|
||
export const RepositoriesFilter = ({ value, onChange, className }: Props) => { | ||
const handleInput = useCallback( | ||
(e: InputEvent) => { | ||
const target = e.target as HTMLSelectElement; | ||
|
||
onChange(target.value as FilterKey); | ||
}, | ||
[onChange], | ||
); | ||
|
||
return ( | ||
<Dropdown value={value} onInput={handleInput} className={className}> | ||
<Codicon name="list-filter" label="Filter..." slot="indicator" /> | ||
<VSCodeOption value={FilterKey.All}>All</VSCodeOption> | ||
<VSCodeOption value={FilterKey.WithResults}>With results</VSCodeOption> | ||
</Dropdown> | ||
); | ||
}; |
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
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.
Minor: Just a question around IDs, since I don't really understand where they come in to play with filtering 😅 When would repository IDs "be given"? As in, where do they come from?
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.
Good question! I believe the answer is whenever you're operating on a list of repos selected by the user, such as when exporting results or copying a repo list to the clipboard. A user can use the tickboxes to select repos, and we pass that list into here using the repository IDs.