aboutsummaryrefslogtreecommitdiffstats
path: root/apps/web/components/dashboard/feeds/FeedSelector.tsx
diff options
context:
space:
mode:
authorMohamed Bassem <me@mbassem.com>2025-04-27 00:02:20 +0100
committerGitHub <noreply@github.com>2025-04-27 00:02:20 +0100
commit136f126296af65f50da598d084d1485c0e40437a (patch)
tree2725c7932ebbcb9b48b5af98eb9b72329a400260 /apps/web/components/dashboard/feeds/FeedSelector.tsx
parentca47be7fe7be128f459c37614a04902a873fe289 (diff)
downloadkarakeep-136f126296af65f50da598d084d1485c0e40437a.tar.zst
feat: Implement generic rule engine (#1318)
* Add schema for the new rule engine * Add rule engine backend logic * Implement the worker logic and event firing * Implement the UI changesfor the rule engine * Ensure that when a referenced list or tag are deleted, the corresponding event/action is * Dont show smart lists in rule engine events * Add privacy validations for attached tag and list ids * Move the rules logic into a models
Diffstat (limited to 'apps/web/components/dashboard/feeds/FeedSelector.tsx')
-rw-r--r--apps/web/components/dashboard/feeds/FeedSelector.tsx53
1 files changed, 53 insertions, 0 deletions
diff --git a/apps/web/components/dashboard/feeds/FeedSelector.tsx b/apps/web/components/dashboard/feeds/FeedSelector.tsx
new file mode 100644
index 00000000..db95a042
--- /dev/null
+++ b/apps/web/components/dashboard/feeds/FeedSelector.tsx
@@ -0,0 +1,53 @@
+import {
+ Select,
+ SelectContent,
+ SelectGroup,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from "@/components/ui/select";
+import LoadingSpinner from "@/components/ui/spinner";
+import { api } from "@/lib/trpc";
+import { cn } from "@/lib/utils";
+
+export function FeedSelector({
+ value,
+ onChange,
+ placeholder = "Select a feed",
+ className,
+}: {
+ className?: string;
+ value?: string | null;
+ onChange: (value: string) => void;
+ placeholder?: string;
+}) {
+ const { data, isPending } = api.feeds.list.useQuery(undefined, {
+ select: (data) => data.feeds,
+ });
+
+ if (isPending) {
+ return <LoadingSpinner />;
+ }
+
+ return (
+ <Select onValueChange={onChange} value={value ?? ""}>
+ <SelectTrigger className={cn("w-full", className)}>
+ <SelectValue placeholder={placeholder} />
+ </SelectTrigger>
+ <SelectContent>
+ <SelectGroup>
+ {data?.map((f) => (
+ <SelectItem key={f.id} value={f.id}>
+ {f.name}
+ </SelectItem>
+ ))}
+ {(data ?? []).length == 0 && (
+ <SelectItem value="nofeed" disabled>
+ You don&apos;t currently have any feeds.
+ </SelectItem>
+ )}
+ </SelectGroup>
+ </SelectContent>
+ </Select>
+ );
+}