Add warning dialog for unsupported browsers for directory sharing#1110
Add warning dialog for unsupported browsers for directory sharing#1110ibeckermayer merged 4 commits intomasterfrom
Conversation
begin directory sharing on an unsupported browser.
| .catch(() => { | ||
| setIsSharingDirectory(false); | ||
| }); | ||
| } catch (e) { |
There was a problem hiding this comment.
I'm not used to seeing a promise's .catch used in conjunction with a standard catch block. Are both of them going to be called in the event of an error?
There was a problem hiding this comment.
Are both of them going to be called in the event of an error?
No, what this means is if the Promise returned by window.showDirectoryPicker() is rejected (which happens if the user closes the directory picker without selecting a directory), we setIsSharingDirectory(false);. On the other hand, if the call to window.showDirectoryPicker() throws an error (as happens on browsers where this feature is not implemented, i.e.:Uncaught TypeError: window.showDirectoryPicker is not a function), we setDirectorySharingBrowserErr(true);.
Granted I'm making the assumption that those are the only two situations common enough to distinguish between, and we don't need to implement any finer grained handling within each block. In theory it's possible that there's some other reason that the promise might be rejected, and some other error that could be thrown, in which case the behavior may or may not be what we want.
|
|
||
| const [canShareDirectory, setCanShareDirectory] = useState(false); | ||
| const [isSharingDirectory, setIsSharingDirectory] = useState(false); | ||
| const [directorySharingBrowserErr, setDirectorySharingBrowserErr] = |
There was a problem hiding this comment.
Instead of 3 booleans, would it make more sense to have a directory sharing state? It could encode all of this info:
- has permissions to share
- is actively sharing
- failed to share due to an error
Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>
* `SharedDirectoryInfoResponse` (#996) * `SharedDirectoryListRequest` (#999) * `SharedDirectoryListResponse` (#1000) * `SharedDirectoryReadRequest` (#1003) * `SharedDirectoryReadResponse` (#1005) * `SharedDirectoryWriteRequest` (#1007) * `SharedDirectoryWriteResponse` (#1008) * Tidy up `sharedDirectoryManager` (#1010) * `SharedDirectoryMoveRequest` (#1045) * `SharedDirectoryMoveResponse` (#1074) * `SharedDirectoryCreateRequest` and `SharedDirectoryCreateResponse` (#1090) * SharedDirectoryDeleteRequest and SharedDirectoryDeleteResponse (#1096) * Add warning dialog for unsupported browsers for directory sharing (#1110) * updates yarn.lock
Adds logic for popping up a non-fatal dialog when the user attempts to initiate directory sharing on an unsupported browser.
Requires backport to v9/v10
How to test manually
webappstruewebapps/packages/teleport/src/config.ts
Line 32 in becfad3
yarn start-teleport --target=https://ec2-35-171-27-185.compute-1.amazonaws.com/What to expect
Due to an arbitrary choice in the ordering of a particular if-else-if statement, you must be logged in as a user with clipboard access disabled to test this change manually
From a browser which doesn't support the File Access API (Safari/FF):
Go to the top right
...menu and clickShare DirectoryYou should see a non-fatal warning dialog