Browse Source

fix(nc-gui): triggering multiple times cmd palette api issue

pull/7490/head
Ramesh Mane 10 months ago
parent
commit
6146f2d7d9
  1. 8
      packages/nc-gui/app.vue
  2. 4
      packages/nc-gui/components/workspace/CreateProjectDlg.vue
  3. 7
      packages/nc-gui/composables/useCommandPalette/index.ts

8
packages/nc-gui/app.vue

@ -13,7 +13,7 @@ const disableBaseLayout = computed(() => route.value.path.startsWith('/nc/view')
useTheme() useTheme()
const { commandPalette, cmdData, cmdPlaceholder, activeScope, loadTemporaryScope } = useCommandPalette() const { commandPalette, cmdData, cmdPlaceholder, activeScope, loadTemporaryScope, refreshCommandPalette } = useCommandPalette()
applyNonSelectable() applyNonSelectable()
useEventListener(document, 'keydown', async (e: KeyboardEvent) => { useEventListener(document, 'keydown', async (e: KeyboardEvent) => {
@ -79,6 +79,12 @@ function setActiveCmdView(cmd: CommandPaletteType) {
cmdK.value = false cmdK.value = false
} }
} }
onMounted(() => {
nextTick(() => {
refreshCommandPalette()
})
})
</script> </script>
<template> <template>

4
packages/nc-gui/components/workspace/CreateProjectDlg.vue

@ -19,10 +19,13 @@ const dialogShow = useVModel(props, 'modelValue', emit)
const baseType = computed(() => props.type ?? NcProjectType.DB) const baseType = computed(() => props.type ?? NcProjectType.DB)
const basesStore = useBases() const basesStore = useBases()
const { createProject: _createProject } = basesStore const { createProject: _createProject } = basesStore
const { navigateToProject } = useGlobal() const { navigateToProject } = useGlobal()
const { refreshCommandPalette } = useCommandPalette()
const nameValidationRules = [ const nameValidationRules = [
{ {
required: true, required: true,
@ -59,6 +62,7 @@ const createProject = async () => {
setTimeout(() => { setTimeout(() => {
creating.value = false creating.value = false
}, 500) }, 500)
refreshCommandPalette()
} }
} }

7
packages/nc-gui/composables/useCommandPalette/index.ts

@ -148,23 +148,26 @@ export const useCommandPalette = createSharedComposable(() => {
if (route.value.params.typeOrId === 'base') { if (route.value.params.typeOrId === 'base') {
if (activeScope.value.scope === 'disabled') return if (activeScope.value.scope === 'disabled') return
activeScope.value = { scope: 'disabled', data: {} } activeScope.value = { scope: 'disabled', data: {} }
loadScope() loadScope()
} else if (route.value.params.typeOrId === 'nc') { } else if (route.value.params.typeOrId === 'nc') {
if (activeScope.value.data.base_id === route.value.params.baseId) return if (activeScope.value.data.base_id === route.value.params.baseId) return
activeScope.value = { activeScope.value = {
scope: `p-${route.value.params.baseId}`, scope: `p-${route.value.params.baseId}`,
data: {}, data: { base_id: route.value.params.baseId },
} }
loadScope()
} }
} else { } else {
if (route.value.path.startsWith('/account')) { if (route.value.path.startsWith('/account')) {
if (activeScope.value.scope === 'account_settings') return if (activeScope.value.scope === 'account_settings') return
activeScope.value = { scope: 'account_settings', data: {} } activeScope.value = { scope: 'account_settings', data: {} }
loadScope() loadScope()
} else { } else {
if (activeScope.value.scope === 'root') return if (activeScope.value.scope === 'root') return
activeScope.value = { scope: 'root', data: {} } activeScope.value = { scope: 'root', data: {} }
loadScope() loadScope()
} }
} }

Loading…
Cancel
Save