aboutsummaryrefslogtreecommitdiff
path: root/src/modules/command-palette/command-palette.vue
diff options
context:
space:
mode:
authorGravatar Corentin Thomasset <corentin.thomasset74@gmail.com> 2023-06-19 21:51:25 +0200
committerGravatar Corentin Thomasset <corentin.thomasset74@gmail.com> 2023-06-19 21:51:25 +0200
commitec4c5337186723e6d0471e3ca03d411fdfa7af4e (patch)
tree83ba98cc0510ccb24d8265b4b6195b482f87c52b /src/modules/command-palette/command-palette.vue
parent63045951e17e34ab9293dcbffd3d2f5bb28040c6 (diff)
downloadit-tools-ec4c5337186723e6d0471e3ca03d411fdfa7af4e.tar.gz
it-tools-ec4c5337186723e6d0471e3ca03d411fdfa7af4e.tar.zst
it-tools-ec4c5337186723e6d0471e3ca03d411fdfa7af4e.zip
feat(command-palette): random tool action
Diffstat (limited to 'src/modules/command-palette/command-palette.vue')
-rw-r--r--src/modules/command-palette/command-palette.vue20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/modules/command-palette/command-palette.vue b/src/modules/command-palette/command-palette.vue
index bd431a0..12ad5fb 100644
--- a/src/modules/command-palette/command-palette.vue
+++ b/src/modules/command-palette/command-palette.vue
@@ -76,19 +76,35 @@ function getOptionIndex(option: PaletteOption) {
}
function activateOption(option: PaletteOption) {
+ const { closeOnSelect } = option;
+
if (option.action) {
option.action();
+
+ if (closeOnSelect) {
+ close();
+ }
+
return;
}
+ const closeAfterNavigation = closeOnSelect || _.isUndefined(closeOnSelect);
+
if (option.to) {
router.push(option.to);
- close();
+
+ if (closeAfterNavigation) {
+ close();
+ }
+ return;
}
if (option.href) {
window.open(option.href, '_blank');
- close();
+
+ if (closeAfterNavigation) {
+ close();
+ }
}
}
</script>