Skip to content

TagSpaces is an offline, open source, document manager with tagging support

refactoring the onboarding mechanism

Ilian Sapundshiev9f900815ca50
diff --git a/app/components/VerticalNavigation.js b/app/components/VerticalNavigation.js
index 2aae546e6..14416cd53 100644
--- a/app/components/VerticalNavigation.js
+++ b/app/components/VerticalNavigation.js
@@ -47,6 +47,7 @@ import {
actions as AppActions,
getDirectoryPath,
isAboutDialogOpened,
+ isOnboardingDialogOpened,
isKeysDialogOpened,
isLicenseDialogOpened,
isThirdPartyLibsDialogOpened,
@@ -56,7 +57,7 @@ import {
isSelectDirectoryDialogOpened,
isReadOnlyMode,
} from '../reducers/app';
-import { actions as SettingActions, isFirstRun } from '../reducers/settings';
+import { actions as SettingsActions, isFirstRun } from '../reducers/settings';
import LoadingLazy from './LoadingLazy';
const LicenseDialog = React.lazy(() => import(/* webpackChunkName: "LicenseDialog" */ './dialogs/LicenseDialog'));
@@ -101,6 +102,13 @@ const ThirdPartyLibsDialogAsync = props => (
</React.Suspense>
);
+const OnboardingDialog = React.lazy(() => import(/* webpackChunkName: "OnboardingDialog" */ './dialogs/OnboardingDialog'));
+const OnboardingDialogAsync = props => (
+ <React.Suspense fallback={<LoadingLazy />}>
+ <OnboardingDialog {...props} />
+ </React.Suspense>
+);
+
export const AppVerticalPanels = {
tagLibrary: 'tagLibrary',
search: 'search',
@@ -111,6 +119,9 @@ export const AppVerticalPanels = {
type Props = {
isFirstRun: boolean,
+ setFirstRun: (isFirstRun: boolean) => void,
+ isOnboardingDialogOpened: boolean,
+ toggleOnboardingDialog: () => void,
isAboutDialogOpened: boolean,
toggleAboutDialog: () => void,
isCreateDirectoryOpened: boolean,
@@ -315,10 +326,19 @@ class VerticalNavigation extends React.Component<Props, State> {
onClose={this.props.toggleKeysDialog}
/>
)}
- {(this.props.isLicenseDialogOpened) && ( // this.props.isFirstRun ||
+ {(this.props.isLicenseDialogOpened) && (
<LicenseDialogAsync
open={this.props.isLicenseDialogOpened}
- onClose={this.props.toggleLicenseDialog}
+ onClose={() => {
+ this.props.setFirstRun(false);
+ this.props.toggleLicenseDialog();
+ }}
+ />
+ )}
+ {(this.props.isOnboardingDialogOpened) && (
+ <OnboardingDialogAsync
+ open={this.props.isOnboardingDialogOpened}
+ onClose={this.props.toggleOnboardingDialog}
/>
)}
{this.props.isThirdPartyLibsDialogOpened && (
@@ -346,7 +366,6 @@ class VerticalNavigation extends React.Component<Props, State> {
/>
<CreateFileDialog
key={uuidv1()}
- resetState={this.resetState}
open={this.props.isCreateFileDialogOpened}
selectedDirectoryPath={
this.state.selectedDirectoryPath || this.props.currentDirectory
@@ -536,6 +555,7 @@ function mapStateToProps(state) {
isFirstRun: isFirstRun(state),
isAboutDialogOpened: isAboutDialogOpened(state),
isKeysDialogOpened: isKeysDialogOpened(state),
+ isOnboardingDialogOpened: isOnboardingDialogOpened(state),
isLicenseDialogOpened: isLicenseDialogOpened(state),
isThirdPartyLibsDialogOpened: isThirdPartyLibsDialogOpened(state),
isSettingsDialogOpened: isSettingsDialogOpened(state),
@@ -553,12 +573,14 @@ function mapActionCreatorsToProps(dispatch) {
toggleCreateDirectoryDialog: AppActions.toggleCreateDirectoryDialog,
toggleCreateFileDialog: AppActions.toggleCreateFileDialog,
toggleSelectDirectoryDialog: AppActions.toggleSelectDirectoryDialog,
+ toggleOnboardingDialog: AppActions.toggleOnboardingDialog,
toggleSettingsDialog: AppActions.toggleSettingsDialog,
toggleKeysDialog: AppActions.toggleKeysDialog,
toggleLicenseDialog: AppActions.toggleLicenseDialog,
toggleThirdPartyLibsDialog: AppActions.toggleThirdPartyLibsDialog,
toggleAboutDialog: AppActions.toggleAboutDialog,
- switchTheme: SettingActions.switchTheme
+ switchTheme: SettingsActions.switchTheme,
+ setFirstRun: SettingsActions.setFirstRun,
},
dispatch
);
diff --git a/app/containers/MainPage.js b/app/containers/MainPage.js
index d3458c8e7..904d19f82 100644
--- a/app/containers/MainPage.js
+++ b/app/containers/MainPage.js
@@ -31,7 +31,6 @@ import IconButton from '@material-ui/core/IconButton';
import CloseIcon from '@material-ui/icons/Close';
import { HotKeys } from 'react-hotkeys';
import HTML5Backend, { NativeTypes } from 'react-dnd-html5-backend';
-// import LinearProgress from '@material-ui/core/LinearProgress';
import { DragDropContext } from 'react-dnd';
import VerticalNavigation, {
AppVerticalPanels
@@ -52,7 +51,6 @@ import {
getNotificationStatus,
isGeneratingThumbs,
isFileOpened,
- // isFileDragged,
isEntryInFullWidth,
isUpdateAvailable,
getDirectoryPath,
@@ -64,18 +62,9 @@ import { normalizePath } from '../utils/paths';
import TargetFileBox from '../components/TargetFileBox';
import PlatformIO from '../services/platform-io';
import AppConfig from '../config';
-// import i18n from '../services/i18n';
import buildDesktopMenu from '../services/electron-menus';
import buildTrayIconMenu from '../services/electron-tray-menu';
import i18n from '../services/i18n';
-import LoadingLazy from '../components/LoadingLazy';
-
-const OnboardingDialog = React.lazy(() => import(/* webpackChunkName: "OnboardingDialog" */ '../components/dialogs/OnboardingDialog'));
-const OnboardingDialogAsync = props => (
- <React.Suspense fallback={<LoadingLazy />}>
- <OnboardingDialog {...props} />
- </React.Suspense>
-);
const initialSplitSize = 44;
const drawerWidth = 300;
@@ -117,7 +106,6 @@ const styles = theme => ({
type Props = {
isDesktopMode: boolean,
isFileOpened: boolean,
- // isFileDragged: boolean,
isIndexing: boolean,
isGeneratingThumbs: boolean,
setGeneratingThumbnails: (isGenerating: boolean) => void,
@@ -128,12 +116,10 @@ type Props = {
isUpdateAvailable: boolean,
isFirstRun: boolean,
isReadOnlyMode: boolean,
- setFirstRun: (isFirstRun: boolean) => void,
setEntryFullWidth: (isFullWidth: boolean) => void,
hideNotifications: () => void,
cancelDirectoryIndexing: () => void,
setUpdateAvailable: (isUpdateAvailable: boolean) => void,
- // setFileDragged: (isFileDragged: boolean) => void,
saveFile: () => void, // needed by electron-menus
setZoomResetApp: () => void, // needed by electron-menus
setZoomInApp: () => void, // needed by electron-menus
@@ -145,6 +131,7 @@ type Props = {
toggleLicenseDialog: () => void, // needed by electron-menus
toggleThirdPartyLibsDialog: () => void, // neede by electron-menus
toggleAboutDialog: () => void, // needed by electron-menus
+ toggleOnboardingDialog: () => void, // needed by electron-menus
setLastSelectedEntry: (path: string) => void, // needed by electron-menus
openFile: (path: string) => void, // needed by electron-menus
openFileNatively: () => void, // needed by electron-menus
@@ -192,7 +179,6 @@ class MainPage extends Component<Props, State> {
// this.setupDesktopMenu();
buildDesktopMenu({
...this.props,
- toggleOnboarding: this.toggleOnboarding,
toggleTagLibrary: this.toggleTagLibrary,
toggleLocationManager: this.toggleLocationManager,
toggleSearch: this.toggleSearch,
@@ -245,10 +231,6 @@ class MainPage extends Component<Props, State> {
this.setState({ shouldTogglePanel: AppVerticalPanels.search });
};
- toggleOnboarding = () => {
- this.props.setFirstRun(!this.props.isFirstRun);
- }
-
updateDimensions = () => {
const width = window.innerWidth || document.documentElement.clientWidth || body.clientWidth;
const height = window.innerHeight || document.documentElement.clientHeight || body.clientHeight;
@@ -569,12 +551,6 @@ class MainPage extends Component<Props, State> {
</Button>,
]}
/>
- {this.props.isFirstRun && (
- <OnboardingDialogAsync
- open={this.props.isFirstRun}
- onClose={this.toggleOnboarding}
- />
- )}
</TargetFileBox>
</HotKeys>
);
@@ -588,7 +564,6 @@ function mapStateToProps(state) {
isReadOnlyMode: isReadOnlyMode(state),
isGeneratingThumbs: isGeneratingThumbs(state),
isFileOpened: isFileOpened(state),
- // isFileDragged: isFileDragged(state),
isEntryInFullWidth: isEntryInFullWidth(state),
isDesktopMode: getDesktopMode(state),
keyBindings: getKeyBindingObject(state),
@@ -603,7 +578,6 @@ function mapStateToProps(state) {
function mapDispatchToProps(dispatch) {
return bindActionCreators({
- // setFileDragged: AppActions.setFileDragged,
hideNotifications: AppActions.hideNotifications,
cancelDirectoryIndexing: LocationIndexActions.cancelDirectoryIndexing,
saveFile: AppActions.saveFile,
@@ -617,6 +591,7 @@ function mapDispatchToProps(dispatch) {
toggleLicenseDialog: AppActions.toggleLicenseDialog,
toggleThirdPartyLibsDialog: AppActions.toggleThirdPartyLibsDialog,
toggleAboutDialog: AppActions.toggleAboutDialog,
+ toggleOnboardingDialog: AppActions.toggleOnboardingDialog,
setLastSelectedEntry: AppActions.setLastSelectedEntry,
setGeneratingThumbnails: AppActions.setGeneratingThumbnails,
openFile: AppActions.openFile,
@@ -630,7 +605,6 @@ function mapDispatchToProps(dispatch) {
setMainVerticalSplitSize: SettingsActions.setMainVerticalSplitSize,
showNotification: AppActions.showNotification,
reflectCreateEntry: AppActions.reflectCreateEntry,
- setFirstRun: SettingsActions.setFirstRun,
}, dispatch);
}
diff --git a/app/containers/Root.js b/app/containers/Root.js
index 0ce1ba803..f23622259 100644
--- a/app/containers/Root.js
+++ b/app/containers/Root.js
@@ -27,7 +27,8 @@ import { actions as AppActions } from '../reducers/app';
import {
actions as SettingsActions,
getCheckForUpdateOnStartup,
- isGlobalKeyBindingEnabled
+ isGlobalKeyBindingEnabled,
+ isFirstRun
} from '../reducers/settings';
import { getDefaultLocationId } from '../reducers/locations';
import PlatformIO from '../services/platform-io';
@@ -51,6 +52,10 @@ function onBeforeLift(store) {
if (getCheckForUpdateOnStartup(state)) {
store.dispatch(SettingsActions.checkForUpdate());
}
+ if (isFirstRun(state)) {
+ store.dispatch(AppActions.toggleOnboardingDialog());
+ setTimeout(store.dispatch(AppActions.toggleLicenseDialog()), 2000);
+ }
PlatformIO.setGlobalShortcuts(isGlobalKeyBindingEnabled(state));
const langURLParam = getURLParameter('locale');
if (
diff --git a/app/services/electron-menus.js b/app/services/electron-menus.js
index 6e8a35056..ff9a3c168 100644
--- a/app/services/electron-menus.js
+++ b/app/services/electron-menus.js
@@ -272,7 +272,7 @@ export default function buildDesktopMenu(mainPageProps: Object) {
{
label: 'Welcome Wizzard',
click: () => {
- mainPageProps.toggleOnboarding();
+ mainPageProps.toggleOnboardingDialog();
}
},
{