Browse Source

fix(nc-gui): show workspace icon in command palette

pull/9722/head
Ramesh Mane 2 weeks ago
parent
commit
3c2b7a7245
  1. 16
      packages/nc-gui/components/cmd-k/index.vue
  2. 37
      packages/nc-gui/composables/useCommandPalette/index.ts

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

@ -2,6 +2,7 @@
import { useMagicKeys, whenever } from '@vueuse/core' import { useMagicKeys, whenever } from '@vueuse/core'
import { commandScore } from './command-score' import { commandScore } from './command-score'
import type { CommandPaletteType } from '~/lib/types' import type { CommandPaletteType } from '~/lib/types'
import LinkedItems from '../virtual-cell/components/LinkedItems.vue'
interface CmdAction { interface CmdAction {
id: string id: string
@ -10,7 +11,8 @@ interface CmdAction {
parent?: string parent?: string
handler?: Function handler?: Function
scopePayload?: any scopePayload?: any
icon?: VNode | string icon?: VNode | string | Record<string, any>
iconType?: string
keywords?: string[] keywords?: string[]
section?: string section?: string
is_default?: number | null is_default?: number | null
@ -85,6 +87,7 @@ const nestedScope = computed(() => {
id: parent, id: parent,
label: parentEl?.title, label: parentEl?.title,
icon: parentEl?.icon, icon: parentEl?.icon,
iconType: parentEl?.iconType,
iconColor: parent.startsWith('ws-') ? parentEl?.iconColor : null, iconColor: parent.startsWith('ws-') ? parentEl?.iconColor : null,
}) })
parent = parentEl?.parent || 'root' parent = parentEl?.parent || 'root'
@ -414,13 +417,15 @@ defineExpose({
<GeneralWorkspaceIcon <GeneralWorkspaceIcon
v-if="el.icon && el.id.startsWith('ws')" v-if="el.icon && el.id.startsWith('ws')"
:workspace="{ :workspace="{
title: el.label,
id: el.id.split('-')[1], id: el.id.split('-')[1],
meta: { meta: {
color: el.iconColor, color: el.iconColor,
icon: el.icon,
iconType: el.iconType,
}, },
}" }"
hide-label size="medium"
size="small"
/> />
<component <component
@ -501,13 +506,16 @@ defineExpose({
<GeneralWorkspaceIcon <GeneralWorkspaceIcon
v-if="item.data.icon && item.data.id.startsWith('ws')" v-if="item.data.icon && item.data.id.startsWith('ws')"
:workspace="{ :workspace="{
title: item.data.title,
id: item.data.id.split('-')[2], id: item.data.id.split('-')[2],
meta: { meta: {
color: item.data?.iconColor, color: item.data?.iconColor,
icon: item.data?.icon,
iconType: item.data?.iconType,
}, },
}" }"
class="mr-2" class="mr-2"
size="small" size="medium"
/> />
<template v-else-if="item.data.section === 'Bases' || item.data.icon === 'project'"> <template v-else-if="item.data.section === 'Bases' || item.data.icon === 'project'">
<GeneralBaseIconColorPicker <GeneralBaseIconColorPicker

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

@ -37,23 +37,30 @@ export const useCommandPalette = createSharedComposable(() => {
const { workspacesList } = storeToRefs(useWorkspace()) const { workspacesList } = storeToRefs(useWorkspace())
const workspacesCmd = computed(() => const workspacesCmd = computed(() =>
(workspacesList.value || []).map((workspace: { id: string; title: string; meta?: { color: string } }) => ({ (workspacesList?.value || []).map(
id: `ws-nav-${workspace.id}`, (workspace: {
title: workspace.title, id: string
icon: 'workspace', title: string
iconColor: workspace.meta?.color, meta?: { color: string; icon: string | Record<string, any>; iconType: string }
section: 'Workspaces', }) => ({
scopePayload: { id: `ws-nav-${workspace.id}`,
scope: `ws-${workspace.id}`, title: workspace.title,
data: { icon: workspace.meta?.icon || 'workspace',
workspace_id: workspace.id, iconType: workspace.meta?.iconType,
iconColor: workspace.meta?.color,
section: 'Workspaces',
scopePayload: {
scope: `ws-${workspace.id}`,
data: {
workspace_id: workspace.id,
},
}, },
}, handler: processHandler({
handler: processHandler({ type: 'navigate',
type: 'navigate', payload: `/${workspace.id}/settings`,
payload: `/${workspace.id}/settings`, }),
}), }),
})), ),
) )
const commands = ref({ const commands = ref({

Loading…
Cancel
Save