Skip to content
Merged
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
81 changes: 81 additions & 0 deletions web/src/components/ui/select.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import * as React from "react";
import * as SelectPrimitive from "@radix-ui/react-select";
import { Check, ChevronDown } from "lucide-react";
import { cn } from "@/lib/utils";

const Select = SelectPrimitive.Root;

const SelectValue = SelectPrimitive.Value;

const SelectTrigger = React.forwardRef<
React.ComponentRef<typeof SelectPrimitive.Trigger>,
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>
>(({ className, children, ...props }, ref) => (
<SelectPrimitive.Trigger
ref={ref}
className={cn(
"flex h-9 w-full items-center justify-between gap-2 rounded-md border border-input bg-background px-3 py-2 text-body-sm text-foreground shadow-1 transition-colors duration-(--duration-fast) ease-(--ease-standard) hover:bg-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[placeholder]:text-muted-foreground [&>span]:truncate",
className,
)}
{...props}
>
{children}
<SelectPrimitive.Icon asChild>
<ChevronDown className="h-4 w-4 shrink-0 text-muted-foreground" />
</SelectPrimitive.Icon>
</SelectPrimitive.Trigger>
));
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;

const SelectContent = React.forwardRef<
React.ComponentRef<typeof SelectPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>
>(({ className, children, position = "popper", ...props }, ref) => (
<SelectPrimitive.Portal>
<SelectPrimitive.Content
ref={ref}
position={position}
sideOffset={4}
className={cn(
"relative z-50 max-h-72 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-2",
className,
)}
{...props}
>
<SelectPrimitive.Viewport
className={cn(
"p-1",
position === "popper" &&
"w-full min-w-[var(--radix-select-trigger-width)]",
)}
>
{children}
</SelectPrimitive.Viewport>
</SelectPrimitive.Content>
</SelectPrimitive.Portal>
));
SelectContent.displayName = SelectPrimitive.Content.displayName;

const SelectItem = React.forwardRef<
React.ComponentRef<typeof SelectPrimitive.Item>,
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>
>(({ className, children, ...props }, ref) => (
<SelectPrimitive.Item
ref={ref}
className={cn(
"relative flex w-full cursor-pointer select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-body-sm outline-none transition-colors duration-(--duration-fast) ease-(--ease-standard) data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground",
className,
)}
{...props}
>
<span className="absolute right-2 flex h-3.5 w-3.5 items-center justify-center">
<SelectPrimitive.ItemIndicator>
<Check className="h-4 w-4" />
</SelectPrimitive.ItemIndicator>
</span>
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
</SelectPrimitive.Item>
));
SelectItem.displayName = SelectPrimitive.Item.displayName;

export { Select, SelectTrigger, SelectValue, SelectContent, SelectItem };
8 changes: 8 additions & 0 deletions web/src/lib/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,11 @@ export const CHANNELS = [
{ id: "feishu", label: "Lark Bot" },
{ id: "discord", label: "Discord" },
] as const;

/**
* Friendly label for a channel id. Unknown ids (retired channels, or names
* written by another build) fall back to the id itself so nothing is hidden.
*/
export function getChannelLabel(id: string): string {
return CHANNELS.find((channel) => channel.id === id)?.label ?? id;
}
15 changes: 14 additions & 1 deletion web/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,20 @@
"noContent": "No message content for this record",
"emptyTitle": "No history yet",
"emptyDesc": "Sent notifications will be recorded here.",
"loadError": "Failed to load history"
"loadError": "Failed to load history",
"sourceItem": "Item",
"sourceApi": "API",
"sourceTest": "Test",
"filterChannel": "Channel",
"allChannels": "All channels",
"filterAll": "All",
"filterSuccess": "Success only",
"filterFailed": "Failed only",
"filterStatus": "Filter by status",
"failureReason": "Failure reason",
"clearFilters": "Clear filters",
"emptyFilteredTitle": "No records match these filters",
"emptyFilteredDesc": "Try another channel or status."
},
"admin": {
"title": "Admin Panel",
Expand Down
15 changes: 14 additions & 1 deletion web/src/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,20 @@
"noContent": "该记录无消息内容",
"emptyTitle": "还没有发送记录",
"emptyDesc": "通知发出后会在这里留下账目。",
"loadError": "发送记录加载失败"
"loadError": "发送记录加载失败",
"sourceItem": "事项",
"sourceApi": "API",
"sourceTest": "测试",
"filterChannel": "渠道",
"allChannels": "全部渠道",
"filterAll": "全部",
"filterSuccess": "仅成功",
"filterFailed": "仅失败",
"filterStatus": "状态筛选",
"failureReason": "失败原因",
"clearFilters": "清除筛选",
"emptyFilteredTitle": "没有符合筛选条件的记录",
"emptyFilteredDesc": "换一个渠道或状态试试。"
},
"admin": {
"title": "管理后台",
Expand Down
Loading
Loading