-
-
Notifications
You must be signed in to change notification settings - Fork 87
Google Drive Data Sync #764
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Implement RemoteJsonBinDataService for JSONBin API integration, fix data persistence race condition with sequential saves, and add fullscreen loading spinner for network operations
|
Just for my clarification, is the intention for this that Andy would create the OAuth client, not individual users? |
Yes. The ForgeSteel OAuth client would be created once by Andy or someone official, and would be the thing that users are granting permission to access their Google Drive's appData folder. I went with appData so that users wouldn't have to grant permissions to their actual drive files, for security/privacy concerns. |
|
Also I'd suggest a squash if you guys accept this PR. |
|
Just a heads up there are a ton of linting errors when I run |
|
What is the expected error flow for a user? I'm in the process of trying this out, and once I connected via OAuth, nothing appears to have changed - the data still seems to be coming from the local storage. Then when I check the console, I see lots of 403 errors from all of the google api calls (I think that is just the client configuration taking time propagating through the google services, but maybe I missed something there). However, if I wasn't a developer, I'd have no way of knowing that something was going wrong. |
|
Heya! Thanks for checking this out. Some thoughts:
|
…d error-checking, only allowing transfers if GDrive is connected
|
OK, I simplified some changes and made it so that it doesn't show the transfer button or let you try to transfer if the Google Drive token has expired. So the user shouldn't face a bunch of forced popups. I also attached a PDF with a step by step of setting up the Client ID, I just ran through it and it works, so that should help. I'll work on linting next. |
|
Ok linting addressed, and more error-handling in place. Want to try it again? Now the user can't get to the transfer page if they aren't connected. One thing I didn't do is add error-handing if there a Google Client ID config issue, but I was reluctant to dive into that part of the transfer page. Maybe some try/catch blocks there, lmk. |
|
In terms of expected user flow, the way I set it up is the whole application still uses local storage like it always did, I didn't touch anything there. The google drive piece only comes into play in the transfer page (and the google settings panel). So you can transfer your local storage to and from google drive. That way you can be on multiple devices and connect to Google Drive with them (using the same email) and you'll be able to share data across by using the transfer page to upload/download data to/from google drive. Once it all seemed to be working, I thought a future PR could add some QoL if needed. |
|
I also noticed npm install added a bunch of peer deps to the package.lock, I can roll that file back if it should be unchanged. Lmk. |
|
It should be unchanged unless you're intentionally adding new dependencies. |
|
Lock file changes rolled back |
|
I think I'm misunderstanding the intended user experience, because when I connect to the Drive API, I still just see all of my local stuff - does this feature just provide a manual backup/sync option, and not change where the live data (what the user sees when using the app) is coming from? |
|
Hi @Veritas1000 the feature works the same way that the warehouse transfer feature does, same data paradigm. I wrote the Google drive as an optional drop in for the warehouse. The main app uses local storage, that part is unchanged. The way the Google drive piece works is on the transfer page, you can transfer your local data to and from Google drive. So it's basically being able to back up and restore your local hero and playbook data from Google drive. The only user interactions currently are just in the feature flags, Google drive connection panel, and the transfer page. Everything else in the app is unchanged. I could change it to not use the transfer page and just have "back to Google"/"restore backup from Google" buttons in the connection panel, but I was reluctant to step outside the merge/download paradigm established in the transfer page. |

Add Google Drive Sync Feature
Overview
resolves #200
Adds client-side Google Drive sync as an alternative to Warehouse for remote data storage. Users can now sync their Forge Steel data (heroes, homebrew.) to their personal Google Drive using the appDataFolder scope - no backend required, and no access required to a user's general Google Drive.
Changes
New Files
src/utils/google-drive-client.ts- Lightweight Drive v3 REST client using GISsrc/utils/remote-google-drive-data-service.ts- DataService implementation for Drive storagesrc/components/panels/connection-settings/google-drive-settings-panel.tsx- Panel for managing google drive.env.example- Template for environment variablesModified Files
src/models/connection-settings.ts- AddeduseGoogleDriveandgoogleClientIdfieldssrc/logic/update/connection-settings-update-logic.ts- Added defaults for new fieldssrc/utils/feature-flags.ts- AddedremoteGoogleDrivefeature flagsrc/components/pages/transfer/transfer-page.tsx- Added gdrive service into transfer logic, some UX updatessrc/components/modals/settings/settings-modal.tsx- Added section for Google Drivesrc/utils/feature-flags.ts- Added google drive feature flag.gitignore- Added.envand.env.localto ignore listHow It Works
forgesteel-data.json) in Drive'sappDataFolderhttps://www.googleapis.com/auth/drive.appdata(sensitive but not restricted)IMPORTANT! Required setup for non-local deployment
Create OAuth 2.0 Client ID in Google Cloud Console:
How to create a Client for GIS (1).pdf
Set environment variable:
User Experience
google-drivefeature flagTesting Checklist
Breaking Changes
Hopefully none - this is a new optional feature behind a feature flag.
Known Issues
NOTES
http://localhost:5173/forgesteel/) if you want you can use my Client ID (it only works on localhost) and put it into your ENV file. HMU if you want that client ID, basically make an env file, put the client ID in, and fire up the app locally and you'll be able to see the google drive stuff in action.Screenshots