1
0
Fork 0
mirror of https://github.com/anyproto/anytype-ts.git synced 2025-06-11 18:20:27 +09:00

Merge pull request #616 from anyproto/feature/JS-3874-custom-storage-local-only-warning

Feature/JS-3874: Custom storage local only warning
This commit is contained in:
Razor 2024-03-20 17:30:16 +01:00 committed by GitHub
commit ee0c79be5e
Signed by: github
GPG key ID: B5690EEEBB952194
2 changed files with 45 additions and 14 deletions

View file

@ -814,6 +814,9 @@
"popupSettingsOnboardingModeTitle": "Network",
"popupSettingsOnboardingNetworkTitle": "Self-hosted Configuration",
"popupSettingsOnboardingStoragePath": "Account Data Location",
"popupSettingsOnboardingLocalOnlyWarningTitle": "Are you sure?",
"popupSettingsOnboardingLocalOnlyWarningText": "Anytype can't transfer your data between directories. <br/>Your Spaces data will be downloaded from another device. <br/>Please ensure that you have such a device active on the same network.",
"popupSettingsOnboardingLocalOnlyWarningConfirm": "Yes, I understand",
"popupSettingsDataLocalFiles": "Local files",
"popupSettingsDataOffloadWarningTitle": "Are you sure?",

View file

@ -1,7 +1,7 @@
import * as React from 'react';
import { Title, Label, Select, Button } from 'Component';
import { I, UtilMenu, UtilCommon, translate, Action, analytics, Renderer, Preview } from 'Lib';
import { commonStore, authStore } from 'Store';
import { commonStore, authStore, popupStore } from 'Store';
import { observer } from 'mobx-react';
const PopupSettingsOnboarding = observer(class PopupSettingsOnboarding extends React.Component<I.Popup> {
@ -21,8 +21,7 @@ const PopupSettingsOnboarding = observer(class PopupSettingsOnboarding extends R
};
render () {
const { mode, path } = this.config;
const userPath = window.Electron.userPath();
const { mode, path, userPath } = this.config;
const { interfaceLang, config } = commonStore;
const interfaceLanguages = UtilMenu.getInterfaceLanguages();
const networkModes: any[] = ([
@ -106,7 +105,15 @@ const PopupSettingsOnboarding = observer(class PopupSettingsOnboarding extends R
};
componentDidMount(): void {
this.config = authStore.networkConfig;
const { networkConfig } = authStore;
const { mode, path } = networkConfig;
const userPath = window.Electron.userPath();
this.config = {
userPath,
mode,
path: path || ''
};
this.refMode?.setValue(this.config.mode);
this.forceUpdate();
};
@ -122,17 +129,40 @@ const PopupSettingsOnboarding = observer(class PopupSettingsOnboarding extends R
onSave () {
const { networkConfig } = authStore;
const userPath = window.Electron.userPath();
if (this.config.mode !== networkConfig.mode) {
analytics.event('SelectNetwork', { route: 'Onboarding', type: this.config.mode });
const callBack = () => {
if (this.config.mode !== networkConfig.mode) {
analytics.event('SelectNetwork', { route: 'Onboarding', type: this.config.mode });
};
if (this.config.path !== networkConfig.path) {
analytics.event('UploadNetworkConfiguration', { route: 'Onboarding' });
};
if (this.config.userPath !== userPath) {
Renderer.send('setUserDataPath', this.config.userPath);
commonStore.dataPathSet(this.config.userPath);
delete this.config.userPath;
};
authStore.networkConfigSet(this.config);
this.props.close();
};
if (this.config.path !== networkConfig.path) {
analytics.event('UploadNetworkConfiguration', { route: 'Onboarding' });
if ((this.config.mode == I.NetworkMode.Local) && (this.config.userPath !== userPath)) {
popupStore.open('confirm', {
className: 'isWide',
data: {
title: translate('popupSettingsOnboardingLocalOnlyWarningTitle'),
text: translate('popupSettingsOnboardingLocalOnlyWarningText'),
onConfirm: callBack,
textConfirm: translate('popupSettingsOnboardingLocalOnlyWarningConfirm'),
},
});
} else {
callBack();
};
authStore.networkConfigSet(this.config);
this.props.close();
};
onPathClick (path: string) {
@ -143,9 +173,7 @@ const PopupSettingsOnboarding = observer(class PopupSettingsOnboarding extends R
onChangeStorage () {
Action.openDir({}, (paths: string[]) => {
Renderer.send('setUserDataPath', paths[0]);
commonStore.dataPathSet(paths[0]);
this.forceUpdate();
this.onChange('userPath', paths[0]);
});
};