mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-08-14 12:00:19 +08:00
Merge pull request #940 from rjmacarthy/refactor/tasks-page
website: Refactor task page routes and repetition
This commit is contained in:
@@ -1,32 +1,9 @@
|
||||
import Head from "next/head";
|
||||
import { TaskEmptyState } from "src/components/EmptyState";
|
||||
import { getDashboardLayout } from "src/components/Layout";
|
||||
import { LoadingScreen } from "src/components/Loading/LoadingScreen";
|
||||
import { Task } from "src/components/Tasks/Task";
|
||||
import { useCreateAssistantReply } from "src/hooks/tasks/useCreateReply";
|
||||
import { TaskPage } from "src/components/TaskPage/TaskPage";
|
||||
import { TaskType } from "src/types/Task";
|
||||
export { getDefaultStaticProps as getStaticProps } from "src/lib/default_static_props";
|
||||
|
||||
const AssistantReply = () => {
|
||||
const { tasks, isLoading, reset, trigger } = useCreateAssistantReply();
|
||||
|
||||
if (isLoading) {
|
||||
return <LoadingScreen text="Loading..." />;
|
||||
}
|
||||
|
||||
if (tasks.length === 0) {
|
||||
return <TaskEmptyState />;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>Reply as Assistant</title>
|
||||
<meta name="description" content="Reply as Assistant." />
|
||||
</Head>
|
||||
<Task key={tasks[0].task.id} frontendId={tasks[0].id} task={tasks[0].task} trigger={trigger} mutate={reset} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
const AssistantReply = () => <TaskPage type={TaskType.assistant_reply} />;
|
||||
|
||||
AssistantReply.getLayout = getDashboardLayout;
|
||||
|
||||
|
||||
@@ -1,32 +1,9 @@
|
||||
import Head from "next/head";
|
||||
import { TaskEmptyState } from "src/components/EmptyState";
|
||||
import { getDashboardLayout } from "src/components/Layout";
|
||||
import { LoadingScreen } from "src/components/Loading/LoadingScreen";
|
||||
import { Task } from "src/components/Tasks/Task";
|
||||
import { useCreateInitialPrompt } from "src/hooks/tasks/useCreateReply";
|
||||
import { TaskPage } from "src/components/TaskPage/TaskPage";
|
||||
import { TaskType } from "src/types/Task";
|
||||
export { getDefaultStaticProps as getStaticProps } from "src/lib/default_static_props";
|
||||
|
||||
const InitialPrompt = () => {
|
||||
const { tasks, isLoading, reset, trigger } = useCreateInitialPrompt();
|
||||
|
||||
if (isLoading) {
|
||||
return <LoadingScreen text="Loading..." />;
|
||||
}
|
||||
|
||||
if (tasks.length === 0) {
|
||||
return <TaskEmptyState />;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>Initial Prompt</title>
|
||||
<meta name="description" content="Add an initial Prompt." />
|
||||
</Head>
|
||||
<Task key={tasks[0].task.id} frontendId={tasks[0].id} task={tasks[0].task} trigger={trigger} mutate={reset} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
const InitialPrompt = () => <TaskPage type={TaskType.initial_prompt} />;
|
||||
|
||||
InitialPrompt.getLayout = getDashboardLayout;
|
||||
|
||||
|
||||
@@ -1,33 +1,10 @@
|
||||
import Head from "next/head";
|
||||
import { TaskEmptyState } from "src/components/EmptyState";
|
||||
import { getDashboardLayout } from "src/components/Layout";
|
||||
import { LoadingScreen } from "src/components/Loading/LoadingScreen";
|
||||
import { Task } from "src/components/Tasks/Task";
|
||||
import { useCreatePrompterReply } from "src/hooks/tasks/useCreateReply";
|
||||
import { TaskPage } from "src/components/TaskPage/TaskPage";
|
||||
import { TaskType } from "src/types/Task";
|
||||
export { getDefaultStaticProps as getStaticProps } from "src/lib/default_static_props";
|
||||
|
||||
const UserReply = () => {
|
||||
const { tasks, isLoading, reset, trigger } = useCreatePrompterReply();
|
||||
const PrompterReply = () => <TaskPage type={TaskType.prompter_reply} />;
|
||||
|
||||
if (isLoading) {
|
||||
return <LoadingScreen text="Loading..." />;
|
||||
}
|
||||
PrompterReply.getLayout = getDashboardLayout;
|
||||
|
||||
if (tasks.length === 0) {
|
||||
return <TaskEmptyState />;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>Reply as User</title>
|
||||
<meta name="description" content="Reply as User." />
|
||||
</Head>
|
||||
<Task key={tasks[0].task.id} frontendId={tasks[0].id} task={tasks[0].task} trigger={trigger} mutate={reset} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
UserReply.getLayout = getDashboardLayout;
|
||||
|
||||
export default UserReply;
|
||||
export default PrompterReply;
|
||||
|
||||
@@ -1,32 +1,9 @@
|
||||
import Head from "next/head";
|
||||
import { TaskEmptyState } from "src/components/EmptyState";
|
||||
import { getDashboardLayout } from "src/components/Layout";
|
||||
import { LoadingScreen } from "src/components/Loading/LoadingScreen";
|
||||
import { Task } from "src/components/Tasks/Task";
|
||||
import { useRankAssistantRepliesTask } from "src/hooks/tasks/useRankReplies";
|
||||
import { TaskPage } from "src/components/TaskPage/TaskPage";
|
||||
import { TaskType } from "src/types/Task";
|
||||
export { getDefaultStaticProps as getStaticProps } from "src/lib/default_static_props";
|
||||
|
||||
const RankAssistantReplies = () => {
|
||||
const { tasks, isLoading, reset, trigger } = useRankAssistantRepliesTask();
|
||||
|
||||
if (isLoading) {
|
||||
return <LoadingScreen text="Loading..." />;
|
||||
}
|
||||
|
||||
if (tasks.length === 0) {
|
||||
return <TaskEmptyState />;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>Rank Assistant Replies</title>
|
||||
<meta name="description" content="Rank Assistant Replies." />
|
||||
</Head>
|
||||
<Task key={tasks[0].task.id} frontendId={tasks[0].id} task={tasks[0].task} trigger={trigger} mutate={reset} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
const RankAssistantReplies = () => <TaskPage type={TaskType.rank_assistant_replies} />;
|
||||
|
||||
RankAssistantReplies.getLayout = getDashboardLayout;
|
||||
|
||||
|
||||
@@ -1,32 +1,9 @@
|
||||
import Head from "next/head";
|
||||
import { TaskEmptyState } from "src/components/EmptyState";
|
||||
import { getDashboardLayout } from "src/components/Layout";
|
||||
import { LoadingScreen } from "src/components/Loading/LoadingScreen";
|
||||
import { Task } from "src/components/Tasks/Task";
|
||||
import { useRankInitialPromptsTask } from "src/hooks/tasks/useRankReplies";
|
||||
import { TaskPage } from "src/components/TaskPage/TaskPage";
|
||||
import { TaskType } from "src/types/Task";
|
||||
export { getDefaultStaticProps as getStaticProps } from "src/lib/default_static_props";
|
||||
|
||||
const RankInitialPrompts = () => {
|
||||
const { tasks, isLoading, reset, trigger } = useRankInitialPromptsTask();
|
||||
|
||||
if (isLoading) {
|
||||
return <LoadingScreen text="Loading..." />;
|
||||
}
|
||||
|
||||
if (tasks.length === 0) {
|
||||
return <TaskEmptyState />;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>Rank Initial Prompts</title>
|
||||
<meta name="description" content="Rank initial prompts." />
|
||||
</Head>
|
||||
<Task key={tasks[0].task.id} frontendId={tasks[0].id} task={tasks[0].task} trigger={trigger} mutate={reset} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
const RankInitialPrompts = () => <TaskPage type={TaskType.rank_initial_prompts} />;
|
||||
|
||||
RankInitialPrompts.getLayout = getDashboardLayout;
|
||||
|
||||
|
||||
@@ -1,33 +1,10 @@
|
||||
import Head from "next/head";
|
||||
import { TaskEmptyState } from "src/components/EmptyState";
|
||||
import { getDashboardLayout } from "src/components/Layout";
|
||||
import { LoadingScreen } from "src/components/Loading/LoadingScreen";
|
||||
import { Task } from "src/components/Tasks/Task";
|
||||
import { useRankPrompterRepliesTask } from "src/hooks/tasks/useRankReplies";
|
||||
import { TaskPage } from "src/components/TaskPage/TaskPage";
|
||||
import { TaskType } from "src/types/Task";
|
||||
export { getDefaultStaticProps as getStaticProps } from "src/lib/default_static_props";
|
||||
|
||||
const RankUserReplies = () => {
|
||||
const { tasks, isLoading, reset, trigger } = useRankPrompterRepliesTask();
|
||||
const RankPrompterReplies = () => <TaskPage type={TaskType.rank_prompter_replies} />;
|
||||
|
||||
if (isLoading) {
|
||||
return <LoadingScreen text="Loading..." />;
|
||||
}
|
||||
RankPrompterReplies.getLayout = getDashboardLayout;
|
||||
|
||||
if (tasks.length === 0) {
|
||||
return <TaskEmptyState />;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>Rank User Replies</title>
|
||||
<meta name="description" content="Rank User Replies." />
|
||||
</Head>
|
||||
<Task key={tasks[0].task.id} frontendId={tasks[0].id} task={tasks[0].task} trigger={trigger} mutate={reset} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
RankUserReplies.getLayout = getDashboardLayout;
|
||||
|
||||
export default RankUserReplies;
|
||||
export default RankPrompterReplies;
|
||||
|
||||
@@ -1,32 +1,9 @@
|
||||
import Head from "next/head";
|
||||
import { TaskEmptyState } from "src/components/EmptyState";
|
||||
import { getDashboardLayout } from "src/components/Layout";
|
||||
import { LoadingScreen } from "src/components/Loading/LoadingScreen";
|
||||
import { Task } from "src/components/Tasks/Task";
|
||||
import { useLabelAssistantReplyTask } from "src/hooks/tasks/useLabelingTask";
|
||||
import { TaskPage } from "src/components/TaskPage/TaskPage";
|
||||
import { TaskType } from "src/types/Task";
|
||||
export { getDefaultStaticProps as getStaticProps } from "src/lib/default_static_props";
|
||||
|
||||
const LabelAssistantReply = () => {
|
||||
const { tasks, isLoading, trigger, reset } = useLabelAssistantReplyTask();
|
||||
|
||||
if (isLoading) {
|
||||
return <LoadingScreen />;
|
||||
}
|
||||
|
||||
if (tasks.length === 0) {
|
||||
return <TaskEmptyState />;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>Label Assistant Reply</title>
|
||||
<meta name="description" content="Label Assistant Reply" />
|
||||
</Head>
|
||||
<Task key={tasks[0].task.id} frontendId={tasks[0].id} task={tasks[0].task} trigger={trigger} mutate={reset} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
const LabelAssistantReply = () => <TaskPage type={TaskType.label_assistant_reply} />;
|
||||
|
||||
LabelAssistantReply.getLayout = getDashboardLayout;
|
||||
|
||||
|
||||
@@ -1,32 +1,9 @@
|
||||
import Head from "next/head";
|
||||
import { TaskEmptyState } from "src/components/EmptyState";
|
||||
import { getDashboardLayout } from "src/components/Layout";
|
||||
import { LoadingScreen } from "src/components/Loading/LoadingScreen";
|
||||
import { Task } from "src/components/Tasks/Task";
|
||||
import { useLabelInitialPromptTask } from "src/hooks/tasks/useLabelingTask";
|
||||
import { TaskPage } from "src/components/TaskPage/TaskPage";
|
||||
import { TaskType } from "src/types/Task";
|
||||
export { getDefaultStaticProps as getStaticProps } from "src/lib/default_static_props";
|
||||
|
||||
const LabelInitialPrompt = () => {
|
||||
const { tasks, isLoading, trigger, reset } = useLabelInitialPromptTask();
|
||||
|
||||
if (isLoading) {
|
||||
return <LoadingScreen />;
|
||||
}
|
||||
|
||||
if (tasks.length === 0) {
|
||||
return <TaskEmptyState />;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>Label Initial Prompt</title>
|
||||
<meta name="description" content="Label Initial Prompt" />
|
||||
</Head>
|
||||
<Task key={tasks[0].task.id} frontendId={tasks[0].id} task={tasks[0].task} trigger={trigger} mutate={reset} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
const LabelInitialPrompt = () => <TaskPage type={TaskType.label_initial_prompt} />;
|
||||
|
||||
LabelInitialPrompt.getLayout = getDashboardLayout;
|
||||
|
||||
|
||||
@@ -1,32 +1,9 @@
|
||||
import Head from "next/head";
|
||||
import { TaskEmptyState } from "src/components/EmptyState";
|
||||
import { getDashboardLayout } from "src/components/Layout";
|
||||
import { LoadingScreen } from "src/components/Loading/LoadingScreen";
|
||||
import { Task } from "src/components/Tasks/Task";
|
||||
import { useLabelPrompterReplyTask } from "src/hooks/tasks/useLabelingTask";
|
||||
import { TaskPage } from "src/components/TaskPage/TaskPage";
|
||||
import { TaskType } from "src/types/Task";
|
||||
export { getDefaultStaticProps as getStaticProps } from "src/lib/default_static_props";
|
||||
|
||||
const LabelPrompterReply = () => {
|
||||
const { tasks, isLoading, trigger, reset } = useLabelPrompterReplyTask();
|
||||
|
||||
if (isLoading) {
|
||||
return <LoadingScreen />;
|
||||
}
|
||||
|
||||
if (tasks.length === 0) {
|
||||
return <TaskEmptyState />;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>Label Prompter Reply</title>
|
||||
<meta name="description" content="Label Prompter Reply" />
|
||||
</Head>
|
||||
<Task key={tasks[0].task.id} frontendId={tasks[0].id} task={tasks[0].task} trigger={trigger} mutate={reset} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
const LabelPrompterReply = () => <TaskPage type={TaskType.label_prompter_reply} />;
|
||||
|
||||
LabelPrompterReply.getLayout = getDashboardLayout;
|
||||
|
||||
|
||||
@@ -1,34 +1,10 @@
|
||||
import Head from "next/head";
|
||||
import { TaskEmptyState } from "src/components/EmptyState";
|
||||
import { getDashboardLayout } from "src/components/Layout";
|
||||
import { LoadingScreen } from "src/components/Loading/LoadingScreen";
|
||||
import { Task } from "src/components/Tasks/Task";
|
||||
import { useGenericTaskAPI } from "src/hooks/tasks/useGenericTaskAPI";
|
||||
import { TaskPage } from "src/components/TaskPage/TaskPage";
|
||||
export { getDefaultStaticProps as getStaticProps } from "src/lib/default_static_props";
|
||||
import { TaskType } from "src/types/Task";
|
||||
|
||||
const RandomTask = () => {
|
||||
const { tasks, isLoading, trigger, reset } = useGenericTaskAPI(TaskType.random);
|
||||
const Random = () => <TaskPage type={TaskType.random} />;
|
||||
|
||||
if (isLoading) {
|
||||
return <LoadingScreen text="Loading..." />;
|
||||
}
|
||||
Random.getLayout = getDashboardLayout;
|
||||
|
||||
if (tasks.length === 0) {
|
||||
return <TaskEmptyState />;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>Random Task</title>
|
||||
<meta name="description" content="Random Task." />
|
||||
</Head>
|
||||
<Task key={tasks[0].task.id} frontendId={tasks[0].id} task={tasks[0].task} trigger={trigger} mutate={reset} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
RandomTask.getLayout = (page) => getDashboardLayout(page);
|
||||
|
||||
export default RandomTask;
|
||||
export default Random;
|
||||
|
||||
Reference in New Issue
Block a user