summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOskar <oskar@mullvad.net>2024-08-30 08:17:42 +0200
committerOskar <oskar@mullvad.net>2024-08-30 08:17:50 +0200
commit8d0f0d23bcc82267f36d7ea9ff820838242436f1 (patch)
treeab659e8fac396ab31b8f10da545122f0f82d4073
parent80ba0a368e61ae9c3718cf911bf1b1795e2de7e3 (diff)
downloadmullvadvpn-8d0f0d23bcc82267f36d7ea9ff820838242436f1.tar.xz
mullvadvpn-8d0f0d23bcc82267f36d7ea9ff820838242436f1.zip
Add ConnectionPanel back action
-rw-r--r--gui/src/renderer/components/KeyboardNavigation.tsx10
-rw-r--r--gui/src/renderer/components/main-view/ConnectionPanel.tsx49
2 files changed, 30 insertions, 29 deletions
diff --git a/gui/src/renderer/components/KeyboardNavigation.tsx b/gui/src/renderer/components/KeyboardNavigation.tsx
index fc11e54699..8ed3caa540 100644
--- a/gui/src/renderer/components/KeyboardNavigation.tsx
+++ b/gui/src/renderer/components/KeyboardNavigation.tsx
@@ -25,12 +25,10 @@ export default function KeyboardNavigation(props: IKeyboardNavigationProps) {
(event: KeyboardEvent) => {
if (event.key === 'Escape') {
const path = location.pathname as RoutePath;
- if (!disableDismissForRoutes.includes(path)) {
- if (event.shiftKey) {
- history.pop(true);
- } else {
- backAction?.();
- }
+ if (event.shiftKey && !disableDismissForRoutes.includes(path)) {
+ history.pop(true);
+ } else {
+ backAction?.();
}
}
},
diff --git a/gui/src/renderer/components/main-view/ConnectionPanel.tsx b/gui/src/renderer/components/main-view/ConnectionPanel.tsx
index 1d5c549254..8754547e1f 100644
--- a/gui/src/renderer/components/main-view/ConnectionPanel.tsx
+++ b/gui/src/renderer/components/main-view/ConnectionPanel.tsx
@@ -4,6 +4,7 @@ import styled from 'styled-components';
import { useBoolean } from '../../lib/utilityHooks';
import { useSelector } from '../../redux/store';
import CustomScrollbars from '../CustomScrollbars';
+import { BackAction } from '../KeyboardNavigation';
import ConnectionActionButton from './ConnectionActionButton';
import ConnectionDetails from './ConnectionDetails';
import ConnectionPanelChevron from './ConnectionPanelChevron';
@@ -86,28 +87,30 @@ export default function ConnectionPanel() {
useEffect(collapse, [tunnelState.state, collapse]);
return (
- <StyledConnectionPanel $expanded={expanded}>
- {allowExpand && (
- <StyledConnectionPanelChevron pointsUp={!expanded} onToggle={toggleExpanded} />
- )}
- <StyledConnectionStatusContainer
- $expanded={expanded}
- $hasFeatureIndicators={hasFeatureIndicators}
- onClick={toggleExpanded}>
- <ConnectionStatus />
- <Location />
- <Hostname />
- </StyledConnectionStatusContainer>
- <StyledCustomScrollbars>
- <FeatureIndicators expanded={expanded} expandIsland={expand} />
- <StyledAccordion expanded={expanded}>
- <ConnectionDetails />
- </StyledAccordion>
- </StyledCustomScrollbars>
- <StyledConnectionButtonContainer>
- <SelectLocationButton />
- <ConnectionActionButton />
- </StyledConnectionButtonContainer>
- </StyledConnectionPanel>
+ <BackAction disabled={!expanded} action={collapse}>
+ <StyledConnectionPanel $expanded={expanded}>
+ {allowExpand && (
+ <StyledConnectionPanelChevron pointsUp={!expanded} onToggle={toggleExpanded} />
+ )}
+ <StyledConnectionStatusContainer
+ $expanded={expanded}
+ $hasFeatureIndicators={hasFeatureIndicators}
+ onClick={toggleExpanded}>
+ <ConnectionStatus />
+ <Location />
+ <Hostname />
+ </StyledConnectionStatusContainer>
+ <StyledCustomScrollbars>
+ <FeatureIndicators expanded={expanded} expandIsland={expand} />
+ <StyledAccordion expanded={expanded}>
+ <ConnectionDetails />
+ </StyledAccordion>
+ </StyledCustomScrollbars>
+ <StyledConnectionButtonContainer>
+ <SelectLocationButton />
+ <ConnectionActionButton />
+ </StyledConnectionButtonContainer>
+ </StyledConnectionPanel>
+ </BackAction>
);
}