This repository was archived by the owner on Feb 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
SharedDirectoryMoveResponse
#1074
Merged
Merged
Changes from 7 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
250e9b7
Adds SharedDirectoryMoveResponse plumbing
53510cc
Adds a move method which won't actually work until that feature is ad…
5b9d7dd
Revert "Adds a move method which won't actually work until that featu…
a3a4d54
Makes all errors in a DesktopSession pop up as a dialog, allowing som…
f7db01d
Merge branch 'master' into isaiah/sd-move-response
6718389
removes unnecessary async
71502da
updates deprecated handleError description
cc3e2a1
Adds clarifying comment in handleSharedDirectoryMoveRequest
5849b9b
Changing copy
b568148
slight update to copy and removes unnecessary react.useState
ad9acbf
Updates snapshots
0815ca0
Merge branch 'master' into isaiah/sd-move-response
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -14,9 +14,15 @@ See the License for the specific language governing permissions and | |||||
| limitations under the License. | ||||||
| */ | ||||||
|
|
||||||
| import React, { PropsWithChildren } from 'react'; | ||||||
| import styled from 'styled-components'; | ||||||
| import { Indicator, Box, Alert, Text, Flex } from 'design'; | ||||||
| import React, { PropsWithChildren, useEffect, useState } from 'react'; | ||||||
| import { Indicator, Box, Text, Flex, ButtonSecondary } from 'design'; | ||||||
| import { Danger, Warning } from 'design/Alert'; | ||||||
| import Dialog, { | ||||||
| DialogHeader, | ||||||
| DialogTitle, | ||||||
| DialogContent, | ||||||
| DialogFooter, | ||||||
| } from 'design/Dialog'; | ||||||
|
|
||||||
| import TdpClientCanvas from 'teleport/components/TdpClientCanvas'; | ||||||
| import AuthnDialog from 'teleport/components/AuthnDialog'; | ||||||
|
|
@@ -40,42 +46,117 @@ export function DesktopSession(props: State) { | |||||
| clipboardState, | ||||||
| fetchAttempt, | ||||||
| tdpConnection, | ||||||
| wsConnection, | ||||||
| disconnected, | ||||||
| wsConnection, | ||||||
| setTdpConnection, | ||||||
| } = props; | ||||||
|
|
||||||
| const clipboardError = clipboardState.enabled && clipboardState.errorText; | ||||||
|
|
||||||
| const clipboardProcessing = | ||||||
| clipboardState.enabled && clipboardState.permission.state === 'prompt'; | ||||||
|
|
||||||
| // Websocket is closed but we haven't | ||||||
| // closed it on purpose or registered a tdp error. | ||||||
| const unknownConnectionError = | ||||||
| wsConnection === 'closed' && | ||||||
| !disconnected && | ||||||
| tdpConnection.status === 'success'; | ||||||
|
|
||||||
| const processing = | ||||||
| fetchAttempt.status === 'processing' || | ||||||
| tdpConnection.status === 'processing' || | ||||||
| clipboardProcessing; | ||||||
|
|
||||||
| let alertText: string; | ||||||
| if (fetchAttempt.status === 'failed') { | ||||||
| alertText = fetchAttempt.statusText || 'fetch attempt failed'; | ||||||
| } else if (tdpConnection.status === 'failed') { | ||||||
| alertText = tdpConnection.statusText || 'tdp connection failed'; | ||||||
| } else if (clipboardError) { | ||||||
| alertText = clipboardState.errorText || 'clipboard sharing failed'; | ||||||
| } else if (unknownConnectionError) { | ||||||
| alertText = 'Session disconnected for an unknown reason'; | ||||||
| } | ||||||
| // Manages the state of the error dialog. | ||||||
| const [errorDialog, setErrorDialog] = useState({ | ||||||
| open: false, | ||||||
| text: '', | ||||||
| fatal: false, | ||||||
| }); | ||||||
|
|
||||||
| // onDialogClose is called when a user | ||||||
| // dismisses a non-fatal error dialog. | ||||||
| const onDialogClose = () => { | ||||||
| // This setTdpConnection call will cause the useEffect below | ||||||
| // to calculate the errorDialog state. | ||||||
| setTdpConnection(prevState => { | ||||||
| // onDialogClose should only be called when | ||||||
| // the user dismisses a non-fatal error dialog, | ||||||
| // and prevState.status === '' means non-fatal | ||||||
| // error dialog, so the below if statement should | ||||||
| // always be true. | ||||||
| if (prevState.status === '') { | ||||||
| // If prevState.status was a non-fatal error, | ||||||
| // we assume that the TDP connection remains open. | ||||||
| return { status: 'success' }; | ||||||
| } | ||||||
| return prevState; | ||||||
| }); | ||||||
| }; | ||||||
|
|
||||||
| if (alertText) { | ||||||
| // Calculate the state of the error dialog based on the various | ||||||
| // sub-states which determine it. | ||||||
| useEffect(() => { | ||||||
| const clipboardError = clipboardState.enabled && clipboardState.errorText; | ||||||
|
|
||||||
| // Websocket is closed but we haven't | ||||||
| // closed it on purpose or registered a fatal tdp error. | ||||||
| const unknownConnectionError = | ||||||
| wsConnection === 'closed' && | ||||||
| !disconnected && | ||||||
| (tdpConnection.status === 'success' || tdpConnection.status === ''); | ||||||
|
|
||||||
| let errorText = ''; | ||||||
| if (fetchAttempt.status === 'failed') { | ||||||
| errorText = fetchAttempt.statusText || 'fetch attempt failed'; | ||||||
| } else if (tdpConnection.status === 'failed') { | ||||||
| errorText = tdpConnection.statusText || 'tdp connection failed'; | ||||||
| } else if (tdpConnection.status === '') { | ||||||
| errorText = tdpConnection.statusText || 'encountered a non-fatal error'; | ||||||
| } else if (clipboardError) { | ||||||
| errorText = clipboardState.errorText || 'clipboard sharing failed'; | ||||||
| } else if (unknownConnectionError) { | ||||||
| errorText = 'Session disconnected for an unknown reason'; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
and then the button could say also i'm confused whether our error messages should be all lower cap or properly capitalized with punctuation. I'm just seeing a mixture of both. It's not a big deal to me but just wondering in general
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In my opinion if we're displaying it as a message to the user, we should strive to give it proper capitalization and punctuation. |
||||||
| } | ||||||
|
|
||||||
| const open = errorText !== ''; | ||||||
| const fatal = tdpConnection.status !== ''; | ||||||
|
|
||||||
| setErrorDialog({ open, text: errorText, fatal }); | ||||||
| }, [clipboardState, fetchAttempt, tdpConnection, wsConnection, disconnected]); | ||||||
|
|
||||||
| if (errorDialog.open) { | ||||||
| return ( | ||||||
| <Session {...props}> | ||||||
| <DesktopSessionAlert my={2} mx={10} children={alertText} /> | ||||||
| <Dialog | ||||||
| dialogCss={() => ({ width: '484px' })} | ||||||
| onClose={onDialogClose} | ||||||
| open={errorDialog.open} | ||||||
| > | ||||||
| <DialogHeader style={{ flexDirection: 'column' }}> | ||||||
| {errorDialog.fatal && <DialogTitle>Fatal Error</DialogTitle>} | ||||||
| {!errorDialog.fatal && ( | ||||||
| <DialogTitle>Dismiss to Continue</DialogTitle> | ||||||
|
ibeckermayer marked this conversation as resolved.
Outdated
|
||||||
| )} | ||||||
| </DialogHeader> | ||||||
| <DialogContent> | ||||||
| {errorDialog.fatal && <Danger my={2} children={errorDialog.text} />} | ||||||
| {!errorDialog.fatal && ( | ||||||
| <Warning my={2} children={errorDialog.text} /> | ||||||
| )} | ||||||
| </DialogContent> | ||||||
|
|
||||||
|
ibeckermayer marked this conversation as resolved.
Outdated
|
||||||
| <DialogFooter> | ||||||
| {!errorDialog.fatal && ( | ||||||
| <ButtonSecondary size="large" width="30%" onClick={onDialogClose}> | ||||||
| Dismiss | ||||||
| </ButtonSecondary> | ||||||
| )} | ||||||
| {errorDialog.fatal && ( | ||||||
| <ButtonSecondary | ||||||
| size="large" | ||||||
| width="30%" | ||||||
| onClick={() => { | ||||||
| window.location.reload(); | ||||||
| }} | ||||||
| > | ||||||
| Retry | ||||||
|
ibeckermayer marked this conversation as resolved.
Outdated
|
||||||
| </ButtonSecondary> | ||||||
| )} | ||||||
| </DialogFooter> | ||||||
| </Dialog> | ||||||
| </Session> | ||||||
| ); | ||||||
| } | ||||||
|
|
@@ -145,7 +226,7 @@ function Session(props: PropsWithChildren<State>) { | |||||
|
|
||||||
| const showCanvas = | ||||||
| fetchAttempt.status === 'success' && | ||||||
| tdpConnection.status === 'success' && | ||||||
| (tdpConnection.status === 'success' || tdpConnection.status === '') && | ||||||
| wsConnection === 'open' && | ||||||
| !disconnected && | ||||||
| clipboardSuccess; | ||||||
|
|
@@ -228,8 +309,3 @@ function Session(props: PropsWithChildren<State>) { | |||||
| </Flex> | ||||||
| ); | ||||||
| } | ||||||
|
|
||||||
| const DesktopSessionAlert = styled(Alert)` | ||||||
| align-self: center; | ||||||
| min-width: 450px; | ||||||
| `; | ||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.