Extract dashboard task action buttons

This commit is contained in:
ejclaw
2026-04-28 21:09:10 +09:00
parent 7e7789b059
commit a8ae4aece4
4 changed files with 116 additions and 65 deletions

View File

@@ -11,16 +11,14 @@ import type {
import { EmptyState } from './EmptyState';
import { localeTags, type Locale, type Messages } from './i18n';
import { redactSecretsForPreview } from './redaction';
import { statusLabel, taskActionsFor } from './dashboardHelpers';
import { statusLabel } from './dashboardHelpers';
import { TaskActionButtons, type TaskActionKey } from './TaskActionButtons';
export type { TaskActionKey } from './TaskActionButtons';
type TaskGroupKey = 'watchers' | 'scheduled' | 'paused' | 'completed';
type TaskResultTone = 'ok' | 'fail' | 'none';
export type TaskActionKey =
| 'create'
| `${string}:edit`
| `${string}:${DashboardTaskAction}`;
export interface RoomOption {
jid: string;
name: string;
@@ -69,13 +67,6 @@ interface TaskCardProps {
t: Messages;
}
interface TaskActionButtonsProps {
onTaskAction: (task: DashboardTask, action: DashboardTaskAction) => void;
task: DashboardTask;
taskActionKey: TaskActionKey | null;
t: Messages;
}
interface TaskDateProps {
locale: Locale;
t: Messages;
@@ -341,37 +332,6 @@ function TaskCreateForm({
);
}
function TaskActionButtons({
onTaskAction,
task,
taskActionKey,
t,
}: TaskActionButtonsProps) {
const taskActions = taskActionsFor(task);
if (taskActions.length === 0) return null;
return (
<div className="task-actions">
{taskActions.map((action) => {
const actionKey: TaskActionKey = `${task.id}:${action}`;
const busy = taskActionKey === actionKey;
return (
<button
aria-busy={busy || undefined}
className={`task-action task-action-${action}${busy ? ' is-busy' : ''}`}
disabled={busy}
key={action}
onClick={() => onTaskAction(task, action)}
type="button"
>
{busy ? t.tasks.actions.busy : t.tasks.actions[action]}
</button>
);
})}
</div>
);
}
function TaskTimeGrid({ locale, t, task }: TaskDateProps) {
return (
<div className="task-time-grid">