-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[WIP] hosting the sync-server with the desktop app (POC) #3631
Draft
MikesGlitch
wants to merge
73
commits into
actualbudget:master
Choose a base branch
from
MikesGlitch:electron/server-hosting
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 49 commits
Commits
Show all changes
73 commits
Select commit
Hold shift + click to select a range
20e2ef2
start to this epic idea
MikesGlitch 361200e
bits
MikesGlitch c718b2c
add a note
MikesGlitch e32fb8b
server starting button erroring on imports due to env differences
MikesGlitch 1802818
working now
MikesGlitch 194f50d
using node_modules and allowing electron-builder to bundle it
MikesGlitch 7782f2d
ensuring deps are built before running server
MikesGlitch 55e9113
unneeded mode
MikesGlitch 3266319
exposing sync server via ngrok
MikesGlitch b3e6d28
log msg for dev
MikesGlitch ce5225e
using official ngrok package for smaller size
MikesGlitch 07e7730
comment
MikesGlitch b9c14dc
ngrok bits
MikesGlitch c6d2f59
correcting ngrok conditional logic
MikesGlitch 8eb145f
ngrok settings optional
MikesGlitch 23fdf04
bits
MikesGlitch 58aa350
moving server folders
MikesGlitch 2dc34de
package process
MikesGlitch 4873c9c
merge
MikesGlitch 5d01674
what an ordeal
MikesGlitch 8eca643
fixes
MikesGlitch b83a3c6
reenable sync server now tests have passed
MikesGlitch 39d060b
splitting up server management to allow config of desktop app server …
MikesGlitch 45d9fae
fix the port thing
MikesGlitch 0a333ed
tunnel erorrs cleanup
MikesGlitch a78ad88
trickle in
MikesGlitch 804425f
resetting state if not available to avoid hard crashes
MikesGlitch a1de454
small updates until I figure out what the issue is
MikesGlitch e1c5a68
merge
MikesGlitch 1178bec
Merge branch 'master' of https://github.com/MikesGlitch/actual into e…
MikesGlitch 17f520f
Merge branch 'master' of https://github.com/MikesGlitch/actual into e…
MikesGlitch 6d0363f
settings
MikesGlitch 7d5af1f
Merge branch 'master' of https://github.com/MikesGlitch/actual into e…
MikesGlitch f3c2743
remove it
MikesGlitch 76b2918
thoughts
MikesGlitch 9ff112c
waiting on sync server before starting
MikesGlitch 312e85e
fix timeout message
MikesGlitch 4f667d0
note
MikesGlitch a5f2f8b
Merge branch 'master' of https://github.com/MikesGlitch/actual into e…
MikesGlitch 79f648f
use env variable instead of https agent for default fetch
MikesGlitch 2265164
updating root ca impl to use node env variable for more support
MikesGlitch 4400ff1
release notes
MikesGlitch 98174bb
removing node-fetch
MikesGlitch 26adfec
clean up
MikesGlitch 8cfd39f
error message
MikesGlitch 4dd1fe0
merg
MikesGlitch 78fbebe
adding the sync server into the workspace as an experiment
MikesGlitch 5886678
merge
MikesGlitch 6513207
update server
MikesGlitch 99b6cb2
Merge branch 'master' of https://github.com/MikesGlitch/actual into e…
MikesGlitch 4036b57
responsive
MikesGlitch c718e67
test
MikesGlitch 2a1bb2c
put it back
MikesGlitch 8847f64
fix rootpath
MikesGlitch 0ce8c57
Merge branch 'master' of https://github.com/MikesGlitch/actual into e…
MikesGlitch 8037e03
Merge branch 'master' of https://github.com/MikesGlitch/actual into e…
MikesGlitch 6671e2c
merge
MikesGlitch 207d63e
Merge branch 'master' of https://github.com/MikesGlitch/actual into e…
MikesGlitch b539e7b
merge
MikesGlitch 99a97c6
Merge branch 'master' of https://github.com/MikesGlitch/actual into e…
MikesGlitch 2656d65
bits
MikesGlitch 3f70a9f
Merge branch 'master' of https://github.com/MikesGlitch/actual into e…
MikesGlitch 64b007f
Merge branch 'master' of https://github.com/MikesGlitch/actual into e…
MikesGlitch 3ada82a
update server
MikesGlitch 53f1054
yarn lock
MikesGlitch 2d27e1d
Merge branch 'master' of https://github.com/MikesGlitch/actual into e…
MikesGlitch f14a118
Merge branch 'master' of https://github.com/MikesGlitch/actual into e…
MikesGlitch 3e3d1cf
Merge branch 'master' of https://github.com/MikesGlitch/actual into e…
MikesGlitch 862c765
Merge branch 'master' of https://github.com/MikesGlitch/actual into e…
MikesGlitch c2aad50
updated server
MikesGlitch 606fe7e
update the lock
MikesGlitch 851f1ef
merge
MikesGlitch f57dac2
merge
MikesGlitch 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 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 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 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 |
---|---|---|
|
@@ -10,6 +10,7 @@ playwright-report | |
|
||
# production | ||
build | ||
build-electron | ||
build-stats | ||
stats.json | ||
|
||
|
This file contains 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
273 changes: 273 additions & 0 deletions
273
packages/desktop-client/src/components/manager/ConfigExternalSyncServer.tsx
This file contains 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 |
---|---|---|
@@ -0,0 +1,273 @@ | ||
// @ts-strict-ignore | ||
import React, { useState, useEffect, useCallback } from 'react'; | ||
import { Trans, useTranslation } from 'react-i18next'; | ||
|
||
import { | ||
isNonProductionEnvironment, | ||
isElectron, | ||
} from 'loot-core/src/shared/environment'; | ||
|
||
import { useActions } from '../../hooks/useActions'; | ||
import { useGlobalPref } from '../../hooks/useGlobalPref'; | ||
import { useNavigate } from '../../hooks/useNavigate'; | ||
import { theme } from '../../style'; | ||
import { Button, ButtonWithLoading } from '../common/Button2'; | ||
import { BigInput } from '../common/Input'; | ||
import { Link } from '../common/Link'; | ||
import { Text } from '../common/Text'; | ||
import { View } from '../common/View'; | ||
import { useServerURL, useSetServerURL } from '../ServerContext'; | ||
|
||
import { Title } from './subscribe/common'; | ||
|
||
export function ConfigExternalSyncServer() { | ||
const { t } = useTranslation(); | ||
const { createBudget, signOut, loggedIn } = useActions(); | ||
const navigate = useNavigate(); | ||
const [url, setUrl] = useState(''); | ||
const currentUrl = useServerURL(); | ||
const setServerUrl = useSetServerURL(); | ||
useEffect(() => { | ||
setUrl(currentUrl); | ||
}, [currentUrl]); | ||
const [loading, setLoading] = useState(false); | ||
const [error, setError] = useState<string | null>(null); | ||
|
||
const restartElectronServer = useCallback(() => { | ||
globalThis.window.Actual.restartElectronServer(); | ||
setError(null); | ||
}, []); | ||
|
||
const [_serverSelfSignedCert, setServerSelfSignedCert] = useGlobalPref( | ||
'serverSelfSignedCert', | ||
restartElectronServer, | ||
); | ||
|
||
function getErrorMessage(error: string) { | ||
switch (error) { | ||
case 'network-failure': | ||
return t( | ||
'Server is not running at this URL. Make sure you have HTTPS set up properly.', | ||
); | ||
default: | ||
return t( | ||
'Server does not look like an Actual server. Is it set up correctly?', | ||
); | ||
} | ||
} | ||
|
||
async function onSubmit() { | ||
if (url === '' || loading) { | ||
return; | ||
} | ||
|
||
setError(null); | ||
setLoading(true); | ||
const { error } = await setServerUrl(url); | ||
|
||
if ( | ||
['network-failure', 'get-server-failure'].includes(error) && | ||
!url.startsWith('http://') && | ||
!url.startsWith('https://') | ||
) { | ||
const { error } = await setServerUrl('https://' + url); | ||
if (error) { | ||
setUrl('https://' + url); | ||
setError(error); | ||
} else { | ||
await signOut(); | ||
navigate('/'); | ||
} | ||
setLoading(false); | ||
} else if (error) { | ||
setLoading(false); | ||
setError(error); | ||
} else { | ||
setLoading(false); | ||
await signOut(); | ||
navigate('/'); | ||
} | ||
} | ||
|
||
function onSameDomain() { | ||
setUrl(window.location.origin); | ||
} | ||
|
||
async function onSelectSelfSignedCertificate() { | ||
const selfSignedCertificateLocation = await window.Actual?.openFileDialog({ | ||
properties: ['openFile'], | ||
filters: [ | ||
{ | ||
name: 'Self Signed Certificate', | ||
extensions: ['crt', 'pem'], | ||
}, | ||
], | ||
}); | ||
|
||
if (selfSignedCertificateLocation) { | ||
setServerSelfSignedCert(selfSignedCertificateLocation[0]); | ||
} | ||
} | ||
|
||
async function onSkip() { | ||
await setServerUrl(null); | ||
await loggedIn(); | ||
navigate('/'); | ||
} | ||
|
||
async function onCreateTestFile() { | ||
await setServerUrl(null); | ||
await createBudget({ testMode: true }); | ||
window.__navigate('/'); | ||
} | ||
|
||
if (isElectron()) { | ||
} | ||
|
||
return ( | ||
<View style={{ maxWidth: 500, marginTop: -30 }}> | ||
<Title text={t('Server configuration')} /> | ||
|
||
<Text | ||
style={{ | ||
fontSize: 16, | ||
color: theme.tableRowHeaderText, | ||
lineHeight: 1.5, | ||
}} | ||
> | ||
{currentUrl ? ( | ||
<Trans> | ||
Existing sessions will be logged out and you will log in to this | ||
server. We will validate that Actual is running at this URL. | ||
</Trans> | ||
) : ( | ||
<Trans> | ||
There is no server configured. After running the server, specify the | ||
URL here to use the app. You can always change this later. We will | ||
validate that Actual is running at this URL. | ||
</Trans> | ||
)} | ||
</Text> | ||
|
||
{error && ( | ||
<> | ||
<Text | ||
style={{ | ||
marginTop: 20, | ||
color: theme.errorText, | ||
borderRadius: 4, | ||
fontSize: 15, | ||
}} | ||
> | ||
{getErrorMessage(error)} | ||
</Text> | ||
{isElectron() && ( | ||
<View | ||
style={{ display: 'flex', flexDirection: 'row', marginTop: 20 }} | ||
> | ||
<Text | ||
style={{ | ||
color: theme.errorText, | ||
borderRadius: 4, | ||
fontSize: 15, | ||
}} | ||
> | ||
<Trans> | ||
If the server is using a self-signed certificate{' '} | ||
<Link | ||
variant="text" | ||
style={{ fontSize: 15 }} | ||
onClick={onSelectSelfSignedCertificate} | ||
> | ||
select it here | ||
</Link> | ||
. | ||
</Trans> | ||
</Text> | ||
</View> | ||
)} | ||
</> | ||
)} | ||
|
||
<View style={{ display: 'flex', flexDirection: 'row', marginTop: 30 }}> | ||
<BigInput | ||
autoFocus={true} | ||
placeholder={t('https://example.com')} | ||
value={url || ''} | ||
onChangeValue={setUrl} | ||
style={{ flex: 1, marginRight: 10 }} | ||
onEnter={onSubmit} | ||
/> | ||
<ButtonWithLoading | ||
variant="primary" | ||
isLoading={loading} | ||
style={{ fontSize: 15 }} | ||
onPress={onSubmit} | ||
> | ||
{t('OK')} | ||
</ButtonWithLoading> | ||
{currentUrl && ( | ||
<Button | ||
variant="bare" | ||
style={{ fontSize: 15, marginLeft: 10 }} | ||
onPress={() => navigate(-1)} | ||
> | ||
{t('Cancel')} | ||
</Button> | ||
)} | ||
</View> | ||
|
||
<View | ||
style={{ | ||
flexDirection: 'row', | ||
flexFlow: 'row wrap', | ||
justifyContent: 'center', | ||
marginTop: 15, | ||
}} | ||
> | ||
{currentUrl ? ( | ||
<Button | ||
variant="bare" | ||
style={{ color: theme.pageTextLight }} | ||
onPress={onSkip} | ||
> | ||
{t('Stop using a server')} | ||
</Button> | ||
) : ( | ||
<> | ||
{!isElectron() && ( | ||
<Button | ||
variant="bare" | ||
style={{ | ||
color: theme.pageTextLight, | ||
margin: 5, | ||
marginRight: 15, | ||
}} | ||
onPress={onSameDomain} | ||
> | ||
{t('Use current domain')} | ||
</Button> | ||
)} | ||
<Button | ||
variant="bare" | ||
style={{ color: theme.pageTextLight, margin: 5 }} | ||
onPress={onSkip} | ||
> | ||
{t('Don’t use a server')} | ||
</Button> | ||
|
||
{isNonProductionEnvironment() && ( | ||
<Button | ||
variant="primary" | ||
style={{ marginLeft: 15 }} | ||
onPress={onCreateTestFile} | ||
> | ||
{t('Create test file')} | ||
</Button> | ||
)} | ||
</> | ||
)} | ||
</View> | ||
</View> | ||
); | ||
} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
crdt is a dependency of actual-server. Build it before packaging the sync-server