Skip to content

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

fix(nc-gui): restrict drop operation if user dont have permission

Ramesh Mane769bcbde5982
diff --git a/packages/nc-gui/components/smartsheet/grid/canvas/cells/index.ts b/packages/nc-gui/components/smartsheet/grid/canvas/cells/index.ts
index 7a561332a9..e37c0630ab 100644
--- a/packages/nc-gui/components/smartsheet/grid/canvas/cells/index.ts
+++ b/packages/nc-gui/components/smartsheet/grid/canvas/cells/index.ts
@@ -332,6 +332,7 @@ export function useGridCellHandler(params: {
isRootCell &&
column.uidt === UITypes.Attachment &&
!column.readonly &&
+ params.hasEditPermission.value &&
params.attachmentCellDropOver.value &&
comparePath(path, params.attachmentCellDropOver.value.path ?? []) &&
params.attachmentCellDropOver.value.columnId === column.id &&
diff --git a/packages/nc-gui/components/smartsheet/grid/canvas/composables/useCopyPaste.ts b/packages/nc-gui/components/smartsheet/grid/canvas/composables/useCopyPaste.ts
index ec11c469dc..19d70ab290 100644
--- a/packages/nc-gui/components/smartsheet/grid/canvas/composables/useCopyPaste.ts
+++ b/packages/nc-gui/components/smartsheet/grid/canvas/composables/useCopyPaste.ts
@@ -1132,6 +1132,8 @@ export function useCopyPaste({
}
const handleAttachmentCellDrop = async (files: File[], attachmentCellDropOver: AttachmentCellDropOverType) => {
+ if (isSqlView.value || isPublic.value || !hasEditPermission.value) return false
+
if (!meta.value?.id) return
const dataCache = getDataCache(attachmentCellDropOver.path)
diff --git a/packages/nc-gui/components/smartsheet/grid/canvas/index.vue b/packages/nc-gui/components/smartsheet/grid/canvas/index.vue
index 52a608ad52..c34e89fcc2 100644
--- a/packages/nc-gui/components/smartsheet/grid/canvas/index.vue
+++ b/packages/nc-gui/components/smartsheet/grid/canvas/index.vue
@@ -2625,7 +2625,7 @@ const resetAttachmentCellDropOver = () => {
}
const onDrop = (files: File[] | null) => {
- if (!attachmentCellDropOver.value || !files?.length) {
+ if (!attachmentCellDropOver.value || !files?.length || !isDataEditAllowed.value) {
return
}
@@ -2661,6 +2661,8 @@ const onDrop = (files: File[] | null) => {
}
const onOver = (_files: File[] | null, e: DragEvent) => {
+ if (!isDataEditAllowed.value) return
+
const rect = canvasRef.value?.getBoundingClientRect()
if (!rect) return