({ className }: Props)
| 10 | } |
| 11 | |
| 12 | function MemoDisplaySettingMenu({ className }: Props) { |
| 13 | const t = useTranslate(); |
| 14 | const { orderByTimeAsc, timeBasis, setTimeBasis, toggleSortOrder } = useView(); |
| 15 | const isApplying = orderByTimeAsc !== false || timeBasis !== "create_time"; |
| 16 | |
| 17 | return ( |
| 18 | <Popover> |
| 19 | <PopoverTrigger className={cn(className, isApplying ? "text-primary bg-primary/10 rounded" : "opacity-40")}> |
| 20 | <Settings2Icon className="w-4 h-auto shrink-0" /> |
| 21 | </PopoverTrigger> |
| 22 | <PopoverContent align="end" alignOffset={-12} sideOffset={14}> |
| 23 | <div className="flex flex-col gap-2 p-1"> |
| 24 | <div className="w-full flex flex-row justify-between items-center"> |
| 25 | <span className="text-sm shrink-0 mr-3 text-foreground">{t("memo.shown-time")}</span> |
| 26 | <Select value={timeBasis} onValueChange={(value) => setTimeBasis(value === "update_time" ? "update_time" : "create_time")}> |
| 27 | <SelectTrigger size="sm" className="w-32"> |
| 28 | <SelectValue /> |
| 29 | </SelectTrigger> |
| 30 | <SelectContent> |
| 31 | <SelectItem value="create_time">{t("common.created-at")}</SelectItem> |
| 32 | <SelectItem value="update_time">{t("common.last-updated-at")}</SelectItem> |
| 33 | </SelectContent> |
| 34 | </Select> |
| 35 | </div> |
| 36 | <div className="w-full flex flex-row justify-between items-center"> |
| 37 | <span className="text-sm shrink-0 mr-3 text-foreground">{t("memo.order")}</span> |
| 38 | <Select |
| 39 | value={orderByTimeAsc.toString()} |
| 40 | onValueChange={(value) => { |
| 41 | if ((value === "true") !== orderByTimeAsc) { |
| 42 | toggleSortOrder(); |
| 43 | } |
| 44 | }} |
| 45 | > |
| 46 | <SelectTrigger size="sm" className="w-32"> |
| 47 | <SelectValue /> |
| 48 | </SelectTrigger> |
| 49 | <SelectContent> |
| 50 | <SelectItem value="false">{t("memo.newest-first")}</SelectItem> |
| 51 | <SelectItem value="true">{t("memo.oldest-first")}</SelectItem> |
| 52 | </SelectContent> |
| 53 | </Select> |
| 54 | </div> |
| 55 | </div> |
| 56 | </PopoverContent> |
| 57 | </Popover> |
| 58 | ); |
| 59 | } |
| 60 | |
| 61 | export default MemoDisplaySettingMenu; |
nothing calls this directly
no test coverage detected