From a0b4751daa92f72d0dfcc31bbccba82e1cc52e59 Mon Sep 17 00:00:00 2001
From: Bram Wiepjes <bramw@protonmail.com>
Date: Thu, 11 Jul 2024 09:43:17 +0200
Subject: [PATCH] Allow disabling live support via env vars

---
 .env.example                                             | 1 +
 docker-compose.local-build.yml                           | 1 +
 docker-compose.no-caddy.yml                              | 1 +
 docker-compose.yml                                       | 1 +
 docs/installation/configuration.md                       | 1 +
 .../web-frontend/modules/baserow_enterprise/plugins.js   | 9 +++++----
 web-frontend/modules/core/module.js                      | 1 +
 7 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/.env.example b/.env.example
index b8b75e3e6..43696aade 100644
--- a/.env.example
+++ b/.env.example
@@ -118,6 +118,7 @@ DATABASE_NAME=baserow
 # BASEROW_DISABLE_PUBLIC_URL_CHECK=
 # DOWNLOAD_FILE_VIA_XHR=
 # BASEROW_DISABLE_GOOGLE_DOCS_FILE_PREVIEW=
+# BASEROW_DISABLE_SUPPORT=
 
 # BASEROW_PLUGIN_GIT_REPOS=
 # BASEROW_PLUGIN_URLS=
diff --git a/docker-compose.local-build.yml b/docker-compose.local-build.yml
index 7321b38d5..c234497b3 100644
--- a/docker-compose.local-build.yml
+++ b/docker-compose.local-build.yml
@@ -205,6 +205,7 @@ services:
       INITIAL_TABLE_DATA_LIMIT:
       DOWNLOAD_FILE_VIA_XHR:
       BASEROW_DISABLE_GOOGLE_DOCS_FILE_PREVIEW:
+      BASEROW_DISABLE_SUPPORT:
       HOURS_UNTIL_TRASH_PERMANENTLY_DELETED:
       DISABLE_ANONYMOUS_PUBLIC_VIEW_WS_CONNECTIONS:
       FEATURE_FLAGS:
diff --git a/docker-compose.no-caddy.yml b/docker-compose.no-caddy.yml
index 834cc6fd3..54797e614 100644
--- a/docker-compose.no-caddy.yml
+++ b/docker-compose.no-caddy.yml
@@ -198,6 +198,7 @@ services:
       INITIAL_TABLE_DATA_LIMIT:
       DOWNLOAD_FILE_VIA_XHR:
       BASEROW_DISABLE_GOOGLE_DOCS_FILE_PREVIEW:
+      BASEROW_DISABLE_SUPPORT:
       HOURS_UNTIL_TRASH_PERMANENTLY_DELETED:
       DISABLE_ANONYMOUS_PUBLIC_VIEW_WS_CONNECTIONS:
       FEATURE_FLAGS:
diff --git a/docker-compose.yml b/docker-compose.yml
index 0968835c5..5bbc5fa11 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -229,6 +229,7 @@ services:
       INITIAL_TABLE_DATA_LIMIT:
       DOWNLOAD_FILE_VIA_XHR:
       BASEROW_DISABLE_GOOGLE_DOCS_FILE_PREVIEW:
+      BASEROW_DISABLE_SUPPORT:
       HOURS_UNTIL_TRASH_PERMANENTLY_DELETED:
       DISABLE_ANONYMOUS_PUBLIC_VIEW_WS_CONNECTIONS:
       FEATURE_FLAGS:
diff --git a/docs/installation/configuration.md b/docs/installation/configuration.md
index 153d7ea0f..55d9f35af 100644
--- a/docs/installation/configuration.md
+++ b/docs/installation/configuration.md
@@ -277,6 +277,7 @@ domain than your Baserow, you need to make sure CORS is configured correctly.
 | BASEROW\_UNIQUE\_ROW\_VALUES\_SIZE\_LIMIT     | Sets the limit for the automatic detection of multiselect options when converting a text field to a multiselect field. Increase the value to detect more options automatically, but consider performance implications.                                                                                           | 100            |
 | BASEROW\_BUILDER\_DOMAINS                     | A comma separated list of domain names that can be used as the domains to create sub domains in the application builder.                                                                                                                                                                                         |                |
 | BASEROW\_FRONTEND\_SAME\_SITE\_COOKIE         | String value indicating what the sameSite value of the created cookies should be.                                                                                                                                                                                                                                | lax            |
+| BASEROW\_DISABLE\_SUPPORT                     | Set to any value to disable the support features in Baserow.                                                                                                                                                                                                                                                     |                |
 
 
 ### SSO Configuration
diff --git a/enterprise/web-frontend/modules/baserow_enterprise/plugins.js b/enterprise/web-frontend/modules/baserow_enterprise/plugins.js
index a220f8aff..fe8c3871a 100644
--- a/enterprise/web-frontend/modules/baserow_enterprise/plugins.js
+++ b/enterprise/web-frontend/modules/baserow_enterprise/plugins.js
@@ -16,10 +16,11 @@ export class EnterprisePlugin extends BaserowPlugin {
   }
 
   getSidebarWorkspaceComponents(workspace) {
-    const sidebarItems = [
-      ChatwootSupportSidebarWorkspace,
-      AuditLogSidebarWorkspace,
-    ]
+    const sidebarItems = []
+    if (!this.app.$config.BASEROW_DISABLE_SUPPORT) {
+      sidebarItems.push(ChatwootSupportSidebarWorkspace)
+    }
+    sidebarItems.push(AuditLogSidebarWorkspace)
     return sidebarItems
   }
 
diff --git a/web-frontend/modules/core/module.js b/web-frontend/modules/core/module.js
index 1cf45a4bc..e08371a2d 100644
--- a/web-frontend/modules/core/module.js
+++ b/web-frontend/modules/core/module.js
@@ -105,6 +105,7 @@ export default function CoreModule(options) {
       : [],
     BASEROW_FRONTEND_SAME_SITE_COOKIE:
       process.env.BASEROW_FRONTEND_SAME_SITE_COOKIE ?? 'lax',
+    BASEROW_DISABLE_SUPPORT: process.env.BASEROW_DISABLE_SUPPORT ?? '',
   }
 
   this.options.publicRuntimeConfig.BASEROW_EMBEDDED_SHARE_URL =