aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha <GlancingMind@outlook.com>2021-04-08 15:50:59 +0200
committerSascha <GlancingMind@outlook.com>2021-04-08 15:52:54 +0200
commitf980d9487ed1e764a364d5a1f385a09835276962 (patch)
treec23b997864e5abf59eeb02df259bec9f9cdcb58b
parent3d5ac70f0a1afa5a77ba1f9e2b23819fb07d5ad1 (diff)
downloadgit-bug-f980d9487ed1e764a364d5a1f385a09835276962.tar.gz
Replace switch to save lines of code :-)
-rw-r--r--webui/src/components/Header/Header.tsx17
1 files changed, 4 insertions, 13 deletions
diff --git a/webui/src/components/Header/Header.tsx b/webui/src/components/Header/Header.tsx
index 864b2c39..63146cc9 100644
--- a/webui/src/components/Header/Header.tsx
+++ b/webui/src/components/Header/Header.tsx
@@ -69,20 +69,11 @@ function Header() {
const location = useLocation();
// Prevents error of invalid tab selection in <Tabs>
+ // Will return a valid tab path or false if path is unkown.
function highlightTab() {
- switch (location.pathname) {
- case '/':
- return '/';
- case '/code':
- return '/code';
- case '/pulls':
- return '/pulls';
- case '/settings':
- return '/settings';
- default:
- // using false as value for tabs will result in no selected tab
- return false;
- }
+ const validTabs = ['/', '/code', '/pulls', '/settings'];
+ const tab = validTabs.find((tabPath) => tabPath === location.pathname);
+ return tab === undefined ? false : tab;
}
return (