Skip to content
Permalink
Browse files

Display accession and/or URL in tip-click info box

This functionality was present in auspice v1 but broken during the move to v2. Includes some comments in the codebase for future refactoring.
  • Loading branch information...
jameshadfield committed Nov 5, 2019
1 parent 3838feb commit 304b958a9414e83377c8a3f60774820e4ae13134
Showing with 21 additions and 5 deletions.
  1. +5 −4 src/components/tree/infoPanels/click.js
  2. +16 −1 src/util/treeMiscHelpers.js
@@ -2,7 +2,7 @@ import React from "react";
import { isValueValid } from "../../../util/globals";
import { infoPanelStyles } from "../../../globalStyles";
import { numericToCalendar } from "../../../util/dateHelpers";
import { getTraitFromNode, getFullAuthorInfoFromNode, getVaccineFromNode } from "../../../util/treeMiscHelpers";
import { getTraitFromNode, getFullAuthorInfoFromNode, getVaccineFromNode, getAccessionFromNode, getUrlFromNode } from "../../../util/treeMiscHelpers";

export const styles = {
container: {
@@ -51,8 +51,9 @@ const formatURL = (url) => {
};

const AccessionAndUrl = ({node}) => {
const accession = getTraitFromNode(node, "accession");
const url = getTraitFromNode(node, "url");
const accession = getAccessionFromNode(node);
const url = getUrlFromNode(node);


if (isValueValid(accession) && isValueValid(url)) {
return (
@@ -70,7 +71,7 @@ const AccessionAndUrl = ({node}) => {
} else if (isValueValid(url)) {
return (
<tr>
<th style={infoPanelStyles.item}>URL</th>
<th style={infoPanelStyles.item}>Strain URL</th>
<td style={infoPanelStyles.item}>
<a href={formatURL(url)} target="_blank"><em>click here</em></a>
</td>
@@ -1,6 +1,14 @@

import { isValueValid } from "./globals";

/* --- TO IMPROVE -----
These "getter" functions for node-related data require knowledge of
the semantics of how data is stored on a node. For instance, you need
to know that `num_date` is stored in a different structure to `div`.
This logic should be encapsulated within `getTraitFromNode` so we
don't need separate `getDivFromNode` functions etc.
james hadfield, nov 2019.
*/

/**
* Given a coloring key or a geographic resolution key
* (sometimes referred to as a "trait")
@@ -35,13 +43,15 @@ export const getTraitFromNode = (node, trait, {entropy=false, confidence=false}=
};

export const getDivFromNode = (node) => {
/* see comment at top of this file */
if (node.node_attrs && node.node_attrs.div !== undefined) {
return node.node_attrs.div;
}
return undefined;
};

export const getVaccineFromNode = (node) => {
/* see comment at top of this file */
if (node.node_attrs && node.node_attrs.vaccine) {
return node.node_attrs.vaccine;
}
@@ -54,8 +64,13 @@ export const getFullAuthorInfoFromNode = (node) =>
undefined;

export const getAccessionFromNode = (node) => {
/* see comment at top of this file */
if (node.node_attrs && node.node_attrs.accession) {
return node.node_attrs.accession;
}
return undefined;
};

/* see comment at top of this file */
export const getUrlFromNode = (node) =>
(node.node_attrs && node.node_attrs.url) ? node.node_attrs.url : undefined;

0 comments on commit 304b958

Please sign in to comment.
You can’t perform that action at this time.