aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/frontend/src/editor/ConnectButton.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'subprojects/frontend/src/editor/ConnectButton.tsx')
-rw-r--r--subprojects/frontend/src/editor/ConnectButton.tsx51
1 files changed, 33 insertions, 18 deletions
diff --git a/subprojects/frontend/src/editor/ConnectButton.tsx b/subprojects/frontend/src/editor/ConnectButton.tsx
index eed6fbc7..d08fbb4d 100644
--- a/subprojects/frontend/src/editor/ConnectButton.tsx
+++ b/subprojects/frontend/src/editor/ConnectButton.tsx
@@ -9,6 +9,7 @@ import CloudOffIcon from '@mui/icons-material/CloudOff';
9import SyncIcon from '@mui/icons-material/Sync'; 9import SyncIcon from '@mui/icons-material/Sync';
10import SyncProblemIcon from '@mui/icons-material/SyncProblem'; 10import SyncProblemIcon from '@mui/icons-material/SyncProblem';
11import IconButton from '@mui/material/IconButton'; 11import IconButton from '@mui/material/IconButton';
12import Tooltip from '@mui/material/Tooltip';
12import { keyframes, styled } from '@mui/material/styles'; 13import { keyframes, styled } from '@mui/material/styles';
13import { observer } from 'mobx-react-lite'; 14import { observer } from 'mobx-react-lite';
14 15
@@ -37,37 +38,51 @@ export default observer(function ConnectButton({
37 (editorStore.opening || editorStore.opened) 38 (editorStore.opening || editorStore.opened)
38 ) { 39 ) {
39 return ( 40 return (
40 <IconButton 41 <Tooltip
41 onClick={() => editorStore.disconnect()} 42 title={
42 aria-label="Disconnect" 43 editorStore.opening
43 color="inherit" 44 ? 'Connecting (click to cancel)'
45 : 'Connected (click to disconnect)'
46 }
44 > 47 >
45 {editorStore.opening ? ( 48 <IconButton
46 <AnimatedSyncIcon fontSize="small" /> 49 onClick={() => editorStore.disconnect()}
47 ) : ( 50 aria-label="Disconnect"
48 <CloudIcon fontSize="small" /> 51 color="inherit"
49 )} 52 >
50 </IconButton> 53 {editorStore.opening ? (
54 <AnimatedSyncIcon fontSize="small" />
55 ) : (
56 <CloudIcon fontSize="small" />
57 )}
58 </IconButton>
59 </Tooltip>
51 ); 60 );
52 } 61 }
53 62
63 let title: string;
54 let disconnectedIcon: JSX.Element; 64 let disconnectedIcon: JSX.Element;
55 if (editorStore === undefined) { 65 if (editorStore === undefined) {
66 title = 'Connecting';
56 disconnectedIcon = <SyncIcon fontSize="small" />; 67 disconnectedIcon = <SyncIcon fontSize="small" />;
57 } else if (editorStore.connectionErrors.length > 0) { 68 } else if (editorStore.connectionErrors.length > 0) {
69 title = 'Connection error (click to retry)';
58 disconnectedIcon = <SyncProblemIcon fontSize="small" />; 70 disconnectedIcon = <SyncProblemIcon fontSize="small" />;
59 } else { 71 } else {
72 title = 'Disconnected (click to connect)';
60 disconnectedIcon = <CloudOffIcon fontSize="small" />; 73 disconnectedIcon = <CloudOffIcon fontSize="small" />;
61 } 74 }
62 75
63 return ( 76 return (
64 <IconButton 77 <Tooltip title={title}>
65 disabled={editorStore === undefined} 78 <IconButton
66 onClick={() => editorStore?.connect()} 79 disabled={editorStore === undefined}
67 aria-label="Connect" 80 onClick={() => editorStore?.connect()}
68 color="inherit" 81 aria-label="Connect"
69 > 82 color="inherit"
70 {disconnectedIcon} 83 >
71 </IconButton> 84 {disconnectedIcon}
85 </IconButton>
86 </Tooltip>
72 ); 87 );
73}); 88});