Browse Source

fix(gui-v2): hide share view from gallery

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/3005/head
Pranav C 2 years ago
parent
commit
15a382ef4d
  1. 5
      packages/nc-gui-v2/components/smartsheet/Toolbar.vue
  2. 8
      packages/nc-gui-v2/components/tabs/Smartsheet.vue
  3. 13
      packages/nc-gui-v2/composables/useSmartsheetStore.ts

5
packages/nc-gui-v2/components/smartsheet/Toolbar.vue

@ -1,8 +1,7 @@
<script setup lang="ts">
import { IsFormInj, IsGridInj } from '~/context'
import { useSmartsheetStoreOrThrow } from '~/composables'
const isForm = inject(IsFormInj)
const isGrid = inject(IsGridInj)
const { isGrid, isForm } = useSmartsheetStoreOrThrow()
</script>
<template>

8
packages/nc-gui-v2/components/tabs/Smartsheet.vue

@ -37,7 +37,7 @@ provide(ReloadViewDataHookInj, reloadEventHook)
provide(FieldsInj, fields)
provide(RightSidebarInj, ref(true))
useProvideSmartsheetStore(activeView as Ref<TableType>, meta)
const { isGallery, isGrid, isForm } = useProvideSmartsheetStore(activeView as Ref<TableType>, meta)
watch(tabMeta, async (newTabMeta, oldTabMeta) => {
if (newTabMeta !== oldTabMeta && newTabMeta?.id) await getMeta(newTabMeta.id)
@ -52,11 +52,11 @@ watch(tabMeta, async (newTabMeta, oldTabMeta) => {
<template v-if="meta">
<div class="flex flex-1 min-h-0">
<div v-if="activeView" class="h-full flex-grow min-w-0 min-h-0">
<SmartsheetGrid v-if="activeView.type === ViewTypes.GRID" :ref="el" />
<SmartsheetGrid v-if="isGrid" :ref="el" />
<SmartsheetGallery v-else-if="activeView.type === ViewTypes.GALLERY" />
<SmartsheetGallery v-else-if="isGallery" />
<SmartsheetForm v-else-if="activeView.type === ViewTypes.FORM" />
<SmartsheetForm v-else-if="isForm" />
</div>
</div>

13
packages/nc-gui-v2/composables/useSmartsheetStore.ts

@ -1,11 +1,12 @@
import { computed } from '@vue/reactivity'
import { createInjectionState } from '@vueuse/core'
import { ViewTypes } from 'nocodb-sdk'
import type { TableType, ViewType } from 'nocodb-sdk'
import type { Ref } from 'vue'
import { useNuxtApp } from '#app'
import { useProject } from '#imports'
import { useInjectionState } from '~/composables/useInjectionState'
const [useProvideSmartsheetStore, useSmartsheetStore] = createInjectionState((view: Ref<ViewType>, meta: Ref<TableType>) => {
const [useProvideSmartsheetStore, useSmartsheetStore] = useInjectionState((view: Ref<ViewType>, meta: Ref<TableType>) => {
const { $api } = useNuxtApp()
const { sqlUi } = useProject()
@ -19,6 +20,9 @@ const [useProvideSmartsheetStore, useSmartsheetStore] = createInjectionState((vi
// getters
const isLocked = computed(() => (view?.value as any)?.lock_type === 'locked')
const isPkAvail = computed(() => meta?.value?.columns?.some((c) => c.pk))
const isGrid = computed(() => (view?.value as any)?.type === ViewTypes.GRID)
const isForm = computed(() => (view?.value as any)?.type === ViewTypes.FORM)
const isGallery = computed(() => (view?.value as any)?.type === ViewTypes.GALLERY)
const xWhere = computed(() => {
let where
const col = meta?.value?.columns?.find(({ id }) => id === search.field) || meta?.value?.columns?.find((v) => v.pv)
@ -43,8 +47,11 @@ const [useProvideSmartsheetStore, useSmartsheetStore] = createInjectionState((vi
search,
xWhere,
isPkAvail,
isForm,
isGrid,
isGallery,
}
})
}, 'smartsheet-store')
export { useProvideSmartsheetStore }

Loading…
Cancel
Save