Skip to content

Commit

Permalink
feat: add nuccore urls in metadata table
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-aksamentov committed Jan 17, 2023
1 parent 659af4c commit 9235b3c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
21 changes: 19 additions & 2 deletions src/components/Species/MetadataTable.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import React from 'react'
import React, { useMemo } from 'react'
import type { ColumnDef } from '@tanstack/react-table'
import { useTranslationSafe } from 'src/helpers/useTranslationSafe'
import { LinkExternal } from 'src/components/Link/LinkExternal'
import { MetadataEntry, SpeciesDesc, useSpeciesMetadata } from 'src/hooks/useDataIndexQuery'
import { Table } from 'src/components/Table/Table'
import { getColumnDefNames } from 'src/components/Table/helpers'
import { useTranslationSafe } from 'src/helpers/useTranslationSafe'

const METADATA_TABLE_COLUMNS: ColumnDef<MetadataEntry>[] = [
{
header: 'Accession',
accessorFn: (meta) => meta.accession,
size: 100,
cell: (context) => <NuccoreUrl accession={context.getValue<string>()} />,
},
{
header: 'Strain',
Expand Down Expand Up @@ -67,3 +69,18 @@ export function MetadataTable({ species }: MetadataTableProps) {
/>
)
}

export interface NuccoreUrlProps {
accession: string
}

export function NuccoreUrl({ accession }: NuccoreUrlProps) {
const { t } = useTranslationSafe()
const href = useMemo(() => `https://www.ncbi.nlm.nih.gov/nuccore/${accession}`, [accession])
const title = useMemo(() => t('Open in NCBI Nuccore'), [t])
return (
<LinkExternal href={href} title={title}>
{accession}
</LinkExternal>
)
}
21 changes: 11 additions & 10 deletions src/components/Species/SpeciesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { useGeneClusterData, useGeneClusterJson } from 'src/hooks/useDataIndexQu
import { GeneClustersTable } from 'src/components/Species/GeneClustersTable'
import { LOADING } from 'src/components/Loading/Loading'
import { Layout } from 'src/components/Layout/Layout'
import { MetadataTable } from './MetadataTable'
// import { MetadataTable } from 'src/components/Species/MetadataTable'

// const Msa = dynamic(() => import('src/components/Msa/Msa'), { suspense: true, ssr: false })
Expand Down Expand Up @@ -83,16 +84,16 @@ export function GeneClustersSection({ species }: GeneClustersSectionProps) {
</Col>
</Row>

{/*<Row noGutters>*/}
{/* <Col>*/}
{/* <MetadataTable species={species} />*/}
{/* </Col>*/}
{/*</Row>*/}
{/*<Row noGutters>*/}
{/* <Col>*/}
{/* <GeneClustersData species={species} gene={gene} />*/}
{/* </Col>*/}
{/*</Row>*/}
<Row noGutters>
<Col>
<MetadataTable species={species} />
</Col>
</Row>
<Row noGutters>
<Col>
<GeneClustersData species={species} gene={gene} />
</Col>
</Row>
</Container>
</Suspense>
)
Expand Down

1 comment on commit 9235b3c

@vercel
Copy link

@vercel vercel bot commented on 9235b3c Jan 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

pangenome – ./

pangenome-git-react-app-neherlab.vercel.app
pangenome-neherlab.vercel.app

Please sign in to comment.