Skip to content

Commit

Permalink
fix: open new resource wizard via hotkeys only if root folder is set
Browse files Browse the repository at this point in the history
  • Loading branch information
devcatalin committed Aug 25, 2021
1 parent 3f048ad commit 83018da
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/components/molecules/Monaco/Monaco.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ const Monaco = (props: {editorHeight: string}) => {
/* eslint-disable no-bitwise */
keybindings: [monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_N],
run: () => {
dispatch(openNewResourceWizard());
if (fileMap[ROOT_FILE_ENTRY]) {
dispatch(openNewResourceWizard());
}
},
});

Expand Down
14 changes: 9 additions & 5 deletions src/components/organisms/HotKeysHandler/HotKeysHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,15 @@ const HotKeysHandler = () => {
dispatch(selectFromHistory({direction: 'right'}));
});

useHotkeys(hotkeys.OPEN_NEW_RESOURCE_WIZARD, () => {
if (!uiState.isNewResourceWizardOpen) {
dispatch(openNewResourceWizard());
}
});
useHotkeys(
hotkeys.OPEN_NEW_RESOURCE_WIZARD,
() => {
if (!uiState.isNewResourceWizardOpen && mainState.fileMap[ROOT_FILE_ENTRY]) {
dispatch(openNewResourceWizard());
}
},
[mainState.fileMap[ROOT_FILE_ENTRY]]
);

return (
<>
Expand Down

0 comments on commit 83018da

Please sign in to comment.