From f059be66feb9c133db1dca16f8f71955fc1faab4 Mon Sep 17 00:00:00 2001 From: Cornelius Roemer Date: Wed, 27 Sep 2023 17:52:59 +0200 Subject: [PATCH] fix: tip_label settable through json default 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) --- cli/server/convertJsonSchemas.js | 2 +- src/actions/recomputeReduxState.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cli/server/convertJsonSchemas.js b/cli/server/convertJsonSchemas.js index e4a804828..3b6547931 100644 --- a/cli/server/convertJsonSchemas.js +++ b/cli/server/convertJsonSchemas.js @@ -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) diff --git a/src/actions/recomputeReduxState.js b/src/actions/recomputeReduxState.js index e1168b1e7..5c1e96a3d 100644 --- a/src/actions/recomputeReduxState.js +++ b/src/actions/recomputeReduxState.js @@ -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; @@ -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])) { @@ -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; } @@ -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",