Skip to content

Commit

Permalink
fix: tip_label settable through json default
Browse files Browse the repository at this point in the history
The schema advertises the ability to set tip_label default
via .meta.diplay_default.tip_label (https://nextstrain.org/schemas/auspice/config/v2#/properties/display_defaults)
  • Loading branch information
corneliusroemer committed Sep 27, 2023
1 parent fca8b6f commit f059be6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cli/server/convertJsonSchemas.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ const setVaccineChoicesOnNodes = (v2, v1meta) => {
*/
const setLabels = (v2) => {
traverseTree(v2.tree, (node) => {
/* are their aa mutations? */
/* are there aa mutations? */
if (node.branch_attrs && node.branch_attrs.mutations) {
const mutations = node.branch_attrs.mutations;
const aaMutsToLabel = Object.keys(mutations)
Expand Down
8 changes: 4 additions & 4 deletions src/actions/recomputeReduxState.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ const restoreQueryableStateToDefaults = (state) => {

state["panelLayout"] = calcBrowserDimensionsInitialState().width > twoColumnBreakpoint ? "grid" : "full";
state.panelsToDisplay = state.panelsAvailable.slice();
state.tipLabelKey = strainSymbol;
state.scatterVariables = {};

state.showAllBranchLabels = false;
Expand Down Expand Up @@ -238,8 +237,8 @@ const modifyStateViaMetadata = (state, metadata, genomeMap) => {
state.filters[strainSymbol] = [];
state.filters[genotypeSymbol] = []; // this doesn't necessitate that mutations are defined
if (metadata.displayDefaults) {
const keysToCheckFor = ["geoResolution", "colorBy", "distanceMeasure", "layout", "mapTriplicate", "selectedBranchLabel", 'sidebar', "showTransmissionLines", "normalizeFrequencies"];
const expectedTypes = ["string", "string", "string", "string", "boolean", "string", 'string', "boolean" , "boolean"];
const keysToCheckFor = ["geoResolution", "colorBy", "distanceMeasure", "layout", "mapTriplicate", "selectedBranchLabel", 'sidebar', "showTransmissionLines", "normalizeFrequencies", "tipLabelKey"];
const expectedTypes = ["string", "string", "string", "string", "boolean", "string", 'string', "boolean" , "boolean" , "string" ];

for (let i = 0; i < keysToCheckFor.length; i += 1) {
if (Object.hasOwnProperty.call(metadata.displayDefaults, keysToCheckFor[i])) {
Expand Down Expand Up @@ -305,7 +304,7 @@ const modifyStateViaMetadata = (state, metadata, genomeMap) => {
state.panelsAvailable = state.panelsAvailable.filter((item) => item !== "entropy");
state.panelsToDisplay = state.panelsToDisplay.filter((item) => item !== "entropy");
if (Object.keys(metadata.colorings).includes('gt')) {
console.error("Genotype coloring ('gt') was specified as an option in the JSON, however the data does not support this: " +
console.error("Genotype coloring ('gt') was specified as an option in the JSON, however the data does not support this: " +
"check that 'metadata.genome_annotations' is correct and that mutations have been assigned to 'branch_attrs' on the tree.")
delete metadata.colorings.gt;
}
Expand Down Expand Up @@ -745,6 +744,7 @@ const createMetadataStateFromJSON = (json) => {
geo_resolution: "geoResolution",
distance_measure: "distanceMeasure",
branch_label: "selectedBranchLabel",
tip_label: "tipLabelKey",
map_triplicate: "mapTriplicate",
layout: "layout",
language: "language",
Expand Down

0 comments on commit f059be6

Please sign in to comment.