Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

feat: allow editors to update view settings on personal views

Pranav C65803ba858ca
diff --git a/packages/nc-gui/components/smartsheet/toolbar/RowHeight.vue b/packages/nc-gui/components/smartsheet/toolbar/RowHeight.vue
index 614968c109..d32c51b3f8 100644
--- a/packages/nc-gui/components/smartsheet/toolbar/RowHeight.vue
+++ b/packages/nc-gui/components/smartsheet/toolbar/RowHeight.vue
@@ -32,14 +32,16 @@ const isPublic = inject(IsPublicInj, ref(false))
const isLocked = inject(IsLockedInj, ref(false))
-const { isUIAllowed } = useRoles()
+const { canUpdateViewMeta } = useViewColumnsOrThrow()
const { addUndo, defineViewScope } = useUndoRedo()
+const isRestrictedEditor = computed(() => isLocked.value || !canUpdateViewMeta.value)
+
const open = ref(false)
const updateRowHeight = async (rh: number, undo = false) => {
- if (isLocked.value) return
+ if (isRestrictedEditor.value) return
if (view.value?.id) {
if (rh === (view.value.view as GridType).row_height) return
@@ -65,7 +67,7 @@ const updateRowHeight = async (rh: number, undo = false) => {
row_height: rh,
},
{
- skipNetworkCall: isPublic.value || isSharedBase.value || !isUIAllowed('viewCreateOrEdit'),
+ skipNetworkCall: isPublic.value || isSharedBase.value || !canUpdateViewMeta.value,
},
)
@@ -93,7 +95,7 @@ useMenuCloseOnEsc(open)
class="nc-height-menu-btn nc-toolbar-btn !border-0 !h-7 !px-1.5 !min-w-7"
size="small"
type="secondary"
- :show-as-disabled="isLocked"
+ :show-as-disabled="isRestrictedEditor"
>
<div class="flex items-center gap-0.5">
<component :is="iconMap.rowHeight" class="!h-3.75 !w-3.75" />
diff --git a/packages/nc-gui/composables/useViewColumns.ts b/packages/nc-gui/composables/useViewColumns.ts
index 9991478546..2024e245df 100644
--- a/packages/nc-gui/composables/useViewColumns.ts
+++ b/packages/nc-gui/composables/useViewColumns.ts
@@ -1,5 +1,5 @@
import type { ButtonType, ColumnType, GridColumnReqType, GridColumnType, MapType, TableType, ViewType } from 'nocodb-sdk'
-import { CommonAggregations, ViewTypes, getFirstNonPersonalView, isHiddenCol, isSystemColumn } from 'nocodb-sdk'
+import { CommonAggregations, ViewLockType, ViewTypes, getFirstNonPersonalView, isHiddenCol, isSystemColumn } from 'nocodb-sdk'
import type { ComputedRef, Ref } from 'vue'
const [useProvideViewColumns, useViewColumns] = useInjectionState(
@@ -50,10 +50,21 @@ const [useProvideViewColumns, useViewColumns] = useInjectionState(
const { addUndo, defineViewScope } = useUndoRedo()
+ const { isUserViewOwner } = useViewsStore()
+
const isLocalMode = computed(() => isPublic || !isUIAllowed('viewFieldEdit') || isSharedBase.value)
const hasViewFieldDataEditPermission = computed(() => isUIAllowed('viewFieldDataEdit'))
+ // Check if user can update view meta (row height, etc.) based on role OR personal view ownership
+ const canUpdateViewMeta = computed(() => {
+ // If user has role permission to update views, allow it
+ if (isUIAllowed('viewCreateOrEdit')) return true
+ // If this is a personal view owned by current user, allow updates
+ if (view.value?.lock_type === ViewLockType.Personal && isUserViewOwner(view.value)) return true
+ return false
+ })
+
const localChanges = ref<Record<string, Field>>({})
const isColumnViewEssential = (column: ColumnType) => {
@@ -691,6 +702,7 @@ const [useProvideViewColumns, useViewColumns] = useInjectionState(
updateDefaultViewColumnMeta,
hidingViewColumnsMap,
hasViewFieldDataEditPermission,
+ canUpdateViewMeta,
}
},
'useViewColumnsOrThrow',
diff --git a/packages/nocodb/src/controllers/internal.controller.ts b/packages/nocodb/src/controllers/internal.controller.ts
index 57a51931db..fa028b86cc 100644
--- a/packages/nocodb/src/controllers/internal.controller.ts
+++ b/packages/nocodb/src/controllers/internal.controller.ts
@@ -59,7 +59,7 @@ export class InternalController {
req: NcRequest,
scope?: string,
) {
- // For filter/sort operations, extract view to check personal view ownership
+ // For filter/sort/view operations, extract view to check personal view ownership
const filterSortOperations = [
'filterList',
'filterChildrenList',
@@ -73,6 +73,12 @@ export class InternalController {
'viewColumnUpdate',
'hideAllColumns',
'showAllColumns',
+ 'gridViewUpdate',
+ 'gridColumnUpdate',
+ 'galleryViewUpdate',
+ 'kanbanViewUpdate',
+ 'mapViewUpdate',
+ 'calendarViewUpdate',
];
if (filterSortOperations.includes(operation as string)) {
diff --git a/packages/nocodb/src/utils/acl.ts b/packages/nocodb/src/utils/acl.ts
index 7b649967d3..ccce6b7d20 100644
--- a/packages/nocodb/src/utils/acl.ts
+++ b/packages/nocodb/src/utils/acl.ts
@@ -342,7 +342,7 @@ const rolePermissions:
// etc
fetchViaUrl: true,
- // Sort/Filter/ViewColumn operations for personal views (middleware handles ownership check)
+ // Sort/Filter/ViewColumn/View operations for personal views (middleware handles ownership check)
sortCreate: true,
sortUpdate: true,
sortDelete: true,
@@ -353,6 +353,11 @@ const rolePermissions:
hideAllColumns: true,
showAllColumns: true,
gridColumnUpdate: true,
+ gridViewUpdate: true,
+ galleryViewUpdate: true,
+ kanbanViewUpdate: true,
+ mapViewUpdate: true,
+ calendarViewUpdate: true,
},
},
[ProjectRoles.CREATOR]: {