-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Update cell strain links. (#968)
Resolves #912 Rather than adding additional logic to the InfoLink component that would only be used for cell strains, this adds a specific CellStrainInfoLink. This PR also moves the InfoLink components to their own files. Lastly, this PR uses the fractal file structure - it fits here anyway, but it would be great to know if there's broader buy in for using this pattern. If so, I'll move over the Hygen template from CZID so we won't have to manually set up the folder/file structure for each component we add.
- Loading branch information
Showing
5 changed files
with
56 additions
and
36 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
44 changes: 44 additions & 0 deletions
44
...pp/components/Dataset/SampleAndExperimentConditionsTable/components/InfoLink/InfoLink.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,44 @@ | ||
import { Link } from 'app/components/Link' | ||
import { | ||
NCBI, | ||
NCBI_ONTOLOGY_PATTERN, | ||
OBO, | ||
OBO_PATTERN, | ||
WORMBASE, | ||
WORMBASE_PATTERN, | ||
} from 'app/constants/datasetInfoLinks' | ||
|
||
export function InfoLink({ | ||
value, | ||
id, | ||
}: { | ||
value?: string | null | ||
id?: string | null | ||
}) { | ||
if (!value) { | ||
return <span>--</span> | ||
} | ||
|
||
if (id) { | ||
let link | ||
if (typeof id === 'number') { | ||
link = `${NCBI}${id as number}` | ||
} else if (id.match(NCBI_ONTOLOGY_PATTERN)) { | ||
link = `${NCBI}${id.replace('NCBITaxon:', '')}` | ||
} else if (id.match(WORMBASE_PATTERN)) { | ||
link = `${WORMBASE}${id.replaceAll(':', '_')}` | ||
} else if (id.match(OBO_PATTERN)) { | ||
link = `${OBO}${id.replaceAll(':', '_')}` | ||
} | ||
// don't link if no patterns match | ||
if (link) { | ||
return ( | ||
<Link to={link} className="text-sds-info-400"> | ||
{value} | ||
</Link> | ||
) | ||
} | ||
} | ||
|
||
return <span>{value}</span> | ||
} |
1 change: 1 addition & 0 deletions
1
...al/app/components/Dataset/SampleAndExperimentConditionsTable/components/InfoLink/index.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 @@ | ||
export { InfoLink } from './InfoLink' |
1 change: 1 addition & 0 deletions
1
...d/packages/data-portal/app/components/Dataset/SampleAndExperimentConditionsTable/index.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 @@ | ||
export { SampleAndExperimentConditionsTable } from './SampleAndExperimentConditionsTable' |
7 changes: 6 additions & 1 deletion
7
frontend/packages/data-portal/app/constants/datasetInfoLinks.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 |
---|---|---|
@@ -1,3 +1,8 @@ | ||
export const NIH = | ||
export const NCBI = | ||
'https://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?id=' | ||
export const OBO = 'http://purl.obolibrary.org/obo/' | ||
export const WORMBASE = 'https://wormbase.org/species/c_elegans/strain/' | ||
|
||
export const NCBI_ONTOLOGY_PATTERN = /NCBITaxon:[0-9]+/ | ||
export const OBO_PATTERN = /[a-zA-Z]+:[0-9]+/ | ||
export const WORMBASE_PATTERN = /WBStrain[0-9]{8}/ |