From 5de1caf7608b64a48a0d7d149e2bc08f86ba6acc Mon Sep 17 00:00:00 2001 From: Ramesh Mane <101566080+rameshmane7218@users.noreply.github.com> Date: Mon, 11 Nov 2024 12:16:57 +0530 Subject: [PATCH] Nc extension url preview (#9789) * feat(extensions): url preview * fix(nc-gui): merge conflicts --------- Co-authored-by: amandesai01 --- packages/nc-gui/components/smartsheet/Topbar.vue | 2 +- packages/nc-gui/components/smartsheet/grid/Table.vue | 11 +++++++++++ packages/nc-gui/composables/useExtensionHelper.ts | 11 ++++++++--- packages/nc-gui/composables/useExtensions.ts | 4 ---- packages/nc-gui/lib/enums.ts | 1 + 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/Topbar.vue b/packages/nc-gui/components/smartsheet/Topbar.vue index 9d8ccc739a..481f755c24 100644 --- a/packages/nc-gui/components/smartsheet/Topbar.vue +++ b/packages/nc-gui/components/smartsheet/Topbar.vue @@ -12,7 +12,7 @@ const { isMobileMode } = storeToRefs(useConfigStore()) const { appInfo } = useGlobal() -const { toggleExtensionPanel, isPanelExpanded, extensionsEgg, onEggClick } = useExtensions() +const { toggleExtensionPanel, isPanelExpanded } = useExtensions() const { isFeatureEnabled } = useBetaFeatureToggle() diff --git a/packages/nc-gui/components/smartsheet/grid/Table.vue b/packages/nc-gui/components/smartsheet/grid/Table.vue index b8f115ea54..106e47985d 100644 --- a/packages/nc-gui/components/smartsheet/grid/Table.vue +++ b/packages/nc-gui/components/smartsheet/grid/Table.vue @@ -1394,6 +1394,17 @@ eventBus.on(async (event, payload) => { } }) +watch(activeCell, (activeCell) => { + const row = activeCell.row !== null ? dataRef.value[activeCell.row].row : undefined; + const col = (row && activeCell.col !== null) ? fields.value[activeCell.col] : undefined; + const val = (row && col) ? row[col.title as string] : undefined; + + const rowId = extractPkFromRow(row!, meta.value?.columns as ColumnType[]) + const viewId = view.value?.id; + + eventBus.emit(SmartsheetStoreEvents.CELL_SELECTED, { rowId, colId: col?.id, val, viewId }); +}) + async function reloadViewDataHandler(params: void | { shouldShowLoading?: boolean | undefined; offset?: number | undefined }) { if (params?.shouldShowLoading) isViewDataLoading.value = true diff --git a/packages/nc-gui/composables/useExtensionHelper.ts b/packages/nc-gui/composables/useExtensionHelper.ts index f83c4ec294..6facc6817c 100644 --- a/packages/nc-gui/composables/useExtensionHelper.ts +++ b/packages/nc-gui/composables/useExtensionHelper.ts @@ -4,6 +4,7 @@ import type { ExtensionManifest, ExtensionType } from '#imports' const [useProvideExtensionHelper, useExtensionHelper] = useInjectionState( (extension: Ref, extensionManifest: ComputedRef, activeError: Ref) => { const { $api } = useNuxtApp() + const route = useRoute(); const basesStore = useBases() @@ -27,6 +28,8 @@ const [useProvideExtensionHelper, useExtensionHelper] = useInjectionState( const fullscreenModalSize = ref(extensionManifest.value?.config?.modalSize || 'lg') + const activeTableId = computed(() => route.params.viewId as string | undefined) + const collapsed = computed({ get: () => extension.value?.meta?.collapsed ?? false, set: (value) => { @@ -81,7 +84,7 @@ const [useProvideExtensionHelper, useExtensionHelper] = useInjectionState( return getMeta(tableId) } - const insertData = async (params: { tableId: string; data: Record }) => { + const insertData = async (params: { tableId: string; data: Record[] }) => { const { tableId, data } = params const chunks = [] @@ -103,7 +106,7 @@ const [useProvideExtensionHelper, useExtensionHelper] = useInjectionState( } } - const updateData = async (params: { tableId: string; data: Record }) => { + const updateData = async (params: { tableId: string; data: Record[] }) => { const { tableId, data } = params const chunks = [] @@ -127,7 +130,7 @@ const [useProvideExtensionHelper, useExtensionHelper] = useInjectionState( const upsertData = async (params: { tableId: string - data: Record + data: Record[] upsertField: ColumnType importType: 'insert' | 'update' | 'insertAndUpdate' }) => { @@ -221,6 +224,7 @@ const [useProvideExtensionHelper, useExtensionHelper] = useInjectionState( tables, showExpandBtn, fullscreenModalSize, + activeTableId, getViewsForTable, getData, getTableMeta, @@ -229,6 +233,7 @@ const [useProvideExtensionHelper, useExtensionHelper] = useInjectionState( upsertData, reloadData, reloadMeta, + eventBus, } }, 'extension-helper', diff --git a/packages/nc-gui/composables/useExtensions.ts b/packages/nc-gui/composables/useExtensions.ts index f0a29befec..190db1e18a 100644 --- a/packages/nc-gui/composables/useExtensions.ts +++ b/packages/nc-gui/composables/useExtensions.ts @@ -449,10 +449,6 @@ export const useExtensions = createSharedComposable(() => { } catch (error) { console.error('Error loading extensions:', error) } - - // if (isEeUI) { - // extensionsEgg.value = true - // } }) watch( diff --git a/packages/nc-gui/lib/enums.ts b/packages/nc-gui/lib/enums.ts index 80b9065919..df97fe0c36 100644 --- a/packages/nc-gui/lib/enums.ts +++ b/packages/nc-gui/lib/enums.ts @@ -79,6 +79,7 @@ export enum SmartsheetStoreEvents { GROUP_BY_ADD = 'group-by-add', GROUP_BY_REMOVE = 'group-by-remove', FILTER_ADD = 'filter-add', + CELL_SELECTED = 'cell-selected', } export enum DataSourcesSubTab {