From fec16fd0b0ac3b7f72907ed24c2948e009647f98 Mon Sep 17 00:00:00 2001
From: Alexander Haller <alex@baserow.io>
Date: Thu, 1 Dec 2022 11:59:00 +0000
Subject: [PATCH] Resolve "Viewers can see row comment counts"

---
 .../GridViewRowExpandButtonWithCommentCount.vue       | 11 ++++++++++-
 .../database/components/view/grid/GridViewRow.vue     | 11 +++++++++++
 .../database/components/view/grid/GridViewRows.vue    |  1 +
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/premium/web-frontend/modules/baserow_premium/components/row_comments/GridViewRowExpandButtonWithCommentCount.vue b/premium/web-frontend/modules/baserow_premium/components/row_comments/GridViewRowExpandButtonWithCommentCount.vue
index cfd3c23d2..87c9d933a 100644
--- a/premium/web-frontend/modules/baserow_premium/components/row_comments/GridViewRowExpandButtonWithCommentCount.vue
+++ b/premium/web-frontend/modules/baserow_premium/components/row_comments/GridViewRowExpandButtonWithCommentCount.vue
@@ -1,6 +1,14 @@
 <template functional>
   <GridViewRowExpandButton
-    v-if="!props.row || !props.row._.metadata.row_comment_count"
+    v-if="
+      !props.row ||
+      !props.row._.metadata.row_comment_count ||
+      !injections.$hasPermission(
+        'database.table.list_comments',
+        props.table,
+        props.groupId
+      )
+    "
     :row="props.row"
     v-on="listeners"
   >
@@ -24,5 +32,6 @@ export default {
   name: 'GridViewRowExpandButtonWithCommentCount',
   functional: true,
   components: { GridViewRowExpandButton },
+  inject: { $hasPermission: '$hasPermission' },
 }
 </script>
diff --git a/web-frontend/modules/database/components/view/grid/GridViewRow.vue b/web-frontend/modules/database/components/view/grid/GridViewRow.vue
index bd05c28a2..187ef7bf1 100644
--- a/web-frontend/modules/database/components/view/grid/GridViewRow.vue
+++ b/web-frontend/modules/database/components/view/grid/GridViewRow.vue
@@ -64,6 +64,8 @@
             <component
               :is="rowExpandButton"
               :row="row"
+              :group-id="groupId"
+              :table="view.table"
               @edit-modal="$emit('edit-modal', row)"
             ></component>
             <component
@@ -120,7 +122,16 @@ export default {
   name: 'GridViewRow',
   components: { GridViewRowExpandButton, GridViewCell, RecursiveWrapper },
   mixins: [gridViewHelpers],
+  provide() {
+    return {
+      $hasPermission: this.$hasPermission,
+    }
+  },
   props: {
+    view: {
+      type: Object,
+      required: true,
+    },
     groupId: {
       type: Number,
       required: true,
diff --git a/web-frontend/modules/database/components/view/grid/GridViewRows.vue b/web-frontend/modules/database/components/view/grid/GridViewRows.vue
index 787b19002..5d6d91cc4 100644
--- a/web-frontend/modules/database/components/view/grid/GridViewRows.vue
+++ b/web-frontend/modules/database/components/view/grid/GridViewRows.vue
@@ -8,6 +8,7 @@
     <GridViewRow
       v-for="(row, index) in rows"
       :key="`row-${row.id}`"
+      :view="view"
       :group-id="groupId"
       :row="row"
       :fields="fields"