From 5c897f4ffb0a1cadc4074e7f3b6a471898c5e48c Mon Sep 17 00:00:00 2001 From: Sascha Date: Thu, 25 Mar 2021 13:17:11 +0100 Subject: [PATCH 1/3] Fix invalid tab selection console error --- webui/src/components/Header/Header.tsx | 30 +++++++++++++++----------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/webui/src/components/Header/Header.tsx b/webui/src/components/Header/Header.tsx index 3064f6e4..864b2c39 100644 --- a/webui/src/components/Header/Header.tsx +++ b/webui/src/components/Header/Header.tsx @@ -67,14 +67,23 @@ const DisabledTabWithTooltip = (props: TabProps) => { function Header() { const classes = useStyles(); const location = useLocation(); - const [selectedTab, setTab] = React.useState(location.pathname); - const handleTabClick = ( - event: React.ChangeEvent<{}>, - newTabValue: string - ) => { - setTab(newTabValue); - }; + // Prevents error of invalid tab selection in + 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; + } + } return ( <> @@ -92,12 +101,7 @@ function Header() {
- + Date: Tue, 30 Mar 2021 21:46:39 +0200 Subject: [PATCH 2/3] Only set bugtitle if title is diffrent --- webui/src/components/BugTitleForm/BugTitleForm.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/webui/src/components/BugTitleForm/BugTitleForm.tsx b/webui/src/components/BugTitleForm/BugTitleForm.tsx index a7d5a820..bb4d2aa2 100644 --- a/webui/src/components/BugTitleForm/BugTitleForm.tsx +++ b/webui/src/components/BugTitleForm/BugTitleForm.tsx @@ -78,6 +78,10 @@ function BugTitleForm({ bug }: Props) { function submitNewTitle() { if (!isFormValid()) return; + if (bug.title === issueTitleInput.value) { + cancelChange(); + return; + } setTitle({ variables: { input: { @@ -106,7 +110,7 @@ function BugTitleForm({ bug }: Props) { function editableBugTitle() { return ( -
+ { issueTitleInput = node; @@ -123,7 +127,7 @@ function BugTitleForm({ bug }: Props) { className={classes.saveButton} size="small" variant="contained" - type="submit" + onClick={() => submitNewTitle()} disabled={issueTitle.length === 0} > Save From f980d9487ed1e764a364d5a1f385a09835276962 Mon Sep 17 00:00:00 2001 From: Sascha Date: Thu, 8 Apr 2021 15:50:59 +0200 Subject: [PATCH 3/3] Replace switch to save lines of code :-) --- webui/src/components/Header/Header.tsx | 17 ++++------------- 1 file 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 + // 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 (