Browse Source

Merge pull request #7392 from nocodb/nc-fix/sentry-error

Nc fix/sentry error
pull/7406/head
Raju Udava 10 months ago committed by GitHub
parent
commit
fbf32cd0fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      packages/nc-gui/components/smartsheet/column/LookupOptions.vue
  2. 17
      packages/nc-gui/components/smartsheet/column/RollupOptions.vue
  3. 6
      packages/nc-gui/composables/useApi/interceptors.ts
  4. 2
      packages/nc-gui/composables/useGlobal/index.ts
  5. 2
      packages/nc-gui/composables/useSmartsheetStore.ts
  6. 14
      packages/nc-gui/composables/useViewData.ts
  7. 1
      packages/nc-gui/utils/columnUtils.ts
  8. 5
      packages/nocodb/src/cache/RedisCacheMgr.ts
  9. 2
      packages/nocodb/src/db/BaseModelSqlv2.ts

16
packages/nc-gui/components/smartsheet/column/LookupOptions.vue

@ -22,7 +22,7 @@ const baseStore = useBase()
const { tables } = storeToRefs(baseStore) const { tables } = storeToRefs(baseStore)
const { metas } = useMetas() const { metas, getMeta } = useMetas()
setAdditionalValidations({ setAdditionalValidations({
fk_relation_column_id: [{ required: true, message: t('general.required') }], fk_relation_column_id: [{ required: true, message: t('general.required') }],
@ -48,12 +48,15 @@ const refTables = computed(() => {
return _refTables as Required<TableType & { column: ColumnType; col: Required<LinkToAnotherRecordType> }>[] return _refTables as Required<TableType & { column: ColumnType; col: Required<LinkToAnotherRecordType> }>[]
}) })
const selectedTable = computed(() => {
return refTables.value.find((t) => t.column.id === vModel.value.fk_relation_column_id)
})
const columns = computed<ColumnType[]>(() => { const columns = computed<ColumnType[]>(() => {
const selectedTable = refTables.value.find((t) => t.column.id === vModel.value.fk_relation_column_id) if (!selectedTable.value?.id) {
if (!selectedTable?.id) {
return [] return []
} }
return metas.value[selectedTable.id].columns.filter( return metas.value[selectedTable.value.id]?.columns.filter(
(c: ColumnType) => (c: ColumnType) =>
vModel.value.fk_lookup_column_id === c.id || (!isSystemColumn(c) && c.id !== vModel.value.id && c.uidt !== UITypes.Links), vModel.value.fk_lookup_column_id === c.id || (!isSystemColumn(c) && c.id !== vModel.value.id && c.uidt !== UITypes.Links),
) )
@ -66,7 +69,10 @@ onMounted(() => {
} }
}) })
const onRelationColChange = () => { const onRelationColChange = async () => {
if (selectedTable.value) {
await getMeta(selectedTable.value.id)
}
vModel.value.fk_lookup_column_id = columns.value?.[0]?.id vModel.value.fk_lookup_column_id = columns.value?.[0]?.id
onDataTypeChange() onDataTypeChange()
} }

17
packages/nc-gui/components/smartsheet/column/RollupOptions.vue

@ -35,7 +35,7 @@ const baseStore = useBase()
const { tables } = storeToRefs(baseStore) const { tables } = storeToRefs(baseStore)
const { metas } = useMetas() const { metas, getMeta } = useMetas()
const { t } = useI18n() const { t } = useI18n()
@ -70,14 +70,16 @@ const refTables = computed(() => {
return _refTables as Required<TableType & { column: ColumnType; col: Required<LinkToAnotherRecordType> }>[] return _refTables as Required<TableType & { column: ColumnType; col: Required<LinkToAnotherRecordType> }>[]
}) })
const columns = computed(() => { const selectedTable = computed(() => {
const selectedTable = refTables.value.find((t) => t.column.id === vModel.value.fk_relation_column_id) return refTables.value.find((t) => t.column.id === vModel.value.fk_relation_column_id)
})
if (!selectedTable?.id) { const columns = computed<ColumnType[]>(() => {
if (!selectedTable.value?.id) {
return [] return []
} }
return metas.value[selectedTable.id].columns.filter( return metas.value[selectedTable.value.id]?.columns.filter(
(c: ColumnType) => !isVirtualCol(c.uidt as UITypes) && (!isSystemColumn(c) || c.pk), (c: ColumnType) => !isVirtualCol(c.uidt as UITypes) && (!isSystemColumn(c) || c.pk),
) )
}) })
@ -90,7 +92,10 @@ onMounted(() => {
} }
}) })
const onRelationColChange = () => { const onRelationColChange = async () => {
if (selectedTable.value) {
await getMeta(selectedTable.value.id)
}
vModel.value.fk_rollup_column_id = columns.value?.[0]?.id vModel.value.fk_rollup_column_id = columns.value?.[0]?.id
onDataTypeChange() onDataTypeChange()
} }

6
packages/nc-gui/composables/useApi/interceptors.ts

@ -84,11 +84,15 @@ export function addAxiosInterceptors(api: Api<any>) {
// ignore since it could have already been handled and redirected to sign in // ignore since it could have already been handled and redirected to sign in
}) })
} else { } else {
// if
refreshTokenPromise = new Promise<string>((resolve, reject) => { refreshTokenPromise = new Promise<string>((resolve, reject) => {
refreshTokenPromiseRes = resolve refreshTokenPromiseRes = resolve
refreshTokenPromiseRej = reject refreshTokenPromiseRej = reject
}) })
// set a catch on the promise to avoid unhandled promise rejection
refreshTokenPromise.catch(() => {
// ignore
})
} }
// Try request again with new token // Try request again with new token

2
packages/nc-gui/composables/useGlobal/index.ts

@ -66,6 +66,8 @@ export const useGlobal = createGlobalState((): UseGlobalReturn => {
(nextPayload) => { (nextPayload) => {
if (nextPayload) { if (nextPayload) {
state.user.value = { state.user.value = {
// keep existing props if user id same as before
...(state.user.value?.id === nextPayload.id ? state.user.value || {} : {}),
id: nextPayload.id, id: nextPayload.id,
email: nextPayload.email, email: nextPayload.email,
firstname: nextPayload.firstname, firstname: nextPayload.firstname,

2
packages/nc-gui/composables/useSmartsheetStore.ts

@ -21,7 +21,7 @@ const [useProvideSmartsheetStore, useSmartsheetStore] = useInjectionState(
const { sqlUis } = storeToRefs(baseStore) const { sqlUis } = storeToRefs(baseStore)
const sqlUi = ref( const sqlUi = computed(() =>
(meta.value as TableType)?.source_id ? sqlUis.value[(meta.value as TableType).source_id!] : Object.values(sqlUis.value)[0], (meta.value as TableType)?.source_id ? sqlUis.value[(meta.value as TableType).source_id!] : Object.values(sqlUis.value)[0],
) )

14
packages/nc-gui/composables/useViewData.ts

@ -211,7 +211,8 @@ export function useViewData(
if (error.code === 'ERR_CANCELED') { if (error.code === 'ERR_CANCELED') {
return return
} }
throw error console.error(error)
return message.error(await extractSdkResponseErrorMsg(error))
} }
formattedData.value = formatData(response.list) formattedData.value = formatData(response.list)
paginationData.value = response.pageInfo paginationData.value = response.pageInfo
@ -238,10 +239,13 @@ export function useViewData(
async function changePage(page: number) { async function changePage(page: number) {
paginationData.value.page = page paginationData.value.page = page
await loadData({ await loadData(
offset: (page - 1) * (paginationData.value.pageSize || appInfoDefaultLimit), {
where: where?.value, offset: (page - 1) * (paginationData.value.pageSize || appInfoDefaultLimit),
} as any) where: where?.value,
} as any,
true,
)
} }
const { const {

1
packages/nc-gui/utils/columnUtils.ts

@ -184,6 +184,7 @@ const isColumnRequired = (col?: ColumnType) => col && col.rqd && !col.cdf && !co
const isVirtualColRequired = (col: ColumnType, columns: ColumnType[]) => const isVirtualColRequired = (col: ColumnType, columns: ColumnType[]) =>
col.uidt === UITypes.LinkToAnotherRecord && col.uidt === UITypes.LinkToAnotherRecord &&
col.colOptions &&
(<LinkToAnotherRecordType>col.colOptions).type === RelationTypes.BELONGS_TO && (<LinkToAnotherRecordType>col.colOptions).type === RelationTypes.BELONGS_TO &&
isColumnRequired(columns.find((c) => c.id === (<LinkToAnotherRecordType>col.colOptions).fk_child_column_id)) isColumnRequired(columns.find((c) => c.id === (<LinkToAnotherRecordType>col.colOptions).fk_child_column_id))

5
packages/nocodb/src/cache/RedisCacheMgr.ts vendored

@ -14,7 +14,10 @@ export default class RedisCacheMgr extends CacheMgr {
this.client = new Redis(config); this.client = new Redis(config);
// avoid flushing db in worker container // avoid flushing db in worker container
if (process.env.NC_WORKER_CONTAINER !== 'true' && process.env.NC_CLOUD !== 'true') { if (
process.env.NC_WORKER_CONTAINER !== 'true' &&
process.env.NC_CLOUD !== 'true'
) {
// flush the existing db with selected key (Default: 0) // flush the existing db with selected key (Default: 0)
this.client.flushdb(); this.client.flushdb();
} }

2
packages/nocodb/src/db/BaseModelSqlv2.ts

@ -5757,7 +5757,7 @@ class BaseModelSqlv2 {
if (Object.keys(updateObject).length === 0) return; if (Object.keys(updateObject).length === 0) return;
const qb = knex(model.table_name).update(updateObject); const qb = knex(this.getTnPath(model.table_name)).update(updateObject);
for (const rowId of Array.isArray(rowIds) ? rowIds : [rowIds]) { for (const rowId of Array.isArray(rowIds) ? rowIds : [rowIds]) {
qb.orWhere(await this._wherePk(rowId)); qb.orWhere(await this._wherePk(rowId));

Loading…
Cancel
Save