Skip to content

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

fix(nc-gui): disable aggregation footer if user dont have access

Ramesh Mane7cf30d178c3a
diff --git a/packages/nc-gui/components/smartsheet/grid/canvas/composables/useCanvasRender.ts b/packages/nc-gui/components/smartsheet/grid/canvas/composables/useCanvasRender.ts
index 3e4f5c2904..229a5244c6 100644
--- a/packages/nc-gui/components/smartsheet/grid/canvas/composables/useCanvasRender.ts
+++ b/packages/nc-gui/components/smartsheet/grid/canvas/composables/useCanvasRender.ts
@@ -1959,15 +1959,16 @@ export function useCanvasRender({
const aggregationValue = column.aggregation?.toString()
- const isHovered = isBoxHovered(
- {
- x: xOffset - scrollLeft.value,
- y: height.value - AGGREGATION_HEIGHT,
- width,
- height: AGGREGATION_HEIGHT,
- },
- mousePosition,
- )
+ const isHovered =
+ isBoxHovered(
+ {
+ x: xOffset - scrollLeft.value,
+ y: height.value - AGGREGATION_HEIGHT,
+ width,
+ height: AGGREGATION_HEIGHT,
+ },
+ mousePosition,
+ ) && isViewOperationsAllowed.value
ctx.fillStyle = isHovered ? '#F4F4F5' : '#F9F9FA'
if (column.agg_fn && ![AllAggregations.None].includes(column.agg_fn as any)) {
ctx.save()
@@ -2079,7 +2080,7 @@ export function useCanvasRender({
mousePosition,
)
- ctx.fillStyle = isHovered ? '#F4F4F5' : '#F9F9FA'
+ ctx.fillStyle = isHovered && isViewOperationsAllowed.value ? '#F4F4F5' : '#F9F9FA'
ctx.fillRect(xOffset, height.value - AGGREGATION_HEIGHT, mergedWidth, AGGREGATION_HEIGHT)
ctx.fillStyle = '#6a7184'
@@ -2127,7 +2128,7 @@ export function useCanvasRender({
const w = ctx.measureText(aggregationValue ?? '').width
availWidth -= w
ctx.restore()
- } else if (isHovered) {
+ } else if (isHovered && isViewOperationsAllowed.value) {
if (!isLocked.value) {
ctx.save()
ctx.beginPath()
diff --git a/packages/nc-gui/components/smartsheet/grid/canvas/index.vue b/packages/nc-gui/components/smartsheet/grid/canvas/index.vue
index d9099f00de..fad160d4d7 100644
--- a/packages/nc-gui/components/smartsheet/grid/canvas/index.vue
+++ b/packages/nc-gui/components/smartsheet/grid/canvas/index.vue
@@ -1428,6 +1428,9 @@ async function handleMouseUp(e: MouseEvent, _elementMap: CanvasElement) {
handleUnlockView()
return
}
+
+ if (isLocked.value || !isViewOperationsAllowed.value) return
+
// If the click is not normal single click, return
const { column: clickedColumn, xOffset } = findClickedColumn(x, scrollLeft.value)
@@ -1983,6 +1986,8 @@ const handleMouseMove = (e: MouseEvent) => {
if (y <= headerRowHeight.value && resizeableColumn.value) {
resizeMouseMove(e)
} else if (mousePosition.y > height.value - 36) {
+ if (!isViewOperationsAllowed.value) return
+
cursor = mousePosition.x < totalColumnsWidth.value - scrollLeft.value ? 'pointer' : 'auto'
setCursor(cursor)
requestAnimationFrame(triggerRefreshCanvas)