Browse Source

fix: multiple sentry errors related to accessing prop of null/undefined

pull/7463/head
Pranav C 11 months ago
parent
commit
fd0803ccc8
  1. 3
      packages/nc-gui/components/dashboard/TreeView/ViewsList.vue
  2. 2
      packages/nc-gui/components/smartsheet/Kanban.vue
  3. 2
      packages/nc-gui/components/smartsheet/column/SelectOptions.vue
  4. 3
      packages/nc-gui/components/smartsheet/expanded-form/index.vue
  5. 6
      packages/nc-gui/components/smartsheet/grid/useColumnDrag.ts
  6. 6
      packages/nc-gui/components/smartsheet/header/CellIcon.ts
  7. 2
      packages/nc-gui/composables/useViewGroupBy.ts

3
packages/nc-gui/components/dashboard/TreeView/ViewsList.vue

@ -158,7 +158,8 @@ async function onSortEnd(evt: SortableEvent, undo = false) {
if (!currentItem || !currentItem.id) return if (!currentItem || !currentItem.id) return
const previousItem = (previousEl ? views.value.find((v) => v.id === previousEl.id) ?? { order: 0 } : {}) as ViewType // set default order value as 0 if item not found
const previousItem = (previousEl ? views.value.find((v) => v.id === previousEl.id) ?? { order: 0 } : { order: 0 }) as ViewType
const nextItem = (nextEl ? views.value.find((v) => v.id === nextEl.id) : {}) as ViewType const nextItem = (nextEl ? views.value.find((v) => v.id === nextEl.id) : {}) as ViewType
let nextOrder: number let nextOrder: number

2
packages/nc-gui/components/smartsheet/Kanban.vue

@ -367,7 +367,7 @@ watch(
// horizontally scroll to the end of the kanban container // horizontally scroll to the end of the kanban container
// when a new option is added within kanban view // when a new option is added within kanban view
nextTick(() => { nextTick(() => {
if (shouldScrollToRight.value) { if (shouldScrollToRight.value && kanbanContainerRef.value) {
kanbanContainerRef.value.scrollTo({ kanbanContainerRef.value.scrollTo({
left: kanbanContainerRef.value.scrollWidth, left: kanbanContainerRef.value.scrollWidth,
behavior: 'smooth', behavior: 'smooth',

2
packages/nc-gui/components/smartsheet/column/SelectOptions.vue

@ -176,6 +176,8 @@ const addNewOption = () => {
// } // }
const syncOptions = () => { const syncOptions = () => {
// set initial colOptions if not set
vModel.value.colOptions = vModel.value.colOptions || {}
vModel.value.colOptions.options = options.value vModel.value.colOptions.options = options.value
.filter((op) => op.status !== 'remove') .filter((op) => op.status !== 'remove')
.sort((a, b) => { .sort((a, b) => {

3
packages/nc-gui/components/smartsheet/expanded-form/index.vue

@ -116,7 +116,8 @@ const fields = computedInject(FieldsInj, (_fields) => {
}) })
const hiddenFields = computed(() => { const hiddenFields = computed(() => {
return (meta.value.columns ?? []).filter((col) => !fields.value?.includes(col)).filter((col) => !isSystemColumn(col)) // todo: figure out when meta.value is undefined
return (meta.value?.columns ?? []).filter((col) => !fields.value?.includes(col)).filter((col) => !isSystemColumn(col))
}) })
const showHiddenFields = ref(false) const showHiddenFields = ref(false)

6
packages/nc-gui/components/smartsheet/grid/useColumnDrag.ts

@ -25,7 +25,11 @@ export const useColumnDrag = ({
const reorderColumn = async (colId: string, toColId: string) => { const reorderColumn = async (colId: string, toColId: string) => {
const toBeReorderedViewCol = gridViewCols.value[colId] const toBeReorderedViewCol = gridViewCols.value[colId]
const toViewCol = gridViewCols.value[toColId]! const toViewCol = gridViewCols.value[toColId]
// if toBeReorderedViewCol/toViewCol is null, return
if (!toBeReorderedViewCol || !toViewCol) return
const toColIndex = fields.value.findIndex((f) => f.id === toColId) const toColIndex = fields.value.findIndex((f) => f.id === toColId)
const nextToColField = toColIndex < fields.value.length - 1 ? fields.value[toColIndex + 1] : null const nextToColField = toColIndex < fields.value.length - 1 ? fields.value[toColIndex + 1] : null

6
packages/nc-gui/components/smartsheet/header/CellIcon.ts

@ -115,9 +115,11 @@ export default defineComponent({
const { sqlUis } = storeToRefs(useBase()) const { sqlUis } = storeToRefs(useBase())
const sqlUi = ref(column.value?.source_id ? sqlUis.value[column.value?.source_id] : Object.values(sqlUis.value)[0]) const sqlUi = computed(() =>
column.value?.source_id ? sqlUis.value[column.value?.source_id] : Object.values(sqlUis.value)[0],
)
const abstractType = computed(() => column.value && sqlUi.value.getAbstractType(column.value)) const abstractType = computed(() => column.value && sqlUi.value?.getAbstractType(column.value))
return () => { return () => {
if (!column.value && !columnMeta.value) return null if (!column.value && !columnMeta.value) return null

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

@ -20,7 +20,7 @@ export const useViewGroupBy = (view: Ref<ViewType | undefined>, where?: Computed
const tempGroupBy: { column: ColumnType; sort: string; order?: number }[] = [] const tempGroupBy: { column: ColumnType; sort: string; order?: number }[] = []
Object.values(gridViewCols.value).forEach((col) => { Object.values(gridViewCols.value).forEach((col) => {
if (col.group_by) { if (col.group_by) {
const column = meta?.value.columns?.find((f) => f.id === col.fk_column_id) const column = meta?.value?.columns?.find((f) => f.id === col.fk_column_id)
if (column) { if (column) {
tempGroupBy.push({ tempGroupBy.push({
column, column,

Loading…
Cancel
Save