Show the coordinator in the workspace rail under the workspace row
This commit is contained in:
@@ -2,7 +2,10 @@ import Divider from "@moduletrace/twui/layout/Divider";
|
|||||||
import { useContext } from "react";
|
import { useContext } from "react";
|
||||||
import { AddFlowContext } from "../(data)/add-flow-context";
|
import { AddFlowContext } from "../(data)/add-flow-context";
|
||||||
import type { BotWithLastMessage, WorkspaceWithActivity } from "@/src/types";
|
import type { BotWithLastMessage, WorkspaceWithActivity } from "@/src/types";
|
||||||
|
import CoordinatorRow from "./coordinator-row";
|
||||||
import RailBackLink from "./rail-back-link";
|
import RailBackLink from "./rail-back-link";
|
||||||
|
import RailBotCard from "./rail-bot-card";
|
||||||
|
import RailBotSessions from "./rail-bot-sessions";
|
||||||
import RailBotsSection from "./rail-bots-section";
|
import RailBotsSection from "./rail-bots-section";
|
||||||
import RailSectionAddButton from "./rail-section-add-button";
|
import RailSectionAddButton from "./rail-section-add-button";
|
||||||
import WorkspaceRow from "./workspace-row";
|
import WorkspaceRow from "./workspace-row";
|
||||||
@@ -10,8 +13,8 @@ import WorkspaceRow from "./workspace-row";
|
|||||||
type Props = {
|
type Props = {
|
||||||
workspace: WorkspaceWithActivity;
|
workspace: WorkspaceWithActivity;
|
||||||
/**
|
/**
|
||||||
* The workspace's crew: the coordinator is left out, only the bots
|
* The workspace's crew: the bots attached to the workspace, plus (for
|
||||||
* attached to the workspace show.
|
* the super admin, who works in every workspace) the coordinator.
|
||||||
*/
|
*/
|
||||||
bots: BotWithLastMessage[];
|
bots: BotWithLastMessage[];
|
||||||
selected_id?: number;
|
selected_id?: number;
|
||||||
@@ -23,11 +26,12 @@ type Props = {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The rail inside a workspace: back to all bots, the workspace itself (its
|
* The rail inside a workspace: back to all bots, the workspace itself (its
|
||||||
* page), then the workspace's bots. Every conversation here runs with the
|
* page), the coordinator working in it, then the workspace's bots. Every
|
||||||
* workspace's context. The coordinator is reached from the main rail.
|
* conversation here runs with the workspace's context.
|
||||||
*/
|
*/
|
||||||
export default function RailWorkspaceList({ workspace, bots, selected_id, on_workspace_page }: Props) {
|
export default function RailWorkspaceList({ workspace, bots, selected_id, on_workspace_page }: Props) {
|
||||||
const { openLinkBots } = useContext(AddFlowContext);
|
const { openLinkBots } = useContext(AddFlowContext);
|
||||||
|
const coordinator = bots.find((bot) => bot.kind === "coordinator");
|
||||||
const workers = bots.filter((bot) => bot.kind !== "coordinator");
|
const workers = bots.filter((bot) => bot.kind !== "coordinator");
|
||||||
const base = `/admin/workspaces/${workspace.id}`;
|
const base = `/admin/workspaces/${workspace.id}`;
|
||||||
|
|
||||||
@@ -39,6 +43,23 @@ export default function RailWorkspaceList({ workspace, bots, selected_id, on_wor
|
|||||||
/>
|
/>
|
||||||
<Divider className="shrink-0 mx-1 @rail:mx-3 my-2 w-auto border-hairline dark:border-hairline" />
|
<Divider className="shrink-0 mx-1 @rail:mx-3 my-2 w-auto border-hairline dark:border-hairline" />
|
||||||
<WorkspaceRow workspace={{ ...workspace, unread: 0 }} selected={on_workspace_page} />
|
<WorkspaceRow workspace={{ ...workspace, unread: 0 }} selected={on_workspace_page} />
|
||||||
|
{coordinator ? (
|
||||||
|
<RailBotCard selected={coordinator.id === selected_id}>
|
||||||
|
<CoordinatorRow
|
||||||
|
bot={coordinator}
|
||||||
|
bots={bots}
|
||||||
|
href={`${base}/bots/${coordinator.id}`}
|
||||||
|
selected={coordinator.id === selected_id}
|
||||||
|
/>
|
||||||
|
{coordinator.id === selected_id ? (
|
||||||
|
<RailBotSessions
|
||||||
|
key={coordinator.id}
|
||||||
|
bot={coordinator}
|
||||||
|
workspace_id={Number(workspace.id)}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
</RailBotCard>
|
||||||
|
) : null}
|
||||||
<RailBotsSection
|
<RailBotsSection
|
||||||
action={<RailSectionAddButton title="Add bots to this workspace" onClick={openLinkBots} />}
|
action={<RailSectionAddButton title="Add bots to this workspace" onClick={openLinkBots} />}
|
||||||
title="Workspace bots"
|
title="Workspace bots"
|
||||||
|
|||||||
Reference in New Issue
Block a user