Browse Source

Nc feat/Readonly source followup (#8795)

* feat: allow partial column update (GUI)

* feat: allow partial column update (backend)

* refactor: swagger schema description correction

* feat: allow edit from multi field editor

* fix: allow meta update in api level

* fix: add tooltip and docs link

* fix: multi field editor corrections

* fix: allow table meta update

* fix: allow table meta update

* fix: allow column validation update

* fix: block adding new option directly from cell

* fix: add tooltip for column menu options

* refactor: tooltips

* test: replace index with count as parameter

* fix: corrections

* refactor: hint text update
pull/8822/head
Pranav C 5 months ago committed by GitHub
parent
commit
d4e5ede2d3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 8
      packages/nc-gui/components/cell/MultiSelect.vue
  2. 6
      packages/nc-gui/components/cell/SingleSelect.vue
  3. 2
      packages/nc-gui/components/dashboard/TreeView/CreateViewBtn.vue
  4. 33
      packages/nc-gui/components/dashboard/TreeView/ProjectNode.vue
  5. 4
      packages/nc-gui/components/dashboard/TreeView/index.vue
  6. 2
      packages/nc-gui/components/dashboard/settings/DataSources.vue
  7. 53
      packages/nc-gui/components/dashboard/settings/data-sources/CreateBase.vue
  8. 50
      packages/nc-gui/components/dashboard/settings/data-sources/EditBase.vue
  9. 64
      packages/nc-gui/components/dashboard/settings/data-sources/SourceRestrictions.vue
  10. 4
      packages/nc-gui/components/general/BaseLogo.vue
  11. 39
      packages/nc-gui/components/general/SourceRestrictionTooltip.vue
  12. 6
      packages/nc-gui/components/nc/Tooltip.vue
  13. 3
      packages/nc-gui/components/smartsheet/column/DecimalOptions.vue
  14. 21
      packages/nc-gui/components/smartsheet/column/EditOrAdd.vue
  15. 4
      packages/nc-gui/components/smartsheet/column/RatingOptions.vue
  16. 20
      packages/nc-gui/components/smartsheet/column/UITypesOptionsWithSearch.vue
  17. 18
      packages/nc-gui/components/smartsheet/details/Fields.vue
  18. 11
      packages/nc-gui/components/smartsheet/header/Cell.vue
  19. 108
      packages/nc-gui/components/smartsheet/header/Menu.vue
  20. 7
      packages/nc-gui/components/smartsheet/toolbar/GroupByMenu.vue
  21. 131
      packages/nc-gui/composables/useColumnCreateStore.ts
  22. 8
      packages/nc-gui/lang/en.json
  23. 92
      packages/nc-gui/utils/treeviewUtils.ts
  24. 23
      packages/nocodb-sdk/src/lib/UITypes.ts
  25. 1
      packages/nocodb-sdk/src/lib/index.ts
  26. 17
      packages/nocodb/src/models/Column.ts
  27. 4
      packages/nocodb/src/modules/jobs/jobs/export-import/duplicate.controller.ts
  28. 4
      packages/nocodb/src/schema/swagger-v2.json
  29. 12
      packages/nocodb/src/schema/swagger.json
  30. 33
      packages/nocodb/src/services/columns.service.ts
  31. 2
      packages/nocodb/src/services/forms.service.ts
  32. 1
      packages/nocodb/src/services/public-datas.service.ts
  33. 5
      packages/nocodb/src/services/tables.service.ts
  34. 2
      packages/nocodb/src/utils/acl.ts
  35. 6
      tests/playwright/pages/Dashboard/common/Cell/RatingCell.ts
  36. 6
      tests/playwright/tests/db/columns/columnRating.spec.ts
  37. 2
      tests/playwright/tests/db/features/verticalFillHandle.spec.ts
  38. 70
      tests/playwright/tests/db/general/sourceRestrictions.spec.ts

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

@ -55,9 +55,7 @@ const searchVal = ref<string | null>()
const { $api } = useNuxtApp()
const { getMeta } = useMetas()
const { isUIAllowed } = useRoles()
const { isUIAllowed, isMetaReadOnly } = useRoles()
const { isPg, isMysql } = useBase()
@ -522,7 +520,9 @@ const onFocus = () => {
</a-select-option>
<a-select-option
v-if="searchVal && isOptionMissing && !isPublic && !disableOptionCreation && isUIAllowed('fieldEdit')"
v-if="
!isMetaReadOnly && searchVal && isOptionMissing && !isPublic && !disableOptionCreation && isUIAllowed('fieldEdit')
"
:key="searchVal"
:value="searchVal"
>

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

@ -49,7 +49,7 @@ const searchVal = ref()
const { getMeta } = useMetas()
const { isUIAllowed } = useRoles()
const { isUIAllowed, isMetaReadOnly } = useRoles()
const { isPg, isMysql } = useBase()
@ -59,7 +59,9 @@ const tempSelectedOptState = ref<string>()
const isFocusing = ref(false)
const isNewOptionCreateEnabled = computed(() => !isPublic.value && !disableOptionCreation && isUIAllowed('fieldEdit'))
const isNewOptionCreateEnabled = computed(
() => !isPublic.value && !disableOptionCreation && isUIAllowed('fieldEdit') && !isMetaReadOnly.value,
)
const options = computed<(SelectOptionType & { value: string })[]>(() => {
if (column?.value.colOptions) {

2
packages/nc-gui/components/dashboard/TreeView/CreateViewBtn.vue

@ -1,5 +1,5 @@
<script lang="ts" setup>
import { SourceRestriction, type ViewType } from 'nocodb-sdk'
import { type ViewType } from 'nocodb-sdk'
import { ViewTypes } from 'nocodb-sdk'
const props = defineProps<{

33
packages/nc-gui/components/dashboard/TreeView/ProjectNode.vue

@ -656,7 +656,7 @@ const getSource = (sourceId: string) => {
v-e="['c:base:expand']"
type="text"
size="xxsmall"
class="nc-sidebar-node-btn nc-sidebar-expand !xs:opacity-100"
class="nc-sidebar-node-btn nc-sidebar-expand !xs:opacity-100 !mr-0 mt-0.5"
:class="{
'!opacity-100': isOptionsOpen,
}"
@ -705,7 +705,7 @@ const getSource = (sourceId: string) => {
v-e="['c:external:base:expand']"
type="text"
size="xxsmall"
class="nc-sidebar-node-btn nc-sidebar-expand !xs:opacity-100"
class="nc-sidebar-node-btn nc-sidebar-expand !xs:opacity-100 !mr-0 mt-0.5"
:class="{ '!opacity-100 !inline-block': isBasesOptionsOpen[source!.id!] }"
>
<GeneralIcon
@ -731,9 +731,21 @@ const getSource = (sourceId: string) => {
class="source-context flex flex-grow items-center gap-1.75 text-gray-800 min-w-1/20 max-w-full"
@contextmenu="setMenuContext('source', source)"
>
<GeneralBaseLogo
class="flex-none min-w-4 !xs:(min-w-4.25 w-4.25 text-sm) !text-gray-600 !group-hover:text-gray-800"
/>
<NcTooltip
:tooltip-style="{ 'min-width': 'max-content' }"
:overlay-inner-style="{ 'min-width': 'max-content' }"
:mouse-leave-delay="0.3"
placement="topLeft"
trigger="hover"
>
<template #title>
<component :is="getSourceTooltip(source)" />
</template>
<GeneralBaseLogo
:color="getSourceIconColor(source)"
class="flex-none min-w-4 !xs:(min-w-4.25 w-4.25 text-sm)"
/>
</NcTooltip>
<input
v-if="source.id && sourceRenameHelpers[source.id]?.editMode"
ref="input"
@ -765,17 +777,6 @@ const getSource = (sourceId: string) => {
{{ source.alias || '' }}
</span>
</NcTooltip>
<NcTooltip class="xs:(hidden) flex items-center mr-1">
<template #title>{{ $t('objects.externalDb') }}</template>
<GeneralIcon
icon="info"
class="flex-none text-gray-400 hover:text-gray-700 nc-sidebar-node-btn"
:class="{
'!hidden': !isBasesOptionsOpen[source!.id!],
}"
/>
</NcTooltip>
</div>
<div class="flex flex-row items-center gap-x-0.25">
<NcDropdown

4
packages/nc-gui/components/dashboard/TreeView/index.vue

@ -249,9 +249,9 @@ watch(
ghost-class="ghost"
@change="onMove($event)"
>
<template #item="{ element: base1 }">
<template #item="{ element: baseItem }">
<div :key="base.id">
<ProjectWrapper :base-role="base1.project_role" :base="base1">
<ProjectWrapper :base-role="baseItem.project_role" :base="baseItem">
<DashboardTreeViewProjectNode />
</ProjectWrapper>
</div>

2
packages/nc-gui/components/dashboard/settings/DataSources.vue

@ -315,7 +315,7 @@ const openedTab = ref('erd')
</template>
<div class="p-6 mt-4 h-full overflow-auto">
<LazyDashboardSettingsDataSourcesEditBase
class="w-600px"
class="w-760px pr-5"
:source-id="activeSource.id"
@source-updated="loadBases(true)"
@close="activeSource = null"

53
packages/nc-gui/components/dashboard/settings/data-sources/CreateBase.vue

@ -1,7 +1,6 @@
<script lang="ts" setup>
import { Form, message } from 'ant-design-vue'
import type { SelectHandler } from 'ant-design-vue/es/vc-select/Select'
import { SourceRestriction } from 'nocodb-sdk'
import {
type CertTypes,
ClientType,
@ -437,7 +436,7 @@ const allowDataWrite = computed({
:closable="!creatingSource"
:keyboard="!creatingSource"
:mask-closable="false"
size="medium"
:width="750"
@update:visible="toggleModal"
>
<div class="py-6 px-8">
@ -454,7 +453,7 @@ const allowDataWrite = computed({
name="external-base-create-form"
layout="horizontal"
no-style
:label-col="{ span: 8 }"
:label-col="{ span: 5 }"
>
<div
class="nc-scrollbar-md"
@ -545,50 +544,10 @@ const allowDataWrite = computed({
<a-input v-model:value="formState.dataSource.searchPath[0]" />
</a-form-item>
</template>
<a-form-item>
<template #label>
<div class="flex gap-1 justify-end">
<span>
{{ $t('labels.allowMetaWrite') }}
</span>
<NcTooltip>
<template #title>
<span>{{ $t('tooltip.allowMetaWrite') }}</span>
</template>
<GeneralIcon class="text-gray-500" icon="info" />
</NcTooltip>
</div>
</template>
<a-switch v-model:checked="allowMetaWrite" data-testid="nc-allow-meta-write" size="small"></a-switch>
</a-form-item>
<a-form-item>
<template #label>
<div class="flex gap-1 justify-end">
<span>
{{ $t('labels.allowDataWrite') }}
</span>
<NcTooltip>
<template #title>
<span>{{ $t('tooltip.allowDataWrite') }}</span>
</template>
<GeneralIcon class="text-gray-500" icon="info" />
</NcTooltip>
</div>
</template>
<div class="flex justify-start">
<NcTooltip :disabled="!allowMetaWrite" placement="topLeft">
<template #title>
{{ $t('tooltip.dataWriteOptionDisabled') }}
</template>
<a-switch
v-model:checked="allowDataWrite"
:disabled="allowMetaWrite"
data-testid="nc-allow-data-write"
size="small"
></a-switch>
</NcTooltip>
</div>
</a-form-item>
<DashboardSettingsDataSourcesSourceRestrictions
v-model:allowMetaWrite="allowMetaWrite"
v-model:allowDataWrite="allowDataWrite"
/>
<template
v-if="
formState.dataSource.client !== ClientType.SQLITE &&

50
packages/nc-gui/components/dashboard/settings/data-sources/EditBase.vue

@ -401,7 +401,7 @@ const allowDataWrite = computed({
<div class="edit-source bg-white relative flex flex-col justify-start gap-2 w-full p-2">
<h1 class="prose-2xl font-bold self-start">{{ $t('activity.editSource') }}</h1>
<a-form ref="form" :model="formState" name="external-base-create-form" layout="horizontal" no-style :label-col="{ span: 8 }">
<a-form ref="form" :model="formState" name="external-base-create-form" layout="horizontal" no-style :label-col="{ span: 5 }">
<div
class="nc-scrollbar-md"
:style="{
@ -563,50 +563,10 @@ const allowDataWrite = computed({
<a-input v-model:value="formState.dataSource.searchPath[0]" />
</a-form-item>
</template>
<a-form-item>
<template #label>
<div class="flex gap-1 justify-end">
<span>
{{ $t('labels.allowMetaWrite') }}
</span>
<NcTooltip>
<template #title>
<span>{{ $t('tooltip.allowMetaWrite') }}</span>
</template>
<GeneralIcon class="text-gray-500" icon="info" />
</NcTooltip>
</div>
</template>
<a-switch v-model:checked="allowMetaWrite" data-testid="nc-allow-meta-write" size="small"></a-switch>
</a-form-item>
<a-form-item>
<template #label>
<div class="flex gap-1 justify-end">
<span>
{{ $t('labels.allowDataWrite') }}
</span>
<NcTooltip>
<template #title>
<span>{{ $t('tooltip.allowDataWrite') }}</span>
</template>
<GeneralIcon class="text-gray-500" icon="info" />
</NcTooltip>
</div>
</template>
<div class="flex justify-start">
<NcTooltip :disabled="!allowMetaWrite" placement="topLeft">
<template #title>
{{ $t('tooltip.dataWriteOptionDisabled') }}
</template>
<a-switch
v-model:checked="allowDataWrite"
:disabled="allowMetaWrite"
data-testid="nc-allow-data-write"
size="small"
></a-switch>
</NcTooltip>
</div>
</a-form-item>
<DashboardSettingsDataSourcesSourceRestrictions
v-model:allowMetaWrite="allowMetaWrite"
v-model:allowDataWrite="allowDataWrite"
/>
<template
v-if="
formState.dataSource.client !== ClientType.SQLITE &&

64
packages/nc-gui/components/dashboard/settings/data-sources/SourceRestrictions.vue

@ -0,0 +1,64 @@
<script setup lang="ts">
const props = defineProps<{
allowMetaWrite: boolean
allowDataWrite: boolean
}>()
const emits = defineEmits(['update:allowMetaWrite', 'update:allowDataWrite'])
const dataWrite = useVModel(props, 'allowDataWrite', emits)
const metaWrite = useVModel(props, 'allowMetaWrite', emits)
</script>
<template>
<a-form-item>
<template #help>
<span class="text-small">
{{ $t('tooltip.allowDataWrite') }}
</span>
</template>
<template #label>
<div class="flex gap-1 justify-end">
<span>
{{ $t('labels.allowDataWrite') }}
</span>
</div>
</template>
<div class="flex justify-start">
<NcTooltip :disabled="!metaWrite" placement="topLeft">
<template #title>
{{ $t('tooltip.dataWriteOptionDisabled') }}
</template>
<a-switch v-model:checked="dataWrite" :disabled="metaWrite" data-testid="nc-allow-data-write" size="small"></a-switch>
</NcTooltip>
</div>
</a-form-item>
<a-form-item>
<template #help>
<span class="text-small">
<span class="font-weight-medium" :class="{ 'nc-allow-meta-write-help': metaWrite }">
{{ $t('labels.notRecommended') }}:
</span>
{{ $t('tooltip.allowMetaWrite') }}
</span>
</template>
<template #label>
<div class="flex gap-1 justify-end">
<span>
{{ $t('labels.allowMetaWrite') }}
</span>
</div>
</template>
<a-switch v-model:checked="metaWrite" data-testid="nc-allow-meta-write" class="nc-allow-meta-write" size="small"></a-switch>
</a-form-item>
</template>
<style scoped>
.nc-allow-meta-write.ant-switch-checked {
background: #b33870;
}
.nc-allow-meta-write-help {
color: #b33870;
}
</style>

4
packages/nc-gui/components/general/BaseLogo.vue

@ -6,7 +6,7 @@ import SimpleIconsMicrosoftsqlserver from '~icons/simple-icons/microsoftsqlserve
import LogosSnowflakeIcon from '~icons/logos/snowflake-icon'
import MdiDatabaseOutline from '~icons/mdi/database-outline'
const { sourceType } = defineProps<{ sourceType?: string }>()
const { sourceType } = defineProps<{ sourceType?: string; color?: string }>()
const baseIcon = computed(() => {
switch (sourceType) {
@ -27,5 +27,5 @@ const baseIcon = computed(() => {
</script>
<template>
<component :is="baseIcon" />
<component :is="baseIcon" :style="color ? { color } : {}" />
</template>

39
packages/nc-gui/components/general/SourceRestrictionTooltip.vue

@ -0,0 +1,39 @@
<script setup lang="ts">
import type { TooltipPlacement } from 'ant-design-vue/es/tooltip'
import type { CSSProperties } from '@vue/runtime-dom'
defineProps<{
tooltipStyle?: CSSProperties
overlayInnerStyle?: CSSProperties
mouseLeaveDelay?: number
placement?: TooltipPlacement
trigger?: 'hover' | 'click'
message?: string
enabled?: boolean
}>()
</script>
<template>
<NcTooltip
:disabled="!enabled"
:tooltip-style="{ 'min-width': 'max-content' }"
:overlay-inner-style="{ 'min-width': 'max-content' }"
:mouse-leave-delay="0.3"
placement="left"
trigger="hover"
>
<template #title>
{{ $t('tooltip.schemaChangeDisabled') }} <br />
{{ message }}
<br v-if="message" />
<a
class="!text-current"
href="https://docs.nocodb.com/data-sources/connect-to-data-source#configuring-permissions"
target="_blank"
>
Learn more
</a>
</template>
<slot />
</NcTooltip>
</template>

6
packages/nc-gui/components/nc/Tooltip.vue

@ -14,6 +14,8 @@ interface Props {
hideOnClick?: boolean
overlayClassName?: string
wrapChild?: keyof HTMLElementTagNameMap
mouseLeaveDelay?: number
overlayInnerStyle?: object
}
const props = defineProps<Props>()
@ -77,7 +79,7 @@ watch([isHovering, () => modifierKey.value, () => disabled.value], ([hovering, k
}
}
if (!hovering || isDisabled) {
if ((!hovering || isDisabled) && !props.mouseLeaveDelay) {
showTooltip.value = false
return
}
@ -117,9 +119,11 @@ const onClick = () => {
v-model:visible="showTooltip"
:overlay-class-name="`nc-tooltip ${showTooltip ? 'visible' : 'hidden'} ${overlayClassName}`"
:overlay-style="tooltipStyle"
:overlay-inner-style="overlayInnerStyle"
arrow-point-at-center
:trigger="[]"
:placement="placement"
:mouse-leave-delay="mouseLeaveDelay"
>
<template #title>
<slot name="title" />

3
packages/nc-gui/components/smartsheet/column/DecimalOptions.vue

@ -36,6 +36,8 @@ vModel.value.meta = {
const onPrecisionChange = (value: number) => {
vModel.value.dtxs = Math.max(value, vModel.value.dtxs)
}
const { isMetaReadOnly } = useRoles()
</script>
<template>
@ -43,6 +45,7 @@ const onPrecisionChange = (value: number) => {
<a-select
v-if="vModel.meta?.precision"
v-model:value="vModel.meta.precision"
:disabled="isMetaReadOnly"
dropdown-class-name="nc-dropdown-decimal-format"
@change="onPrecisionChange"
>

21
packages/nc-gui/components/smartsheet/column/EditOrAdd.vue

@ -1,5 +1,5 @@
<script lang="ts" setup>
import type { ColumnReqType, ColumnType } from 'nocodb-sdk'
import { type ColumnReqType, type ColumnType } from 'nocodb-sdk'
import {
UITypes,
UITypesName,
@ -343,6 +343,14 @@ const filterOption = (input: string, option: { value: UITypes }) => {
(UITypesName[option.value] && UITypesName[option.value].toLowerCase().includes(input.toLowerCase()))
)
}
const isFullUpdateAllowed = computed(() => {
if (isMetaReadOnly.value && !readonlyMetaAllowedTypes.includes(formState.value?.uidt) && !isVirtualCol(formState.value)) {
return false
}
return true
})
</script>
<template>
@ -376,7 +384,7 @@ const filterOption = (input: string, option: { value: UITypes }) => {
<input
ref="antInput"
v-model="formState.title"
:disabled="readOnly"
:disabled="readOnly || !isFullUpdateAllowed"
:placeholder="`${$t('objects.field')} ${$t('general.name').toLowerCase()} ${isEdit ? '' : $t('labels.optional')}`"
class="flex flex-grow nc-fields-input text-sm font-semibold outline-none bg-inherit min-h-6"
:contenteditable="true"
@ -390,7 +398,7 @@ const filterOption = (input: string, option: { value: UITypes }) => {
v-model:value="formState.title"
class="nc-column-name-input !rounded-lg"
:placeholder="`${$t('objects.field')} ${$t('general.name').toLowerCase()} ${isEdit ? '' : $t('labels.optional')}`"
:disabled="isKanban || readOnly"
:disabled="isKanban || readOnly || !isFullUpdateAllowed"
@input="onAlter(8)"
/>
</a-form-item>
@ -411,10 +419,11 @@ const filterOption = (input: string, option: { value: UITypes }) => {
show-search
class="nc-column-type-input !rounded-lg"
:disabled="
(isMetaReadOnly && !readonlyMetaAllowedTypes.includes(formState.uidt)) ||
(isEdit && isMetaReadOnly && !readonlyMetaAllowedTypes.includes(formState.uidt)) ||
isKanban ||
readOnly ||
(isEdit && !!onlyNameUpdateOnEditColumns.includes(column?.uidt))
(isEdit && !!onlyNameUpdateOnEditColumns.includes(column?.uidt)) ||
(isEdit && !isFullUpdateAllowed)
"
dropdown-class-name="nc-dropdown-column-type border-1 !rounded-lg border-gray-200"
:filter-option="filterOption"
@ -511,7 +520,7 @@ const filterOption = (input: string, option: { value: UITypes }) => {
</NcSwitch>
</div>
<template v-if="!readOnly">
<template v-if="!readOnly && isFullUpdateAllowed">
<div class="nc-column-options-wrapper flex flex-col gap-4">
<!--
Default Value for JSON & LongText is not supported in MySQL

4
packages/nc-gui/components/smartsheet/column/RatingOptions.vue

@ -113,13 +113,13 @@ watch(
</a-col>
<a-col :span="8">
<a-form-item :label="$t('labels.max')">
<a-select v-model:value="vModel.meta.max" class="w-52" dropdown-class-name="nc-dropdown-rating-color">
<a-select v-model:value="vModel.meta.max" data-testid="nc-dropdown-rating-max" class="w-52" dropdown-class-name="nc-dropdown-rating-color">
<template #suffixIcon>
<GeneralIcon icon="arrowDown" class="text-gray-700" />
</template>
<a-select-option v-for="(v, i) in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]" :key="i" :value="v">
<div class="flex gap-2 w-full justify-between items-center">
<div class="flex gap-2 w-full justify-between items-center nc-dropdown-rating-max-option">
{{ v }}
<component
:is="iconMap.check"

20
packages/nc-gui/components/smartsheet/column/UITypesOptionsWithSearch.vue

@ -26,6 +26,10 @@ const inputRef = ref()
const activeFieldIndex = ref(-1)
const isDisabledUIType = (type: UITypes) => {
return isMetaReadOnly.value && !readonlyMetaAllowedTypes.includes(type)
}
const onClick = (uidt: UITypes) => {
if (!uidt || isDisabledUIType(uidt)) return
@ -64,10 +68,6 @@ onMounted(() => {
searchQuery.value = ''
activeFieldIndex.value = options.value.findIndex((o) => o.name === UITypes.SingleLineText)
})
const isDisabledUIType = (type: UITypes) => {
return isMetaReadOnly.value && !readonlyMetaAllowedTypes.includes(type)
}
</script>
<template>
@ -100,16 +100,12 @@ const isDisabledUIType = (type: UITypes) => {
{{ options.length ? $t('title.noResultsMatchedYourSearch') : 'The list is empty' }}
</div>
<NcTooltip
<GeneralSourceRestrictionTooltip
v-for="(option, index) in filteredOptions"
:key="index"
:disabled="!isDisabledUIType(option.name)"
placement="left"
:message="$t('tooltip.typeNotAllowed')"
:enabled="isDisabledUIType(option.name)"
>
<template #title>
{{ $t('tooltip.typeNotAllowed') }}
</template>
<div
class="flex w-full py-2 items-center justify-between px-2 rounded-md"
:class="[
@ -133,7 +129,7 @@ const isDisabledUIType = (type: UITypes) => {
<span v-if="option.deprecated" class="!text-xs !text-gray-300">({{ $t('general.deprecated') }})</span>
</div>
</div>
</NcTooltip>
</GeneralSourceRestrictionTooltip>
</div>
</div>
</template>

18
packages/nc-gui/components/smartsheet/details/Fields.vue

@ -1,7 +1,14 @@
<script setup lang="ts">
import { diff } from 'deep-object-diff'
import { message } from 'ant-design-vue'
import { UITypes, isLinksOrLTAR, isSystemColumn, isVirtualCol, readonlyMetaAllowedTypes } from 'nocodb-sdk'
import {
UITypes,
isLinksOrLTAR,
isSystemColumn,
isVirtualCol,
partialUpdateAllowedTypes,
readonlyMetaAllowedTypes,
} from 'nocodb-sdk'
import type { ColumnType, FilterType, SelectOptionsType } from 'nocodb-sdk'
import Draggable from 'vuedraggable'
import { onKeyDown, useMagicKeys } from '@vueuse/core'
@ -185,12 +192,17 @@ const setFieldMoveHook = (field: TableExplorerColumn, before = false) => {
const { isMetaReadOnly } = useRoles()
const isColumnUpdateAllowed = (column: ColumnType) => {
if (isMetaReadOnly.value && !readonlyMetaAllowedTypes.includes(column?.uidt)) return false
if (
isMetaReadOnly.value &&
!readonlyMetaAllowedTypes.includes(column?.uidt) &&
!partialUpdateAllowedTypes.includes(column?.uidt)
)
return false
return true
}
const changeField = (field?: TableExplorerColumn, event?: MouseEvent) => {
if (!isColumnUpdateAllowed(field)) {
if (field?.id && field?.uidt && !isColumnUpdateAllowed(field)) {
return message.info(t('msg.info.schemaReadOnly'))
}

11
packages/nc-gui/components/smartsheet/header/Cell.vue

@ -1,5 +1,5 @@
<script setup lang="ts">
import { type ColumnReqType, type ColumnType, readonlyMetaAllowedTypes } from 'nocodb-sdk'
import { type ColumnReqType, type ColumnType } from 'nocodb-sdk'
import { UITypes, UITypesName } from 'nocodb-sdk'
interface Props {
@ -32,7 +32,7 @@ const isDropDownOpen = ref(false)
const column = toRef(props, 'column')
const { isUIAllowed, isMetaReadOnly } = useRoles()
const { isUIAllowed } = useRoles()
provide(ColumnInj, column)
@ -60,12 +60,7 @@ const closeAddColumnDropdown = () => {
const openHeaderMenu = (e?: MouseEvent) => {
if (isLocked.value || (isExpandedForm.value && e?.type === 'dblclick') || isExpandedBulkUpdateForm.value) return
if (
!isForm.value &&
isUIAllowed('fieldEdit') &&
!isMobileMode.value &&
(!isMetaReadOnly.value || readonlyMetaAllowedTypes.includes(column.value.uidt))
) {
if (!isForm.value && isUIAllowed('fieldEdit') && !isMobileMode.value) {
editColumnDropdown.value = true
}
}

108
packages/nc-gui/components/smartsheet/header/Menu.vue

@ -1,5 +1,5 @@
<script lang="ts" setup>
import { type ColumnReqType, readonlyMetaAllowedTypes } from 'nocodb-sdk'
import { type ColumnReqType, partialUpdateAllowedTypes, readonlyMetaAllowedTypes } from 'nocodb-sdk'
import { PlanLimitTypes, RelationTypes, UITypes, isLinksOrLTAR, isSystemColumn } from 'nocodb-sdk'
import { SmartsheetStoreEvents } from '#imports'
@ -363,6 +363,16 @@ const isColumnUpdateAllowed = computed(() => {
if (isMetaReadOnly.value && !readonlyMetaAllowedTypes.includes(column.value?.uidt)) return false
return true
})
const isColumnEditAllowed = computed(() => {
if (
isMetaReadOnly.value &&
!readonlyMetaAllowedTypes.includes(column.value?.uidt) &&
!partialUpdateAllowedTypes.includes(column.value?.uidt)
)
return false
return true
})
</script>
<template>
@ -385,28 +395,33 @@ const isColumnUpdateAllowed = computed(() => {
'min-w-[256px]': isExpandedForm,
}"
>
<NcMenuItem
v-if="isUIAllowed('fieldAlter')"
:disabled="column?.pk || isSystemColumn(column) || !isColumnUpdateAllowed"
@click="onEditPress"
>
<div class="nc-column-edit nc-header-menu-item">
<component :is="iconMap.ncEdit" class="text-gray-700" />
<!-- Edit -->
{{ $t('general.edit') }}
</div>
</NcMenuItem>
<NcMenuItem
v-if="isUIAllowed('duplicateColumn') && isExpandedForm && !column?.pk"
:disabled="!isDuplicateAllowed"
@click="openDuplicateDlg"
>
<div v-e="['a:field:duplicate']" class="nc-column-duplicate nc-header-menu-item">
<component :is="iconMap.duplicate" class="text-gray-700" />
<!-- Duplicate -->
{{ t('general.duplicate') }}
</div>
</NcMenuItem>
<GeneralSourceRestrictionTooltip message="Field properties cannot be edited." :enabled="!isColumnEditAllowed">
<NcMenuItem
v-if="isUIAllowed('fieldAlter')"
:disabled="column?.pk || isSystemColumn(column) || !isColumnEditAllowed"
@click="onEditPress"
>
<div class="nc-column-edit nc-header-menu-item">
<component :is="iconMap.ncEdit" class="text-gray-700" />
<!-- Edit -->
{{ $t('general.edit') }}
</div>
</NcMenuItem>
</GeneralSourceRestrictionTooltip>
<GeneralSourceRestrictionTooltip message="Field cannot be duplicated." :enabled="!isDuplicateAllowed">
<NcMenuItem
v-if="isUIAllowed('duplicateColumn') && isExpandedForm && !column?.pk"
:disabled="!isDuplicateAllowed"
@click="openDuplicateDlg"
>
<div v-e="['a:field:duplicate']" class="nc-column-duplicate nc-header-menu-item">
<component :is="iconMap.duplicate" class="text-gray-700" />
<!-- Duplicate -->
{{ t('general.duplicate') }}
</div>
</NcMenuItem>
</GeneralSourceRestrictionTooltip>
<a-divider v-if="isUIAllowed('fieldAlter') && !column?.pv" class="!my-0" />
<NcMenuItem v-if="!column?.pv" @click="hideOrShowField">
<div v-e="['a:field:hide']" class="nc-column-insert-before nc-header-menu-item">
@ -510,14 +525,15 @@ const isColumnUpdateAllowed = computed(() => {
</NcTooltip>
<a-divider class="!my-0" />
<NcMenuItem v-if="!column?.pk" :disabled="!isDuplicateAllowed" @click="openDuplicateDlg">
<div v-e="['a:field:duplicate']" class="nc-column-duplicate nc-header-menu-item">
<component :is="iconMap.duplicate" class="text-gray-700" />
<!-- Duplicate -->
{{ t('general.duplicate') }}
</div>
</NcMenuItem>
<GeneralSourceRestrictionTooltip message="Field cannot be duplicated." :enabled="!isDuplicateAllowed && isMetaReadOnly">
<NcMenuItem v-if="!column?.pk" :disabled="!isDuplicateAllowed" @click="openDuplicateDlg">
<div v-e="['a:field:duplicate']" class="nc-column-duplicate nc-header-menu-item">
<component :is="iconMap.duplicate" class="text-gray-700" />
<!-- Duplicate -->
{{ t('general.duplicate') }}
</div>
</NcMenuItem>
</GeneralSourceRestrictionTooltip>
<NcMenuItem @click="onInsertAfter">
<div v-e="['a:field:insert:after']" class="nc-column-insert-after nc-header-menu-item">
<component :is="iconMap.colInsertAfter" class="text-gray-700 !w-4.5 !h-4.5" />
@ -534,21 +550,23 @@ const isColumnUpdateAllowed = computed(() => {
</NcMenuItem>
</template>
<a-divider v-if="!column?.pv" class="!my-0" />
<NcMenuItem
v-if="!column?.pv && isUIAllowed('fieldDelete')"
:disabled="!isDeleteAllowed || !isColumnUpdateAllowed"
class="!hover:bg-red-50"
@click="handleDelete"
>
<div
class="nc-column-delete nc-header-menu-item"
:class="{ ' text-red-600': isDeleteAllowed && isColumnUpdateAllowed }"
<GeneralSourceRestrictionTooltip message="Field cannot be deleted." :enabled="!isColumnUpdateAllowed">
<NcMenuItem
v-if="!column?.pv && isUIAllowed('fieldDelete')"
:disabled="!isDeleteAllowed || !isColumnUpdateAllowed"
class="!hover:bg-red-50"
@click="handleDelete"
>
<component :is="iconMap.delete" />
<!-- Delete -->
{{ $t('general.delete') }}
</div>
</NcMenuItem>
<div
class="nc-column-delete nc-header-menu-item"
:class="{ ' text-red-600': isDeleteAllowed && isColumnUpdateAllowed }"
>
<component :is="iconMap.delete" />
<!-- Delete -->
{{ $t('general.delete') }}
</div>
</NcMenuItem>
</GeneralSourceRestrictionTooltip>
</NcMenu>
</template>
</a-dropdown>

7
packages/nc-gui/components/smartsheet/toolbar/GroupByMenu.vue

@ -214,12 +214,7 @@ const onMove = async (event: { moved: { newIndex: number; oldIndex: number } })
data-testid="nc-group-by-menu"
>
<div class="max-h-100" @click.stop>
<Draggable
:model-value="_groupBy"
item-key="fk_column_id"
ghost-class="bg-gray-50"
@change="onMove($event)"
>
<Draggable :model-value="_groupBy" item-key="fk_column_id" ghost-class="bg-gray-50" @change="onMove($event)">
<template #item="{ element: group }">
<div :key="group.fk_column_id" class="flex first:mb-0 !mb-1.5 !last:mb-0 items-center">
<NcButton type="secondary" size="small" class="!border-r-transparent !rounded-r-none">

131
packages/nc-gui/composables/useColumnCreateStore.ts

@ -34,6 +34,8 @@ const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState
const { getMeta } = useMetas()
const { isMetaReadOnly } = useRoles()
const { t } = useI18n()
const { $e } = useNuxtApp()
@ -71,12 +73,74 @@ const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState
postSaveOrUpdateCbk = cbk
}
const defaultType = isMetaReadOnly.value ? UITypes.Formula : UITypes.SingleLineText
const formState = ref<Record<string, any>>({
title: '',
uidt: fromTableExplorer?.value ? UITypes.SingleLineText : null,
uidt: fromTableExplorer?.value ? defaultType : null,
...clone(column.value || {}),
})
const onUidtOrIdTypeChange = () => {
disableSubmitBtn.value = false
const newTitle = updateFieldName(false)
const colProp = sqlUi.value.getDataTypeForUiType(formState.value as { uidt: UITypes }, idType ?? undefined)
formState.value = {
...(!isEdit.value && {
// only take title, column_name and uidt when creating a column
// to avoid the extra props from being taken (e.g. SingleLineText -> LTAR -> SingleLineText)
// to mess up the column creation
title: newTitle || formState.value.title,
column_name: newTitle || formState.value.column_name,
uidt: formState.value.uidt,
temp_id: formState.value.temp_id,
userHasChangedTitle: !!formState.value?.userHasChangedTitle,
}),
...(isEdit.value && {
// take the existing formState.value when editing a column
// LTAR is not available in this case
...formState.value,
}),
meta: {},
rqd: false,
pk: false,
ai: false,
cdf: null,
un: false,
dtx: 'specificType',
...colProp,
}
formState.value.dtxp = sqlUi.value.getDefaultLengthForDatatype(formState.value.dt)
formState.value.dtxs = sqlUi.value.getDefaultScaleForDatatype(formState.value.dt)
const selectTypes = [UITypes.MultiSelect, UITypes.SingleSelect]
if (column && selectTypes.includes(formState.value.uidt) && selectTypes.includes(column.value?.uidt as UITypes)) {
formState.value.dtxp = column.value?.dtxp
}
if (columnToValidate.includes(formState.value.uidt)) {
formState.value.meta = {
validate: formState.value.meta && formState.value.meta.validate,
}
}
// keep length and scale for same datatype
if (column.value && formState.value.uidt === column.value?.uidt) {
formState.value.dtxp = column.value.dtxp
formState.value.dtxs = column.value.dtxs
} else {
// default length and scale for currency
if (formState.value?.uidt === UITypes.Currency) {
formState.value.dtxp = 19
formState.value.dtxs = 2
}
}
formState.value.altered = formState.value.altered || 2
}
// actions
const generateNewColumnMeta = (ignoreUidt = false) => {
setAdditionalValidations({})
@ -87,6 +151,10 @@ const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState
formState.value.title = ''
formState.value.column_name = ''
if (isMetaReadOnly.value) {
formState.value.uidt = defaultType
onUidtOrIdTypeChange()
}
if (ignoreUidt && !fromTableExplorer?.value) {
formState.value.uidt = null
}
@ -150,67 +218,6 @@ const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState
const { resetFields, validate, validateInfos } = useForm(formState, validators)
const onUidtOrIdTypeChange = () => {
disableSubmitBtn.value = false
const newTitle = updateFieldName(false)
const colProp = sqlUi.value.getDataTypeForUiType(formState.value as { uidt: UITypes }, idType ?? undefined)
formState.value = {
...(!isEdit.value && {
// only take title, column_name and uidt when creating a column
// to avoid the extra props from being taken (e.g. SingleLineText -> LTAR -> SingleLineText)
// to mess up the column creation
title: newTitle || formState.value.title,
column_name: newTitle || formState.value.column_name,
uidt: formState.value.uidt,
temp_id: formState.value.temp_id,
userHasChangedTitle: !!formState.value?.userHasChangedTitle,
}),
...(isEdit.value && {
// take the existing formState.value when editing a column
// LTAR is not available in this case
...formState.value,
}),
meta: {},
rqd: false,
pk: false,
ai: false,
cdf: null,
un: false,
dtx: 'specificType',
...colProp,
}
formState.value.dtxp = sqlUi.value.getDefaultLengthForDatatype(formState.value.dt)
formState.value.dtxs = sqlUi.value.getDefaultScaleForDatatype(formState.value.dt)
const selectTypes = [UITypes.MultiSelect, UITypes.SingleSelect]
if (column && selectTypes.includes(formState.value.uidt) && selectTypes.includes(column.value?.uidt as UITypes)) {
formState.value.dtxp = column.value?.dtxp
}
if (columnToValidate.includes(formState.value.uidt)) {
formState.value.meta = {
validate: formState.value.meta && formState.value.meta.validate,
}
}
// keep length and scale for same datatype
if (column.value && formState.value.uidt === column.value?.uidt) {
formState.value.dtxp = column.value.dtxp
formState.value.dtxs = column.value.dtxs
} else {
// default length and scale for currency
if (formState.value?.uidt === UITypes.Currency) {
formState.value.dtxp = 19
formState.value.dtxs = 2
}
}
formState.value.altered = formState.value.altered || 2
}
const onDataTypeChange = () => {
formState.value.rqd = false
if (formState.value.uidt !== UITypes.ID) {

8
packages/nc-gui/lang/en.json

@ -456,6 +456,7 @@
"looksLikeThisStackIsEmpty": "Looks like this stack does not have any records"
},
"labels": {
"notRecommended": "Not recommended",
"allowMetaWrite" : "Allow Schema Edit",
"allowDataWrite" : "Allow Data Edit",
"selectView": "Select a View",
@ -1040,10 +1041,11 @@
"group": "Group"
},
"tooltip": {
"typeNotAllowed": "This datatype is not allowed due to restricted schema alterations for this source.",
"schemaChangeDisabled": "Schema editing is disabled for this data source.",
"typeNotAllowed": "This datatype is not allowed.",
"dataWriteOptionDisabled": "Data editing can only be disabled when 'Schema editing' is also disabled.",
"allowMetaWrite": "Enable this option to allow modifications to the database schema, including adding, altering, or deleting tables and columns. Use with caution, as changes may affect application functionality.",
"allowDataWrite": "Enable this option to allow updating, deleting, or inserting data within the database tables. Ideal for administrative users who need to manage data directly.",
"allowMetaWrite": "This option allows modification of database schema, including adding, altering, or deleting tables and columns. Use with caution, as changes may impact the structural integrity of your database.",
"allowDataWrite": "This option allows create, update, or delete of records within database tables. Ideal for administrative users need to change data directly.",
"reachedSourceLimit": "Limited to 10 data sources per base",
"saveChanges": "Save changes",
"xcDB": "Create a new base",

92
packages/nc-gui/utils/treeviewUtils.ts

@ -0,0 +1,92 @@
// based on source restriction decide the icon color
import type { SourceType } from 'nocodb-sdk'
import { clientTypes } from '~/utils/baseCreateUtils'
export const getSourceIconColor = (source: SourceType) => {
if (source.is_schema_readonly && source.is_data_readonly) {
return '#278bff'
}
if (source.is_schema_readonly) {
return '#df830f'
}
return '#de0062'
}
// based on source restriction decide the tooltip message with docs link
export const getSourceTooltip = (source: SourceType) => {
const dbLabel = `Connection type is ${clientTypes.find((c) => c.value === source.type)?.text || source.type?.toUpperCase()}.`
if (source.is_schema_readonly && source.is_data_readonly) {
return h(
'div',
{
className: 'w-max',
},
[
dbLabel,
h('br'),
'Both data and schema editing are disabled.',
h('br'),
'These settings are ideal for read-only use cases of your data.',
h('br'),
h(
'a',
{
className: '!text-current',
href: 'https://docs.nocodb.com/data-sources/connect-to-data-source#configuring-permissions',
target: '_blank',
},
'Learn more',
),
],
)
}
if (source.is_schema_readonly) {
return h(
'div',
{
className: 'max-w-90',
},
[
dbLabel,
h('br'),
'Data editing is allowed and Schema edit is not allowed.',
h('br'),
'An ideal settings for administrative users who need to change data directly on database.',
h('br'),
h(
'a',
{
className: '!text-current',
href: 'https://docs.nocodb.com/data-sources/connect-to-data-source#configuring-permissions',
target: '_blank',
},
'Learn more',
),
],
)
}
return h(
'div',
{
className: 'max-w-90',
},
[
dbLabel,
h('br'),
'Both Data and Schema Editing are enabled.',
h('br'),
'We highly recommend ',
h(
'a',
{
className: '!text-current',
href: 'https://docs.nocodb.com/data-sources/connect-to-data-source#configuring-permissions',
target: '_blank',
},
'disabling schema editing',
),
' to maintain data integrity and avoid potential issues.',
],
)
}

23
packages/nocodb-sdk/src/lib/UITypes.ts

@ -262,3 +262,26 @@ export const readonlyMetaAllowedTypes = [
UITypes.Barcode,
UITypes.QrCode,
];
export const partialUpdateAllowedTypes = [
// Single/Multi select is disabled for now since it involves updating type in some cases
// UITypes.SingleSelect,
// UITypes.MultiSelect,
UITypes.Checkbox,
UITypes.Number,
UITypes.Decimal,
UITypes.Currency,
UITypes.Percent,
UITypes.Duration,
UITypes.Rating,
UITypes.DateTime,
UITypes.Date,
UITypes.Time,
UITypes.CreatedTime,
UITypes.LastModifiedTime,
UITypes.LinkToAnotherRecord,
UITypes.Links,
UITypes.PhoneNumber,
UITypes.Email,
UITypes.URL,
];

1
packages/nocodb-sdk/src/lib/index.ts

@ -21,6 +21,7 @@ export {
getEquivalentUIType,
isSelectTypeCol,
readonlyMetaAllowedTypes,
partialUpdateAllowedTypes
} from '~/lib/UITypes';
export { default as CustomAPI, FileType } from '~/lib/CustomAPI';
export { default as TemplateGenerator } from '~/lib/TemplateGenerator';

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

@ -1387,6 +1387,23 @@ export default class Column<T = any> implements ColumnType {
);
}
static async updateValidation(
context: NcContext,
{ colId, validate }: { colId: string; validate: any },
ncMeta = Noco.ncMeta,
) {
// set meta
await ncMeta.metaUpdate(
context.workspace_id,
context.base_id,
MetaTable.COLUMNS,
prepareForDb({ validate }, 'validate'),
colId,
);
await NocoCache.update(`${CacheScope.COLUMN}:${colId}`, { validate });
}
static async updateTargetView(
context: NcContext,
{ colId, fk_target_view_id }: { colId: string; fk_target_view_id: string },

4
packages/nocodb/src/modules/jobs/jobs/export-import/duplicate.controller.ts

@ -11,9 +11,7 @@ import {
import {
ProjectStatus,
readonlyMetaAllowedTypes,
SourceRestriction,
} from 'nocodb-sdk';
import type { UITypes } from 'nocodb-sdk';
import { GlobalGuard } from '~/guards/global/global.guard';
import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware';
import { BasesService } from '~/services/bases.service';
@ -293,7 +291,7 @@ export class DuplicateController {
const source = await Source.get(context, model.source_id);
// check if source is readonly and column type is not allowed
if (!readonlyMetaAllowedTypes.includes(column.uidt as UITypes)) {
if (!readonlyMetaAllowedTypes.includes(column.uidt)) {
if (source.is_schema_readonly) {
NcError.sourceMetaReadOnly(source.alias);
}

4
packages/nocodb/src/schema/swagger-v2.json

@ -12168,11 +12168,11 @@
},
"is_schema_readonly": {
"$ref": "#/components/schemas/Bool",
"description": "Is the data source minimal db"
"description": "Is the data source schema readonly"
},
"is_data_readonly": {
"$ref": "#/components/schemas/Bool",
"description": "Is the data source minimal db"
"description": "Is the data source data readonly"
},
"order": {
"description": "The order of the list of sources",

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

@ -18217,11 +18217,11 @@
},
"is_schema_readonly": {
"$ref": "#/components/schemas/Bool",
"description": "Is the data source minimal db"
"description": "Is the data source schema readonly"
},
"is_data_readonly": {
"$ref": "#/components/schemas/Bool",
"description": "Is the data source minimal db"
"description": "Is the data source data readonly"
},
"order": {
"description": "The order of the list of sources",
@ -18397,6 +18397,14 @@
"description": "Is the data source minimal db",
"type": "boolean"
},
"is_schema_readonly": {
"$ref": "#/components/schemas/Bool",
"description": "Is the data source schema readonly"
},
"is_data_readonly": {
"$ref": "#/components/schemas/Bool",
"description": "Is the data source data readonly"
},
"type": {
"description": "DB Type",
"enum": [

33
packages/nocodb/src/services/columns.service.ts

@ -5,6 +5,7 @@ import {
isCreatedOrLastModifiedTimeCol,
isLinksOrLTAR,
isVirtualCol,
partialUpdateAllowedTypes,
readonlyMetaAllowedTypes,
RelationTypes,
SourceRestriction,
@ -199,12 +200,17 @@ export class ColumnsService {
Source.get(context, table.source_id),
);
const isMetaOnlyUpdateAllowed =
source?.is_schema_readonly &&
partialUpdateAllowedTypes.includes(column.uidt);
// check if source is readonly and column type is not allowed
if (
source?.is_schema_readonly &&
(!readonlyMetaAllowedTypes.includes(column.uidt) ||
(param.column.uidt &&
!readonlyMetaAllowedTypes.includes(param.column.uidt as UITypes)))
!readonlyMetaAllowedTypes.includes(param.column.uidt as UITypes))) &&
!partialUpdateAllowedTypes.includes(column.uidt)
) {
NcError.sourceMetaReadOnly(source.alias);
}
@ -217,7 +223,7 @@ export class ColumnsService {
const mxColumnLength = Column.getMaxColumnNameLength(sqlClientType);
if (!isVirtualCol(param.column)) {
if (!isVirtualCol(param.column) && !isMetaOnlyUpdateAllowed) {
param.column.column_name = sanitizeColumnName(
param.column.column_name,
source.type,
@ -229,7 +235,7 @@ export class ColumnsService {
param.column.title = param.column.title.trim();
}
if (param.column.column_name) {
if (param.column.column_name && !isMetaOnlyUpdateAllowed) {
// - 5 is a buffer for suffix
let colName = param.column.column_name.slice(0, mxColumnLength - 5);
let suffix = 1;
@ -247,6 +253,7 @@ export class ColumnsService {
}
if (
!isMetaOnlyUpdateAllowed &&
!isVirtualCol(param.column) &&
param.column.column_name.length > mxColumnLength
) {
@ -291,6 +298,7 @@ export class ColumnsService {
} & Partial<Pick<ColumnReqType, 'column_order'>>;
if (
isMetaOnlyUpdateAllowed ||
isCreatedOrLastModifiedTimeCol(column) ||
isCreatedOrLastModifiedByCol(column) ||
[
@ -365,15 +373,28 @@ export class ColumnsService {
}
if (
'meta' in colBody &&
[UITypes.CreatedTime, UITypes.LastModifiedTime].includes(
([UITypes.CreatedTime, UITypes.LastModifiedTime].includes(
column.uidt,
)
) ||
isMetaOnlyUpdateAllowed)
) {
await Column.updateMeta(context, {
colId: param.columnId,
meta: colBody.meta,
});
}
if (
'validate' in colBody &&
([UITypes.URL, UITypes.PhoneNumber, UITypes.Email].includes(
column.uidt,
) ||
isMetaOnlyUpdateAllowed)
) {
await Column.updateValidation(context, {
colId: param.columnId,
validate: colBody.validate,
});
}
if (isLinksOrLTAR(column)) {
if ('meta' in colBody) {
@ -436,7 +457,7 @@ export class ColumnsService {
await this.updateRollupOrLookup(context, colBody, column);
} else {
NcError.notImplemented(`Updating ${colBody.uidt} => ${colBody.uidt}`);
NcError.notImplemented(`Updating ${column.uidt} => ${colBody.uidt}`);
}
} else if (
[

2
packages/nocodb/src/services/forms.service.ts

@ -1,5 +1,5 @@
import { Injectable } from '@nestjs/common';
import { AppEvents, SourceRestriction, ViewTypes } from 'nocodb-sdk';
import { AppEvents, ViewTypes } from 'nocodb-sdk';
import type {
FormUpdateReqType,
UserType,

1
packages/nocodb/src/services/public-datas.service.ts

@ -3,7 +3,6 @@ import { Injectable } from '@nestjs/common';
import { nanoid } from 'nanoid';
import {
populateUniqueFileName,
SourceRestriction,
UITypes,
ViewTypes,
} from 'nocodb-sdk';

5
packages/nocodb/src/services/tables.service.ts

@ -76,6 +76,11 @@ export class TablesService {
return true;
}
// allow user to only update meta json data when source is restricted changes to schema
if (source?.is_schema_readonly) {
NcError.sourceMetaReadOnly(source.alias);
}
if (!param.table.table_name) {
NcError.badRequest(
'Missing table name `table_name` property in request body',

2
packages/nocodb/src/utils/acl.ts

@ -456,8 +456,6 @@ export const sourceRestrictions = {
[SourceRestriction.SCHEMA_READONLY]: {
tableCreate: true,
tableDelete: true,
tableUpdate: true,
columnBulk: true,
},
[SourceRestriction.DATA_READONLY]: {
dataUpdate: true,

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

@ -17,7 +17,11 @@ export class RatingCellPageObject extends BasePage {
async select({ index, columnHeader, rating }: { index?: number; columnHeader: string; rating: number }) {
await this.get({ index, columnHeader }).scrollIntoViewIfNeeded();
await this.waitForResponse({
uiAction: async () => await this.get({ index, columnHeader }).locator('.ant-rate-star > div').nth(rating).click(),
uiAction: async () =>
await this.get({ index, columnHeader })
.locator('.ant-rate-star > div')
.nth(rating - 1)
.click(),
httpMethodsToMatch: ['POST', 'PATCH'],
requestUrlPathToMatch: 'api/v1/db/data/noco/',
});

6
tests/playwright/tests/db/columns/columnRating.spec.ts

@ -66,9 +66,9 @@ test.describe('Rating - cell, filter, sort', () => {
});
// In cell insert
await dashboard.grid.cell.rating.select({ index: 0, columnHeader: 'rating', rating: 2 });
await dashboard.grid.cell.rating.select({ index: 2, columnHeader: 'rating', rating: 1 });
await dashboard.grid.cell.rating.select({ index: 5, columnHeader: 'rating', rating: 0 });
await dashboard.grid.cell.rating.select({ index: 0, columnHeader: 'rating', rating: 3 });
await dashboard.grid.cell.rating.select({ index: 2, columnHeader: 'rating', rating: 2 });
await dashboard.grid.cell.rating.select({ index: 5, columnHeader: 'rating', rating: 1 });
// column values
// 1a : 3

2
tests/playwright/tests/db/features/verticalFillHandle.spec.ts

@ -113,7 +113,7 @@ test.describe('Fill Handle', () => {
await p.dashboard.grid.cell.time.set({ index: 0, columnHeader: 'Time', value: '02:02' });
// set rating for first record
await p.dashboard.grid.cell.rating.select({ index: 0, columnHeader: 'Rating', rating: 2 });
await p.dashboard.grid.cell.rating.select({ index: 0, columnHeader: 'Rating', rating: 3 });
await dragDrop({ firstColumn: 'Number', lastColumn: 'Time', params: p });

70
tests/playwright/tests/db/general/sourceRestrictions.spec.ts

@ -80,12 +80,70 @@ test.describe('Source Restrictions', () => {
.scrollIntoViewIfNeeded();
await dashboard.grid.get().locator(`th[data-title="LastName"]`).first().locator('.nc-ui-dt-dropdown').click();
for (const item of ['Edit', 'Delete', 'Duplicate']) {
await expect(
await dashboard.rootPage.locator(`li[role="menuitem"]:has-text("${item}"):visible`).last()
).toBeVisible();
await expect(
await dashboard.rootPage.locator(`li[role="menuitem"]:has-text("${item}"):visible`).last()
).toHaveClass(/ant-dropdown-menu-item-disabled/);
await expect(dashboard.rootPage.locator(`li[role="menuitem"]:has-text("${item}"):visible`).last()).toBeVisible();
await expect(dashboard.rootPage.locator(`li[role="menuitem"]:has-text("${item}"):visible`).last()).toHaveClass(
/ant-dropdown-menu-item-disabled/
);
}
});
test('Readonly schema source - edit column', async () => {
await dashboard.treeView.openTable({
title: 'Country',
});
// Create Rating column
await dashboard.grid.column.create({
title: 'Rating',
type: 'Rating',
});
await dashboard.treeView.openProjectSourceSettings({ title: context.base.title, context });
await settingsPage.selectTab({ tab: 'dataSources' });
await dashboard.rootPage.waitForTimeout(300);
await settingsPage.source.updateSchemaReadOnly({ sourceName: 'Default', readOnly: true });
await settingsPage.close();
// reload page to reflect source changes
await dashboard.rootPage.reload();
await dashboard.treeView.verifyTable({ title: 'Country' });
// open table and verify that it is readonly
await dashboard.treeView.openTable({ title: 'Country' });
await dashboard.grid
.get()
.locator(`th[data-title="Rating"]`)
.first()
.locator('.nc-ui-dt-dropdown')
.scrollIntoViewIfNeeded();
await dashboard.grid.get().locator(`th[data-title="Rating"]`).first().locator('.nc-ui-dt-dropdown').click();
for (const item of ['Delete', 'Duplicate']) {
await expect(dashboard.rootPage.locator(`li[role="menuitem"]:has-text("${item}"):visible`).last()).toBeVisible();
await expect(dashboard.rootPage.locator(`li[role="menuitem"]:has-text("${item}"):visible`).last()).toHaveClass(
/ant-dropdown-menu-item-disabled/
);
}
await expect(await dashboard.rootPage.locator(`li[role="menuitem"]:has-text("Edit"):visible`).last()).toBeVisible();
await dashboard.rootPage.locator(`li[role="menuitem"]:has-text("Edit"):visible`).last().click();
await dashboard.rootPage.waitForTimeout(300);
await expect(
dashboard.rootPage.locator(`.nc-dropdown-edit-column .ant-form-item-label:has-text("Icon")`).last()
).toBeVisible();
await dashboard.rootPage.locator(`.nc-dropdown-edit-column`).getByTestId('nc-dropdown-rating-max').click();
await dashboard.rootPage.locator(`.nc-dropdown-rating-max-option:has-text("9")`).click();
await dashboard.grid.column.save({ isUpdated: true });
await dashboard.grid.cell.rating.select({ index: 0, columnHeader: 'Rating', rating: 6 });
await dashboard.grid.cell.rating.verify({ index: 0, columnHeader: 'Rating', rating: 6 });
});
});

Loading…
Cancel
Save