Browse Source

fix(nc-gui): open view new tab in background on cmd+click

pull/7818/head
Ramesh Mane 9 months ago
parent
commit
839e93ce33
  1. 6
      packages/nc-gui/components/dashboard/Sidebar/TopSection.vue
  2. 4
      packages/nc-gui/components/dashboard/TreeView/ProjectNode.vue
  3. 2
      packages/nc-gui/components/dashboard/TreeView/TableNode.vue
  4. 17
      packages/nc-gui/components/dashboard/TreeView/ViewsNode.vue
  5. 4
      packages/nc-gui/composables/useTableNew.ts
  6. 2
      packages/nc-gui/store/views.ts
  7. 11
      packages/nc-gui/store/workspace.ts

6
packages/nc-gui/components/dashboard/Sidebar/TopSection.vue

@ -6,6 +6,8 @@ const { isUIAllowed } = useRoles()
const { appInfo } = useGlobal() const { appInfo } = useGlobal()
const { meta: metaKey, ctrlKey } = useMagicKeys()
const { isWorkspaceLoading, isWorkspaceSettingsPageOpened } = storeToRefs(workspaceStore) const { isWorkspaceLoading, isWorkspaceSettingsPageOpened } = storeToRefs(workspaceStore)
const { navigateToWorkspaceSettings } = workspaceStore const { navigateToWorkspaceSettings } = workspaceStore
@ -15,8 +17,10 @@ const { isSharedBase } = storeToRefs(baseStore)
const isCreateProjectOpen = ref(false) const isCreateProjectOpen = ref(false)
const navigateToSettings = () => { const navigateToSettings = () => {
const cmdOrCtrl = isMac() ? metaKey.value : ctrlKey.value
// TODO: Handle cloud case properly // TODO: Handle cloud case properly
navigateToWorkspaceSettings() navigateToWorkspaceSettings('', cmdOrCtrl)
// if (appInfo.value.baseHostName) { // if (appInfo.value.baseHostName) {
// window.location.href = `https://app.${appInfo.value.baseHostName}/dashboard` // window.location.href = `https://app.${appInfo.value.baseHostName}/dashboard`

4
packages/nc-gui/components/dashboard/TreeView/ProjectNode.vue

@ -16,6 +16,7 @@ import {
h, h,
inject, inject,
navigateTo, navigateTo,
navigateToBlankTargetOpenOption,
openLink, openLink,
ref, ref,
resolveComponent, resolveComponent,
@ -26,14 +27,13 @@ import {
useDialog, useDialog,
useGlobal, useGlobal,
useI18n, useI18n,
useMagicKeys,
useNuxtApp, useNuxtApp,
useRoles, useRoles,
useRouter, useRouter,
useTablesStore, useTablesStore,
useTabs, useTabs,
useToggle, useToggle,
useMagicKeys,
navigateToBlankTargetOpenOption,
} from '#imports' } from '#imports'
import type { NcProject } from '#imports' import type { NcProject } from '#imports'

2
packages/nc-gui/components/dashboard/TreeView/TableNode.vue

@ -4,7 +4,7 @@ import { toRef } from '@vue/reactivity'
import { message } from 'ant-design-vue' import { message } from 'ant-design-vue'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { ProjectRoleInj, TreeViewInj, useNuxtApp, useRoles, useTabs, useMagicKeys } from '#imports' import { ProjectRoleInj, TreeViewInj, useMagicKeys, useNuxtApp, useRoles, useTabs } from '#imports'
import type { SidebarTableNode } from '~/lib' import type { SidebarTableNode } from '~/lib'
const props = withDefaults( const props = withDefaults(

17
packages/nc-gui/components/dashboard/TreeView/ViewsNode.vue

@ -9,6 +9,7 @@ import {
message, message,
onKeyStroke, onKeyStroke,
useDebounceFn, useDebounceFn,
useMagicKeys,
useNuxtApp, useNuxtApp,
useRoles, useRoles,
useVModel, useVModel,
@ -52,6 +53,8 @@ const { activeView } = storeToRefs(useViewsStore())
const { getMeta } = useMetas() const { getMeta } = useMetas()
const { meta: metaKey, ctrlKey } = useMagicKeys()
const table = computed(() => props.table) const table = computed(() => props.table)
const injectedTable = ref(table.value) const injectedTable = ref(table.value)
@ -80,10 +83,20 @@ const _title = ref<string | undefined>()
/** Debounce click handler, so we can potentially enable editing view name {@see onDblClick} */ /** Debounce click handler, so we can potentially enable editing view name {@see onDblClick} */
const onClick = useDebounceFn(() => { const onClick = useDebounceFn(() => {
emits('changeView', vModel.value)
}, 250)
const handleOnClick = () => {
if (isEditing.value || isStopped.value) return if (isEditing.value || isStopped.value) return
const cmdOrCtrl = isMac() ? metaKey.value : ctrlKey.value
if (cmdOrCtrl) {
emits('changeView', vModel.value) emits('changeView', vModel.value)
}, 250) } else {
onClick()
}
}
/** Enable editing view name on dbl click */ /** Enable editing view name on dbl click */
function onDblClick() { function onDblClick() {
@ -209,7 +222,7 @@ watch(isDropdownOpen, async () => {
}" }"
:data-testid="`view-sidebar-view-${vModel.alias || vModel.title}`" :data-testid="`view-sidebar-view-${vModel.alias || vModel.title}`"
@dblclick.stop="onDblClick" @dblclick.stop="onDblClick"
@click="onClick" @click.prevent="handleOnClick"
> >
<div v-e="['a:view:open', { view: vModel.type }]" class="text-sm flex items-center w-full gap-1" data-testid="view-item"> <div v-e="['a:view:open', { view: vModel.type }]" class="text-sm flex items-center w-full gap-1" data-testid="view-item">
<div <div

4
packages/nc-gui/composables/useTableNew.ts

@ -10,17 +10,17 @@ import {
extractSdkResponseErrorMsg, extractSdkResponseErrorMsg,
generateUniqueTitle as generateTitle, generateUniqueTitle as generateTitle,
message, message,
navigateToBlankTargetOpenOption,
reactive, reactive,
storeToRefs, storeToRefs,
useBase, useBase,
useCommandPalette, useCommandPalette,
useI18n, useI18n,
useMagicKeys,
useMetas, useMetas,
useNuxtApp, useNuxtApp,
useTabs, useTabs,
watch, watch,
useMagicKeys,
navigateToBlankTargetOpenOption,
} from '#imports' } from '#imports'
export function useTableNew(param: { onTableCreate?: (tableMeta: TableType) => void; baseId: string; sourceId?: string }) { export function useTableNew(param: { onTableCreate?: (tableMeta: TableType) => void; baseId: string; sourceId?: string }) {

2
packages/nc-gui/store/views.ts

@ -1,7 +1,7 @@
import type { FilterType, SortType, ViewType, ViewTypes } from 'nocodb-sdk' import type { FilterType, SortType, ViewType, ViewTypes } from 'nocodb-sdk'
import { acceptHMRUpdate, defineStore } from 'pinia' import { acceptHMRUpdate, defineStore } from 'pinia'
import type { ViewPageType } from '~/lib' import type { ViewPageType } from '~/lib'
import { useMagicKeys, navigateToBlankTargetOpenOption } from '#imports' import { navigateToBlankTargetOpenOption, useMagicKeys } from '#imports'
export const useViewsStore = defineStore('viewsStore', () => { export const useViewsStore = defineStore('viewsStore', () => {
const { $api } = useNuxtApp() const { $api } = useNuxtApp()

11
packages/nc-gui/store/workspace.ts

@ -199,8 +199,15 @@ export const useWorkspace = defineStore('workspaceStore', () => {
}) })
} }
const navigateToWorkspaceSettings = async () => { const navigateToWorkspaceSettings = async (_, cmdOrCtrl) => {
navigateTo('/account/users') await navigateTo(
`${cmdOrCtrl ? '#' : ''}/account/users`,
cmdOrCtrl
? {
open: navigateToBlankTargetOpenOption,
}
: undefined,
)
} }
function setLoadingState(isLoading = false) { function setLoadingState(isLoading = false) {

Loading…
Cancel
Save