From 93c6bbe404cf253049e77162f4aaee3ad2955e32 Mon Sep 17 00:00:00 2001 From: Stephen Zweibel Date: Fri, 3 Nov 2023 13:45:56 -0400 Subject: [PATCH] workshops --- components/Hooks/UseWorkshop.js | 18 +----------------- components/WorkshopsView.js | 2 +- pages/_app.js | 16 +++++++++++++++- pages/inst/index.js | 2 +- styles/styles.scss | 3 +-- 5 files changed, 19 insertions(+), 22 deletions(-) diff --git a/components/Hooks/UseWorkshop.js b/components/Hooks/UseWorkshop.js index f5eaba1..ca065b7 100644 --- a/components/Hooks/UseWorkshop.js +++ b/components/Hooks/UseWorkshop.js @@ -1,5 +1,4 @@ import useSWRImmutable from "swr/immutable"; -import { useSWRConfig } from "swr"; import { useState, useEffect } from "react"; import { GitHub } from "@mui/icons-material"; @@ -7,22 +6,7 @@ export default function useWorkshop(gitUser, gitFile, builtURL, editing) { let headers; const [shouldFetch, setShouldFetch] = useState(false); - const [cacheCleared, setCacheCleared] = useState(false); - const { cache, mutate } = useSWRConfig() - const clearCache = () => { - cache.clear() - } - - useEffect(() => { - if (editing == 'true' && cacheCleared == false) { - localStorage.removeItem('app-cache'); - localStorage.removeItem('app-cache-time'); - clearCache() - setCacheCleared(true) - console.log('cache cleared') - } - }, [editing]) - + if (process.env.NEXT_PUBLIC_GITHUBSECRET !== 'false') { headers = new Headers( { diff --git a/components/WorkshopsView.js b/components/WorkshopsView.js index ec64e49..edd9310 100644 --- a/components/WorkshopsView.js +++ b/components/WorkshopsView.js @@ -58,7 +58,7 @@ export default function WorkshopsView({ gitUser, gitRepo, instUser, instRepo }) if (workshops[v] && workshops[v].type != 'dir' && workshops[v].name != 'README.md') { return (
- {gitUser && gitRepo && + { } diff --git a/pages/_app.js b/pages/_app.js index 2db6390..5ef077c 100644 --- a/pages/_app.js +++ b/pages/_app.js @@ -12,9 +12,9 @@ import PyodideProvider from '../components/Wasm/PyodideProvider'; import { SWRConfig } from 'swr'; import { useRef } from 'react'; import NextNProgress from 'nextjs-progressbar'; +import { useSWRConfig } from "swr"; import { useRouter } from 'next/router'; - function MyApp({ Component, pageProps }) { const [title, setTitle] = useState(''); @@ -23,7 +23,12 @@ function MyApp({ Component, pageProps }) { const [gitRepo, setGitRepo] = useState(null); const [instGitUser, setInstGitUser] = useState(null); const [instGitRepo, setInstGitRepo] = useState(null); + const [cacheCleared, setCacheCleared] = useState(false); + const { cache, mutate } = useSWRConfig() const router = useRouter(); + const clearCache = () => { + cache.clear() + } useEffect(() => { @@ -35,6 +40,15 @@ function MyApp({ Component, pageProps }) { if (router.pathname === '/inst' && urlParams.get('user') && urlParams.get('repo')) { router.push('/inst?instUser=' + urlParams.get('user') + '&instRepo=' + urlParams.get('repo')) } + if (urlParams.get('edit') === 'true') { + if (cacheCleared == false) { + localStorage.removeItem('app-cache'); + localStorage.removeItem('app-cache-time'); + clearCache() + setCacheCleared(true) + console.log('cache cleared') + } + } }, [router]) pageProps.title = title diff --git a/pages/inst/index.js b/pages/inst/index.js index 64b68da..efeeaef 100644 --- a/pages/inst/index.js +++ b/pages/inst/index.js @@ -145,7 +145,7 @@ export default function Institute(props) {

Workshops

- {props.gitUser && props.gitRepo && parsedYAML && + {parsedYAML && }
diff --git a/styles/styles.scss b/styles/styles.scss index a372eeb..5190195 100644 --- a/styles/styles.scss +++ b/styles/styles.scss @@ -984,12 +984,11 @@ nav.sidenav { } // Glossary -.glossary{ +.glossary { flex-grow: 1; } // Forms - .form { width: 100%;