Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import {
Check,
GripVertical,
Image as ImageIcon,
MousePointer2,
NotebookPen,
Rss,
} from "lucide-react";
import { useTheme } from "next-themes";
import { toast } from "sonner";
Expand Down Expand Up @@ -78,6 +80,36 @@ function BottomRow({
);
}

function SourceIndicator({ bookmark }: { bookmark: ZBookmark }) {
const { t } = useTranslation();
if (bookmark.source === "rss") {
return (
<div
className="flex h-5 w-5 items-center justify-center rounded-full bg-orange-100 text-orange-600 dark:bg-orange-900/30 dark:text-orange-400"
title={t("common.bookmark_sources.rss")}
>
<Rss size={12} />
</div>
);
}

// Show a "manual" indicator for everything else except API/Import maybe?
// For now let's just show it for web/extension/mobile/cli
const manualSources = ["web", "extension", "mobile", "cli"];
if (manualSources.includes(bookmark.source)) {
return (
<div
className="flex h-5 w-5 items-center justify-center rounded-full bg-blue-100 text-blue-600 dark:bg-blue-900/30 dark:text-blue-400"
title={t(`common.bookmark_sources.${bookmark.source}`)}
>
<MousePointer2 size={12} />
</div>
);
}

return null;
}

function OwnerIndicator({ bookmark }: { bookmark: ZBookmark }) {
const api = useTRPC();
const listContext = useBookmarkListContext();
Expand Down Expand Up @@ -313,6 +345,9 @@ function ListView({
className="left-1 top-1/2 -translate-y-1/2"
/>
<HoverActionBar bookmark={bookmark} />
<div className="absolute left-2 top-2 z-40">
<SourceIndicator bookmark={bookmark} />
</div>
<div className="flex size-32 items-center justify-center overflow-hidden">
{image("list", cn("size-32 rounded-lg", imgFitClass))}
</div>
Expand Down Expand Up @@ -375,6 +410,9 @@ function GridView({
<OwnerIndicator bookmark={bookmark} />
<DragHandle bookmark={bookmark} className="left-2 top-2" />
<HoverActionBar bookmark={bookmark} />
<div className="absolute right-10 top-2 z-40">
<SourceIndicator bookmark={bookmark} />
</div>
{img && <div className="h-56 w-full shrink-0 overflow-hidden">{img}</div>}
<div className="flex h-full flex-col justify-between gap-2 overflow-hidden p-2">
<div className="grow-1 flex flex-col gap-2 overflow-hidden">
Expand Down Expand Up @@ -415,6 +453,7 @@ function CompactView({ bookmark, title, footer, className }: Props) {
<OwnerIndicator bookmark={bookmark} />
<div className="flex h-full justify-between gap-2 overflow-hidden p-2">
<div className="flex items-center gap-2">
<SourceIndicator bookmark={bookmark} />
{bookmark.content.type === BookmarkTypes.LINK &&
bookmark.content.favicon && (
<Image
Expand Down
54 changes: 54 additions & 0 deletions apps/web/components/dashboard/rules/RuleEngineConditionBuilder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
Archive,
ChevronDown,
ChevronRight,
Database,
FileType,
Heading,
Link,
Expand Down Expand Up @@ -75,6 +76,9 @@ export function ConditionBuilder({
case "bookmarkTypeIs":
onChange({ type: "bookmarkTypeIs", bookmarkType: "link" });
break;
case "bookmarkSourceIs":
onChange({ type: "bookmarkSourceIs", source: "web" });
break;
case "hasTag":
onChange({ type: "hasTag", tagId: "" });
break;
Expand Down Expand Up @@ -112,6 +116,8 @@ export function ConditionBuilder({
return <Rss className="h-4 w-4" />;
case "bookmarkTypeIs":
return <FileType className="h-4 w-4" />;
case "bookmarkSourceIs":
return <Database className="h-4 w-4" />;
case "hasTag":
return <Tag className="h-4 w-4" />;
case "isFavourited":
Expand Down Expand Up @@ -214,6 +220,51 @@ export function ConditionBuilder({
</div>
);

case "bookmarkSourceIs":
return (
<div className="mt-2">
<Select
value={value.source}
onValueChange={(source) =>
onChange({
...value,
source: source as "api" | "web" | "cli" | "mobile" | "extension" | "singlefile" | "rss" | "import",
})
}
>
<SelectTrigger>
<SelectValue placeholder="Select bookmark source" />
</SelectTrigger>
<SelectContent>
<SelectItem value="web">
{t("common.bookmark_sources.web")}
</SelectItem>
<SelectItem value="extension">
{t("common.bookmark_sources.extension")}
</SelectItem>
<SelectItem value="mobile">
{t("common.bookmark_sources.mobile")}
</SelectItem>
<SelectItem value="rss">
{t("common.bookmark_sources.rss")}
</SelectItem>
<SelectItem value="api">
{t("common.bookmark_sources.api")}
</SelectItem>
<SelectItem value="cli">
{t("common.bookmark_sources.cli")}
</SelectItem>
<SelectItem value="singlefile">
{t("common.bookmark_sources.singlefile")}
</SelectItem>
<SelectItem value="import">
{t("common.bookmark_sources.import")}
</SelectItem>
</SelectContent>
</Select>
</div>
);

case "hasTag":
return (
<div className="mt-2">
Expand Down Expand Up @@ -314,6 +365,9 @@ export function ConditionBuilder({
<SelectItem value="bookmarkTypeIs">
{t("settings.rules.conditions_types.bookmark_type_is")}
</SelectItem>
<SelectItem value="bookmarkSourceIs">
{t("settings.rules.conditions_types.bookmark_source_is")}
</SelectItem>
<SelectItem value="hasTag">
{t("settings.rules.conditions_types.has_tag")}
</SelectItem>
Expand Down
14 changes: 12 additions & 2 deletions apps/web/lib/i18n/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@
"text": "Text",
"media": "Media"
},
"bookmark_sources": {
"api": "API",
"web": "Web",
"extension": "Browser Extension",
"cli": "CLI",
"mobile": "Mobile",
"singlefile": "SingleFile",
"rss": "RSS Feed",
"import": "Import"
},
"quota": "Quota",
"bookmarks": "Bookmarks",
"storage": "Storage"
Expand Down Expand Up @@ -370,8 +380,8 @@
"has_tag": "Has Tag",
"is_favourited": "Is Favourited",
"is_archived": "Is Archived",
"and": "All of the following are true",
"or": "Any of the following are true"
"bookmark_source_is": "Bookmark Source Is",
"and": "All of the following are true", "or": "Any of the following are true"
},
"actions_types": {
"add_tag": "Add Tag",
Expand Down
Loading