From 935f0aeed909a1566ad3bc199d4f2d0d4d0f0db6 Mon Sep 17 00:00:00 2001 From: Sebastian Stein Date: Tue, 25 Jun 2024 10:22:19 +0200 Subject: [PATCH] - removed GitHub Link in Sidebar for embedded mode --- src/App.tsx | 6 +++--- src/routes/sidebar.tsx | 23 +++++++++++++++-------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 1bb68cd8..c2f6c2e6 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,5 +1,5 @@ import { AppShell, SideBar, Content, AuthProvider, Modal, LoginPage, SignupPage, Quests, RequestPasswordPage, SetNewPasswordPage, OverlayProfile, OverlayProfileSettings, OverlayUserSettings, OverlayItemsIndexPage, OverlayItemProfile, OverlayItemProfileSettings, Permissions, Tags } from 'utopia-ui' -import { bottomRoutes, routes } from './routes/sidebar' +import { getBottomRoutes, routes } from './routes/sidebar' import { Route, Routes } from 'react-router-dom' import MapContainer from "./pages/MapContainer" import './App.css' @@ -15,7 +15,6 @@ import { Tag } from 'utopia-ui/dist/types' import { mapApi } from './api/mapApi' import { layersApi } from './api/layersApi' - function App() { @@ -80,7 +79,8 @@ function App() { }, [map]) - + const currentUrl = window.location.href; + const bottomRoutes = getBottomRoutes(currentUrl); if (map && layers) return ( diff --git a/src/routes/sidebar.tsx b/src/routes/sidebar.tsx index 2c4535ec..dcb07934 100644 --- a/src/routes/sidebar.tsx +++ b/src/routes/sidebar.tsx @@ -1,4 +1,3 @@ - import { MapIcon } from '@heroicons/react/24/outline' @@ -44,14 +43,22 @@ export const routes = [ */ ] -export const bottomRoutes = [ +export const getBottomRoutes = (currentUrl: string) => { + const url = new URL(currentUrl); + const isEmbedded = url.searchParams.get('embedded') === 'true'; + const bottomRoutes = [ + // Other routes can be added here + ]; - { - path: 'https://github.com/utopia-os/utopia-ui', // url - icon: , - name: 'Github', // name that appear in Sidebar - blank: true + if (!isEmbedded) { + bottomRoutes.push({ + path: 'https://github.com/utopia-os/utopia-ui', // url + icon: , + name: 'Github', // name that appear in Sidebar + blank: true + }); } -] \ No newline at end of file + return bottomRoutes; +};