Browse Source

fix: cmdk issue (#9529)

* fix: shift modifier ref

* fix: use state workspaces for cmdk
pull/9542/head
Mert E. 3 months ago committed by GitHub
parent
commit
c73a3133a4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      packages/nc-gui/components/cmd-k/index.vue
  2. 24
      packages/nc-gui/composables/useCommandPalette/index.ts

4
packages/nc-gui/components/cmd-k/index.vue

@ -166,6 +166,8 @@ const actionListGroupedBySection = computed(() => {
const keys = useMagicKeys()
const shiftModifier = keys.shift
const setAction = (action: string) => {
selected.value = action
nextTick(() => {
@ -294,7 +296,7 @@ whenever(keys.Enter, () => {
const selectedEl = formattedData.value.find((el) => el.id === selected.value)
cmdInput.value = ''
if (selectedEl) {
fireAction(selectedEl, keys.shift.value)
fireAction(selectedEl, shiftModifier.value)
}
}
})

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

@ -34,6 +34,8 @@ export const useCommandPalette = createSharedComposable(() => {
const { token, user, signOut } = useGlobal()
const { workspacesList } = storeToRefs(useWorkspace())
const commands = ref({
homeCommands,
baseCommands: [],
@ -61,7 +63,25 @@ export const useCommandPalette = createSharedComposable(() => {
staticCmd.push(...commands.value.baseCommands)
return staticCmd
return (workspacesList.value || [])
.map((workspace: { id: string; title: string; meta?: { color: string } }) => ({
id: `ws-nav-${workspace.id}`,
title: workspace.title,
icon: 'workspace',
iconColor: workspace.meta?.color,
section: 'Workspaces',
scopePayload: {
scope: `ws-${workspace.id}`,
data: {
workspace_id: workspace.id,
},
},
handler: processHandler({
type: 'navigate',
payload: `/${workspace.id}/settings`,
}),
}))
.concat(staticCmd)
})
const dynamicData = ref<any>([])
@ -74,7 +94,7 @@ export const useCommandPalette = createSharedComposable(() => {
if (cmdLoading.value) {
return [{ id: 'loading', title: 'Loading...' }, ...staticData.value]
} else {
return [...dynamicData.value, ...staticData.value]
return [...dynamicData.value, ...tempData.value, ...staticData.value]
}
})

Loading…
Cancel
Save