From c302f3fa83bf2dbd5df5112fbd62e54b6a1c2d1e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 26 Oct 2024 13:59:18 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- taxonium_website/src/App.jsx | 46 +++++++++++++++++---------------- taxonium_website/src/trees.json | 2 +- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/taxonium_website/src/App.jsx b/taxonium_website/src/App.jsx index feff83e8..bfd15c49 100644 --- a/taxonium_website/src/App.jsx +++ b/taxonium_website/src/App.jsx @@ -9,26 +9,29 @@ import useQueryAsState from "./hooks/useQueryAsState"; import classNames from "classnames"; import { useInputHelper } from "./hooks/useInputHelper"; import InputSupplier from "./components/InputSupplier"; -import treeConfig from './trees.json'; +import treeConfig from "./trees.json"; // Hardcoded list of paths to show in the showcase const SHOWCASE_PATHS = [ "sars-cov-2/public", "taxonomy/visual", "taxonomy/full", - "mpox/public" + "mpox/public", ]; function checkLegacyHostname() { const currentHostname = window.location.hostname; - + // Look through all configurations for matching legacy hostnames for (const [path, config] of Object.entries(treeConfig)) { - if (config.legacyHostnames && config.legacyHostnames.includes(currentHostname)) { + if ( + config.legacyHostnames && + config.legacyHostnames.includes(currentHostname) + ) { // If we find a match, redirect to the new path // Preserve any query parameters const newPath = `${window.location.protocol}//${window.location.host}/${path}${window.location.search}`; - + // Only redirect if we're not already on the correct path if (!window.location.pathname.startsWith(`/${path}`)) { window.location.href = newPath; @@ -36,7 +39,7 @@ function checkLegacyHostname() { } } } - + return false; } @@ -45,10 +48,10 @@ function getConfigFromPath() { if (checkLegacyHostname()) { return null; // Return null as we're about to redirect } - + // Remove leading slash and get full path const path = window.location.pathname.substring(1); - + // Return the configuration for this path, if it exists return treeConfig[path] || null; } @@ -57,19 +60,19 @@ function App() { useEffect(() => { import("taxonium-component"); }, []); - + const pathConfig = getConfigFromPath(); const default_query = pathConfig || {}; - + const [uploadedData, setUploadedData] = useState(null); const [query, updateQuery] = useQueryAsState(default_query); const [title, setTitle] = useState(null); const [beingDragged, setBeingDragged] = useState(false); const [aboutEnabled, setAboutEnabled] = useState(false); const [overlayContent, setOverlayContent] = useState(null); - + const dragTimeout = useRef(null); - + const inputHelper = useInputHelper({ setUploadedData, updateQuery, @@ -95,7 +98,10 @@ function App() { } function onDragOver(ev) { - if (uploadedData && (uploadedData.status === "loaded" || uploadedData.status === "loading")) { + if ( + uploadedData && + (uploadedData.status === "loaded" || uploadedData.status === "loading") + ) { ev.preventDefault(); return; } @@ -116,7 +122,7 @@ function App() { } // Generate showcase items from hardcoded list - const showCase = SHOWCASE_PATHS.map(path => { + const showCase = SHOWCASE_PATHS.map((path) => { const config = treeConfig[path]; if (!config) { console.warn(`No configuration found for showcase path: ${path}`); @@ -125,7 +131,7 @@ function App() { return { title: config.title, url: `/${path}`, - desc: config.description + desc: config.description, }; }).filter(Boolean); // Remove any null entries from missing configs @@ -150,7 +156,7 @@ function App() { className={classNames( "from-gray-500 to-gray-600 bg-gradient-to-bl shadow-md", "flex justify-between items-center px-4 flex-shrink-0", - "h-16" + "h-16" )} >