-
Notifications
You must be signed in to change notification settings - Fork 0
feat(website): replace plain textarea in VariantEditor with validated AdvancedQueryFilter #1197
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| import { memo, useCallback, useRef } from 'react'; | ||
|
|
||
| import type { FilterObject, VariantUpdate } from '../../../types/Collection.ts'; | ||
| import { AdvancedQueryFilter } from '../../genspectrum/AdvancedQueryFilter.tsx'; | ||
| import { GsLineageFilter } from '../../genspectrum/GsLineageFilter.tsx'; | ||
| import { GsMutationFilter } from '../../genspectrum/GsMutationFilter.tsx'; | ||
|
|
||
|
|
@@ -11,6 +12,7 @@ type Props = { | |
| onRemove: (index: number) => void; | ||
| canRemove?: boolean; | ||
| lineageFields: string[]; | ||
| lapisUrl: string; | ||
| }; | ||
|
|
||
| // Memoized to prevent re-rendering all variant cards when only one changes in the parent list. | ||
|
|
@@ -21,6 +23,7 @@ export const VariantEditor = memo(function VariantEditor({ | |
| onRemove, | ||
| canRemove = true, | ||
| lineageFields, | ||
| lapisUrl, | ||
| }: Props) { | ||
| const variantRef = useRef(variant); | ||
| variantRef.current = variant; | ||
|
|
@@ -75,7 +78,14 @@ export const VariantEditor = memo(function VariantEditor({ | |
|
|
||
| <div className='col-span-2 flex flex-col gap-4'> | ||
| {variant.type === 'query' ? ( | ||
| <QueryVariantFields variant={variant} onChange={(v) => onChange(index, v)} /> | ||
| <AdvancedQueryFilter | ||
| enabled | ||
| lapisUrl={lapisUrl} | ||
| value={variant.countQuery} | ||
| allowedFields={lineageFields.length > 0 ? lineageFields : undefined} | ||
| onInput={(newValue) => onChange(index, { ...variant, countQuery: newValue ?? '' })} | ||
| errorTooltipClass='tooltip-top' | ||
| /> | ||
|
Comment on lines
+81
to
+88
Contributor
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.
Contributor
Author
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.
Contributor
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. Yes, we can improve later. |
||
| ) : ( | ||
| <MutationListVariantFields | ||
| filterObject={variant.filterObject} | ||
|
|
@@ -109,26 +119,6 @@ export const VariantEditor = memo(function VariantEditor({ | |
| ); | ||
| }); | ||
|
|
||
| function QueryVariantFields({ | ||
| variant, | ||
| onChange, | ||
| }: { | ||
| variant: Extract<VariantUpdate, { type: 'query' }>; | ||
| onChange: (v: VariantUpdate) => void; | ||
| }) { | ||
| return ( | ||
| <div className='flex flex-col'> | ||
| <label className='label'>Query</label> | ||
| <textarea | ||
| className='textarea textarea-bordered w-full max-w-xl font-mono text-sm' | ||
| placeholder='LAPIS filter expression for counting sequences matching this variant.' | ||
| value={variant.countQuery} | ||
| onChange={(e) => onChange({ ...variant, countQuery: e.currentTarget.value })} | ||
| /> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| // Memoized because GsMutationFilter is expensive to re-render. Relies on handleFilterObjectChange | ||
| // being stable (via useCallback) in the parent — otherwise memo would have no effect. | ||
| const MutationListVariantFields = memo(function MutationListVariantFields({ | ||
|
|
||


Uh oh!
There was an error while loading. Please reload this page.