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
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { SelectTodoSchedule } from "@superset/local-db";
import { Button } from "@superset/ui/button";
import { Input } from "@superset/ui/input";
import { ScrollArea } from "@superset/ui/scroll-area";
import { useMemo, useState } from "react";
import { HiMiniPlus } from "react-icons/hi2";
Expand All @@ -15,6 +16,7 @@ import { ScheduleListRow } from "./components/ScheduleListRow";
export function SchedulesSection() {
const [editorOpen, setEditorOpen] = useState(false);
const [editing, setEditing] = useState<SelectTodoSchedule | null>(null);
const [filter, setFilter] = useState("");

const { data: schedules } = electronTrpc.todoAgent.schedule.listAll.useQuery(
undefined,
Expand All @@ -37,6 +39,25 @@ export function SchedulesSection() {
return map;
}, [projects]);

const filteredSchedules = useMemo(() => {
const list = schedules ?? [];
const needle = filter.trim().toLowerCase();
if (!needle) return list;
return list.filter((s) => {
const wsName = s.workspaceId
? (workspaceNameById.get(s.workspaceId) ?? "")
: "";
const projName = projectNameById.get(s.projectId) ?? "";
return (
s.name.toLowerCase().includes(needle) ||
s.title.toLowerCase().includes(needle) ||
s.description.toLowerCase().includes(needle) ||
wsName.toLowerCase().includes(needle) ||
projName.toLowerCase().includes(needle)
);
});
}, [schedules, filter, workspaceNameById, projectNameById]);

const openNew = () => {
setEditing(null);
setEditorOpen(true);
Expand Down Expand Up @@ -65,30 +86,43 @@ export function SchedulesSection() {
新規
</Button>
</div>
<div className="p-2 border-b shrink-0">
<Input
value={filter}
onChange={(e) => setFilter(e.target.value)}
placeholder="絞り込み(名前 / タイトル / プロジェクト)"
className="h-8 text-xs rounded-md"
/>
</div>
<ScrollArea className="flex-1">
<div className="flex flex-col gap-1.5 p-2">
{(schedules?.length ?? 0) === 0 && (
{(schedules?.length ?? 0) === 0 ? (
<p className="text-xs text-muted-foreground px-1 py-4">
まだスケジュールはありません。「新規」ボタンから作成してください。
<br />
<span className="text-[10px]">
スケジュールはアプリ起動中のみ発火します。
</span>
</p>
) : filteredSchedules.length === 0 ? (
<p className="text-xs text-muted-foreground px-1 py-4">
条件に一致するスケジュールがありません。
</p>
) : (
filteredSchedules.map((schedule) => (
<ScheduleListRow
key={schedule.id}
schedule={schedule}
projectName={projectNameById.get(schedule.projectId) ?? null}
workspaceName={
schedule.workspaceId
? (workspaceNameById.get(schedule.workspaceId) ?? null)
: null
}
onEdit={() => openEdit(schedule)}
/>
))
)}
{(schedules ?? []).map((schedule) => (
<ScheduleListRow
key={schedule.id}
schedule={schedule}
projectName={projectNameById.get(schedule.projectId) ?? null}
workspaceName={
schedule.workspaceId
? (workspaceNameById.get(schedule.workspaceId) ?? null)
: null
}
onEdit={() => openEdit(schedule)}
/>
))}
</div>
</ScrollArea>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,22 @@ export function TodoManager({
<SchedulesSection />
) : (
<>
<div className="p-2 border-b shrink-0 flex items-center justify-between gap-2">
<span className="text-xs text-muted-foreground">
{(sessions?.length ?? 0) > 0
? `${sessions?.length} 件のタスク`
: "タスクなし"}
</span>
<Button
type="button"
size="sm"
className="h-7 gap-1 px-2.5 text-xs rounded-md"
onClick={() => setComposerOpen(true)}
>
<HiMiniPlus className="size-4" />
新規
</Button>
</div>
<div className="p-2 border-b shrink-0">
<Input
value={filter}
Expand All @@ -502,7 +518,7 @@ export function TodoManager({
{grouped.length === 0 && (
<p className="text-xs text-muted-foreground px-3 py-6">
{(sessions?.length ?? 0) === 0
? "まだ TODO セッションはありません。右上の『新しい TODO』から作成してください。"
? "まだ TODO セッションはありません。『新規』から作成してください。"
: "条件に一致するセッションがありません。"}
</p>
)}
Expand Down Expand Up @@ -566,16 +582,7 @@ export function TodoManager({
</div>

<div className="flex-1 min-w-0 min-h-0 flex flex-col">
{composerOpen ? (
<TodoComposer
currentWorkspaceId={currentWorkspaceId}
onCreated={(id) => {
setComposerOpen(false);
setSelectedId(id);
}}
onCancel={() => setComposerOpen(false)}
/>
) : selected ? (
{selected ? (
<SessionDetail
session={selected}
onDeleted={() => setSelectedId(null)}
Expand Down Expand Up @@ -620,6 +627,24 @@ export function TodoManager({
open={presetsDialogOpen}
onOpenChange={setPresetsDialogOpen}
/>
<Dialog open={composerOpen} onOpenChange={setComposerOpen}>
<DialogContent
className="w-[1080px] max-w-[calc(100vw-3rem)] h-[84vh] max-h-[900px] p-0 gap-0 overflow-hidden flex flex-col rounded-xl"
showCloseButton={false}
>
<DialogTitle className="sr-only">新しい TODO</DialogTitle>
{composerOpen && (
<TodoComposer
currentWorkspaceId={currentWorkspaceId}
onCreated={(id) => {
setComposerOpen(false);
setSelectedId(id);
}}
onCancel={() => setComposerOpen(false)}
/>
)}
</DialogContent>
</Dialog>
</Dialog>
);
}
Expand Down
Loading