Browse Source

Merge branch 'develop' into feat/ltar-rollup-on-creation

pull/5848/head
Raju Udava 1 year ago committed by GitHub
parent
commit
785a5d8827
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      .github/workflows/playwright-test-workflow.yml
  2. 29
      packages/nc-gui/components/cell/DatePicker.vue
  3. 21
      packages/nc-gui/components/cell/DateTimePicker.vue
  4. 6
      packages/nc-gui/components/cell/MultiSelect.vue
  5. 6
      packages/nc-gui/components/cell/SingleSelect.vue
  6. 508
      packages/nc-gui/components/dlg/BulkUpdate.vue
  7. 44
      packages/nc-gui/components/smartsheet/Grid.vue
  8. 18
      packages/nc-gui/composables/useViewData.ts
  9. 2
      packages/nc-gui/package-lock.json
  10. 2
      packages/nc-lib-gui/package.json
  11. 4
      packages/nocodb-sdk/package-lock.json
  12. 2
      packages/nocodb-sdk/package.json
  13. 2
      packages/nocodb-sdk/src/lib/Api.ts
  14. 319
      packages/nocodb/README.md
  15. 71
      packages/nocodb/package-lock.json
  16. 7
      packages/nocodb/package.json
  17. 21
      packages/nocodb/src/controllers/test/TestResetService/index.ts
  18. 167
      packages/nocodb/src/db/BaseModelSqlv2.ts
  19. 1
      packages/nocodb/src/models/Column.ts
  20. 14
      packages/nocodb/src/models/Model.ts
  21. 79
      packages/nocodb/src/modules/jobs/jobs/at-import/helpers/readAndProcessData.ts
  22. 7
      packages/nocodb/src/schema/swagger.json
  23. 2
      packages/nocodb/src/services/bulk-data-alias.service.ts
  24. 7
      packages/nocodb/src/version-upgrader/ncXcdbLTARUpgrader.ts
  25. 4
      tests/playwright/pages/Account/License.ts
  26. 192
      tests/playwright/pages/Dashboard/BulkUpdate/index.ts
  27. 13
      tests/playwright/pages/Dashboard/Grid/index.ts
  28. 2
      tests/playwright/pages/Dashboard/common/Cell/SelectOptionCell.ts
  29. 23
      tests/playwright/pages/Dashboard/common/Cell/TimeCell.ts
  30. 23
      tests/playwright/pages/Dashboard/common/Cell/YearCell.ts
  31. 6
      tests/playwright/pages/Dashboard/common/Cell/index.ts
  32. 3
      tests/playwright/pages/Dashboard/index.ts
  33. 30
      tests/playwright/setup/demoTable.ts
  34. 1
      tests/playwright/tests/db/filters.spec.ts
  35. 4
      tests/playwright/tests/db/projectOperations.spec.ts
  36. 14
      tests/playwright/tests/db/timezone.spec.ts
  37. 288
      tests/playwright/tests/db/updateBulk.ts

13
.github/workflows/playwright-test-workflow.yml

@ -69,10 +69,23 @@ jobs:
working-directory: ./packages/nc-gui
run: npm run ci:run
- name: Run backend
if: ${{ inputs.db == 'sqlite' }}
working-directory: ./packages/nocodb
run: |
npm install
npm run watch:run:playwright > ${{ inputs.db }}_${{ inputs.shard }}_test_backend.log &
- name: Run backend:mysql
if: ${{ inputs.db == 'mysql' }}
working-directory: ./packages/nocodb
run: |
npm install
npm run watch:run:playwright:mysql > ${{ inputs.db }}_${{ inputs.shard }}_test_backend.log &
- name: Run backend:pg
if: ${{ inputs.db == 'pg' }}
working-directory: ./packages/nocodb
run: |
npm install
npm run watch:run:playwright:pg > ${{ inputs.db }}_${{ inputs.shard }}_test_backend.log &
- name: Cache playwright npm modules
uses: actions/cache@v3
id: playwright-cache

29
packages/nc-gui/components/cell/DatePicker.vue

@ -2,6 +2,7 @@
import dayjs from 'dayjs'
import {
ActiveCellInj,
CellClickHookInj,
ColumnInj,
EditModeInj,
ReadonlyInj,
@ -165,6 +166,31 @@ useSelectedCellKeyupListener(active, (e: KeyboardEvent) => {
break
}
})
// use the default date picker open sync only to close the picker
const updateOpen = (next: boolean) => {
if (open.value && !next) {
open.value = false
}
}
const cellClickHook = inject(CellClickHookInj, null)
const cellClickHandler = () => {
open.value = (active.value || editable.value) && !open.value
}
onMounted(() => {
cellClickHook?.on(cellClickHandler)
})
onUnmounted(() => {
cellClickHook?.on(cellClickHandler)
})
const clickHandler = () => {
if (cellClickHook) {
return
}
cellClickHandler()
}
</script>
<template>
@ -179,7 +205,8 @@ useSelectedCellKeyupListener(active, (e: KeyboardEvent) => {
:input-read-only="true"
:dropdown-class-name="`${randomClass} nc-picker-date ${open ? 'active' : ''}`"
:open="(readOnly || (localState && isPk)) && !active && !editable ? false : open"
@click="open = (active || editable) && !open"
@click="clickHandler"
@update:open="updateOpen"
>
<template #suffixIcon></template>
</a-date-picker>

21
packages/nc-gui/components/cell/DateTimePicker.vue

@ -2,6 +2,7 @@
import dayjs from 'dayjs'
import {
ActiveCellInj,
CellClickHookInj,
ColumnInj,
ReadonlyInj,
dateFormats,
@ -213,6 +214,24 @@ useSelectedCellKeyupListener(active, (e: KeyboardEvent) => {
break
}
})
const cellClickHook = inject(CellClickHookInj, null)
const cellClickHandler = () => {
open.value = (active.value || editable.value) && !open.value
}
onMounted(() => {
cellClickHook?.on(cellClickHandler)
})
onUnmounted(() => {
cellClickHook?.on(cellClickHandler)
})
const clickHandler = () => {
if (cellClickHook) {
return
}
cellClickHandler()
}
</script>
<template>
@ -229,7 +248,7 @@ useSelectedCellKeyupListener(active, (e: KeyboardEvent) => {
:dropdown-class-name="`${randomClass} nc-picker-datetime ${open ? 'active' : ''}`"
:open="readOnly || (localState && isPk) ? false : open && (active || editable)"
:disabled="readOnly || (localState && isPk)"
@click="open = (active || editable) && !open"
@click="clickHandler"
@ok="open = !open"
>
<template #suffixIcon></template>

6
packages/nc-gui/components/cell/MultiSelect.vue

@ -48,11 +48,11 @@ const readOnly = inject(ReadonlyInj)!
const isEditable = inject(EditModeInj, ref(false))
const _active = inject(ActiveCellInj, ref(false))
const activeCell = inject(ActiveCellInj, ref(false))
// use both ActiveCellInj or EditModeInj to determine the active state
// since active will be false in case of form view
const active = computed(() => _active.value || isEditable.value)
const active = computed(() => activeCell.value || isEditable.value)
const isPublic = inject(IsPublicInj, ref(false))
@ -180,7 +180,7 @@ watch(isOpen, (n, _o) => {
}
})
useSelectedCellKeyupListener(active, (e) => {
useSelectedCellKeyupListener(activeCell, (e) => {
switch (e.key) {
case 'Escape':
isOpen.value = false

6
packages/nc-gui/components/cell/SingleSelect.vue

@ -42,11 +42,11 @@ const readOnly = inject(ReadonlyInj)!
const isEditable = inject(EditModeInj, ref(false))
const _active = inject(ActiveCellInj, ref(false))
const activeCell = inject(ActiveCellInj, ref(false))
// use both ActiveCellInj or EditModeInj to determine the active state
// since active will be false in case of form view
const active = computed(() => _active.value || isEditable.value)
const active = computed(() => activeCell.value || isEditable.value)
const aselect = ref<typeof AntSelect>()
@ -119,7 +119,7 @@ watch(isOpen, (n, _o) => {
}
})
useSelectedCellKeyupListener(active, (e) => {
useSelectedCellKeyupListener(activeCell, (e) => {
switch (e.key) {
case 'Escape':
isOpen.value = false

508
packages/nc-gui/components/dlg/BulkUpdate.vue

@ -0,0 +1,508 @@
<script setup lang="ts">
import type { TableType, ViewType } from 'nocodb-sdk'
import { RelationTypes, UITypes, isSystemColumn, isVirtualCol } from 'nocodb-sdk'
import Draggable from 'vuedraggable'
import {
CellClickHookInj,
IsExpandedFormOpenInj,
IsFormInj,
MetaInj,
PaginationDataInj,
provide,
ref,
toRef,
useVModel,
} from '#imports'
import type { Row } from '~/lib'
interface Props {
modelValue: boolean
meta: TableType
view?: ViewType
bulkUpdateRows?: Function
bulkUpdateView?: Function
selectedAllRecords?: boolean
rows?: Row[]
}
const props = defineProps<Props>()
const emits = defineEmits(['update:modelValue', 'cancel'])
enum BulkUpdateMode {
ALL = 0,
SELECTED = 1,
}
const meta = toRef(props, 'meta')
const isExpanded = useVModel(props, 'modelValue', emits, {
defaultValue: false,
})
// override cell click hook to avoid unexpected behavior at form fields
provide(CellClickHookInj, null)
provide(MetaInj, meta)
provide(IsFormInj, ref(true))
provide(IsExpandedFormOpenInj, isExpanded)
const formState: Record<string, any> = reactive({})
const updateMode = ref(BulkUpdateMode.ALL)
const moved = ref(false)
const drag = ref(false)
const editColumns = ref<Record<string, any>[]>([])
const tempRow = ref<Row>({
row: {},
oldRow: {},
rowMeta: {},
})
useProvideSmartsheetRowStore(meta, tempRow)
const fields = computed(() => {
return (meta.value.columns ?? []).filter(
(col) =>
!isSystemColumn(col) &&
!isVirtualCol(col) &&
!col.pk &&
!col.unique &&
editColumns.value.find((c) => c.id === col.id) === undefined,
)
})
const paginatedData = inject(PaginationDataInj)!
const editCount = computed(() => {
if (updateMode.value === BulkUpdateMode.SELECTED) {
return props.rows!.length
} else {
return paginatedData.value?.totalRows ?? Infinity
}
})
function isRequired(_columnObj: Record<string, any>, required = false) {
let columnObj = _columnObj
if (
columnObj.uidt === UITypes.LinkToAnotherRecord &&
columnObj.colOptions &&
columnObj.colOptions.type === RelationTypes.BELONGS_TO
) {
columnObj = (meta?.value?.columns || []).find(
(c: Record<string, any>) => c.id === columnObj.colOptions.fk_child_column_id,
) as Record<string, any>
}
return required || (columnObj && columnObj.rqd && !columnObj.cdf)
}
function onMove(event: any) {
const { element } = event.added || event.moved || event.removed
if (event.added) {
if (editColumns.value.find((c) => c.id === element.id)) {
return
}
editColumns.value.push(element)
formState[element.title] = null
}
if (event.removed) {
delete formState[element.title]
}
}
function handleMouseUp(col: Record<string, any>) {
if (!moved.value) {
if (editColumns.value.find((c) => c.id === col.id)) {
return
}
editColumns.value.push(col)
formState[col.title] = null
}
}
function handleRemove(col: Record<string, any>) {
const index = editColumns.value.findIndex((c) => c.id === col.id)
if (index > -1) {
editColumns.value.splice(index, 1)
delete formState[col.title]
}
}
const save = () => {
Modal.confirm({
title:
updateMode.value === BulkUpdateMode.SELECTED
? `Do you want to update selected ${editCount.value} records?`
: h('div', {}, [
`Do you want to update all ${editCount.value} records in current view?`,
h('br'),
h('div', { class: 'text-gray-500 text-xs mt-2' }, `Note: Undo on bulk update ALL is not supported`),
]),
type: 'warn',
onOk: async () => {
if (updateMode.value === BulkUpdateMode.SELECTED) {
if (props.rows && props.bulkUpdateRows) {
const propsToUpdate = Object.keys(formState)
for (const row of props.rows) {
for (const prop of Object.keys(row.row)) {
if (propsToUpdate.includes(prop)) {
row.row[prop] = formState[prop]
row.rowMeta.selected = false
}
}
}
await props.bulkUpdateRows(props.rows, propsToUpdate)
}
} else {
if (props.bulkUpdateView) {
await props.bulkUpdateView(formState)
}
}
isExpanded.value = false
},
})
}
const addAllColumns = () => {
for (const col of fields.value) {
if (editColumns.value.find((c) => c.id === col.id)) {
continue
}
if (!col || !col.title) continue
editColumns.value.push(col)
formState[col.title] = null
}
}
const removeAllColumns = () => {
for (const col of editColumns.value) {
delete formState[col.title]
}
editColumns.value = []
}
onMounted(() => {
if (!props.selectedAllRecords && !props.rows) {
isExpanded.value = false
return
}
if (props.selectedAllRecords && props.selectedAllRecords === true) {
updateMode.value = BulkUpdateMode.ALL
} else {
if (props.rows && props.rows.length) {
updateMode.value = BulkUpdateMode.SELECTED
}
}
})
</script>
<template>
<a-drawer
v-model:visible="isExpanded"
:footer="null"
width="min(90vw,900px)"
:body-style="{ 'padding': 0, 'display': 'flex', 'flex-direction': 'column' }"
:closable="false"
class="nc-drawer-bulk-update"
:class="{ active: isExpanded }"
>
<div class="flex p-2 items-center gap-2 p-4 nc-bulk-update-header">
<h5 class="text-lg font-weight-medium flex items-center gap-1 mb-0 min-w-0 overflow-x-hidden truncate">
<GeneralTableIcon :style="{ color: iconColor }" :meta="meta" class="mx-2" />
<template v-if="meta">
{{ meta.title }}
</template>
<!-- TODO i18n -->
<div>: Bulk Update ({{ editCount }} records)</div>
</h5>
<div class="flex-1" />
<a-button
v-if="updateMode === BulkUpdateMode.ALL"
class="nc-bulk-update-save-btn"
type="primary"
:disabled="!editColumns.length"
@click="save"
>
<div class="flex items-center">
<component :is="iconMap.contentSaveExit" class="mr-1" />
<!-- TODO i18n -->
Bulk Update All
</div>
</a-button>
<a-button
v-else-if="updateMode === BulkUpdateMode.SELECTED"
class="nc-bulk-update-save-btn"
type="primary"
:disabled="!editColumns.length"
@click="save"
>
<div class="flex items-center">
<component :is="iconMap.contentSaveStay" class="mr-1" />
<!-- TODO i18n -->
Bulk Update Selected
</div>
</a-button>
<a-dropdown>
<component :is="iconMap.threeDotVertical" class="nc-icon-transition" />
<template #overlay>
<a-menu>
<a-menu-item @click="isExpanded = false">
<div v-e="['c:row-expand:delete']" class="py-2 flex gap-2 items-center">
<component
:is="iconMap.closeCircle"
class="nc-icon-transition cursor-pointer select-none nc-delete-row text-gray-500 mx-1 min-w-4"
/>
{{ $t('general.close') }}
</div>
</a-menu-item>
</a-menu>
</template>
</a-dropdown>
</div>
<div class="flex w-full !bg-gray-100 flex-1">
<div class="form w-2/3 p-4">
<Draggable
ref="draggableRef"
:list="editColumns"
item-key="fk_column_id"
draggable=".item"
group="form-inputs"
class="h-full"
:move="onMoveCallback"
@change="onMove($event)"
@start="drag = true"
@end="drag = false"
>
<template #item="{ element }">
<div
class="color-transition nc-editable item cursor-pointer hover:(bg-primary bg-opacity-10 ring-1 ring-accent ring-opacity-100) px-4 lg:px-12 py-4 relative"
:class="[`nc-bulk-update-drag-${element.title.replaceAll(' ', '')}`]"
data-testid="nc-bulk-update-fields"
>
<div class="text-gray group absolute top-4 right-12">
<component
:is="iconMap.eyeSlash"
class="opacity-0 nc-field-remove-icon group-hover:text-red-500 cursor-pointer !text-xl"
data-testid="nc-bulk-update-fields-remove-icon"
@click="handleRemove(element)"
/>
</div>
<div>
<LazySmartsheetHeaderVirtualCell
v-if="isVirtualCol(element)"
:column="{ ...element, title: element.label || element.title }"
:required="isRequired(element, element.required)"
:hide-menu="true"
data-testid="nc-bulk-update-input-label"
/>
<LazySmartsheetHeaderCell
v-else
:column="{ ...element, title: element.label || element.title }"
:required="isRequired(element, element.required)"
:hide-menu="true"
data-testid="nc-bulk-update-input-label"
/>
</div>
<a-form-item
v-if="isVirtualCol(element)"
:name="element.title"
class="!mb-0 nc-input-required-error"
:rules="[
{
required: isRequired(element, element.required),
message: `${element.label || element.title} is required`,
},
]"
>
<LazySmartsheetVirtualCell
v-model="formState[element.title]"
class="nc-input"
:class="`nc-bulk-update-input-${element.title.replaceAll(' ', '')}`"
:data-testid="`nc-bulk-update-input-${element.title.replaceAll(' ', '')}`"
:column="element"
/>
</a-form-item>
<a-form-item
v-else
:name="element.title"
class="!mb-0 nc-input-required-error"
:rules="[
{
required: isRequired(element, element.required),
message: `${element.label || element.title} is required`,
},
]"
>
<LazySmartsheetDivDataCell class="!bg-white rounded px-1 min-h-[35px] flex items-center mt-2 relative">
<LazySmartsheetCell
v-model="formState[element.title]"
:data-testid="`nc-bulk-update-input-${element.title.replaceAll(' ', '')}`"
:column="element"
:edit-enabled="true"
:active="true"
/>
</LazySmartsheetDivDataCell>
</a-form-item>
<div class="nc-bulk-update-help-text text-gray-500 text-xs" data-testid="nc-bulk-update-input-help-text-label">
{{ element.description }}
</div>
</div>
</template>
<template #footer>
<div v-if="!editColumns.length" class="mt-4 border-dashed border-2 border-gray-400 py-3 text-gray-400 text-center">
<!-- TODO i18n -->
Drag and drop fields here to edit
</div>
</template>
</Draggable>
</div>
<div class="nc-columns-drawer w-1/3 p-3 flex flex-col bg-[#eceff1]" :class="{ active: columnsDrawer }">
<div class="text-bold uppercase text-gray-500 font-weight-bold !mb-2">
<!-- TODO i18n -->
Select columns to Edit
</div>
<div class="flex flex-wrap gap-2 mb-4">
<button
v-if="fields.length > editColumns.length"
type="button"
class="nc-bulk-update-add-all color-transition bg-white transform hover:(text-primary ring-1 ring-primary ring-opacity-100) active:translate-y-[1px] px-2 py-1 shadow-md rounded"
data-testid="nc-bulk-update-add-all"
tabindex="-1"
@click="addAllColumns"
>
<!-- Add all -->
{{ $t('general.addAll') }}
</button>
<button
v-if="editColumns.length"
type="button"
class="nc-bulk-update-remove-all color-transition bg-white transform hover:(text-primary ring-1 ring-primary ring-opacity-100) active:translate-y-[1px] px-2 py-1 shadow-md rounded"
data-testid="nc-bulk-update-remove-all"
tabindex="-1"
@click="removeAllColumns"
>
<!-- Remove all -->
{{ $t('general.removeAll') }}
</button>
</div>
<Draggable
:list="fields"
item-key="id"
draggable=".item"
group="form-inputs"
class="flex flex-col gap-2 flex-1"
@start="drag = true"
@end="drag = false"
>
<template #item="{ element }">
<a-card
size="small"
class="!border-0 color-transition cursor-pointer item hover:(bg-primary ring-1 ring-accent ring-opacity-100) bg-opacity-10 !rounded !shadow-lg"
:data-testid="`nc-bulk-update-hidden-column-${element.label || element.title}`"
@mousedown="moved = false"
@mousemove="moved = false"
@mouseup="handleMouseUp(element)"
>
<div class="flex">
<div class="flex flex-1">
<LazySmartsheetHeaderVirtualCell
v-if="isVirtualCol(element)"
:column="{ ...element, title: element.label || element.title }"
:required="isRequired(element, element.required)"
:hide-menu="true"
/>
<LazySmartsheetHeaderCell
v-else
:column="{ ...element, title: element.label || element.title }"
:required="isRequired(element, element.required)"
:hide-menu="true"
/>
</div>
</div>
</a-card>
</template>
</Draggable>
</div>
</div>
</a-drawer>
</template>
<style scoped lang="scss">
:deep(input, select, textarea) {
@apply !bg-white;
}
.nc-bulk-update-wrapper {
max-height: max(calc(100vh - 65px), 600px);
height: max-content !important;
}
.nc-editable:hover {
:deep(.nc-field-remove-icon) {
@apply opacity-100;
}
}
.nc-input {
@apply appearance-none w-full !bg-white rounded px-2 py-2 my-2 border-solid border-1 border-primary border-opacity-50;
:deep(input) {
@apply !px-1;
}
}
.form-meta-input::placeholder {
@apply text-[#3d3d3d] italic;
}
.nc-bulk-update-input-label,
.nc-bulk-update-input-help-text {
&::placeholder {
@apply !text-gray-500 !text-xs;
}
}
.nc-bulk-update-help-text,
.nc-input-required-error {
max-width: 100%;
word-break: break-all;
white-space: pre-line;
}
:deep(.nc-cell-attachment) {
@apply p-0;
.nc-attachment-cell {
@apply px-4 min-h-[75px] w-full h-full;
.nc-attachment {
@apply md: (w-[50px] h-[50px]) lg:(w-[75px] h-[75px]) min-h-[50px] min-w-[50px];
}
.nc-attachment-cell-dropzone {
@apply rounded bg-gray-400/75;
}
}
}
</style>

44
packages/nc-gui/components/smartsheet/Grid.vue

@ -82,6 +82,8 @@ const isView = false
let editEnabled = $ref(false)
const { appInfo } = useGlobal()
const { xWhere, isPkAvail, isSqlView, eventBus } = useSmartsheetStoreOrThrow()
const visibleColLength = $computed(() => fields.value?.length)
@ -99,6 +101,8 @@ const contextMenu = computed({
})
const contextMenuClosing = ref(false)
const bulkUpdateDlg = ref(false)
const routeQuery = $computed(() => route.query as Record<string, string>)
const contextMenuTarget = ref<{ row: number; col: number } | null>(null)
const expandedFormDlg = ref(false)
@ -128,6 +132,7 @@ const {
getExpandedRowIndex,
deleteRangeOfRows,
bulkUpdateRows,
bulkUpdateView,
} = useViewData(meta, view, xWhere)
const { getMeta } = useMetas()
@ -977,7 +982,12 @@ function addEmptyRow(row?: number) {
:style="{ height: rowHeight ? `${rowHeight * 1.8}rem` : `1.8rem` }"
:data-testid="`grid-row-${rowIndex}`"
>
<td key="row-index" class="caption nc-grid-cell pl-5 pr-1" :data-testid="`cell-Id-${rowIndex}`">
<td
key="row-index"
class="caption nc-grid-cell pl-5 pr-1"
:data-testid="`cell-Id-${rowIndex}`"
@contextmenu="contextMenuTarget = null"
>
<div class="items-center flex gap-1 min-w-[60px]">
<div
v-if="!readOnly || !isLocked"
@ -1120,8 +1130,23 @@ function addEmptyRow(row?: number) {
</div>
</a-menu-item>
<a-menu-item v-if="!contextMenuClosing && data.some((r) => r.rowMeta.selected)" @click="deleteSelectedRows">
<div v-e="['a:row:delete-bulk']" class="nc-project-menu-item">
<a-menu-item
v-if="appInfo.ee && !contextMenuClosing && !contextMenuTarget && data.some((r) => r.rowMeta.selected)"
@click="bulkUpdateDlg = true"
>
<div v-e="['a:row:update-bulk']" class="nc-project-menu-item">
<component :is="iconMap.edit" />
<!-- TODO i18n -->
Update Selected Rows
</div>
</a-menu-item>
<a-menu-item
v-if="!contextMenuClosing && !contextMenuTarget && data.some((r) => r.rowMeta.selected)"
@click="deleteSelectedRows"
>
<div v-e="['a:row:delete-bulk']" class="nc-project-menu-item text-red-500">
<component :is="iconMap.delete" />
<!-- Delete Selected Rows -->
{{ $t('activity.deleteSelectedRow') }}
</div>
@ -1207,6 +1232,19 @@ function addEmptyRow(row?: number) {
@prev="navigateToSiblingRow(NavigateDir.PREV)"
/>
</Suspense>
<Suspense>
<LazyDlgBulkUpdate
v-if="bulkUpdateDlg"
v-model="bulkUpdateDlg"
:meta="meta"
:view="view"
:bulk-update-rows="bulkUpdateRows"
:bulk-update-view="bulkUpdateView"
:selected-all-records="selectedAllRecords"
:rows="data.filter((r) => r.rowMeta.selected)"
/>
</Suspense>
</div>
</template>

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

@ -492,6 +492,8 @@ export function useViewData(
updateArray.push({ ...updateData, ...pk })
}
await $api.dbTableRow.bulkUpdate(NOCO, metaValue?.project_id as string, metaValue?.id as string, updateArray)
if (!undo) {
addUndo({
redo: {
@ -548,8 +550,6 @@ export function useViewData(
})
}
await $api.dbTableRow.bulkUpdate(NOCO, metaValue?.project_id as string, metaValue?.id as string, updateArray)
for (const row of rows) {
if (!undo) {
/** update row data(to sync formula and other related columns)
@ -577,6 +577,19 @@ export function useViewData(
}
}
async function bulkUpdateView(
data: Record<string, any>[],
{ metaValue = meta.value, viewMetaValue = viewMeta.value }: { metaValue?: TableType; viewMetaValue?: ViewType } = {},
) {
if (!viewMetaValue) return
await $api.dbTableRow.bulkUpdateAll(NOCO, metaValue?.project_id as string, metaValue?.id as string, data, {
viewId: viewMetaValue.id,
})
await loadData()
}
async function changePage(page: number) {
paginationData.value.page = page
await loadData({
@ -995,6 +1008,7 @@ export function useViewData(
deleteRangeOfRows,
updateOrSaveRow,
bulkUpdateRows,
bulkUpdateView,
selectedAllRecords,
syncCount,
syncPagination,

2
packages/nc-gui/package-lock.json generated

@ -110,7 +110,7 @@
}
},
"../nocodb-sdk": {
"version": "0.109.2",
"version": "0.109.3",
"license": "AGPL-3.0-or-later",
"dependencies": {
"axios": "^0.21.1",

2
packages/nc-lib-gui/package.json

@ -1,6 +1,6 @@
{
"name": "nc-lib-gui",
"version": "0.109.2",
"version": "0.109.3",
"description": "NocoDB GUI",
"author": {
"name": "NocoDB",

4
packages/nocodb-sdk/package-lock.json generated

@ -1,12 +1,12 @@
{
"name": "nocodb-sdk",
"version": "0.109.2",
"version": "0.109.3",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "nocodb-sdk",
"version": "0.109.2",
"version": "0.109.3",
"license": "AGPL-3.0-or-later",
"dependencies": {
"axios": "^0.21.1",

2
packages/nocodb-sdk/package.json

@ -1,6 +1,6 @@
{
"name": "nocodb-sdk",
"version": "0.109.2",
"version": "0.109.3",
"description": "NocoDB SDK",
"main": "build/main/index.js",
"typings": "build/main/index.d.ts",

2
packages/nocodb-sdk/src/lib/Api.ts

@ -7251,6 +7251,7 @@ export class Api<
data: object,
query?: {
where?: string;
viewId?: string;
},
params: RequestParams = {}
) =>
@ -7291,6 +7292,7 @@ export class Api<
data: object,
query?: {
where?: string;
viewId?: string;
},
params: RequestParams = {}
) =>

319
packages/nocodb/README.md

@ -1,73 +1,306 @@
<h1 align="center" style="border-bottom: none">
<div>
<a href="https://www.nocodb.com">
<img src="/packages/nc-gui/assets/img/icons/512x512.png" width="80" />
<br>
NocoDB
</a>
</div>
The Open Source Airtable Alternative <br>
</h1>
<p align="center">
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="200" alt="Nest Logo" /></a>
Turns any MySQL, PostgreSQL, SQL Server, SQLite & MariaDB into a smart spreadsheet.
</p>
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
[circleci-url]: https://circleci.com/gh/nestjs/nest
<div align="center">
[![Node version](https://img.shields.io/badge/node-%3E%3D%2016.14.0-brightgreen)](http://nodejs.org/download/)
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-green.svg)](https://conventionalcommits.org)
</div>
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
<p align="center">
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
<a href="http://www.nocodb.com"><b>Website</b></a>
<a href="https://discord.gg/5RgZmkW"><b>Discord</b></a>
<a href="https://community.nocodb.com/"><b>Community</b></a>
<a href="https://twitter.com/nocodb"><b>Twitter</b></a>
<a href="https://www.reddit.com/r/NocoDB/"><b>Reddit</b></a>
<a href="https://docs.nocodb.com/"><b>Documentation</b></a>
</p>
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->
## Description
![All Views](https://user-images.githubusercontent.com/35857179/194825053-3aa3373d-3e0f-4b42-b3f1-42928332054a.gif)
<div align="center">
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263434-75fe793d-42af-49e4-b964-d70920e41655.png">](markdown/readme/languages/chinese.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263474-787d71e7-3a87-42a8-92a8-be1d1f55413d.png">](markdown/readme/languages/french.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263531-fae58600-6616-4b43-95a0-5891019dd35d.png">](markdown/readme/languages/german.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263589-3dbeda9a-0d2e-4bbd-b1fc-691404bb74fb.png">](markdown/readme/languages/spanish.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263669-f567196a-d4e8-4143-a80a-93d3be32ba90.png">](markdown/readme/languages/portuguese.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263707-ba4e04a4-268a-4626-91b8-048e572fd9f6.png">](markdown/readme/languages/italian.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263770-38e3e79d-11d4-472e-ac27-ae0f17cf65c4.png">](markdown/readme/languages/japanese.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263822-28fce9de-915a-44dc-962d-7a61d340e91d.png">](markdown/readme/languages/korean.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263888-151d4ad1-7084-4943-97c9-56f28cd40b80.png">](markdown/readme/languages/russian.md)
</div>
<p align="center"><a href="markdown/readme/languages/README.md"><b>See other languages »</b></a></p>
<img src="https://static.scarf.sh/a.png?x-pxid=c12a77cc-855e-4602-8a0f-614b2d0da56a" />
# Join Our Team
<p align=""><a href="http://careers.nocodb.com" target="_blank"><img src="https://user-images.githubusercontent.com/61551451/169663818-45643495-e95b-48e2-be13-01d6a77dc2fd.png" width="250"/></a></p>
# Join Our Community
<a href="https://discord.gg/5RgZmkW" target="_blank">
<img src="https://discordapp.com/api/guilds/661905455894888490/widget.png?style=banner3" alt="">
</a>
<!-- <a href="https://community.nocodb.com/" target="_blank">
<img src="https://i2.wp.com/www.feverbee.com/wp-content/uploads/2018/07/logo-discourse.png" alt="">
</a>
-->
[![Stargazers repo roster for @nocodb/nocodb](https://reporoster.com/stars/nocodb/nocodb)](https://github.com/nocodb/nocodb/stargazers)
# Quick try
## NPX
You can run the below command if you need an interactive configuration.
```
npx create-nocodb-app
```
<img src="https://user-images.githubusercontent.com/35857179/163672964-00ef5d62-0434-447d-ac01-3ebb780099b9.png" width="520px"/>
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
## Node Application
## Installation
We provide a simple NodeJS Application for getting started.
```bash
$ npm install
git clone https://github.com/nocodb/nocodb-seed
cd nocodb-seed
npm install
npm start
```
## Running the app
## Docker
```bash
# development
$ npm run start
# for SQLite
docker run -d --name nocodb \
-v "$(pwd)"/nocodb:/usr/app/data/ \
-p 8080:8080 \
nocodb/nocodb:latest
# watch mode
$ npm run start:dev
# for MySQL
docker run -d --name nocodb-mysql \
-v "$(pwd)"/nocodb:/usr/app/data/ \
-p 8080:8080 \
-e NC_DB="mysql2://host.docker.internal:3306?u=root&p=password&d=d1" \
-e NC_AUTH_JWT_SECRET="569a1821-0a93-45e8-87ab-eb857f20a010" \
nocodb/nocodb:latest
# production mode
$ npm run start:prod
# for PostgreSQL
docker run -d --name nocodb-postgres \
-v "$(pwd)"/nocodb:/usr/app/data/ \
-p 8080:8080 \
-e NC_DB="pg://host.docker.internal:5432?u=root&p=password&d=d1" \
-e NC_AUTH_JWT_SECRET="569a1821-0a93-45e8-87ab-eb857f20a010" \
nocodb/nocodb:latest
# for MSSQL
docker run -d --name nocodb-mssql \
-v "$(pwd)"/nocodb:/usr/app/data/ \
-p 8080:8080 \
-e NC_DB="mssql://host.docker.internal:1433?u=root&p=password&d=d1" \
-e NC_AUTH_JWT_SECRET="569a1821-0a93-45e8-87ab-eb857f20a010" \
nocodb/nocodb:latest
```
> To persist data in docker you can mount volume at `/usr/app/data/` since 0.10.6. Otherwise your data will be lost after recreating the container.
> If you plan to input some special characters, you may need to change the character set and collation yourself when creating the database. Please check out the examples for [MySQL Docker](https://github.com/nocodb/nocodb/issues/1340#issuecomment-1049481043).
## Binaries
##### MacOS (x64)
```bash
curl http://get.nocodb.com/macos-x64 -o nocodb -L && chmod +x nocodb && ./nocodb
```
##### MacOS (arm64)
```bash
curl http://get.nocodb.com/macos-arm64 -o nocodb -L && chmod +x nocodb && ./nocodb
```
##### Linux (x64)
```bash
curl http://get.nocodb.com/linux-x64 -o nocodb -L && chmod +x nocodb && ./nocodb
```
## Test
##### Linux (arm64)
```bash
# unit tests
$ npm run test
curl http://get.nocodb.com/linux-arm64 -o nocodb -L && chmod +x nocodb && ./nocodb
```
# e2e tests
$ npm run test:e2e
##### Windows (x64)
# test coverage
$ npm run test:cov
```bash
iwr http://get.nocodb.com/win-x64.exe
.\Noco-win-x64.exe
```
## Support
##### Windows (arm64)
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
```bash
iwr http://get.nocodb.com/win-arm64.exe
.\Noco-win-arm64.exe
```
## Stay in touch
## Docker Compose
We provide different docker-compose.yml files under [this directory](https://github.com/nocodb/nocodb/tree/master/docker-compose). Here are some examples.
```bash
git clone https://github.com/nocodb/nocodb
# for MySQL
cd nocodb/docker-compose/mysql
# for PostgreSQL
cd nocodb/docker-compose/pg
# for MSSQL
cd nocodb/docker-compose/mssql
docker-compose up -d
```
> To persist data in docker, you can mount volume at `/usr/app/data/` since 0.10.6. Otherwise your data will be lost after recreating the container.
> If you plan to input some special characters, you may need to change the character set and collation yourself when creating the database. Please check out the examples for [MySQL Docker Compose](https://github.com/nocodb/nocodb/issues/1313#issuecomment-1046625974).
# GUI
Access Dashboard using: [http://localhost:8080/dashboard](http://localhost:8080/dashboard)
# Screenshots
![1](https://user-images.githubusercontent.com/35857179/194844858-d353bd15-1edf-406c-889b-ba60f76831f4.png)
![2](https://user-images.githubusercontent.com/35857179/194844872-1a1094b9-761b-4ab6-a0ab-8e11dcae6571.png)
![3](https://user-images.githubusercontent.com/35857179/194844881-23f12c4c-7a5f-403e-928c-ef4c53b2665d.png)
![4](https://user-images.githubusercontent.com/35857179/194844885-faaf042f-bad2-4924-84f0-2c08813271d8.png)
![5](https://user-images.githubusercontent.com/35857179/194844886-a17006e0-979d-493f-83c4-0e72f5a9b716.png)
![6](https://user-images.githubusercontent.com/35857179/194844890-b9f265ae-6e40-4fa5-9267-d1367c27c8e6.png)
![7](https://user-images.githubusercontent.com/35857179/194844891-bee9aea3-aff3-4247-a918-b2f3fbbc672e.png)
![8](https://user-images.githubusercontent.com/35857179/194844893-82d5e21b-ae61-41bd-9990-31ad659bf490.png)
![9](https://user-images.githubusercontent.com/35857179/194844897-cfd79946-e413-4c97-b16d-eb4d7678bb79.png)
![10](https://user-images.githubusercontent.com/35857179/194844902-c0122570-0dd5-41cf-a26f-6f8d71fefc99.png)
![11](https://user-images.githubusercontent.com/35857179/194844903-c1e47f40-e782-4f5d-8dce-6449cc70b181.png)
![12](https://user-images.githubusercontent.com/35857179/194844907-09277d3e-cbbf-465c-9165-6afc4161e279.png)
# Table of Contents
- [Quick try](#quick-try)
- [NPX](#npx)
- [Node Application](#node-application)
- [Docker](#docker)
- [Docker Compose](#docker-compose)
- [GUI](#gui)
- [Join Our Community](#join-our-community)
- [Screenshots](#screenshots)
- [Table of Contents](#table-of-contents)
- [Features](#features)
- [Rich Spreadsheet Interface](#rich-spreadsheet-interface)
- [App Store for Workflow Automations](#app-store-for-workflow-automations)
- [Programmatic Access](#programmatic-access)
- [Sync Schema](#sync-schema)
- [Audit](#audit)
- [Production Setup](#production-setup)
- [Environment variables](#environment-variables)
- [Development Setup](#development-setup)
- [Contributing](#contributing)
- [Why are we building this?](#why-are-we-building-this)
- [Our Mission](#our-mission)
- [License](#license)
- [Contributors](#contributors)
# Features
### Rich Spreadsheet Interface
- ⚡ &nbsp;Basic Operations: Create, Read, Update and Delete Tables, Columns, and Rows
- ⚡ &nbsp;Fields Operations: Sort, Filter, Hide / Unhide Columns
- ⚡ &nbsp;Multiple Views Types: Grid (By default), Gallery, Form View and Kanban View
- ⚡ &nbsp;View Permissions Types: Collaborative Views, & Locked Views
- ⚡ &nbsp;Share Bases / Views: either Public or Private (with Password Protected)
- ⚡ &nbsp;Variant Cell Types: ID, LinkToAnotherRecord, Lookup, Rollup, SingleLineText, Attachment, Currency, Formula, etc
- ⚡ &nbsp;Access Control with Roles: Fine-grained Access Control at different levels
- ⚡ &nbsp;and more ...
### App Store for Workflow Automations
We provide different integrations in three main categories. See <a href="https://docs.nocodb.com/setup-and-usages/account-settings#app-store" target="_blank">App Store</a> for details.
- ⚡ &nbsp;Chat: Slack, Discord, Mattermost, and etc
- ⚡ &nbsp;Email: AWS SES, SMTP, MailerSend, and etc
- ⚡ &nbsp;Storage: AWS S3, Google Cloud Storage, Minio, and etc
### Programmatic Access
We provide the following ways to let users programmatically invoke actions. You can use a token (either JWT or Social Auth) to sign your requests for authorization to NocoDB.
- ⚡ &nbsp;REST APIs
- ⚡ &nbsp;NocoDB SDK
### Sync Schema
We allow you to sync schema changes if you have made changes outside NocoDB GUI. However, it has to be noted then you will have to bring your own schema migrations for moving from one environment to another. See <a href="https://docs.nocodb.com/setup-and-usages/sync-schema/" target="_blank">Sync Schema</a> for details.
### Audit
We are keeping all the user operation logs in one place. See <a href="https://docs.nocodb.com/setup-and-usages/audit" target="_blank">Audit</a> for details.
# Production Setup
By default, SQLite is used for storing metadata. However, you can specify your database. The connection parameters for this database can be specified in `NC_DB` environment variable. Moreover, we also provide the below environment variables for configuration.
## Environment variables
Please refer to the [Environment variables](https://docs.nocodb.com/getting-started/environment-variables)
# Development Setup
Please refer to [Development Setup](https://docs.nocodb.com/engineering/development-setup)
# Contributing
Please refer to [Contribution Guide](https://github.com/nocodb/nocodb/blob/master/.github/CONTRIBUTING.md).
# Why are we building this?
Most internet businesses equip themselves with either spreadsheet or a database to solve their business needs. Spreadsheets are used by Billion+ humans collaboratively every single day. However, we are way off working at similar speeds on databases which are way more powerful tools when it comes to computing. Attempts to solve this with SaaS offerings have meant horrible access controls, vendor lock-in, data lock-in, abrupt price changes & most importantly a glass ceiling on what's possible in the future.
# Our Mission
Our mission is to provide the most powerful no-code interface for databases that is open source to every single internet business in the world. This would not only democratise access to a powerful computing tool but also bring forth a billion+ people who will have radical tinkering-and-building abilities on the internet.
# License
<p>
This project is licensed under <a href="./LICENSE">AGPLv3</a>.
</p>
- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
- Website - [https://nestjs.com](https://nestjs.com/)
- Twitter - [@nestframework](https://twitter.com/nestframework)
# Contributors
## License
Thank you for your contributions! We appreciate all the contributions from the community.
Nest is [MIT licensed](LICENSE).
<a href="https://github.com/nocodb/nocodb/graphs/contributors">
<img src="https://contrib.rocks/image?repo=nocodb/nocodb" />
</a>

71
packages/nocodb/package-lock.json generated

@ -1,12 +1,12 @@
{
"name": "nocodb",
"version": "0.109.2",
"version": "0.109.3",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "nocodb",
"version": "0.109.2",
"version": "0.109.3",
"license": "AGPL-3.0-or-later",
"dependencies": {
"@google-cloud/storage": "^5.7.2",
@ -80,12 +80,13 @@
"mysql2": "^3.2.0",
"nanoid": "^3.1.20",
"nc-help": "^0.2.87",
"nc-lib-gui": "0.109.2",
"nc-lib-gui": "0.109.3",
"nc-plugin": "^0.1.3",
"ncp": "^2.0.0",
"nocodb-sdk": "file:../nocodb-sdk",
"nodemailer": "^6.4.10",
"object-hash": "^3.0.0",
"object-sizeof": "^2.6.1",
"os-locale": "^6.0.2",
"p-queue": "^6.6.2",
"papaparse": "^5.3.1",
@ -190,7 +191,7 @@
}
},
"../nocodb-sdk": {
"version": "0.109.2",
"version": "0.109.3",
"license": "AGPL-3.0-or-later",
"dependencies": {
"axios": "^0.21.1",
@ -13157,9 +13158,9 @@
}
},
"node_modules/nc-lib-gui": {
"version": "0.109.2",
"resolved": "https://registry.npmjs.org/nc-lib-gui/-/nc-lib-gui-0.109.2.tgz",
"integrity": "sha512-eZ1ANukU8LCjXlrhQdRixjeh/JPgvLt6MJwrQ/rHdgMC5Ip/O5c8WRd/HkzQSnapHbmSrv5c/Ng74p5DPjL6rA==",
"version": "0.109.3",
"resolved": "https://registry.npmjs.org/nc-lib-gui/-/nc-lib-gui-0.109.3.tgz",
"integrity": "sha512-8a1M+yBBRXWX3qz1HfY8YyGq1fg+aviwEv6IhGouZy4PnkBmbwbjXFNLxVidQoDor92AYACZHRltE3dxeIb1Sw==",
"dependencies": {
"express": "^4.17.1"
}
@ -13568,6 +13569,37 @@
"resolved": "https://registry.npmjs.org/object-keys/-/object-keys-0.4.0.tgz",
"integrity": "sha512-ncrLw+X55z7bkl5PnUvHwFK9FcGuFYo9gtjws2XtSzL+aZ8tm830P60WJ0dSmFVaSalWieW5MD7kEdnXda9yJw=="
},
"node_modules/object-sizeof": {
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/object-sizeof/-/object-sizeof-2.6.1.tgz",
"integrity": "sha512-a7VJ1Zx7ZuHceKwjgfsSqzV/X0PVGvpZz7ho3Dn4Cs0LLcR5e5WuV+gsbizmplD8s0nAXMJmckKB2rkSiPm/Gg==",
"dependencies": {
"buffer": "^6.0.3"
}
},
"node_modules/object-sizeof/node_modules/buffer": {
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz",
"integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"dependencies": {
"base64-js": "^1.3.1",
"ieee754": "^1.2.1"
}
},
"node_modules/object.assign": {
"version": "4.1.4",
"resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.4.tgz",
@ -28442,9 +28474,9 @@
}
},
"nc-lib-gui": {
"version": "0.109.2",
"resolved": "https://registry.npmjs.org/nc-lib-gui/-/nc-lib-gui-0.109.2.tgz",
"integrity": "sha512-eZ1ANukU8LCjXlrhQdRixjeh/JPgvLt6MJwrQ/rHdgMC5Ip/O5c8WRd/HkzQSnapHbmSrv5c/Ng74p5DPjL6rA==",
"version": "0.109.3",
"resolved": "https://registry.npmjs.org/nc-lib-gui/-/nc-lib-gui-0.109.3.tgz",
"integrity": "sha512-8a1M+yBBRXWX3qz1HfY8YyGq1fg+aviwEv6IhGouZy4PnkBmbwbjXFNLxVidQoDor92AYACZHRltE3dxeIb1Sw==",
"requires": {
"express": "^4.17.1"
}
@ -28765,6 +28797,25 @@
"resolved": "https://registry.npmjs.org/object-keys/-/object-keys-0.4.0.tgz",
"integrity": "sha512-ncrLw+X55z7bkl5PnUvHwFK9FcGuFYo9gtjws2XtSzL+aZ8tm830P60WJ0dSmFVaSalWieW5MD7kEdnXda9yJw=="
},
"object-sizeof": {
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/object-sizeof/-/object-sizeof-2.6.1.tgz",
"integrity": "sha512-a7VJ1Zx7ZuHceKwjgfsSqzV/X0PVGvpZz7ho3Dn4Cs0LLcR5e5WuV+gsbizmplD8s0nAXMJmckKB2rkSiPm/Gg==",
"requires": {
"buffer": "^6.0.3"
},
"dependencies": {
"buffer": {
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz",
"integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==",
"requires": {
"base64-js": "^1.3.1",
"ieee754": "^1.2.1"
}
}
}
},
"object.assign": {
"version": "4.1.4",
"resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.4.tgz",

7
packages/nocodb/package.json

@ -1,6 +1,6 @@
{
"name": "nocodb",
"version": "0.109.2",
"version": "0.109.3",
"description": "NocoDB Backend",
"main": "dist/bundle.js",
"author": {
@ -34,6 +34,8 @@
"watch:run": "cross-env NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/run/docker --log-error --project tsconfig.json\"",
"watch:run:mysql": "cross-env NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/run/dockerRunMysql --log-error --project tsconfig.json\"",
"watch:run:pg": "cross-env NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/run/dockerRunPG --log-error --project tsconfig.json\"",
"watch:run:playwright:mysql": "rm -f ./test_noco.db; cross-env NC_DB=\"mysql2://localhost:3306?u=root&p=password&d=pw_ncdb\" PLAYWRIGHT_TEST=true NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/run/testDocker --log-error --project tsconfig.json\"",
"watch:run:playwright:pg": "rm -f ./test_noco.db; cross-env NC_DB=\"pg://localhost:5432?u=postgres&p=password&d=pw_ncdb\" PLAYWRIGHT_TEST=true NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/run/testDocker --log-error --project tsconfig.json\"",
"watch:run:playwright": "rm -f ./test_noco.db; cross-env DATABASE_URL=sqlite:./test_noco.db PLAYWRIGHT_TEST=true NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/run/testDocker --log-error --project tsconfig.json\"",
"watch:run:playwright:quick": "rm -f ./test_noco.db; cp ../../tests/playwright/fixtures/noco_0_91_7.db ./test_noco.db; cross-env DATABASE_URL=sqlite:./test_noco.db NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/run/docker --log-error --project tsconfig.json\"",
"watch:run:playwright:pg:cyquick": "rm -f ./test_noco.db; cp ../../tests/playwright/fixtures/noco_0_91_7.db ./test_noco.db; cross-env NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/run/dockerRunPG_CyQuick.ts --log-error --project tsconfig.json\"",
@ -113,12 +115,13 @@
"mysql2": "^3.2.0",
"nanoid": "^3.1.20",
"nc-help": "^0.2.87",
"nc-lib-gui": "0.109.2",
"nc-lib-gui": "0.109.3",
"nc-plugin": "^0.1.3",
"ncp": "^2.0.0",
"nocodb-sdk": "file:../nocodb-sdk",
"nodemailer": "^6.4.10",
"object-hash": "^3.0.0",
"object-sizeof": "^2.6.1",
"os-locale": "^6.0.2",
"p-queue": "^6.6.2",
"papaparse": "^5.3.1",

21
packages/nocodb/src/controllers/test/TestResetService/index.ts

@ -116,14 +116,19 @@ export class TestResetService {
if (project) {
await removeProjectUsersFromCache(project);
const bases = await project.getBases();
for (const base of bases) {
await NcConnectionMgrv2.deleteAwait(base);
await base.delete(Noco.ncMeta, { force: true });
}
await Project.delete(project.id);
// Kludge: Soft reset to support PG as root DB in PW tests
// Revisit to fix this later
// const bases = await project.getBases();
//
// for (const base of bases) {
// await NcConnectionMgrv2.deleteAwait(base);
// await base.delete(Noco.ncMeta, { force: true });
// }
//
// await Project.delete(project.id);
await Project.softDelete(project.id);
}
if (dbType == 'sqlite') {

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

@ -2261,38 +2261,152 @@ class BaseModelSqlv2 {
chunkSize: _chunkSize = 100,
cookie,
foreign_key_checks = true,
skip_hooks = false,
raw = false,
}: {
chunkSize?: number;
cookie?: any;
foreign_key_checks?: boolean;
skip_hooks?: boolean;
raw?: boolean;
} = {},
) {
let trx;
try {
// TODO: ag column handling for raw bulk insert
const insertDatas = raw
? datas
: await Promise.all(
datas.map(async (d) => {
await populatePk(this.model, d);
return this.model.mapAliasToColumn(
d,
this.clientMeta,
this.dbDriver,
);
}),
const insertDatas = raw ? datas : [];
if (!raw) {
await this.model.getColumns();
for (const d of datas) {
const insertObj = {};
// populate pk, map alias to column, validate data
for (let i = 0; i < this.model.columns.length; ++i) {
const col = this.model.columns[i];
// populate pk columns
if (col.pk) {
if (col.meta?.ag && !d[col.title]) {
d[col.title] =
col.meta?.ag === 'nc' ? `rc_${nanoidv2()}` : uuidv4();
}
}
// map alias to column
if (!isVirtualCol(col)) {
let val =
d?.[col.column_name] !== undefined
? d?.[col.column_name]
: d?.[col.title];
if (val !== undefined) {
if (
col.uidt === UITypes.Attachment &&
typeof val !== 'string'
) {
val = JSON.stringify(val);
}
if (col.uidt === UITypes.DateTime && dayjs(val).isValid()) {
const { isMySQL, isSqlite, isMssql, isPg } = this.clientMeta;
if (
val.indexOf('-') < 0 &&
val.indexOf('+') < 0 &&
val.slice(-1) !== 'Z'
) {
// if no timezone is given,
// then append +00:00 to make it as UTC
val += '+00:00';
}
if (isMySQL) {
// first convert the value to utc
// from UI
// e.g. 2022-01-01 20:00:00Z -> 2022-01-01 20:00:00
// from API
// e.g. 2022-01-01 20:00:00+08:00 -> 2022-01-01 12:00:00
// if timezone info is not found - considered as utc
// e.g. 2022-01-01 20:00:00 -> 2022-01-01 20:00:00
// if timezone info is found
// e.g. 2022-01-01 20:00:00Z -> 2022-01-01 20:00:00
// e.g. 2022-01-01 20:00:00+00:00 -> 2022-01-01 20:00:00
// e.g. 2022-01-01 20:00:00+08:00 -> 2022-01-01 12:00:00
// then we use CONVERT_TZ to convert that in the db timezone
val = this.dbDriver.raw(
`CONVERT_TZ(?, '+00:00', @@GLOBAL.time_zone)`,
[dayjs(val).utc().format('YYYY-MM-DD HH:mm:ss')],
);
} else if (isSqlite) {
// convert to UTC
// e.g. 2022-01-01T10:00:00.000Z -> 2022-01-01 04:30:00+00:00
val = dayjs(val).utc().format('YYYY-MM-DD HH:mm:ssZ');
} else if (isPg) {
// convert to UTC
// e.g. 2023-01-01T12:00:00.000Z -> 2023-01-01 12:00:00+00:00
// then convert to db timezone
val = this.dbDriver.raw(
`? AT TIME ZONE CURRENT_SETTING('timezone')`,
[dayjs(val).utc().format('YYYY-MM-DD HH:mm:ssZ')],
);
} else if (isMssql) {
// convert ot UTC
// e.g. 2023-05-10T08:49:32.000Z -> 2023-05-10 08:49:32-08:00
// then convert to db timezone
val = this.dbDriver.raw(
`SWITCHOFFSET(CONVERT(datetimeoffset, ?), DATENAME(TzOffset, SYSDATETIMEOFFSET()))`,
[dayjs(val).utc().format('YYYY-MM-DD HH:mm:ssZ')],
);
} else {
// e.g. 2023-01-01T12:00:00.000Z -> 2023-01-01 12:00:00+00:00
val = dayjs(val).utc().format('YYYY-MM-DD HH:mm:ssZ');
}
}
insertObj[sanitize(col.column_name)] = val;
}
}
// await this.beforeInsertb(insertDatas, null);
// validate data
if (col?.meta?.validate && col?.validate) {
const validate = col.getValidators();
const cn = col.column_name;
const columnTitle = col.title;
if (validate) {
const { func, msg } = validate;
for (let j = 0; j < func.length; ++j) {
const fn =
typeof func[j] === 'string'
? customValidators[func[j]]
? customValidators[func[j]]
: Validator[func[j]]
: func[j];
const columnValue =
insertObj?.[cn] || insertObj?.[columnTitle];
const arg =
typeof func[j] === 'string'
? columnValue + ''
: columnValue;
if (
![null, undefined, ''].includes(columnValue) &&
!(fn.constructor.name === 'AsyncFunction'
? await fn(arg)
: fn(arg))
) {
NcError.badRequest(
msg[j]
.replace(/\{VALUE}/g, columnValue)
.replace(/\{cn}/g, columnTitle),
);
}
}
}
}
}
if (!raw) {
for (const data of datas) {
await this.validate(data);
insertDatas.push(insertObj);
}
}
// await this.beforeInsertb(insertDatas, null);
// fallbacks to `10` if database client is sqlite
// to avoid `too many SQL variables` error
// refer : https://www.sqlite.org/limits.html
@ -2325,7 +2439,8 @@ class BaseModelSqlv2 {
await trx.commit();
if (!raw) await this.afterBulkInsert(insertDatas, this.dbDriver, cookie);
if (!raw && !skip_hooks)
await this.afterBulkInsert(insertDatas, this.dbDriver, cookie);
return response;
} catch (e) {
@ -2395,7 +2510,7 @@ class BaseModelSqlv2 {
}
async bulkUpdateAll(
args: { where?: string; filterArr?: Filter[] } = {},
args: { where?: string; filterArr?: Filter[]; viewId?: string } = {},
data,
{ cookie }: { cookie?: any } = {},
) {
@ -2417,8 +2532,7 @@ class BaseModelSqlv2 {
const aliasColObjMap = await this.model.getAliasColObjMap();
const filterObj = extractFilterFromXwhere(where, aliasColObjMap);
await conditionV2(
[
const conditionObj = [
new Filter({
children: args.filterArr || [],
is_group: true,
@ -2429,10 +2543,19 @@ class BaseModelSqlv2 {
is_group: true,
logical_op: 'and',
}),
],
qb,
this.dbDriver,
];
if (args.viewId) {
conditionObj.push(
new Filter({
children:
(await Filter.rootFilterList({ viewId: args.viewId })) || [],
is_group: true,
}),
);
}
await conditionV2(conditionObj, qb, this.dbDriver);
qb.update(updateData);

1
packages/nocodb/src/models/Column.ts

@ -766,6 +766,7 @@ export default class Column<T = any> implements ColumnType {
});
}
for (const filter of filters) {
if (filter.fk_parent_id) continue;
await Filter.delete(filter.id, ncMeta);
}
}

14
packages/nocodb/src/models/Model.ts

@ -14,6 +14,7 @@ import {
import { NcError } from '../helpers/catchError';
import { sanitize } from '../helpers/sqlSanitize';
import { extractProps } from '../helpers/extractProps';
import Hook from './Hook';
import Audit from './Audit';
import View from './View';
import Column from './Column';
@ -376,6 +377,11 @@ export default class Model implements TableType {
await view.delete(ncMeta);
}
// delete associated hooks
for (const hook of await Hook.list({ fk_model_id: this.id }, ncMeta)) {
await Hook.delete(hook.id, ncMeta);
}
for (const col of await this.getColumns(ncMeta)) {
let colOptionTableName = null;
let cacheScopeName = null;
@ -402,6 +408,14 @@ export default class Model implements TableType {
colOptionTableName = MetaTable.COL_FORMULA;
cacheScopeName = CacheScope.COL_FORMULA;
break;
case UITypes.QrCode:
colOptionTableName = MetaTable.COL_QRCODE;
cacheScopeName = CacheScope.COL_QRCODE;
break;
case UITypes.Barcode:
colOptionTableName = MetaTable.COL_BARCODE;
cacheScopeName = CacheScope.COL_BARCODE;
break;
}
if (colOptionTableName && cacheScopeName) {
await ncMeta.metaDelete(null, null, colOptionTableName, {

79
packages/nocodb/src/modules/jobs/jobs/at-import/helpers/readAndProcessData.ts

@ -1,5 +1,6 @@
/* eslint-disable no-async-promise-executor */
import { RelationTypes, UITypes } from 'nocodb-sdk';
import sizeof from 'object-sizeof';
import EntityMap from './EntityMap';
import type { BulkDataAliasService } from '../../../../../services/bulk-data-alias.service';
import type { TablesService } from '../../../../../services/tables.service';
@ -7,8 +8,8 @@ import type { TablesService } from '../../../../../services/tables.service';
import type { AirtableBase } from 'airtable/lib/airtable_base';
import type { TableType } from 'nocodb-sdk';
const BULK_DATA_BATCH_SIZE = 500;
const ASSOC_BULK_DATA_BATCH_SIZE = 1000;
const BULK_DATA_BATCH_COUNT = 20; // check size for every 100 records
const BULK_DATA_BATCH_SIZE = 50 * 1024; // in bytes
const BULK_PARALLEL_PROCESS = 5;
interface AirtableImportContext {
@ -42,6 +43,12 @@ async function readAllData({
.eachPage(
async function page(records, fetchNextPage) {
if (!data) {
/*
EntityMap is a sqlite3 table dynamically populated based on json data provided
It is used to store data temporarily and then stream it in bulk to import
This is done to avoid memory issues - heap out of memory - while importing large data
*/
data = new EntityMap();
await data.init();
}
@ -96,8 +103,8 @@ export async function importData({
services: AirtableImportContext;
}): Promise<EntityMap> {
try {
// @ts-ignore
const records = await readAllData({
// returns EntityMap which allows us to stream data
const records: EntityMap = await readAllData({
table,
base,
logDetailed,
@ -108,22 +115,32 @@ export async function importData({
const readable = records.getStream();
const allRecordsCount = await records.getCount();
const promises = [];
let tempData = [];
let importedCount = 0;
let tempCount = 0;
// we keep track of active process to pause and resume the stream as we have async calls within the stream and we don't want to load all data in memory
let activeProcess = 0;
readable.on('data', async (record) => {
promises.push(
new Promise(async (resolve) => {
activeProcess++;
if (activeProcess >= BULK_PARALLEL_PROCESS) readable.pause();
const { id: rid, ...fields } = record;
const r = await nocoBaseDataProcessing_v2(sDB, table, {
id: rid,
fields,
});
tempData.push(r);
tempCount++;
if (tempCount >= BULK_DATA_BATCH_COUNT) {
if (sizeof(tempData) >= BULK_DATA_BATCH_SIZE) {
readable.pause();
if (tempData.length >= BULK_DATA_BATCH_SIZE) {
let insertArray = tempData.splice(0, tempData.length);
await services.bulkDataService.bulkDataInsert({
@ -131,18 +148,24 @@ export async function importData({
tableName: table.title,
body: insertArray,
cookie: {},
skip_hooks: true,
});
logBasic(
`:: Importing '${
table.title
}' data :: ${importedCount} - ${Math.min(
importedCount + BULK_DATA_BATCH_SIZE,
importedCount + insertArray.length,
allRecordsCount,
)}`,
);
importedCount += insertArray.length;
insertArray = [];
readable.resume();
}
tempCount = 0;
}
activeProcess--;
if (activeProcess < BULK_PARALLEL_PROCESS) readable.resume();
@ -151,26 +174,31 @@ export async function importData({
);
});
readable.on('end', async () => {
// ensure all chunks are processed
await Promise.all(promises);
// insert remaining data
if (tempData.length > 0) {
await services.bulkDataService.bulkDataInsert({
projectName,
tableName: table.title,
body: tempData,
cookie: {},
skip_hooks: true,
});
logBasic(
`:: Importing '${
table.title
}' data :: ${importedCount} - ${Math.min(
importedCount + BULK_DATA_BATCH_SIZE,
importedCount + tempData.length,
allRecordsCount,
)}`,
);
importedCount += tempData.length;
tempData = [];
}
resolve(true);
});
});
@ -219,7 +247,7 @@ export async function importLTARData({
curCol: { title?: string };
refCol: { title?: string };
}> = [];
const allData =
const allData: EntityMap =
records ||
(await readAllData({
table,
@ -277,17 +305,16 @@ export async function importLTARData({
for await (const assocMeta of assocTableMetas) {
let assocTableData = [];
let importedCount = 0;
let tempCount = 0;
// extract insert data from records
// extract link data from records
await new Promise((resolve) => {
const promises = [];
const readable = allData.getStream();
let activeProcess = 0;
readable.on('data', async (record) => {
promises.push(
new Promise(async (resolve) => {
activeProcess++;
if (activeProcess >= BULK_PARALLEL_PROCESS) readable.pause();
const { id: _atId, ...rec } = record;
// todo: use actual alias instead of sanitized
@ -299,14 +326,22 @@ export async function importLTARData({
[assocMeta.refCol.title]: id,
})),
);
tempCount++;
if (tempCount >= BULK_DATA_BATCH_COUNT) {
if (sizeof(assocTableData) >= BULK_DATA_BATCH_SIZE) {
readable.pause();
let insertArray = assocTableData.splice(
0,
assocTableData.length,
);
if (assocTableData.length >= ASSOC_BULK_DATA_BATCH_SIZE) {
let insertArray = assocTableData.splice(0, assocTableData.length);
logBasic(
`:: Importing '${
table.title
}' LTAR data :: ${importedCount} - ${Math.min(
importedCount + ASSOC_BULK_DATA_BATCH_SIZE,
importedCount + insertArray.length,
insertArray.length,
)}`,
);
@ -316,25 +351,31 @@ export async function importLTARData({
tableName: assocMeta.modelMeta.title,
body: insertArray,
cookie: {},
skip_hooks: true,
});
importedCount += insertArray.length;
insertArray = [];
readable.resume();
}
tempCount = 0;
}
activeProcess--;
if (activeProcess < BULK_PARALLEL_PROCESS) readable.resume();
resolve(true);
}),
);
});
readable.on('end', async () => {
// ensure all chunks are processed
await Promise.all(promises);
// insert remaining data
if (assocTableData.length >= 0) {
logBasic(
`:: Importing '${
table.title
}' LTAR data :: ${importedCount} - ${Math.min(
importedCount + ASSOC_BULK_DATA_BATCH_SIZE,
importedCount + assocTableData.length,
assocTableData.length,
)}`,
);
@ -344,11 +385,13 @@ export async function importLTARData({
tableName: assocMeta.modelMeta.title,
body: assocTableData,
cookie: {},
skip_hooks: true,
});
importedCount += assocTableData.length;
assocTableData = [];
}
resolve(true);
});
});

7
packages/nocodb/src/schema/swagger.json

@ -10059,6 +10059,13 @@
},
"in": "query",
"name": "where"
},
{
"schema": {
"type": "string"
},
"in": "query",
"name": "viewId"
}
],
"patch": {

2
packages/nocodb/src/services/bulk-data-alias.service.ts

@ -43,6 +43,7 @@ export class BulkDataAliasService {
cookie: any;
chunkSize?: number;
foreign_key_checks?: boolean;
skip_hooks?: boolean;
raw?: boolean;
},
) {
@ -54,6 +55,7 @@ export class BulkDataAliasService {
{
cookie: param.cookie,
foreign_key_checks: param.foreign_key_checks,
skip_hooks: param.skip_hooks,
raw: param.raw,
},
],

7
packages/nocodb/src/version-upgrader/ncXcdbLTARUpgrader.ts

@ -44,6 +44,11 @@ async function upgradeModelRelations({
ncMeta,
);
// if colOptions not found then skip
if (!colOptions) {
continue;
}
switch (colOptions.type) {
case RelationTypes.HAS_MANY:
{
@ -77,7 +82,6 @@ async function upgradeModelRelations({
childTable: relation.tn,
foreignKeyName: relation.cstn,
});
}
// skip postgres since we were already creating the index while creating the relation
if (ncMeta.knex.clientType() !== 'pg') {
@ -90,6 +94,7 @@ async function upgradeModelRelations({
await sqlClient.indexCreate(indexArgs);
}
}
}
break;
}

4
tests/playwright/pages/Account/License.ts

@ -28,6 +28,10 @@ export class AccountLicensePage extends BasePage {
}
async saveLicenseKey(licenseKey: string) {
// Kludge: fix me!
// await this.get().waitFor({ state: 'visible' });
await this.rootPage.waitForTimeout(1000);
await this.get().fill(licenseKey);
await this.getSaveButton().click();
await this.verifyToast({ message: 'License key updated' });

192
tests/playwright/pages/Dashboard/BulkUpdate/index.ts

@ -0,0 +1,192 @@
import { expect, Locator } from '@playwright/test';
import BasePage from '../../Base';
import { DashboardPage } from '..';
import { DateTimeCellPageObject } from '../common/Cell/DateTimeCell';
import { getTextExcludeIconText } from '../../../tests/utils/general';
export class BulkUpdatePage extends BasePage {
readonly dashboard: DashboardPage;
readonly bulkUpdateButton: Locator;
readonly formHeader: Locator;
readonly columnsDrawer: Locator;
readonly form: Locator;
constructor(dashboard: DashboardPage) {
super(dashboard.rootPage);
this.dashboard = dashboard;
this.bulkUpdateButton = this.dashboard.get().locator('.nc-bulk-update-save-btn');
this.formHeader = this.dashboard.get().locator('.nc-bulk-update-bulk-update-header');
this.columnsDrawer = this.dashboard.get().locator('.nc-columns-drawer');
this.form = this.dashboard.get().locator('div.form');
}
get() {
return this.dashboard.get().locator(`.nc-drawer-bulk-update`);
}
async close() {
return this.dashboard.rootPage.keyboard.press('Escape');
}
async getInactiveColumn(index: number) {
const inactiveColumns = await this.columnsDrawer.locator('.ant-card');
return inactiveColumns.nth(index);
}
async getActiveColumn(index: number) {
const activeColumns = await this.form.locator('[data-testid="nc-bulk-update-fields"]');
return activeColumns.nth(index);
}
async getInactiveColumns() {
const inactiveColumns = await this.columnsDrawer.locator('.ant-card');
const inactiveColumnsCount = await inactiveColumns.count();
const inactiveColumnsTitles = [];
// get title for each inactive column
for (let i = 0; i < inactiveColumnsCount; i++) {
const title = await getTextExcludeIconText(inactiveColumns.nth(i).locator('.ant-card-body'));
inactiveColumnsTitles.push(title);
}
return inactiveColumnsTitles;
}
async getActiveColumns() {
const activeColumns = await this.form.locator('[data-testid="nc-bulk-update-fields"]');
const activeColumnsCount = await activeColumns.count();
const activeColumnsTitles = [];
// get title for each active column
for (let i = 0; i < activeColumnsCount; i++) {
const title = await getTextExcludeIconText(activeColumns.nth(i).locator('[data-testid="nc-bulk-update-input-label"]'));
activeColumnsTitles.push(title);
}
return activeColumnsTitles;
}
async removeField(index: number) {
const removeFieldButton = await this.form.locator('[data-testid="nc-bulk-update-fields"]');
const removeFieldButtonCount = await removeFieldButton.count();
await removeFieldButton.nth(index).locator('[data-testid="nc-bulk-update-fields-remove-icon"]').click();
const newRemoveFieldButtonCount = await removeFieldButton.count();
expect(newRemoveFieldButtonCount).toBe(removeFieldButtonCount - 1);
}
async addField(index: number) {
const addFieldButton = await this.columnsDrawer.locator('.ant-card');
const addFieldButtonCount = await addFieldButton.count();
await addFieldButton.nth(index).click();
const newAddFieldButtonCount = await addFieldButton.count();
expect(newAddFieldButtonCount).toBe(addFieldButtonCount - 1);
}
//////////////////////////////////////////////////////////////////////////////
async fillField({ columnTitle, value, type = 'text' }: { columnTitle: string; value: string; type?: string }) {
let picker = null;
const field = this.form.locator(`[data-testid="nc-bulk-update-input-${columnTitle}"]`);
await field.scrollIntoViewIfNeeded();
await field.hover();
if (type !== 'checkbox' && type !== 'attachment') {
await field.click();
}
switch (type) {
case 'text':
await field.locator('input').waitFor();
await field.locator('input').fill(value);
break;
case 'longText':
await field.locator('textarea').waitFor();
await field.locator('textarea').fill(value);
break;
case 'rating':
await field
.locator('.ant-rate-star')
.nth(Number(value) - 1)
.click();
break;
case 'year':
picker = this.rootPage.locator('.ant-picker-dropdown.active');
await picker.waitFor();
await picker.locator(`td[title="${value}"]`).click();
break;
case 'time':
picker = this.rootPage.locator('.ant-picker-dropdown.active');
await picker.waitFor();
// eslint-disable-next-line no-case-declarations
const time = value.split(':');
// eslint-disable-next-line no-case-declarations
const timePanel = picker.locator('.ant-picker-time-panel-column');
await timePanel.nth(0).locator('li').nth(+time[0]).click();
await timePanel.nth(1).locator('li').nth(+time[1]).click();
await picker.locator('.ant-picker-ok').click();
break;
case 'singleSelect':
picker = this.rootPage.locator('.ant-select-dropdown.active');
await picker.waitFor();
await picker.locator(`.nc-select-option-SingleSelect-${value}`).click();
break;
case 'multiSelect':
picker = this.rootPage.locator('.ant-select-dropdown.active');
await picker.waitFor();
for (const val of value.split(',')) {
await picker.locator(`.nc-select-option-MultiSelect-${val}`).click();
}
break;
case 'checkbox':
if (value === 'true') {
await field.click();
}
break;
case 'attachment':
// eslint-disable-next-line no-case-declarations
const attachFileAction = field.locator('[data-testid="attachment-cell-file-picker-button"]').click();
await this.attachFile({ filePickUIAction: attachFileAction, filePath: value });
break;
case 'date':
{
const values = value.split('-');
const { year, month, day } = { year: values[0], month: values[1], day: values[2] };
picker = this.rootPage.locator('.ant-picker-dropdown.active');
const monthBtn = picker.locator('.ant-picker-month-btn');
const yearBtn = picker.locator('.ant-picker-year-btn');
await yearBtn.click();
await picker.waitFor();
await picker.locator(`td[title="${year}"]`).click();
await monthBtn.click();
await picker.waitFor();
await picker.locator(`td[title="${year}-${month}"]`).click();
await picker.waitFor();
await picker.locator(`td[title="${year}-${month}-${day}"]`).click();
}
break;
}
}
async save({
awaitResponse = true,
}: {
awaitResponse?: boolean;
} = {}) {
await this.bulkUpdateButton.click();
const confirmModal = await this.rootPage.locator('.ant-modal-confirm');
const saveRowAction = () => confirmModal.locator('.ant-btn-primary').click();
if (!awaitResponse) {
await saveRowAction();
} else {
await this.waitForResponse({
uiAction: saveRowAction,
requestUrlPathToMatch: 'api/v1/db/data/noco/',
httpMethodsToMatch: ['GET'],
responseJsonMatcher: json => json['pageInfo'],
});
}
await this.get().waitFor({ state: 'hidden' });
await this.rootPage.locator('[data-testid="grid-load-spinner"]').waitFor({ state: 'hidden' });
}
}

13
tests/playwright/pages/Dashboard/Grid/index.ts

@ -220,6 +220,19 @@ export class GridPage extends BasePage {
await this.deleteSelectedRows();
}
async updateSelectedRows() {
await this.get().locator('[data-testid="nc-check-all"]').nth(0).click({
button: 'right',
});
await this.rootPage.locator('text=Update Selected Rows').click();
await this.dashboard.waitForLoaderToDisappear();
}
async updateAll() {
await this.selectAll();
await this.updateSelectedRows();
}
async verifyTotalRowCount({ count }: { count: number }) {
// wait for 100 ms and try again : 5 times
let i = 0;

2
tests/playwright/pages/Dashboard/common/Cell/SelectOptionCell.ts

@ -126,7 +126,7 @@ export class SelectOptionCellPageObject extends BasePage {
await expect(this.rootPage.locator(`div.ant-select-item-option`).nth(counter)).toHaveText(option);
counter++;
}
await this.get({ index, columnHeader }).click();
await this.rootPage.keyboard.press('Escape');
await this.rootPage.locator(`.nc-dropdown-single-select-cell`).nth(index).waitFor({ state: 'hidden' });
}

23
tests/playwright/pages/Dashboard/common/Cell/TimeCell.ts

@ -0,0 +1,23 @@
import { CellPageObject } from '.';
import BasePage from '../../../Base';
import { expect } from '@playwright/test';
export class TimeCellPageObject extends BasePage {
readonly cell: CellPageObject;
constructor(cell: CellPageObject) {
super(cell.rootPage);
this.cell = cell;
}
get({ index, columnHeader }: { index?: number; columnHeader: string }) {
return this.cell.get({ index, columnHeader });
}
async verify({ index, columnHeader, value }: { index: number; columnHeader: string; value: string }) {
const cell = await this.get({ index, columnHeader });
await cell.scrollIntoViewIfNeeded();
await cell.locator(`input[title="${value}"]`).waitFor({ state: 'visible' });
await expect(cell.locator(`[title="${value}"]`)).toBeVisible();
}
}

23
tests/playwright/pages/Dashboard/common/Cell/YearCell.ts

@ -0,0 +1,23 @@
import { CellPageObject } from '.';
import BasePage from '../../../Base';
import { expect } from '@playwright/test';
export class YearCellPageObject extends BasePage {
readonly cell: CellPageObject;
constructor(cell: CellPageObject) {
super(cell.rootPage);
this.cell = cell;
}
get({ index, columnHeader }: { index?: number; columnHeader: string }) {
return this.cell.get({ index, columnHeader });
}
async verify({ index, columnHeader, value }: { index: number; columnHeader: string; value: number }) {
const cell = await this.get({ index, columnHeader });
await cell.scrollIntoViewIfNeeded();
await cell.locator(`input[title="${value}"]`).waitFor({ state: 'visible' });
await expect(cell.locator(`[title="${value}"]`)).toBeVisible();
}
}

6
tests/playwright/pages/Dashboard/common/Cell/index.ts

@ -10,6 +10,8 @@ import { DateCellPageObject } from './DateCell';
import { DateTimeCellPageObject } from './DateTimeCell';
import { GeoDataCellPageObject } from './GeoDataCell';
import { getTextExcludeIconText } from '../../../../tests/utils/general';
import { YearCellPageObject } from './YearCell';
import { TimeCellPageObject } from './TimeCell';
export interface CellProps {
index?: number;
@ -22,6 +24,8 @@ export class CellPageObject extends BasePage {
readonly attachment: AttachmentCellPageObject;
readonly checkbox: CheckboxCellPageObject;
readonly rating: RatingCellPageObject;
readonly year: YearCellPageObject;
readonly time: TimeCellPageObject;
readonly geoData: GeoDataCellPageObject;
readonly date: DateCellPageObject;
readonly dateTime: DateTimeCellPageObject;
@ -33,6 +37,8 @@ export class CellPageObject extends BasePage {
this.attachment = new AttachmentCellPageObject(this);
this.checkbox = new CheckboxCellPageObject(this);
this.rating = new RatingCellPageObject(this);
this.year = new YearCellPageObject(this);
this.time = new TimeCellPageObject(this);
this.geoData = new GeoDataCellPageObject(this);
this.date = new DateCellPageObject(this);
this.dateTime = new DateTimeCellPageObject(this);

3
tests/playwright/pages/Dashboard/index.ts

@ -3,6 +3,7 @@ import BasePage from '../Base';
import { GridPage } from './Grid';
import { FormPage } from './Form';
import { ExpandedFormPage } from './ExpandedForm';
import { BulkUpdatePage } from './BulkUpdate';
import { ChildList } from './Grid/Column/LTAR/ChildList';
import { LinkRecord } from './Grid/Column/LTAR/LinkRecord';
import { TreeViewPage } from './TreeView';
@ -29,6 +30,7 @@ export class DashboardPage extends BasePage {
readonly kanban: KanbanPage;
readonly map: MapPage;
readonly expandedForm: ExpandedFormPage;
readonly bulkUpdateForm: BulkUpdatePage;
readonly webhookForm: WebhookFormPage;
readonly findRowByScanOverlay: FindRowByScanOverlay;
readonly childList: ChildList;
@ -51,6 +53,7 @@ export class DashboardPage extends BasePage {
this.kanban = new KanbanPage(this);
this.map = new MapPage(this);
this.expandedForm = new ExpandedFormPage(this);
this.bulkUpdateForm = new BulkUpdatePage(this);
this.webhookForm = new WebhookFormPage(this);
this.findRowByScanOverlay = new FindRowByScanOverlay(this);
this.childList = new ChildList(this);

30
tests/playwright/setup/demoTable.ts

@ -116,6 +116,24 @@ const columns = {
uidt: UITypes.Time,
},
],
miscellaneous: [
{
column_name: 'Id',
title: 'Id',
uidt: UITypes.ID,
},
{
column_name: 'Checkbox',
title: 'Checkbox',
uidt: UITypes.Checkbox,
},
{
column_name: 'Attachment',
title: 'Attachment',
uidt: UITypes.Attachment,
},
],
};
async function createDemoTable({
@ -198,6 +216,18 @@ async function createDemoTable({
console.error(e);
}
break;
case 'miscellaneous':
try {
for (let i = 0; i < recordCnt; i++) {
const row = {
Checkbox: rowMixedValue(columns.miscellaneous[1], i),
};
rowAttributes.push(row);
}
} catch (e) {
console.error(e);
}
break;
}
await api.dbTableRow.bulkCreate('noco', context.project.id, table.id, rowAttributes);

1
tests/playwright/tests/db/filters.spec.ts

@ -7,6 +7,7 @@ import { Api } from 'nocodb-sdk';
import { rowMixedValue } from '../../setup/xcdb-records';
import dayjs from 'dayjs';
import { createDemoTable } from '../../setup/demoTable';
import { isPg } from '../../setup/db';
let dashboard: DashboardPage, toolbar: ToolbarPage;
let context: any;

4
tests/playwright/tests/db/projectOperations.spec.ts

@ -107,9 +107,9 @@ test.describe('Project operations', () => {
const testProjectId = await projectList.list.find((p: any) => p.title === testProjectName);
const dupeProjectId = await projectList.list.find((p: any) => p.title === dupeProjectName);
const projectInfoOp: ProjectInfoApiUtil = new ProjectInfoApiUtil(context.token);
const orginal: Promise<ProjectInfo> = projectInfoOp.extractProjectInfo(testProjectId.id);
const original: Promise<ProjectInfo> = projectInfoOp.extractProjectInfo(testProjectId.id);
const duplicate: Promise<ProjectInfo> = projectInfoOp.extractProjectInfo(dupeProjectId.id);
await Promise.all([orginal, duplicate]).then(arr => {
await Promise.all([original, duplicate]).then(arr => {
const ignoredFields: Set<string> = new Set([
'id',
'prefix',

14
tests/playwright/tests/db/timezone.spec.ts

@ -539,6 +539,8 @@ test.describe.serial('Timezone- ExtDB : DateTime column, Browser Timezone same a
let dashboard: DashboardPage;
let context: any;
let counter = 0;
const expectedDisplayValues = {
pg: {
// PG ignores timezone information for datetime without timezone
@ -587,8 +589,8 @@ test.describe.serial('Timezone- ExtDB : DateTime column, Browser Timezone same a
'xc-auth': context.token,
},
});
await createTableWithDateTimeColumn(context.dbType, 'datetimetable01');
counter++;
await createTableWithDateTimeColumn(context.dbType, `datetimetable01${counter}`);
});
// ExtDB : DateAdd, DateTime_Diff verification
@ -596,13 +598,13 @@ test.describe.serial('Timezone- ExtDB : DateTime column, Browser Timezone same a
// - verify API response value
//
test('Formula, verify display value', async () => {
await connectToExtDb(context, 'datetimetable01');
await connectToExtDb(context, `datetimetable01${counter}`);
await dashboard.rootPage.reload();
await dashboard.rootPage.waitForTimeout(2000);
// insert a record to work with formula experiments
//
await dashboard.treeView.openBase({ title: 'datetimetable01' });
await dashboard.treeView.openBase({ title: `datetimetable01${counter}` });
await dashboard.treeView.openTable({ title: 'MyTable' });
// Create formula column (dummy)
@ -756,14 +758,14 @@ test.describe.serial('Timezone- ExtDB : DateTime column, Browser Timezone same a
});
test('Verify display value, UI insert, API response', async () => {
await connectToExtDb(context, 'datetimetable01');
await connectToExtDb(context, `datetimetable01${counter}`);
await dashboard.rootPage.reload();
await dashboard.rootPage.waitForTimeout(2000);
// get timezone offset
const formattedOffset = getBrowserTimezoneOffset();
await dashboard.treeView.openBase({ title: 'datetimetable01' });
await dashboard.treeView.openBase({ title: `datetimetable01${counter}` });
await dashboard.treeView.openTable({ title: 'MyTable' });
if (isSqlite(context)) {

288
tests/playwright/tests/db/updateBulk.ts

@ -0,0 +1,288 @@
import { expect, test } from '@playwright/test';
import setup from '../../setup';
import { DashboardPage } from '../../pages/Dashboard';
import { Api } from 'nocodb-sdk';
import { createDemoTable } from '../../setup/demoTable';
import { BulkUpdatePage } from '../../pages/Dashboard/BulkUpdate';
import { AccountLicensePage } from '../../pages/Account/License';
import { AccountPage } from '../../pages/Account';
let bulkUpdateForm: BulkUpdatePage;
let dashboard: DashboardPage;
let context: any;
let api: Api<any>;
let table;
async function updateBulkFields(fields) {
// move all fields to active
for (let i = 0; i < fields.length; i++) {
await bulkUpdateForm.addField(0);
}
// fill all fields
for (let i = 0; i < fields.length; i++) {
await bulkUpdateForm.fillField({ columnTitle: fields[i].title, value: fields[i].value, type: fields[i].type });
}
// save form
await bulkUpdateForm.save({ awaitResponse: true });
}
async function beforeEachInit({ page, tableType }: { page: any; tableType: string }) {
context = await setup({ page, isEmptyProject: true });
dashboard = new DashboardPage(page, context.project);
bulkUpdateForm = dashboard.bulkUpdateForm;
const accountPage: AccountPage = new AccountPage(page);
const accountLicensePage: AccountLicensePage = new AccountLicensePage(accountPage);
api = new Api({
baseURL: `http://localhost:8080/`,
headers: {
'xc-auth': context.token,
},
});
table = await createDemoTable({ context, type: tableType, recordCnt: 50 });
await accountLicensePage.goto();
await accountLicensePage.saveLicenseKey('1234567890');
await dashboard.goto();
await dashboard.treeView.openTable({ title: tableType });
// Open bulk update form
await dashboard.grid.updateAll();
}
test.describe('Bulk update', () => {
test.beforeEach(async ({ page }) => {
await beforeEachInit({ page, tableType: 'textBased' });
});
test('General- Click to add & remove', async () => {
let inactiveColumns = await bulkUpdateForm.getInactiveColumns();
expect(inactiveColumns).toEqual(['SingleLineText', 'MultiLineText', 'Email', 'PhoneNumber', 'URL']);
let activeColumns = await bulkUpdateForm.getActiveColumns();
expect(activeColumns).toEqual([]);
await bulkUpdateForm.addField(0);
await bulkUpdateForm.addField(0);
inactiveColumns = await bulkUpdateForm.getInactiveColumns();
expect(inactiveColumns).toEqual(['Email', 'PhoneNumber', 'URL']);
activeColumns = await bulkUpdateForm.getActiveColumns();
expect(activeColumns).toEqual(['SingleLineText', 'MultiLineText']);
});
test('General- Drag drop', async () => {
const src = await bulkUpdateForm.getInactiveColumn(0);
const dst = await bulkUpdateForm.form;
await src.dragTo(dst);
expect(await bulkUpdateForm.getActiveColumns()).toEqual(['SingleLineText']);
expect(await bulkUpdateForm.getInactiveColumns()).toEqual(['MultiLineText', 'Email', 'PhoneNumber', 'URL']);
const src2 = await bulkUpdateForm.getActiveColumn(0);
const dst2 = await bulkUpdateForm.columnsDrawer;
await src2.dragTo(dst2);
expect(await bulkUpdateForm.getActiveColumns()).toEqual([]);
expect(await bulkUpdateForm.getInactiveColumns()).toEqual([
'SingleLineText',
'MultiLineText',
'Email',
'PhoneNumber',
'URL',
]);
});
test('Text based', async () => {
const fields = [
{ title: 'SingleLineText', value: 'SingleLineText', type: 'text' },
{ title: 'Email', value: 'a@b.com', type: 'text' },
{ title: 'PhoneNumber', value: '987654321', type: 'text' },
{ title: 'URL', value: 'https://www.google.com', type: 'text' },
{
title: 'MultiLineText',
value: 'Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. Long text. ',
type: 'longText',
},
];
await updateBulkFields(fields);
// verify data on grid
for (let i = 0; i < fields.length; i++) {
await dashboard.grid.cell.verify({ index: 5, columnHeader: fields[i].title, value: fields[i].value });
}
// verify api response
const updatedRecords = (await api.dbTableRow.list('noco', context.project.id, table.id, { limit: 50 })).list;
for (let i = 0; i < updatedRecords.length; i++) {
for (let j = 0; j < fields.length; j++) {
expect(updatedRecords[i][fields[j].title]).toEqual(fields[j].value);
}
}
});
});
test.describe('Bulk update', () => {
test.beforeEach(async ({ page }) => {
await beforeEachInit({ page, tableType: 'numberBased' });
});
test('Number based', async () => {
const fields = [
{ title: 'Number', value: '1', type: 'text' },
{ title: 'Decimal', value: '1.1', type: 'text' },
{ title: 'Currency', value: '1.1', type: 'text' },
{ title: 'Percent', value: '10', type: 'text' },
{ title: 'Duration', value: '16:40', type: 'text' },
{ title: 'Rating', value: '3', type: 'rating' },
{ title: 'Year', value: '2024', type: 'year' },
{ title: 'Time', value: '10:10', type: 'time' },
];
await updateBulkFields(fields);
// verify data on grid
for (let i = 0; i < fields.length; i++) {
if (fields[i].type === 'rating') {
await dashboard.grid.cell.rating.verify({ index: 5, columnHeader: fields[i].title, rating: +fields[i].value });
} else if (fields[i].type === 'year') {
await dashboard.grid.cell.year.verify({ index: 5, columnHeader: fields[i].title, value: +fields[i].value });
} else if (fields[i].type === 'time') {
await dashboard.grid.cell.time.verify({ index: 5, columnHeader: fields[i].title, value: fields[i].value });
} else {
await dashboard.grid.cell.verify({ index: 5, columnHeader: fields[i].title, value: fields[i].value });
}
}
// verify api response
// duration in seconds
const APIResponse = [1, 1.1, 1.1, 10, 60000, 3, 2024, '10:10:00'];
const updatedRecords = (await api.dbTableRow.list('noco', context.project.id, table.id, { limit: 50 })).list;
for (let i = 0; i < updatedRecords.length; i++) {
for (let j = 0; j < fields.length; j++) {
if (fields[j].title === 'Time') {
expect(updatedRecords[i][fields[j].title]).toContain(APIResponse[j]);
} else {
expect(+updatedRecords[i][fields[j].title]).toEqual(APIResponse[j]);
}
}
}
});
});
test.describe('Bulk update', () => {
test.beforeEach(async ({ page }) => {
await beforeEachInit({ page, tableType: 'selectBased' });
});
test('Select based', async () => {
const fields = [
{ title: 'SingleSelect', value: 'jan', type: 'singleSelect' },
{ title: 'MultiSelect', value: 'jan,feb,mar', type: 'multiSelect' },
];
await updateBulkFields(fields);
// verify data on grid
const displayOptions = ['jan', 'feb', 'mar'];
for (let i = 0; i < fields.length; i++) {
if (fields[i].type === 'singleSelect') {
await dashboard.grid.cell.selectOption.verify({
index: 5,
columnHeader: fields[i].title,
option: fields[i].value,
});
} else {
await dashboard.grid.cell.selectOption.verifyOptions({
index: 5,
columnHeader: fields[i].title,
options: displayOptions,
});
}
}
// verify api response
const updatedRecords = (await api.dbTableRow.list('noco', context.project.id, table.id, { limit: 50 })).list;
for (let i = 0; i < updatedRecords.length; i++) {
for (let j = 0; j < fields.length; j++) {
expect(updatedRecords[i][fields[j].title]).toContain(fields[j].value);
}
}
});
});
test.describe('Bulk update', () => {
test.beforeEach(async ({ page }) => {
await beforeEachInit({ page, tableType: 'miscellaneous' });
});
test('Miscellaneous (Checkbox, attachment)', async () => {
const fields = [
{ title: 'Checkbox', value: 'true', type: 'checkbox' },
{ title: 'Attachment', value: `${process.cwd()}/fixtures/sampleFiles/1.json`, type: 'attachment' },
];
await updateBulkFields(fields);
// verify data on grid
for (let i = 0; i < fields.length; i++) {
if (fields[i].type === 'checkbox') {
await dashboard.grid.cell.checkbox.verifyChecked({
index: 5,
columnHeader: fields[i].title,
});
} else {
await dashboard.grid.cell.attachment.verifyFileCount({
index: 5,
columnHeader: fields[i].title,
count: 1,
});
}
}
// verify api response
const updatedRecords = (await api.dbTableRow.list('noco', context.project.id, table.id, { limit: 50 })).list;
for (let i = 0; i < updatedRecords.length; i++) {
for (let j = 0; j < fields.length; j++) {
expect(+updatedRecords[i]['Checkbox']).toBe(1);
expect(updatedRecords[i]['Attachment'][0].title).toBe('1.json');
expect(updatedRecords[i]['Attachment'][0].mimetype).toBe('application/json');
}
}
});
});
test.describe('Bulk update', () => {
test.beforeEach(async ({ page }) => {
await beforeEachInit({ page, tableType: 'dateTimeBased' });
});
test('Date Time Based', async () => {
const fields = [{ title: 'Date', value: '2024-08-04', type: 'date' }];
await updateBulkFields(fields);
// verify data on grid
for (let i = 0; i < fields.length; i++) {
await dashboard.grid.cell.date.verify({
index: 5,
columnHeader: fields[i].title,
date: fields[i].value,
});
}
// verify api response
const updatedRecords = (await api.dbTableRow.list('noco', context.project.id, table.id, { limit: 50 })).list;
for (let i = 0; i < updatedRecords.length; i++) {
for (let j = 0; j < fields.length; j++) {
expect(updatedRecords[i]['Date']).toBe(fields[j].value);
}
}
});
});
Loading…
Cancel
Save