Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

James/second tree dropdown #1795

Merged
merged 2 commits into from
Jun 27, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions src/components/controls/choose-second-tree.js
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous code used .filter in a rather strange way!

git blame just out of bootcamp Jover from ~5 years ago 🙈

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! I assumed it was me! Progress from each of us 😃

Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,12 @@ 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
)]

if (this.props.showTreeToo) options.unshift("REMOVE");

Expand Down