Skip to content

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

fix(nc-gui): some permission related changes

Ramesh Mane11108a2ddaf2
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 e37c0630ab..0e018ac8c1 100644
--- a/packages/nc-gui/components/smartsheet/grid/canvas/cells/index.ts
+++ b/packages/nc-gui/components/smartsheet/grid/canvas/cells/index.ts
@@ -331,8 +331,7 @@ export function useGridCellHandler(params: {
!isGroupHeader &&
isRootCell &&
column.uidt === UITypes.Attachment &&
- !column.readonly &&
- params.hasEditPermission.value &&
+ !readonly &&
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 19d70ab290..a4c63b37ed 100644
--- a/packages/nc-gui/components/smartsheet/grid/canvas/composables/useCopyPaste.ts
+++ b/packages/nc-gui/components/smartsheet/grid/canvas/composables/useCopyPaste.ts
@@ -193,7 +193,7 @@ export function useCopyPaste({
// Keep this check at the end so that readonly or other field restrictions get priority over permission check
if (restrictEditCell) {
if (showInfo) {
- message.toast('You do not have permission to paste into this field')
+ message.toast(t('tooltip.youDoNotHavePermissionToPasteIntoThisField'))
}
return false
}
@@ -454,7 +454,7 @@ export function useCopyPaste({
}
if (isTruncated) {
- message.warning(`Paste operation limited to ${MAX_ROWS} rows. Additional rows were truncated.`)
+ message.warning(t('tooltip.pasteOperationLimitedToMaxRows', { max: MAX_ROWS }))
}
} else {
if (selection.value.isSingleCell()) {
@@ -1141,9 +1141,11 @@ export function useCopyPaste({
const { cachedRows } = dataCache
const rowObj = (unref(cachedRows) as Map<number, Row>).get(attachmentCellDropOver.rowIndex!)
- const columnObj = unref(fields)[attachmentCellDropOver.colIndex]
+ const canvasGridColumn = (unref(columns) ?? [])[attachmentCellDropOver.colIndex]
- if (!rowObj || !columnObj) return
+ if (!rowObj || !canvasGridColumn || canvasGridColumn.readonly || !canvasGridColumn.columnObj) return
+
+ const columnObj = canvasGridColumn.columnObj
let dropValue: any
diff --git a/packages/nc-gui/components/smartsheet/grid/canvas/index.vue b/packages/nc-gui/components/smartsheet/grid/canvas/index.vue
index c34e89fcc2..0d0fdd99bd 100644
--- a/packages/nc-gui/components/smartsheet/grid/canvas/index.vue
+++ b/packages/nc-gui/components/smartsheet/grid/canvas/index.vue
@@ -2638,7 +2638,7 @@ const onDrop = (files: File[] | null) => {
const column = columns.value[attachmentCellDropOver.value.colIndex]!
- if (!row || !column) {
+ if (!row || !column || column.readonly) {
resetAttachmentCellDropOver()
return
}
@@ -2695,8 +2695,8 @@ const onOver = (_files: File[] | null, e: DragEvent) => {
const colIndex = column ? columns.value.findIndex((col) => col.id === column.id) : -1
- // If hover column is not attachment, skip
- if (ncIsUndefined(rowIndex) || !column || colIndex === -1 || column.uidt !== UITypes.Attachment) {
+ // If hover column is not attachment or is readonly, skip
+ if (ncIsUndefined(rowIndex) || !column || colIndex === -1 || column.uidt !== UITypes.Attachment || column.readonly) {
return resetAttachmentCellDropOver()
}
diff --git a/packages/nc-gui/lang/en.json b/packages/nc-gui/lang/en.json
index d8c810170f..e46531ab50 100644
--- a/packages/nc-gui/lang/en.json
+++ b/packages/nc-gui/lang/en.json
@@ -1876,7 +1876,9 @@
"thisFieldTypeDoesNotSupportFiltering": "This field type doesn't support filtering",
"thisFieldTypeDoesNotSupportGrouping": "This field type doesn't support grouping",
"filterByLimitExceeded": "Filter by limit exceeded",
- "groupByLimitExceeded": "Group by limit exceeded"
+ "groupByLimitExceeded": "Group by limit exceeded",
+ "youDoNotHavePermissionToPasteIntoThisField": "You do not have permission to paste into this field",
+ "pasteOperationLimitedToMaxRows": "Paste operation limited to {max} rows. Additional rows were truncated."
},
"placeholder": {
"searchIcons": "Search icons",