From 6eb7df717c7d7df0c035073cfffdb1fcc0660376 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Thu, 9 Nov 2023 19:14:33 -0800 Subject: [PATCH] Only show search in web app nav pane if user has documents indexed --- src/database/adapters/__init__.py | 4 ++-- src/khoj/interface/web/base_config.html | 2 +- src/khoj/interface/web/chat.html | 2 +- src/khoj/interface/web/search.html | 2 +- src/khoj/interface/web/utils.html | 4 +++- src/khoj/routers/api.py | 4 +--- src/khoj/routers/web_client.py | 17 +++++++++++++++++ 7 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/database/adapters/__init__.py b/src/database/adapters/__init__.py index 61bb82ce..70d94df3 100644 --- a/src/database/adapters/__init__.py +++ b/src/database/adapters/__init__.py @@ -371,8 +371,8 @@ class EntryAdapters: ) @staticmethod - async def user_has_entries(user: KhojUser): - return await Entry.objects.filter(user=user).aexists() + def user_has_entries(user: KhojUser): + return Entry.objects.filter(user=user).exists() @staticmethod async def adelete_entry_by_file(user: KhojUser, file_path: str): diff --git a/src/khoj/interface/web/base_config.html b/src/khoj/interface/web/base_config.html index fc1d8a0e..309fdba6 100644 --- a/src/khoj/interface/web/base_config.html +++ b/src/khoj/interface/web/base_config.html @@ -15,7 +15,7 @@ {% import 'utils.html' as utils %} - {{ utils.heading_pane(user_photo, username, is_active) }} + {{ utils.heading_pane(user_photo, username, is_active, has_documents) }}
diff --git a/src/khoj/interface/web/chat.html b/src/khoj/interface/web/chat.html index 7fd054b8..d0f94491 100644 --- a/src/khoj/interface/web/chat.html +++ b/src/khoj/interface/web/chat.html @@ -363,7 +363,7 @@ {% import 'utils.html' as utils %} - {{ utils.heading_pane(user_photo, username, is_active) }} + {{ utils.heading_pane(user_photo, username, is_active, has_documents) }}
diff --git a/src/khoj/interface/web/search.html b/src/khoj/interface/web/search.html index 00b378a2..dcd98ede 100644 --- a/src/khoj/interface/web/search.html +++ b/src/khoj/interface/web/search.html @@ -272,7 +272,7 @@ {% import 'utils.html' as utils %} - {{ utils.heading_pane(user_photo, username, is_active) }} + {{ utils.heading_pane(user_photo, username, is_active, has_documents) }} diff --git a/src/khoj/interface/web/utils.html b/src/khoj/interface/web/utils.html index 7b9c99f1..4579368b 100644 --- a/src/khoj/interface/web/utils.html +++ b/src/khoj/interface/web/utils.html @@ -1,11 +1,13 @@ -{% macro heading_pane(user_photo, username, is_active) -%} +{% macro heading_pane(user_photo, username, is_active, has_documents) -%}