diff --git a/CHANGELOG.md b/CHANGELOG.md index be0ecf2e8..c720c0b0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +* We no longer show the "second tree" sidebar dropdown when there are no available options. The possible options are defined by [the charon/getAvailable API](https://docs.nextstrain.org/projects/auspice/en/stable/server/api.html) response and as such vary depending on the server in use. ([#1795](https://github.com/nextstrain/auspice/pull/1795)) + + ## version 2.55.1 - 2024/06/25 diff --git a/src/components/controls/choose-second-tree.js b/src/components/controls/choose-second-tree.js index 296c9d8a3..b7a8766ba 100644 --- a/src/components/controls/choose-second-tree.js +++ b/src/components/controls/choose-second-tree.js @@ -26,14 +26,15 @@ class ChooseSecondTree extends React.Component { .replace(/\/$/, '') .split(':')[0]; - let options = []; - this.props.available.datasets - .filter((dataset) => { - if (dataset.request === displayedDataset) { - options = [...dataset.secondTreeOptions]; - } - return null; - }); + const options = [...new Set( + this.props.available.datasets + .filter((dataset) => dataset.request === displayedDataset) + .flatMap((dataset) => dataset.secondTreeOptions) + .filter((opt) => !!opt) // .secondTreeOptions is not required + )] + + // Don't display the sidebar UI if we're just going to display an empty dropdown! + if (!options.length) return null; if (this.props.showTreeToo) options.unshift("REMOVE");