mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Desktop: Add a menu option to reset the application layout (#7786)
This commit is contained in:
parent
e1a8c76598
commit
3a14b76a61
@ -177,6 +177,7 @@ packages/app-desktop/gui/MainScreen/commands/openTag.js
|
|||||||
packages/app-desktop/gui/MainScreen/commands/print.js
|
packages/app-desktop/gui/MainScreen/commands/print.js
|
||||||
packages/app-desktop/gui/MainScreen/commands/renameFolder.js
|
packages/app-desktop/gui/MainScreen/commands/renameFolder.js
|
||||||
packages/app-desktop/gui/MainScreen/commands/renameTag.js
|
packages/app-desktop/gui/MainScreen/commands/renameTag.js
|
||||||
|
packages/app-desktop/gui/MainScreen/commands/resetLayout.js
|
||||||
packages/app-desktop/gui/MainScreen/commands/revealResourceFile.js
|
packages/app-desktop/gui/MainScreen/commands/revealResourceFile.js
|
||||||
packages/app-desktop/gui/MainScreen/commands/search.js
|
packages/app-desktop/gui/MainScreen/commands/search.js
|
||||||
packages/app-desktop/gui/MainScreen/commands/setTags.js
|
packages/app-desktop/gui/MainScreen/commands/setTags.js
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -165,6 +165,7 @@ packages/app-desktop/gui/MainScreen/commands/openTag.js
|
|||||||
packages/app-desktop/gui/MainScreen/commands/print.js
|
packages/app-desktop/gui/MainScreen/commands/print.js
|
||||||
packages/app-desktop/gui/MainScreen/commands/renameFolder.js
|
packages/app-desktop/gui/MainScreen/commands/renameFolder.js
|
||||||
packages/app-desktop/gui/MainScreen/commands/renameTag.js
|
packages/app-desktop/gui/MainScreen/commands/renameTag.js
|
||||||
|
packages/app-desktop/gui/MainScreen/commands/resetLayout.js
|
||||||
packages/app-desktop/gui/MainScreen/commands/revealResourceFile.js
|
packages/app-desktop/gui/MainScreen/commands/revealResourceFile.js
|
||||||
packages/app-desktop/gui/MainScreen/commands/search.js
|
packages/app-desktop/gui/MainScreen/commands/search.js
|
||||||
packages/app-desktop/gui/MainScreen/commands/setTags.js
|
packages/app-desktop/gui/MainScreen/commands/setTags.js
|
||||||
|
@ -38,6 +38,7 @@ export interface AppState extends State {
|
|||||||
watchedResources: any;
|
watchedResources: any;
|
||||||
mainLayout: LayoutItem;
|
mainLayout: LayoutItem;
|
||||||
dialogs: AppStateDialog[];
|
dialogs: AppStateDialog[];
|
||||||
|
isResettingLayout: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createAppDefaultState(windowContentSize: any, resourceEditWatcherDefaultState: any): AppState {
|
export function createAppDefaultState(windowContentSize: any, resourceEditWatcherDefaultState: any): AppState {
|
||||||
@ -60,6 +61,7 @@ export function createAppDefaultState(windowContentSize: any, resourceEditWatche
|
|||||||
mainLayout: null,
|
mainLayout: null,
|
||||||
startupPluginsLoaded: false,
|
startupPluginsLoaded: false,
|
||||||
dialogs: [],
|
dialogs: [],
|
||||||
|
isResettingLayout: false,
|
||||||
...resourceEditWatcherDefaultState,
|
...resourceEditWatcherDefaultState,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -308,7 +310,15 @@ export default function(state: AppState, action: any) {
|
|||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
case 'RESET_LAYOUT':
|
||||||
|
newState = {
|
||||||
|
...state,
|
||||||
|
isResettingLayout: action.value,
|
||||||
|
};
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.message = `In reducer: ${error.message} Action: ${JSON.stringify(action)}`;
|
error.message = `In reducer: ${error.message} Action: ${JSON.stringify(action)}`;
|
||||||
throw error;
|
throw error;
|
||||||
|
@ -78,6 +78,7 @@ interface Props {
|
|||||||
isSafeMode: boolean;
|
isSafeMode: boolean;
|
||||||
needApiAuth: boolean;
|
needApiAuth: boolean;
|
||||||
processingShareInvitationResponse: boolean;
|
processingShareInvitationResponse: boolean;
|
||||||
|
isResettingLayout: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ShareFolderDialogOptions {
|
interface ShareFolderDialogOptions {
|
||||||
@ -371,6 +372,15 @@ class MainScreenComponent extends React.Component<Props, State> {
|
|||||||
name: 'promptDialog',
|
name: 'promptDialog',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.props.isResettingLayout) {
|
||||||
|
Setting.setValue('ui.layout', null);
|
||||||
|
this.updateMainLayout(this.buildLayout(this.props.plugins));
|
||||||
|
this.props.dispatch({
|
||||||
|
type: 'RESET_LAYOUT',
|
||||||
|
value: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
layoutModeListenerKeyDown(event: any) {
|
layoutModeListenerKeyDown(event: any) {
|
||||||
@ -880,6 +890,7 @@ const mapStateToProps = (state: AppState) => {
|
|||||||
isSafeMode: state.settings.isSafeMode,
|
isSafeMode: state.settings.isSafeMode,
|
||||||
needApiAuth: state.needApiAuth,
|
needApiAuth: state.needApiAuth,
|
||||||
showInstallTemplatesPlugin: state.hasLegacyTemplates && !state.pluginService.plugins['joplin.plugin.templates'],
|
showInstallTemplatesPlugin: state.hasLegacyTemplates && !state.pluginService.plugins['joplin.plugin.templates'],
|
||||||
|
isResettingLayout: state.isResettingLayout,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ import * as openTag from './openTag';
|
|||||||
import * as print from './print';
|
import * as print from './print';
|
||||||
import * as renameFolder from './renameFolder';
|
import * as renameFolder from './renameFolder';
|
||||||
import * as renameTag from './renameTag';
|
import * as renameTag from './renameTag';
|
||||||
|
import * as resetLayout from './resetLayout';
|
||||||
import * as revealResourceFile from './revealResourceFile';
|
import * as revealResourceFile from './revealResourceFile';
|
||||||
import * as search from './search';
|
import * as search from './search';
|
||||||
import * as setTags from './setTags';
|
import * as setTags from './setTags';
|
||||||
@ -61,6 +62,7 @@ const index:any[] = [
|
|||||||
print,
|
print,
|
||||||
renameFolder,
|
renameFolder,
|
||||||
renameTag,
|
renameTag,
|
||||||
|
resetLayout,
|
||||||
revealResourceFile,
|
revealResourceFile,
|
||||||
search,
|
search,
|
||||||
setTags,
|
setTags,
|
||||||
|
25
packages/app-desktop/gui/MainScreen/commands/resetLayout.ts
Normal file
25
packages/app-desktop/gui/MainScreen/commands/resetLayout.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import { CommandRuntime, CommandDeclaration, CommandContext } from '@joplin/lib/services/CommandService';
|
||||||
|
import { _ } from '@joplin/lib/locale';
|
||||||
|
import dialogs from '../../dialogs';
|
||||||
|
|
||||||
|
export const declaration: CommandDeclaration = {
|
||||||
|
name: 'resetLayout',
|
||||||
|
label: () => _('Reset application layout'),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const runtime = (): CommandRuntime => {
|
||||||
|
return {
|
||||||
|
execute: async (context: CommandContext) => {
|
||||||
|
|
||||||
|
const message = _('Are you sure you want to return to the default layout? The current layout configuration will be lost.');
|
||||||
|
const isConfirmed = await dialogs.confirm(message);
|
||||||
|
|
||||||
|
if (!isConfirmed) return;
|
||||||
|
|
||||||
|
context.dispatch({
|
||||||
|
type: 'RESET_LAYOUT',
|
||||||
|
value: true,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
@ -675,6 +675,7 @@ function useMenu(props: Props) {
|
|||||||
label: _('&View'),
|
label: _('&View'),
|
||||||
submenu: [
|
submenu: [
|
||||||
menuItemDic.toggleLayoutMoveMode,
|
menuItemDic.toggleLayoutMoveMode,
|
||||||
|
menuItemDic.resetLayout,
|
||||||
separator(),
|
separator(),
|
||||||
menuItemDic.toggleSideBar,
|
menuItemDic.toggleSideBar,
|
||||||
menuItemDic.toggleNoteList,
|
menuItemDic.toggleNoteList,
|
||||||
|
@ -32,6 +32,7 @@ export default function() {
|
|||||||
'textBulletedList',
|
'textBulletedList',
|
||||||
'toggleExternalEditing',
|
'toggleExternalEditing',
|
||||||
'toggleLayoutMoveMode',
|
'toggleLayoutMoveMode',
|
||||||
|
'resetLayout',
|
||||||
'toggleNoteList',
|
'toggleNoteList',
|
||||||
'toggleNotesSortOrderField',
|
'toggleNotesSortOrderField',
|
||||||
'toggleNotesSortOrderReverse',
|
'toggleNotesSortOrderReverse',
|
||||||
|
Loading…
Reference in New Issue
Block a user