refactor: only enable some menu item when workspace is main

This commit is contained in:
lin onetwo 2022-04-16 17:40:47 +08:00
parent f66716dbee
commit f7877b46dc

View file

@ -18,7 +18,7 @@ interface IWorkspaceMenuRequiredServices {
context: Pick<IContextService, 'isOnline'>;
git: Pick<IGitService, 'commitAndSync'>;
native: Pick<INativeService, 'open' | 'openInEditor' | 'openInGitGuiApp'>;
view: Pick<IViewService, 'reloadViewsWebContents'>;
view: Pick<IViewService, 'reloadViewsWebContents' | 'enterSafeModeForViewsWebContents'>;
wiki: Pick<IWikiService, 'requestOpenTiddlerInWiki' | 'requestWikiSendActionMessage'>;
wikiGitWorkspace: Pick<IWikiGitWorkspaceService, 'removeWorkspace'>;
window: Pick<IWindowService, 'open'>;
@ -88,17 +88,6 @@ export async function getWorkspaceMenuTemplate(
label: t('WorkspaceSelector.OpenWorkspaceFolderInGitGUI'),
click: async () => await service.native.openInGitGuiApp(wikiFolderLocation),
},
{
label: t('ContextMenu.Reload'),
click: async () => await service.view.reloadViewsWebContents(id),
},
{
label: t('ContextMenu.RestartService'),
click: async () => {
await service.workspaceView.restartWorkspaceViewService(id);
await service.workspaceView.realignActiveWorkspace(id);
},
},
];
if (gitUrl !== null && gitUrl.length > 0 && storageService !== SupportedStorageServices.local) {
@ -125,6 +114,22 @@ export async function getWorkspaceMenuTemplate(
});
}
if (!isSubWiki) {
template.push(
{
label: t('ContextMenu.RestartService'),
click: async () => {
await service.workspaceView.restartWorkspaceViewService(id);
await service.workspaceView.realignActiveWorkspace(id);
},
},
{
label: t('ContextMenu.Reload'),
click: async () => await service.view.reloadViewsWebContents(id),
},
);
}
if (!active && !isSubWiki) {
template.splice(1, 0, {
label: hibernated ? t('WorkspaceSelector.WakeUpWorkspace') : t('WorkspaceSelector.HibernateWorkspace'),