From e4736d9a3882cb762d716caac228be6a70f160c9 Mon Sep 17 00:00:00 2001 From: nith2001 Date: Mon, 22 May 2023 18:02:05 -0700 Subject: [PATCH 01/13] Fixing Issue #5648 --- packages/nc-gui/components/smartsheet/toolbar/ColumnFilter.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/nc-gui/components/smartsheet/toolbar/ColumnFilter.vue b/packages/nc-gui/components/smartsheet/toolbar/ColumnFilter.vue index ee722d89c9..523c17cd64 100644 --- a/packages/nc-gui/components/smartsheet/toolbar/ColumnFilter.vue +++ b/packages/nc-gui/components/smartsheet/toolbar/ColumnFilter.vue @@ -225,7 +225,8 @@ defineExpose({ /> -
+ {{ $t('labels.where') }} +
Date: Tue, 30 May 2023 11:00:43 +0530 Subject: [PATCH 02/13] fix: set fallback dashboard path while creating config Signed-off-by: Pranav C --- packages/nocodb/src/utils/nc-config/NcConfig.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nocodb/src/utils/nc-config/NcConfig.ts b/packages/nocodb/src/utils/nc-config/NcConfig.ts index b8d3654551..3b25d952f9 100644 --- a/packages/nocodb/src/utils/nc-config/NcConfig.ts +++ b/packages/nocodb/src/utils/nc-config/NcConfig.ts @@ -149,7 +149,7 @@ export class NcConfig { port: process.env.NC_PORT, tryMode: !!process.env.NC_TRY, worker: !!process.env.NC_WORKER, - dashboardPath: process.env.NC_DASHBOARD_PATH, + dashboardPath: process.env.NC_DASHBOARD_PATH || '/dashboard', publicUrl: process.env.NC_PUBLIC_URL, }); } From 477420fd50058a0d23c7df2e6d216aa7ba97e0c8 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 30 May 2023 15:57:44 +0530 Subject: [PATCH 03/13] refactor: set default dashboard path inside the root method which generates config Signed-off-by: Pranav C --- packages/nocodb/src/utils/nc-config/NcConfig.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/nocodb/src/utils/nc-config/NcConfig.ts b/packages/nocodb/src/utils/nc-config/NcConfig.ts index 3b25d952f9..cd8cb0e2fe 100644 --- a/packages/nocodb/src/utils/nc-config/NcConfig.ts +++ b/packages/nocodb/src/utils/nc-config/NcConfig.ts @@ -126,6 +126,8 @@ export class NcConfig { if (dashboardPath) { ncConfig.dashboardPath = dashboardPath; + } else { + ncConfig.dashboardPath = '/dashboard'; } try { @@ -149,7 +151,7 @@ export class NcConfig { port: process.env.NC_PORT, tryMode: !!process.env.NC_TRY, worker: !!process.env.NC_WORKER, - dashboardPath: process.env.NC_DASHBOARD_PATH || '/dashboard', + dashboardPath: process.env.NC_DASHBOARD_PATH, publicUrl: process.env.NC_PUBLIC_URL, }); } From a20c295ee11143486347babc6751e28f36c2f16f Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 30 May 2023 18:53:41 +0530 Subject: [PATCH 04/13] fix: include lookup related metas in shared view meta api Signed-off-by: Pranav C --- .../src/services/public-metas.service.ts | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/packages/nocodb/src/services/public-metas.service.ts b/packages/nocodb/src/services/public-metas.service.ts index 1ce6605e73..36f4dcc405 100644 --- a/packages/nocodb/src/services/public-metas.service.ts +++ b/packages/nocodb/src/services/public-metas.service.ts @@ -2,7 +2,7 @@ import { Injectable } from '@nestjs/common'; import { ErrorMessages, RelationTypes, UITypes } from 'nocodb-sdk'; import { NcError } from '../helpers/catchError'; import { Base, Column, Model, Project, View } from '../models'; -import type { LinkToAnotherRecordColumn } from '../models'; +import type { LinkToAnotherRecordColumn, LookupColumn } from '../models'; import type { LinkToAnotherRecordType } from 'nocodb-sdk'; @Injectable() @@ -73,6 +73,11 @@ export class PublicMetasService { id: colOpt.fk_mm_model_id, }); } + } else if (UITypes.Lookup === col.uidt) { + await this.extractLookupRelatedMetas({ + lookupColOption: await col.getColOptions(), + relatedMetas, + }); } } @@ -80,6 +85,40 @@ export class PublicMetasService { return view; } + + private async extractLookupRelatedMetas({ + lookupColOption, + relatedMetas = {}, + }: { + lookupColOption: LookupColumn; + relatedMetas: { [key: string]: Model }; + }) { + const relationCol = await Column.get({ + colId: lookupColOption.fk_relation_column_id, + }); + const lookupCol = await Column.get({ + colId: lookupColOption.fk_lookup_column_id, + }); + + if (!relatedMetas[relationCol.fk_model_id]) { + relatedMetas[relationCol.fk_model_id] = await Model.getWithInfo({ + id: lookupCol.fk_model_id, + }); + } + if (!relatedMetas[lookupCol.fk_model_id]) { + relatedMetas[lookupCol.fk_model_id] = await Model.getWithInfo({ + id: lookupCol.fk_model_id, + }); + } + + if (lookupCol.uidt === UITypes.Lookup) { + await this.extractLookupRelatedMetas({ + lookupColOption: await lookupCol.getColOptions(), + relatedMetas, + }); + } + } + async publicSharedBaseGet(param: { sharedBaseUuid: string }): Promise { const project = await Project.getByUuid(param.sharedBaseUuid); From c56ff5e8dc004df24ab280554c7b449c1c944370 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Wed, 31 May 2023 01:33:41 +0530 Subject: [PATCH 05/13] chore: add some comments Signed-off-by: Pranav C --- packages/nocodb/src/services/public-metas.service.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/nocodb/src/services/public-metas.service.ts b/packages/nocodb/src/services/public-metas.service.ts index 36f4dcc405..cb4e3664a4 100644 --- a/packages/nocodb/src/services/public-metas.service.ts +++ b/packages/nocodb/src/services/public-metas.service.ts @@ -100,17 +100,22 @@ export class PublicMetasService { colId: lookupColOption.fk_lookup_column_id, }); + // extract meta for table which belongs the relation column + // if not already extracted if (!relatedMetas[relationCol.fk_model_id]) { relatedMetas[relationCol.fk_model_id] = await Model.getWithInfo({ id: lookupCol.fk_model_id, }); } + // extract meta for table in which looked up column belongs + // if not already extracted if (!relatedMetas[lookupCol.fk_model_id]) { relatedMetas[lookupCol.fk_model_id] = await Model.getWithInfo({ id: lookupCol.fk_model_id, }); } + // if looked up column is a lookup column do the same for it by recursion if (lookupCol.uidt === UITypes.Lookup) { await this.extractLookupRelatedMetas({ lookupColOption: await lookupCol.getColOptions(), From 002c1948f6413d715a5bc342edf002b4f6e58ea2 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Wed, 31 May 2023 13:36:52 +0800 Subject: [PATCH 06/13] fix(nocodb): comparison_op & fk_column_id types in swagger.json --- packages/nocodb/src/schema/swagger.json | 146 +++++++++++++----------- 1 file changed, 80 insertions(+), 66 deletions(-) diff --git a/packages/nocodb/src/schema/swagger.json b/packages/nocodb/src/schema/swagger.json index b7d5a6e102..57083b9061 100644 --- a/packages/nocodb/src/schema/swagger.json +++ b/packages/nocodb/src/schema/swagger.json @@ -15197,38 +15197,45 @@ }, "comparison_op": { "description": "Comparison Operator", - "enum": [ - "allof", - "anyof", - "blank", - "btw", - "checked", - "empty", - "eq", - "ge", - "gt", - "gte", - "in", - "is", - "isWithin", - "isnot", - "le", - "like", - "lt", - "lte", - "nallof", - "nanyof", - "nbtw", - "neq", - "nlike", - "not", - "notblank", - "notchecked", - "notempty", - "notnull", - "null" - ], - "type": "string" + "anyOf": [ + { + "enum": [ + "allof", + "anyof", + "blank", + "btw", + "checked", + "empty", + "eq", + "ge", + "gt", + "gte", + "in", + "is", + "isWithin", + "isnot", + "le", + "like", + "lt", + "lte", + "nallof", + "nanyof", + "nbtw", + "neq", + "nlike", + "not", + "notblank", + "notchecked", + "notempty", + "notnull", + "null" + ], + "type": "string" + }, + { + "type": "null" + } + ] }, "comparison_sub_op": { "anyOf": [ @@ -15262,7 +15269,7 @@ "description": "Comparison Sub-Operator" }, "fk_column_id": { - "$ref": "#/components/schemas/Id", + "$ref": "#/components/schemas/StringOrNull", "description": "Foreign Key to Column" }, "fk_hook_id": { @@ -15518,38 +15525,45 @@ "properties": { "comparison_op": { "description": "Comparison Operator", - "enum": [ - "allof", - "anyof", - "blank", - "btw", - "checked", - "empty", - "eq", - "ge", - "gt", - "gte", - "in", - "is", - "isWithin", - "isnot", - "le", - "like", - "lt", - "lte", - "nallof", - "nanyof", - "nbtw", - "neq", - "nlike", - "not", - "notblank", - "notchecked", - "notempty", - "notnull", - "null" - ], - "type": "string" + "anyOf": [ + { + "enum": [ + "allof", + "anyof", + "blank", + "btw", + "checked", + "empty", + "eq", + "ge", + "gt", + "gte", + "in", + "is", + "isWithin", + "isnot", + "le", + "like", + "lt", + "lte", + "nallof", + "nanyof", + "nbtw", + "neq", + "nlike", + "not", + "notblank", + "notchecked", + "notempty", + "notnull", + "null" + ], + "type": "string" + }, + { + "type": "null" + } + ] }, "comparison_sub_op": { "anyOf": [ @@ -15583,7 +15597,7 @@ "description": "Comparison Sub-Operator" }, "fk_column_id": { - "$ref": "#/components/schemas/Id", + "$ref": "#/components/schemas/StringOrNull", "description": "Foreign Key to Column" }, "fk_parent_id": { From 5971a67f0a97189a248301f38218fb29d0fd56ef Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Wed, 31 May 2023 13:37:02 +0800 Subject: [PATCH 07/13] chore(sdk): regenerate Api.ts --- packages/nocodb-sdk/src/lib/Api.ts | 72 ++++++++++++++++++++++++++++-- 1 file changed, 68 insertions(+), 4 deletions(-) diff --git a/packages/nocodb-sdk/src/lib/Api.ts b/packages/nocodb-sdk/src/lib/Api.ts index 06493d405c..948638e4ed 100644 --- a/packages/nocodb-sdk/src/lib/Api.ts +++ b/packages/nocodb-sdk/src/lib/Api.ts @@ -546,7 +546,39 @@ export interface FilterType { | 'notchecked' | 'notempty' | 'notnull' - | 'null'; + | 'null' + | null + | ( + | 'allof' + | 'anyof' + | 'blank' + | 'btw' + | 'checked' + | 'empty' + | 'eq' + | 'ge' + | 'gt' + | 'gte' + | 'in' + | 'is' + | 'isWithin' + | 'isnot' + | 'le' + | 'like' + | 'lt' + | 'lte' + | 'nallof' + | 'nanyof' + | 'nbtw' + | 'neq' + | 'nlike' + | 'not' + | 'notblank' + | 'notchecked' + | 'notempty' + | 'notnull' + | ('null' & null) + ); /** Comparison Sub-Operator */ comparison_sub_op?: | 'daysAgo' @@ -589,7 +621,7 @@ export interface FilterType { | ('yesterday' & null) ); /** Foreign Key to Column */ - fk_column_id?: IdType; + fk_column_id?: StringOrNullType; /** Foreign Key to Hook */ fk_hook_id?: StringOrNullType; /** Foreign Key to Model */ @@ -664,7 +696,39 @@ export interface FilterReqType { | 'notchecked' | 'notempty' | 'notnull' - | 'null'; + | 'null' + | null + | ( + | 'allof' + | 'anyof' + | 'blank' + | 'btw' + | 'checked' + | 'empty' + | 'eq' + | 'ge' + | 'gt' + | 'gte' + | 'in' + | 'is' + | 'isWithin' + | 'isnot' + | 'le' + | 'like' + | 'lt' + | 'lte' + | 'nallof' + | 'nanyof' + | 'nbtw' + | 'neq' + | 'nlike' + | 'not' + | 'notblank' + | 'notchecked' + | 'notempty' + | 'notnull' + | ('null' & null) + ); /** Comparison Sub-Operator */ comparison_sub_op?: | 'daysAgo' @@ -707,7 +771,7 @@ export interface FilterReqType { | ('yesterday' & null) ); /** Foreign Key to Column */ - fk_column_id?: IdType; + fk_column_id?: StringOrNullType; /** Belong to which filter ID */ fk_parent_id?: StringOrNullType; /** Is this filter grouped? */ From 1d7027f67ac739053a9f29d04c080a5a4b7ae573 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Wed, 31 May 2023 11:39:17 +0530 Subject: [PATCH 08/13] fix: handle if lookup column is LTAR Signed-off-by: Pranav C --- .../src/services/public-metas.service.ts | 77 ++++++++++++------- 1 file changed, 49 insertions(+), 28 deletions(-) diff --git a/packages/nocodb/src/services/public-metas.service.ts b/packages/nocodb/src/services/public-metas.service.ts index cb4e3664a4..0073502bba 100644 --- a/packages/nocodb/src/services/public-metas.service.ts +++ b/packages/nocodb/src/services/public-metas.service.ts @@ -63,22 +63,7 @@ export class PublicMetasService { // load related table metas for (const col of view.model.columns) { - if (UITypes.LinkToAnotherRecord === col.uidt) { - const colOpt = await col.getColOptions(); - relatedMetas[colOpt.fk_related_model_id] = await Model.getWithInfo({ - id: colOpt.fk_related_model_id, - }); - if (colOpt.type === 'mm') { - relatedMetas[colOpt.fk_mm_model_id] = await Model.getWithInfo({ - id: colOpt.fk_mm_model_id, - }); - } - } else if (UITypes.Lookup === col.uidt) { - await this.extractLookupRelatedMetas({ - lookupColOption: await col.getColOptions(), - relatedMetas, - }); - } + await this.extractRelatedMetas({ col, relatedMetas }); } view.relatedMetas = relatedMetas; @@ -86,6 +71,43 @@ export class PublicMetasService { return view; } + private async extractRelatedMetas({ + col, + relatedMetas = {}, + }: { + col: Column; + relatedMetas: Record; + }) { + if (UITypes.LinkToAnotherRecord === col.uidt) { + await this.extractLTARRelatedMetas({ + ltarColOption: await col.getColOptions(), + relatedMetas, + }); + } else if (UITypes.Lookup === col.uidt) { + await this.extractLookupRelatedMetas({ + lookupColOption: await col.getColOptions(), + relatedMetas, + }); + } + } + + private async extractLTARRelatedMetas({ + ltarColOption, + relatedMetas = {}, + }: { + ltarColOption: LinkToAnotherRecordColumn; + relatedMetas: { [key: string]: Model }; + }) { + relatedMetas[ltarColOption.fk_related_model_id] = await Model.getWithInfo({ + id: ltarColOption.fk_related_model_id, + }); + if (ltarColOption.type === 'mm') { + relatedMetas[ltarColOption.fk_mm_model_id] = await Model.getWithInfo({ + id: ltarColOption.fk_mm_model_id, + }); + } + } + private async extractLookupRelatedMetas({ lookupColOption, relatedMetas = {}, @@ -96,7 +118,7 @@ export class PublicMetasService { const relationCol = await Column.get({ colId: lookupColOption.fk_relation_column_id, }); - const lookupCol = await Column.get({ + const lookedUpCol = await Column.get({ colId: lookupColOption.fk_lookup_column_id, }); @@ -104,24 +126,23 @@ export class PublicMetasService { // if not already extracted if (!relatedMetas[relationCol.fk_model_id]) { relatedMetas[relationCol.fk_model_id] = await Model.getWithInfo({ - id: lookupCol.fk_model_id, + id: relationCol.fk_model_id, }); } + // extract meta for table in which looked up column belongs // if not already extracted - if (!relatedMetas[lookupCol.fk_model_id]) { - relatedMetas[lookupCol.fk_model_id] = await Model.getWithInfo({ - id: lookupCol.fk_model_id, + if (!relatedMetas[lookedUpCol.fk_model_id]) { + relatedMetas[lookedUpCol.fk_model_id] = await Model.getWithInfo({ + id: lookedUpCol.fk_model_id, }); } - // if looked up column is a lookup column do the same for it by recursion - if (lookupCol.uidt === UITypes.Lookup) { - await this.extractLookupRelatedMetas({ - lookupColOption: await lookupCol.getColOptions(), - relatedMetas, - }); - } + // extract metas related to the looked up column + await this.extractRelatedMetas({ + col: lookedUpCol, + relatedMetas, + }); } async publicSharedBaseGet(param: { sharedBaseUuid: string }): Promise { From 40aeec53a47940ba4559ff4cc505aa9473441e7f Mon Sep 17 00:00:00 2001 From: Pranav C Date: Wed, 31 May 2023 12:05:35 +0530 Subject: [PATCH 09/13] fix: disable expand form in public shared gallery Signed-off-by: Pranav C --- packages/nc-gui/components/smartsheet/Gallery.vue | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/nc-gui/components/smartsheet/Gallery.vue b/packages/nc-gui/components/smartsheet/Gallery.vue index f4f4a160f4..4f94e91973 100644 --- a/packages/nc-gui/components/smartsheet/Gallery.vue +++ b/packages/nc-gui/components/smartsheet/Gallery.vue @@ -7,6 +7,7 @@ import { IsFormInj, IsGalleryInj, IsGridInj, + IsPublicInj, MetaInj, NavigateDir, OpenNewRecordFormHookInj, @@ -62,6 +63,8 @@ provide(IsGridInj, ref(false)) provide(PaginationDataInj, paginationData) provide(ChangePageInj, changePage) +const isPublic = inject(IsPublicInj, ref(false)) + const fields = inject(FieldsInj, ref([])) const route = useRoute() @@ -125,6 +128,10 @@ const attachments = (record: any): Attachment[] => { } const expandForm = (row: RowType, state?: Record) => { + if (isPublic.value) { + return + } + const rowId = extractPkFromRow(row.row, meta.value!.columns!) if (rowId) { From 897cb583074f9cc86364c34d05122ffb561f0ccd Mon Sep 17 00:00:00 2001 From: Pranav C Date: Wed, 31 May 2023 12:19:42 +0530 Subject: [PATCH 10/13] fix: ignore redirection if public page Signed-off-by: Pranav C --- packages/nc-gui/composables/useApi/interceptors.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/nc-gui/composables/useApi/interceptors.ts b/packages/nc-gui/composables/useApi/interceptors.ts index 4c12bc083c..ca95a62243 100644 --- a/packages/nc-gui/composables/useApi/interceptors.ts +++ b/packages/nc-gui/composables/useApi/interceptors.ts @@ -67,9 +67,8 @@ export function addAxiosInterceptors(api: Api) { }) .catch(async (error) => { await state.signOut() - // todo: handle new user - navigateTo('/signIn') + if (!route.meta.public) navigateTo('/signIn') return Promise.reject(error) }) From c427332eea0684c0bc8c8c2d50fb3fb253e8b58e Mon Sep 17 00:00:00 2001 From: Pranav C Date: Wed, 31 May 2023 12:49:05 +0530 Subject: [PATCH 11/13] fix: make cursor in public shared gallery default for card Signed-off-by: Pranav C --- packages/nc-gui/components/smartsheet/Gallery.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/nc-gui/components/smartsheet/Gallery.vue b/packages/nc-gui/components/smartsheet/Gallery.vue index 4f94e91973..5b0a2f5088 100644 --- a/packages/nc-gui/components/smartsheet/Gallery.vue +++ b/packages/nc-gui/components/smartsheet/Gallery.vue @@ -241,6 +241,7 @@ watch(view, async (nextView) => { :data-testid="`nc-gallery-card-${record.row.id}`" @click="expandFormClick($event, record)" @contextmenu="showContextMenu($event, { row: rowIndex })" + :style="isPublic ? { cursor: 'default' } : { cursor: 'pointer' }" >
-
+
= Symbol('toggle-dialog-inj export const CellClickHookInj: InjectionKey | undefined> = Symbol('cell-click-injection') export const SaveRowInj: InjectionKey<(() => void) | undefined> = Symbol('save-row-injection') export const CurrentCellInj: InjectionKey> = Symbol('current-cell-injection') +export const IsUnderLookupInj: InjectionKey> = Symbol('is-under-lookup-injection')