-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into chart-pointer
- Loading branch information
Showing
15 changed files
with
311 additions
and
73 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
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
29 changes: 10 additions & 19 deletions
29
src/js/components/Beacon/BeaconCommon/ToolTips/VariantsInstructions.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
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 |
---|---|---|
@@ -1,21 +1,35 @@ | ||
import { Form, Input } from 'antd'; | ||
import { Form, Input, Select } from 'antd'; | ||
import type { DefaultOptionType } from 'antd/es/select/index'; | ||
import { useTranslationFn } from '@/hooks'; | ||
import type { FormField } from '@/types/beacon'; | ||
|
||
const VariantInput = ({ field, disabled }: VariantInputProps) => { | ||
type InputMode = { type: 'input' } | { type: 'select'; options?: DefaultOptionType[] }; | ||
|
||
const VariantInput = ({ field, disabled, mode }: VariantInputProps) => { | ||
const t = useTranslationFn(); | ||
return ( | ||
<div> | ||
<> | ||
<Form.Item name={field.name} label={t(field.name)} rules={field.rules}> | ||
<Input placeholder={field.placeholder} disabled={disabled} /> | ||
{!mode || mode.type === 'input' ? ( | ||
<Input placeholder={field.placeholder} disabled={disabled} /> | ||
) : ( | ||
<Select | ||
placeholder={field.placeholder} | ||
disabled={disabled} | ||
options={mode.options} | ||
showSearch={true} | ||
optionFilterProp="value" | ||
/> | ||
)} | ||
</Form.Item> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export interface VariantInputProps { | ||
field: FormField; | ||
disabled: boolean; | ||
mode?: InputMode; | ||
} | ||
|
||
export default VariantInput; |
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,50 @@ | ||
import { useEffect, useState } from 'react'; | ||
import { useAuthorizationHeader } from 'bento-auth-js'; | ||
import { referenceGenomesUrl } from '@/constants/configConstants'; | ||
import { useAppSelector } from '@/hooks'; | ||
import { RequestStatus } from '@/types/requests'; | ||
import type { GenomeFeature } from './types'; | ||
|
||
export const useReference = () => { | ||
return useAppSelector((state) => state.reference); | ||
}; | ||
|
||
export const useGeneNameSearch = (referenceGenomeID: string | undefined, nameQuery: string | null | undefined) => { | ||
const authHeader = useAuthorizationHeader(); | ||
|
||
const [status, setStatus] = useState<RequestStatus>(RequestStatus.Idle); | ||
const [data, setData] = useState<GenomeFeature[]>([]); | ||
const [error, setError] = useState<string | null>(null); | ||
|
||
useEffect(() => { | ||
if (!referenceGenomeID || !nameQuery) return; | ||
|
||
const params = new URLSearchParams({ name: nameQuery, name_fzy: 'true', limit: '10' }); | ||
const searchUrl = `${referenceGenomesUrl}/${referenceGenomeID}/features?${params.toString()}`; | ||
|
||
setError(null); | ||
|
||
(async () => { | ||
setStatus(RequestStatus.Pending); | ||
|
||
try { | ||
const res = await fetch(searchUrl, { headers: { Accept: 'application/json', ...authHeader } }); | ||
const resData = await res.json(); | ||
if (res.ok) { | ||
console.debug('Genome feature search - got results:', resData.results); | ||
setData(resData.results); | ||
setStatus(RequestStatus.Fulfilled); | ||
} else { | ||
setError(`Genome feature search failed with message: ${resData.message}`); | ||
setStatus(RequestStatus.Rejected); | ||
} | ||
} catch (e) { | ||
console.error(e); | ||
setError(`Genome feature search failed: ${(e as Error).toString()}`); | ||
setStatus(RequestStatus.Rejected); | ||
} | ||
})(); | ||
}, [referenceGenomeID, nameQuery, authHeader]); | ||
|
||
return { status, data, error }; | ||
}; |
Oops, something went wrong.