From 5ecdc36b7d60aa66b49e01e9fec8ba61ad537376 Mon Sep 17 00:00:00 2001
From: Mohamed Bassem <me@mbassem.com>
Date: Thu, 2 Jan 2025 13:00:58 +0200
Subject: feat: Add support for smart lists (#802)

* feat: Add support for smart lists

* i18n

* Fix update list endpoint

* Add a test for smart lists

* Add header to the query explainer

* Hide remove from lists in the smart context list

* Add proper validation to list form

---------

Co-authored-by: Deepak Kapoor <41769111+orthdron@users.noreply.github.com>
---
 .../components/dashboard/search/SearchInput.tsx    | 24 +++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

(limited to 'apps/web/components/dashboard/search/SearchInput.tsx')

diff --git a/apps/web/components/dashboard/search/SearchInput.tsx b/apps/web/components/dashboard/search/SearchInput.tsx
index 8ed2ea3c..ace3d785 100644
--- a/apps/web/components/dashboard/search/SearchInput.tsx
+++ b/apps/web/components/dashboard/search/SearchInput.tsx
@@ -1,11 +1,13 @@
 "use client";
 
-import React, { useEffect, useImperativeHandle, useRef } from "react";
+import React, { useEffect, useImperativeHandle, useRef, useState } from "react";
+import { Button } from "@/components/ui/button";
 import { Input } from "@/components/ui/input";
 import { useDoBookmarkSearch } from "@/lib/hooks/bookmark-search";
 import { useTranslation } from "@/lib/i18n/client";
 import { cn } from "@/lib/utils";
 
+import { EditListModal } from "../lists/EditListModal";
 import QueryExplainerTooltip from "./QueryExplainerTooltip";
 
 function useFocusSearchOnKeyPress(
@@ -63,6 +65,7 @@ const SearchInput = React.forwardRef<
 
   useFocusSearchOnKeyPress(inputRef, onChange);
   useImperativeHandle(ref, () => inputRef.current!);
+  const [newNestedListModalOpen, setNewNestedListModalOpen] = useState(false);
 
   useEffect(() => {
     if (!isInSearchPage) {
@@ -72,10 +75,29 @@ const SearchInput = React.forwardRef<
 
   return (
     <div className={cn("relative flex-1", className)}>
+      <EditListModal
+        open={newNestedListModalOpen}
+        setOpen={setNewNestedListModalOpen}
+        prefill={{
+          type: "smart",
+          query: value,
+        }}
+      />
       <QueryExplainerTooltip
         className="-translate-1/2 absolute right-1.5 top-2 p-0.5"
         parsedSearchQuery={parsedSearchQuery}
       />
+      {parsedSearchQuery.result === "full" &&
+        parsedSearchQuery.text.length == 0 && (
+          <Button
+            onClick={() => setNewNestedListModalOpen(true)}
+            size="none"
+            variant="secondary"
+            className="absolute right-9 top-2 z-50 px-2 py-1 text-xs"
+          >
+            {t("actions.save")}
+          </Button>
+        )}
       <Input
         ref={inputRef}
         value={value}
-- 
cgit v1.2.3-70-g09d2

