You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-12-02 22:49:09 +02:00
All: Add mechanism to lock and upgrade sync targets (#3524)
This commit is contained in:
@@ -450,6 +450,7 @@ class ScreenHeaderComponent extends React.PureComponent {
|
||||
|
||||
if (this.props.showMissingMasterKeyMessage) warningComps.push(this.renderWarningBox('EncryptionConfig', _('Press to set the decryption password.')));
|
||||
if (this.props.hasDisabledSyncItems) warningComps.push(this.renderWarningBox('Status', _('Some items cannot be synchronised. Press for more info.')));
|
||||
if (this.props.shouldUpgradeSyncTarget && this.props.showShouldUpgradeSyncTargetMessage !== false) warningComps.push(this.renderWarningBox('UpgradeSyncTarget', _('The sync target needs to be upgraded. Press this banner to proceed.')));
|
||||
|
||||
const showSideMenuButton = !!this.props.showSideMenuButton && !this.props.noteSelectionEnabled;
|
||||
const showSelectAllButton = this.props.noteSelectionEnabled;
|
||||
@@ -536,6 +537,7 @@ const ScreenHeader = connect(state => {
|
||||
selectedNoteIds: state.selectedNoteIds,
|
||||
showMissingMasterKeyMessage: state.notLoadedMasterKeys.length && state.masterKeys.length,
|
||||
hasDisabledSyncItems: state.hasDisabledSyncItems,
|
||||
shouldUpgradeSyncTarget: state.settings['sync.upgradeState'] === Setting.SYNC_UPGRADE_STATE_SHOULD_DO,
|
||||
};
|
||||
})(ScreenHeaderComponent);
|
||||
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
import * as React from 'react';
|
||||
import { View, Text, ScrollView } from 'react-native';
|
||||
import useSyncTargetUpgrade from 'lib/services/synchronizer/gui/useSyncTargetUpgrade';
|
||||
|
||||
const { connect } = require('react-redux');
|
||||
const { themeStyle } = require('lib/components/global-style.js');
|
||||
const { ScreenHeader } = require('lib/components/screen-header.js');
|
||||
const { _ } = require('lib/locale.js');
|
||||
|
||||
function UpgradeSyncTargetScreen(props:any) {
|
||||
const upgradeResult = useSyncTargetUpgrade();
|
||||
|
||||
const theme = themeStyle(props.theme);
|
||||
|
||||
const lineStyle = { ...theme.normalText, marginBottom: 20 };
|
||||
const stackTraceStyle = { ...theme.normalText, flexWrap: 'nowrap', fontSize: theme.fontSize * 0.5, color: theme.colorFaded };
|
||||
const headerStyle = { ...theme.headerStyle, marginBottom: 20 };
|
||||
|
||||
function renderUpgradeError() {
|
||||
if (!upgradeResult.error) return null;
|
||||
|
||||
return (
|
||||
<View style={{ backgroundColor: theme.backgroundColor, flex: 1, flexDirection: 'column' }}>
|
||||
<Text style={headerStyle}>Error</Text>
|
||||
<Text style={lineStyle}>The sync target could not be upgraded due to an error. For support, please copy the content of this page and paste it in the forum: https://discourse.joplinapp.org/</Text>
|
||||
<Text style={lineStyle}>The full error was:</Text>
|
||||
<Text style={lineStyle}>{upgradeResult.error.message}</Text>
|
||||
<Text style={stackTraceStyle}>{upgradeResult.error.stack}</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
function renderInProgress() {
|
||||
if (upgradeResult.error || upgradeResult.done) return null;
|
||||
|
||||
return (
|
||||
<View>
|
||||
<Text style={headerStyle}>Joplin upgrade in progress...</Text>
|
||||
<Text style={lineStyle}>Please wait while the sync target is being upgraded. It may take a few seconds or a few minutes depending on the upgrade.</Text>
|
||||
<Text style={lineStyle}>Make sure you leave your device on and the app opened while the upgrade is in progress.</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
function renderDone() {
|
||||
if (upgradeResult.error || !upgradeResult.done) return null;
|
||||
|
||||
return (
|
||||
<View>
|
||||
<Text style={headerStyle}>Upgrade complete</Text>
|
||||
<Text style={lineStyle}>The upgrade has been applied successfully. Please press Back to exit this screen.</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<ScrollView style={{ flex: 1, flexDirection: 'column', backgroundColor: theme.backgroundColor }}>
|
||||
<ScreenHeader title={_('Sync Target Upgrade')} parentComponent={this} showShouldUpgradeSyncTargetMessage={false} showSearchButton={false} showBackButton={upgradeResult.done}/>
|
||||
<View style={{ padding: 15, flex: 1 }}>
|
||||
{renderInProgress()}
|
||||
{renderDone()}
|
||||
{renderUpgradeError()}
|
||||
</View>
|
||||
</ScrollView>
|
||||
);
|
||||
}
|
||||
|
||||
export default connect((state:any) => {
|
||||
return {
|
||||
theme: state.settings.theme,
|
||||
};
|
||||
})(UpgradeSyncTargetScreen);
|
||||
Reference in New Issue
Block a user