aboutsummaryrefslogtreecommitdiffstats
path: root/apps/web
diff options
context:
space:
mode:
authorMohamed Bassem <me@mbassem.com>2025-01-12 20:03:47 +0000
committerMohamed Bassem <me@mbassem.com>2025-01-12 20:03:47 +0000
commit9fd26b472b18924ab11afcebace90329b0fe3abf (patch)
tree04d2a8f8603978c27611574d663dfc58b3f285b0 /apps/web
parentc5298cf4b43795c0c261922ef0ad0f20245be4d5 (diff)
downloadkarakeep-9fd26b472b18924ab11afcebace90329b0fe3abf.tar.zst
feat: Add ability to filter by bookmark type
Diffstat (limited to 'apps/web')
-rw-r--r--apps/web/components/dashboard/search/QueryExplainerTooltip.tsx16
-rw-r--r--apps/web/lib/i18n/locales/en/translation.json10
-rw-r--r--apps/web/lib/utils.ts14
3 files changed, 39 insertions, 1 deletions
diff --git a/apps/web/components/dashboard/search/QueryExplainerTooltip.tsx b/apps/web/components/dashboard/search/QueryExplainerTooltip.tsx
index f5f73be3..37815b0a 100644
--- a/apps/web/components/dashboard/search/QueryExplainerTooltip.tsx
+++ b/apps/web/components/dashboard/search/QueryExplainerTooltip.tsx
@@ -1,6 +1,7 @@
import InfoTooltip from "@/components/ui/info-tooltip";
import { Table, TableBody, TableCell, TableRow } from "@/components/ui/table";
import { useTranslation } from "@/lib/i18n/client";
+import { match } from "@/lib/utils";
import { TextAndMatcher } from "@hoarder/shared/searchQueryParser";
import { Matcher } from "@hoarder/shared/types/search";
@@ -134,6 +135,21 @@ export default function QueryExplainerTooltip({
<TableCell>{matcher.url}</TableCell>
</TableRow>
);
+ case "type":
+ return (
+ <TableRow>
+ <TableCell>
+ {matcher.inverse ? t("search.type_is_not") : t("search.type_is")}
+ </TableCell>
+ <TableCell>
+ {match(matcher.typeName, {
+ link: t("common.bookmark_types.link"),
+ text: t("common.bookmark_types.text"),
+ asset: t("common.bookmark_types.media"),
+ })}
+ </TableCell>
+ </TableRow>
+ );
default: {
const _exhaustiveCheck: never = matcher;
return null;
diff --git a/apps/web/lib/i18n/locales/en/translation.json b/apps/web/lib/i18n/locales/en/translation.json
index ac08fa3f..1e9f8e4d 100644
--- a/apps/web/lib/i18n/locales/en/translation.json
+++ b/apps/web/lib/i18n/locales/en/translation.json
@@ -24,7 +24,13 @@
"screenshot": "Screenshot",
"video": "Video",
"archive": "Archive",
- "home": "Home"
+ "home": "Home",
+ "bookmark_types": {
+ "title": "Bookmark Type",
+ "link": "Link",
+ "text": "Text",
+ "media": "Media"
+ }
},
"layouts": {
"masonry": "Masonry",
@@ -218,6 +224,8 @@
"has_tag": "Has Tag",
"does_not_have_tag": "Does Not Have Tag",
"full_text_search": "Full Text Search",
+ "type_is": "Type is",
+ "type_is_not": "Type is not",
"and": "And",
"or": "Or"
},
diff --git a/apps/web/lib/utils.ts b/apps/web/lib/utils.ts
index 12207765..230c9eef 100644
--- a/apps/web/lib/utils.ts
+++ b/apps/web/lib/utils.ts
@@ -29,3 +29,17 @@ export function getOS() {
}
return os;
}
+
+export function match<T extends string | number | symbol, U>(
+ val: T,
+ options: Record<T, U>,
+) {
+ return options[val];
+}
+
+export function matchFunc<T extends string | number | symbol, U>(
+ val: T,
+ options: Record<T, () => U>,
+) {
+ return options[val]();
+}