Skip to content

Commit

Permalink
Merge pull request #7392 from nocodb/nc-fix/sentry-error
Browse files Browse the repository at this point in the history
Nc fix/sentry error
  • Loading branch information
dstala committed Jan 11, 2024
2 parents ed6332c + 728e2fa commit fbf32cd
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 20 deletions.
16 changes: 11 additions & 5 deletions packages/nc-gui/components/smartsheet/column/LookupOptions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const baseStore = useBase()
const { tables } = storeToRefs(baseStore)
const { metas } = useMetas()
const { metas, getMeta } = useMetas()
setAdditionalValidations({
fk_relation_column_id: [{ required: true, message: t('general.required') }],
Expand All @@ -48,12 +48,15 @@ const refTables = computed(() => {
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 selectedTable = refTables.value.find((t) => t.column.id === vModel.value.fk_relation_column_id)
if (!selectedTable?.id) {
if (!selectedTable.value?.id) {
return []
}
return metas.value[selectedTable.id].columns.filter(
return metas.value[selectedTable.value.id]?.columns.filter(
(c: ColumnType) =>
vModel.value.fk_lookup_column_id === c.id || (!isSystemColumn(c) && c.id !== vModel.value.id && c.uidt !== UITypes.Links),
)
Expand All @@ -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
onDataTypeChange()
}
Expand Down
17 changes: 11 additions & 6 deletions packages/nc-gui/components/smartsheet/column/RollupOptions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const baseStore = useBase()
const { tables } = storeToRefs(baseStore)
const { metas } = useMetas()
const { metas, getMeta } = useMetas()
const { t } = useI18n()
Expand Down Expand Up @@ -70,14 +70,16 @@ const refTables = computed(() => {
return _refTables as Required<TableType & { column: ColumnType; col: Required<LinkToAnotherRecordType> }>[]
})
const columns = computed(() => {
const selectedTable = refTables.value.find((t) => t.column.id === vModel.value.fk_relation_column_id)
const selectedTable = computed(() => {
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 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),
)
})
Expand All @@ -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
onDataTypeChange()
}
Expand Down
6 changes: 5 additions & 1 deletion packages/nc-gui/composables/useApi/interceptors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,15 @@ export function addAxiosInterceptors(api: Api<any>) {
// ignore since it could have already been handled and redirected to sign in
})
} else {
// if
refreshTokenPromise = new Promise<string>((resolve, reject) => {
refreshTokenPromiseRes = resolve
refreshTokenPromiseRej = reject
})

// set a catch on the promise to avoid unhandled promise rejection
refreshTokenPromise.catch(() => {
// ignore
})
}

// Try request again with new token
Expand Down
2 changes: 2 additions & 0 deletions packages/nc-gui/composables/useGlobal/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ export const useGlobal = createGlobalState((): UseGlobalReturn => {
(nextPayload) => {
if (nextPayload) {
state.user.value = {
// keep existing props if user id same as before
...(state.user.value?.id === nextPayload.id ? state.user.value || {} : {}),
id: nextPayload.id,
email: nextPayload.email,
firstname: nextPayload.firstname,
Expand Down
2 changes: 1 addition & 1 deletion packages/nc-gui/composables/useSmartsheetStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const [useProvideSmartsheetStore, useSmartsheetStore] = useInjectionState(

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],
)

Expand Down
14 changes: 9 additions & 5 deletions packages/nc-gui/composables/useViewData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ export function useViewData(
if (error.code === 'ERR_CANCELED') {
return
}
throw error
console.error(error)
return message.error(await extractSdkResponseErrorMsg(error))
}
formattedData.value = formatData(response.list)
paginationData.value = response.pageInfo
Expand All @@ -238,10 +239,13 @@ export function useViewData(

async function changePage(page: number) {
paginationData.value.page = page
await loadData({
offset: (page - 1) * (paginationData.value.pageSize || appInfoDefaultLimit),
where: where?.value,
} as any)
await loadData(
{
offset: (page - 1) * (paginationData.value.pageSize || appInfoDefaultLimit),
where: where?.value,
} as any,
true,
)
}

const {
Expand Down
1 change: 1 addition & 0 deletions packages/nc-gui/utils/columnUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ const isColumnRequired = (col?: ColumnType) => col && col.rqd && !col.cdf && !co

const isVirtualColRequired = (col: ColumnType, columns: ColumnType[]) =>
col.uidt === UITypes.LinkToAnotherRecord &&
col.colOptions &&
(<LinkToAnotherRecordType>col.colOptions).type === RelationTypes.BELONGS_TO &&
isColumnRequired(columns.find((c) => c.id === (<LinkToAnotherRecordType>col.colOptions).fk_child_column_id))

Expand Down
5 changes: 4 additions & 1 deletion packages/nocodb/src/cache/RedisCacheMgr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ export default class RedisCacheMgr extends CacheMgr {
this.client = new Redis(config);

// 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)
this.client.flushdb();
}
Expand Down
2 changes: 1 addition & 1 deletion packages/nocodb/src/db/BaseModelSqlv2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5757,7 +5757,7 @@ class BaseModelSqlv2 {

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]) {
qb.orWhere(await this._wherePk(rowId));
Expand Down

0 comments on commit fbf32cd

Please sign in to comment.