import React from "react"; import { useTranslation } from 'react-i18next'; import { useSelector } from "react-redux"; import { useAppDispatch } from "../../hooks"; import { toggleStreamTree, changeStreamTreeBranchLabel } from "../../actions/treeStreams"; import Toggle from "./toggle"; import { RootState } from "../../store"; import { FaInfoCircle } from "react-icons/fa"; import { SidebarSubtitleFlex, StyledTooltip, SidebarIconContainer } from "./styles"; import { controlsWidth } from "../../util/globals"; import CustomSelect from "./customSelect"; export const ChooseStreamTrees = (): JSX.Element => { const streamTreesToggledOn = useSelector((state: RootState) => state.controls.showStreamTrees); const streamTreeBranchLabel = useSelector((state: RootState) => state.controls.streamTreeBranchLabel); const showTreeToo = useSelector((state: RootState) => state.controls.showTreeToo); const focusOn = useSelector((state: RootState) => state.controls.focus); const rectangular = useSelector((state: RootState) => state.controls.layout === "rect"); const explodedTree = useSelector((state: RootState) => !!state.controls.explodeAttr); const availableBranchLabels = useSelector((state: RootState) => state.controls.availableStreamLabelKeys); const dispatch = useAppDispatch(); const { t } = useTranslation(); /** Certain conditions mean we can't show stream trees. If the dataset doesn't support them * (either because there are no branch labels on the tree or the dataset specifies an empty * array of `stream_labels`) we don't show any streamtrees-related UI. If the dataset supports * them but they're not available we show a disabled toggle and an info-box explanation */ if (!availableBranchLabels.length) return null; const unavailable = []; // empty array means it is available if (showTreeToo) unavailable.push("Two trees are being displayed"); if (focusOn) unavailable.push("'Focus on selected' is on"); if (!rectangular) unavailable.push("Tree layout is not rectangular"); if (explodedTree) unavailable.push("Viewing exploded tree"); const selectOptions = [ ...availableBranchLabels.map((x) => ({value: x, label: x})) ]; return (