|
|
@ -44,12 +44,14 @@ export default function MigrateV2(props: PropsType) {
|
|
|
|
const [username, setUsername] = React.useState("");
|
|
|
|
const [username, setUsername] = React.useState("");
|
|
|
|
const [password, setPassword] = React.useState("");
|
|
|
|
const [password, setPassword] = React.useState("");
|
|
|
|
const [server, setServer] = React.useState("");
|
|
|
|
const [server, setServer] = React.useState("");
|
|
|
|
|
|
|
|
const [hasAccount, setHasAccount] = React.useState(false);
|
|
|
|
const [showAdvanced, setShowAdvanced] = React.useState(false);
|
|
|
|
const [showAdvanced, setShowAdvanced] = React.useState(false);
|
|
|
|
const [loading, setLoading] = React.useState(false);
|
|
|
|
const [loading, setLoading] = React.useState(false);
|
|
|
|
const [progress, setProgress] = React.useState("");
|
|
|
|
const [progress, setProgress] = React.useState("");
|
|
|
|
const [errors, setErrors] = React.useState<FormErrors>({});
|
|
|
|
const [errors, setErrors] = React.useState<FormErrors>({});
|
|
|
|
const journals = useSelector((state: StoreState) => state.cache.journals!);
|
|
|
|
const journals = useSelector((state: StoreState) => state.cache.journals!);
|
|
|
|
const journalEntries = useSelector((state: StoreState) => state.cache.entries);
|
|
|
|
const journalEntries = useSelector((state: StoreState) => state.cache.entries);
|
|
|
|
|
|
|
|
const email = props.etesync.credentials.email;
|
|
|
|
const derived = props.etesync.encryptionKey;
|
|
|
|
const derived = props.etesync.encryptionKey;
|
|
|
|
|
|
|
|
|
|
|
|
const decryptedJournals = React.useMemo(() => {
|
|
|
|
const decryptedJournals = React.useMemo(() => {
|
|
|
@ -152,8 +154,18 @@ export default function MigrateV2(props: PropsType) {
|
|
|
|
const serverUrl = (showAdvanced) ? server : undefined;
|
|
|
|
const serverUrl = (showAdvanced) ? server : undefined;
|
|
|
|
let malformed = 0;
|
|
|
|
let malformed = 0;
|
|
|
|
|
|
|
|
|
|
|
|
setProgress("Logging into EteSync 2.0 account");
|
|
|
|
let etebase: Etebase.Account;
|
|
|
|
const etebase = await Etebase.Account.login(username, password, serverUrl);
|
|
|
|
if (hasAccount) {
|
|
|
|
|
|
|
|
setProgress("Logging into EteSync 2.0 account");
|
|
|
|
|
|
|
|
etebase = await Etebase.Account.login(username, password, serverUrl);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
setProgress("Logging into EteSync 2.0 account");
|
|
|
|
|
|
|
|
const user: Etebase.User = {
|
|
|
|
|
|
|
|
username,
|
|
|
|
|
|
|
|
email,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
etebase = await Etebase.Account.signup(user, password, serverUrl);
|
|
|
|
|
|
|
|
}
|
|
|
|
const colMgr = etebase.getCollectionManager();
|
|
|
|
const colMgr = etebase.getCollectionManager();
|
|
|
|
|
|
|
|
|
|
|
|
const { etesync, userInfo } = props;
|
|
|
|
const { etesync, userInfo } = props;
|
|
|
@ -327,6 +339,11 @@ export default function MigrateV2(props: PropsType) {
|
|
|
|
</List>
|
|
|
|
</List>
|
|
|
|
|
|
|
|
|
|
|
|
<h3>EteSync 2.0 credentials</h3>
|
|
|
|
<h3>EteSync 2.0 credentials</h3>
|
|
|
|
|
|
|
|
<FormControlLabel
|
|
|
|
|
|
|
|
control={<Checkbox checked={hasAccount} onChange={() => setHasAccount(!hasAccount)} />}
|
|
|
|
|
|
|
|
label="I already have an EteSync 2.0 account"
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
<br />
|
|
|
|
<TextField
|
|
|
|
<TextField
|
|
|
|
type="text"
|
|
|
|
type="text"
|
|
|
|
style={styles.textField}
|
|
|
|
style={styles.textField}
|
|
|
@ -347,6 +364,11 @@ export default function MigrateV2(props: PropsType) {
|
|
|
|
value={password}
|
|
|
|
value={password}
|
|
|
|
onChange={handleInputChange(setPassword)}
|
|
|
|
onChange={handleInputChange(setPassword)}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
|
|
|
|
{!hasAccount && (
|
|
|
|
|
|
|
|
<Alert severity="warning" style={styles.alertInfo}>
|
|
|
|
|
|
|
|
Please make sure you remember your password, as it <em>can't</em> be recovered if lost!
|
|
|
|
|
|
|
|
</Alert>
|
|
|
|
|
|
|
|
)}
|
|
|
|
<FormGroup>
|
|
|
|
<FormGroup>
|
|
|
|
<FormControlLabel
|
|
|
|
<FormControlLabel
|
|
|
|
control={
|
|
|
|
control={
|
|
|
@ -375,7 +397,7 @@ export default function MigrateV2(props: PropsType) {
|
|
|
|
>
|
|
|
|
>
|
|
|
|
{loading ? (
|
|
|
|
{loading ? (
|
|
|
|
<CircularProgress />
|
|
|
|
<CircularProgress />
|
|
|
|
) : "Migrate"
|
|
|
|
) : (hasAccount) ? "Login & Migrate" : "Signup & Migrate"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</Button>
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|