Skip to content

Commit 36ea43d

Browse files
authored
Merge pull request #21 from oslabs-beta/ctstamper/Timeout
Made dialog popups DRY
2 parents 8809e73 + 35db8ae commit 36ea43d

File tree

1 file changed

+9
-23
lines changed

1 file changed

+9
-23
lines changed

src/app/containers/ButtonsContainer.tsx

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function ButtonsContainer(): JSX.Element {
5959

6060
//logic for handling dialog box opening and closing
6161
const handleReconnectClick = () => {
62-
connectionStatus ? setReconnectDialogOpen(true) : setDisconnectedDialogOpen(true);
62+
setReconnectDialogOpen(true);
6363
}
6464

6565
const handleReconnectConfirm = () => {
@@ -70,11 +70,11 @@ function ButtonsContainer(): JSX.Element {
7070

7171
const handleReconnectCancel = () => {
7272
//closing the dialog
73-
reconnectDialogOpen ? setReconnectDialogOpen(false) : setDisconnectedDialogOpen(false);
73+
setReconnectDialogOpen(false);
7474
}
7575

7676
useEffect(() => {
77-
if (!connectionStatus) setDisconnectedDialogOpen(true);
77+
if (!connectionStatus) setReconnectDialogOpen(true);
7878
}, [connectionStatus])
7979

8080
return (
@@ -125,32 +125,18 @@ function ButtonsContainer(): JSX.Element {
125125
<DialogContent>
126126
{/* //insert info here on current connection status */}
127127
<h3>Status: {connectionStatus ? 'Connected' : 'Disconnected'}</h3>
128-
Reconnecting while Reactime is still connected to application will clear all current data. Are you sure you want to proceed with the reconnection?
128+
{connectionStatus
129+
? 'Reconnecting while Reactime is still connected to application will clear all current data. Are you sure you want to proceed with the reconnection?'
130+
: 'Reactime has unexpectedly disconnected from your application. To continue using Reactime, please reconnect. WARNING: Reconnecting will clear all data currently stored in Reactime, so consider downloading the data before proceeding with the reconnection, if needed' }
129131
</DialogContent>
132+
{/* I don't know how to split this up ^ I wanted there to be a break between "please reconnect." and "WARNING:" but idk how */}
130133
<DialogActions>
131134
<Button onClick={() => handleReconnectCancel()} color="primary">
132135
Cancel
133136
</Button>
134-
<Button onClick={() => handleReconnectConfirm()} color="primary">
135-
Confirm Reconnect
136-
</Button>
137-
</DialogActions>
138-
</Dialog>
139-
<Dialog open={disconnectedDialogOpen} onClose={handleReconnectCancel}>
140-
<DialogTitle>Reactime Disconnected</DialogTitle>
141-
<DialogContent>
142-
{/* //insert info here on current connection status */}
143-
<h3>Status: {connectionStatus ? 'Connected' : 'Disconnected'}</h3>
144-
Reactime has unexpectedly disconnected from your application. To continue using Reactime, please reconnect.
145-
WARNING: Reconnecting will clear all data currently stored in Reactime, so consider downloading the data before proceeding with the reconnection, if needed.
146-
</DialogContent>
147-
<DialogActions>
148-
<Button onClick={() => handleReconnectCancel()} color="primary">
149-
Cancel
150-
</Button>
151-
<Button onClick={() => exportHandler(tabs[currentTab])} color="primary">
137+
{ !connectionStatus && <Button onClick={() => exportHandler(tabs[currentTab])} color="primary">
152138
Download
153-
</Button>
139+
</Button> }
154140
<Button onClick={() => handleReconnectConfirm()} color="primary">
155141
Reconnect
156142
</Button>

0 commit comments

Comments
 (0)