@burdenoff/microfe-botmanor 2026.1120.5 → 2026.1120.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/botlit/components/AssistantChannelPanel.js +3 -3
- package/dist/botlit/components/AssistantChannelPanel.js.map +1 -1
- package/dist/botlit/components/ChannelRoutesPanel.d.ts +9 -0
- package/dist/botlit/components/ChannelRoutesPanel.js +275 -0
- package/dist/botlit/components/ChannelRoutesPanel.js.map +1 -0
- package/dist/botlit/components/CreateChannelRouteDialog.d.ts +13 -0
- package/dist/botlit/components/CreateChannelRouteDialog.js +188 -0
- package/dist/botlit/components/CreateChannelRouteDialog.js.map +1 -0
- package/dist/botlit/hooks/index.d.ts +3 -3
- package/dist/botlit/hooks/index.js +19 -19
- package/dist/botlit/hooks/useAssistantChat.d.ts +32 -0
- package/dist/botlit/hooks/useAssistantChat.js +98 -0
- package/dist/botlit/hooks/useAssistantChat.js.map +1 -0
- package/dist/botlit/hooks/useBots.d.ts +5 -0
- package/dist/botlit/hooks/useBots.js +63 -50
- package/dist/botlit/hooks/useBots.js.map +1 -1
- package/dist/botlit/hooks/useChannels.d.ts +49 -23
- package/dist/botlit/hooks/useChannels.js +141 -135
- package/dist/botlit/hooks/useChannels.js.map +1 -1
- package/dist/botlit/pages/BotChannelsTab.js +12 -3
- package/dist/botlit/pages/BotChannelsTab.js.map +1 -1
- package/dist/botlit/pages/ChannelDetailPage.js +642 -776
- package/dist/botlit/pages/ChannelDetailPage.js.map +1 -1
- package/dist/botlit/pages/ChannelRoutesPage.js +22 -208
- package/dist/botlit/pages/ChannelRoutesPage.js.map +1 -1
- package/dist/botlit/pages/ChannelsPage.js +314 -251
- package/dist/botlit/pages/ChannelsPage.js.map +1 -1
- package/dist/botlit/pages/ChatPage.js +207 -83
- package/dist/botlit/pages/ChatPage.js.map +1 -1
- package/dist/botlit/utils/assistantAvailability.d.ts +34 -0
- package/dist/botlit/utils/assistantAvailability.js +24 -0
- package/dist/botlit/utils/assistantAvailability.js.map +1 -0
- package/dist/botlit/utils/channelConnectors.d.ts +13 -0
- package/dist/botlit/utils/channelConnectors.js +21 -1
- package/dist/botlit/utils/channelConnectors.js.map +1 -1
- package/dist/botlit/utils/errors.d.ts +8 -0
- package/dist/botlit/utils/errors.js +21 -1
- package/dist/botlit/utils/errors.js.map +1 -1
- package/dist/generated/wspace-operations.d.ts +200 -12
- package/dist/generated/wspace-operations.js +153 -110
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/generated/wspace-types.d.ts +40 -0
- package/dist/generated/wspace-types.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useAssistantChannels as e } from "../hooks/useAssistantChannels.js";
|
|
2
2
|
import { useAssistantWebsites as t } from "../hooks/useAssistantWebsites.js";
|
|
3
|
-
import {
|
|
3
|
+
import { useAllChannelRoutes as n } from "../hooks/useChannels.js";
|
|
4
4
|
import { useBotlit as r } from "../providers/BotlitProvider.js";
|
|
5
5
|
import { Button as i } from "./Button.js";
|
|
6
6
|
import { useState as a } from "react";
|
|
@@ -51,7 +51,7 @@ function l({ agentId: r }) {
|
|
|
51
51
|
children: [/* @__PURE__ */ o("option", {
|
|
52
52
|
value: "",
|
|
53
53
|
children: "Select a route"
|
|
54
|
-
}), u.data.map((e) => /* @__PURE__ */ s("option", {
|
|
54
|
+
}), u.data.filter((e) => e.isActive).map((e) => /* @__PURE__ */ s("option", {
|
|
55
55
|
value: e.id,
|
|
56
56
|
children: [
|
|
57
57
|
e.locationId,
|
|
@@ -62,7 +62,7 @@ function l({ agentId: r }) {
|
|
|
62
62
|
})]
|
|
63
63
|
}),
|
|
64
64
|
/* @__PURE__ */ o(i, {
|
|
65
|
-
disabled: !_.some((e) => e.id === p) || !u.data.some((e) => e.id === d) || !!u.error,
|
|
65
|
+
disabled: !_.some((e) => e.id === p) || !u.data.some((e) => e.id === d && e.isActive) || !!u.error,
|
|
66
66
|
isLoading: c.configure.isPending,
|
|
67
67
|
onClick: async () => {
|
|
68
68
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssistantChannelPanel.js","names":["AssistantChannelPanel","useBotlit","ScopedChannelPanel","workspaceId","currentUser","agentId","channels","useAssistantChannels","publications","useAssistantWebsites","routes","
|
|
1
|
+
{"version":3,"file":"AssistantChannelPanel.js","names":["AssistantChannelPanel","useBotlit","ScopedChannelPanel","workspaceId","currentUser","agentId","channels","useAssistantChannels","publications","useAssistantWebsites","routes","useAllChannelRoutes","routeId","setRouteId","useState","publicationId","setPublicationId","message","setMessage","approved","row","ownIds","event","route","Button"],"sources":["../../../src/botlit/components/AssistantChannelPanel.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { useAssistantChannels } from '../hooks/useAssistantChannels';\nimport { useAssistantWebsites } from '../hooks/useAssistantWebsites';\nimport { useAllChannelRoutes } from '../hooks/useChannels';\nimport { useBotlit } from '../providers/BotlitProvider';\nimport { Button } from './Button';\n\nexport function AssistantChannelPanel({ agentId }: { agentId: string }) {\n const { workspaceId, currentUser } = useBotlit();\n return (\n <ScopedChannelPanel key={`${workspaceId}:${currentUser?.id}:${agentId}`} agentId={agentId} />\n );\n}\nfunction ScopedChannelPanel({ agentId }: { agentId: string }) {\n const channels = useAssistantChannels(),\n publications = useAssistantWebsites(agentId),\n routes = useAllChannelRoutes();\n const [routeId, setRouteId] = useState(''),\n [publicationId, setPublicationId] = useState(''),\n [message, setMessage] = useState('');\n const approved = publications.installations.data?.filter((row) => row.enabled) ?? [];\n const ownIds = new Set(publications.installations.data?.map((row) => row.id) ?? []);\n return (\n <section className=\"space-y-4 rounded-lg border border-border-default p-5\">\n <h2 className=\"text-lg font-semibold\">Channel assistant</h2>\n <p className=\"text-sm text-text-secondary\">\n Use an approved public assistant publication on an existing channel route. Messages run\n through Fluidgrids and replies use channel-svc. Private course teachers cannot be published.\n </p>\n {(routes.error || publications.installations.isError || channels.installations.isError) && (\n <p role=\"alert\">\n Channel setup could not be loaded. Check your publishing permission and reload.\n </p>\n )}\n <label className=\"grid gap-2 text-sm\">\n Approved public publication\n <select\n className=\"h-10 rounded-md border border-border-default bg-bg-surface px-3\"\n value={publicationId}\n onChange={(event) => setPublicationId(event.target.value)}\n >\n <option value=\"\">Select a reviewed publication</option>\n {approved.map((row) => (\n <option key={row.id} value={row.id}>\n {row.name}\n </option>\n ))}\n </select>\n </label>\n <label className=\"grid gap-2 text-sm\">\n Existing channel route\n <select\n className=\"h-10 rounded-md border border-border-default bg-bg-surface px-3\"\n value={routeId}\n onChange={(event) => setRouteId(event.target.value)}\n >\n <option value=\"\">Select a route</option>\n {routes.data\n .filter((route) => route.isActive)\n .map((route) => (\n <option key={route.id} value={route.id}>\n {route.locationId} · {route.appId}\n </option>\n ))}\n </select>\n </label>\n <Button\n disabled={\n !approved.some((row) => row.id === publicationId) ||\n !routes.data.some((row) => row.id === routeId && row.isActive) ||\n Boolean(routes.error)\n }\n isLoading={channels.configure.isPending}\n onClick={async () => {\n try {\n await channels.configure.mutateAsync({ routeId, publicationId });\n setMessage('Channel assistant enabled.');\n } catch {\n setMessage(\n 'Channel publication failed. Check the public assistant configuration, channel ownership and publishing permission.'\n );\n }\n }}\n >\n Enable channel assistant\n </Button>\n {message && <p role=\"status\">{message}</p>}\n {channels.installations.data\n ?.filter((row) => ownIds.has(row.publicationId))\n .map((row) => (\n <div key={row.id} className=\"flex items-center justify-between gap-3 text-sm\">\n <span>\n {routes.data.find((route) => route.id === row.routeId)?.locationId ?? row.routeId} ·{' '}\n {row.enabled ? 'Enabled' : 'Disabled'}\n </span>\n {row.enabled && (\n <Button\n variant=\"outline\"\n isLoading={channels.disable.isPending}\n onClick={async () => {\n try {\n await channels.disable.mutateAsync(row.id);\n setMessage('Channel assistant disabled.');\n } catch {\n setMessage('Channel could not be disabled. Reload and try again.');\n }\n }}\n >\n Disable\n </Button>\n )}\n </div>\n ))}\n </section>\n );\n}\n"],"mappings":";;;;;;;;AAOA,SAAgBA,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GACzCF,EAAW,6BAA6B;MAC1C,QAAQ;OACN,EAAW,sDAAsD;MACnE;KACF;KACD,UAAA;IAEO,CAAA,CAEP;GArBK,GAAAE,EAAI,EAqBT,CACN;EACI;;AAEb"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
interface ChannelRoutesPanelProps {
|
|
3
|
+
/** Show the totals row (the Routes page does; the tab shows them in its label). */
|
|
4
|
+
showSummary?: boolean;
|
|
5
|
+
/** Called after a route is created or toggled, so the host can refresh its own counts. */
|
|
6
|
+
onRoutesChanged?: () => void;
|
|
7
|
+
}
|
|
8
|
+
export declare const ChannelRoutesPanel: FC<ChannelRoutesPanelProps>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import { useTr as e } from "../../shared/hooks/useTr.js";
|
|
2
|
+
import "../hooks/index.js";
|
|
3
|
+
import "../permissions/index.js";
|
|
4
|
+
import { useAllBots as t } from "../hooks/useBots.js";
|
|
5
|
+
import { useBotlit as n } from "../providers/BotlitProvider.js";
|
|
6
|
+
import { BOTMANOR_PERMISSIONS as r } from "../permissions/botmanorPermissions.js";
|
|
7
|
+
import { BotmanorPermissionGate as i } from "../permissions/useBotmanorPermissions.js";
|
|
8
|
+
import { graphqlErrorMessage as ee } from "../utils/errors.js";
|
|
9
|
+
import { formatRelativeTime as a } from "../utils/formatters.js";
|
|
10
|
+
import { Badge as o } from "./Badge.js";
|
|
11
|
+
import { Button as s } from "./Button.js";
|
|
12
|
+
import { Card as c, CardContent as l } from "./Card.js";
|
|
13
|
+
import { CreateChannelRouteDialog as u } from "./CreateChannelRouteDialog.js";
|
|
14
|
+
import { EmptyState as d } from "./EmptyState.js";
|
|
15
|
+
import { ErrorState as f } from "./ErrorState.js";
|
|
16
|
+
import { routeMetadataString as p, useAllChannelConnectors as te, useChannelOverview as ne, useChannelRoutes as re, useUpdateChannelRoute as ie } from "../hooks/useChannels.js";
|
|
17
|
+
import { Input as m } from "./Input.js";
|
|
18
|
+
import { LoadMore as h } from "./LoadMore.js";
|
|
19
|
+
import { useMemo as g, useState as _ } from "react";
|
|
20
|
+
import { GlassCard as v } from "@burdenoff/fe-libs/ui";
|
|
21
|
+
import { jsx as y, jsxs as b } from "react/jsx-runtime";
|
|
22
|
+
import { Link as x } from "react-router";
|
|
23
|
+
import { AppWindow as S, Plus as C, Power as w, PowerOff as ae, Radio as oe, Route as se, Search as ce } from "lucide-react";
|
|
24
|
+
import { toast as T } from "sonner";
|
|
25
|
+
// src/botlit/components/ChannelRoutesPanel.tsx
|
|
26
|
+
var E = "h-10 rounded-md border border-border-default bg-bg-surface px-3 py-2 text-sm", D = ({ showSummary: D = !0, onRoutesChanged: O }) => {
|
|
27
|
+
let k = e(), { getPath: A } = n(), [j, M] = _(""), [N, P] = _(""), [F, I] = _("all"), [L, R] = _(!1), [z, B] = _(null), V = g(() => ({
|
|
28
|
+
connectorId: N || void 0,
|
|
29
|
+
isActive: F === "all" ? void 0 : F === "active"
|
|
30
|
+
}), [N, F]), H = re(V), U = ne(), W = te(), G = t(), [le] = ie(), K = (e) => W.data.find((t) => t.id === e)?.name ?? k("botlit.channelRoutes.unknownConnector", "Unknown connector"), q = (e) => G.data.find((t) => t.id === e.appId)?.name ?? p(e, "appName") ?? k("botlit.channelRoutes.unknownBot", "Unknown bot"), J = (e) => p(e, "locationName") ?? e.locationId, Y = j.trim().toLowerCase(), X = Y ? H.data.filter((e) => [
|
|
31
|
+
e.locationId,
|
|
32
|
+
J(e),
|
|
33
|
+
K(e.connectorId),
|
|
34
|
+
q(e)
|
|
35
|
+
].join(" ").toLowerCase().includes(Y)) : H.data, Z = !!(Y || N || F !== "all"), Q = () => {
|
|
36
|
+
H.refetch(), U.refetch(), O?.();
|
|
37
|
+
}, ue = async (e) => {
|
|
38
|
+
B(e.id);
|
|
39
|
+
try {
|
|
40
|
+
await le({
|
|
41
|
+
routeId: e.id,
|
|
42
|
+
input: { isActive: !e.isActive }
|
|
43
|
+
}), T.success(e.isActive ? k("botlit.channelRoutes.toggle.off", "Route turned off: {{location}}", { location: J(e) }) : k("botlit.channelRoutes.toggle.on", "Route turned on: {{location}}", { location: J(e) })), Q();
|
|
44
|
+
} catch (e) {
|
|
45
|
+
T.error(ee(e, k("botlit.channelRoutes.toggle.failed", "The route could not be changed.")));
|
|
46
|
+
} finally {
|
|
47
|
+
B(null);
|
|
48
|
+
}
|
|
49
|
+
}, $ = /* @__PURE__ */ y(i, {
|
|
50
|
+
permission: r.CHANNEL_CREATE,
|
|
51
|
+
children: /* @__PURE__ */ y(s, {
|
|
52
|
+
leftIcon: /* @__PURE__ */ y(C, { size: 16 }),
|
|
53
|
+
onClick: () => R(!0),
|
|
54
|
+
children: k("botlit.channels.actions.createRoute", "Create Route")
|
|
55
|
+
})
|
|
56
|
+
});
|
|
57
|
+
return /* @__PURE__ */ b("div", {
|
|
58
|
+
className: "space-y-6",
|
|
59
|
+
children: [
|
|
60
|
+
(!!(D && U.error) || W.error || G.error) && /* @__PURE__ */ b("div", {
|
|
61
|
+
role: "alert",
|
|
62
|
+
className: "flex flex-wrap items-center justify-between gap-3 rounded-lg border border-status-warning-border bg-status-warning-bg-subtle px-4 py-3 text-sm",
|
|
63
|
+
children: [/* @__PURE__ */ y("span", {
|
|
64
|
+
className: "text-text-primary",
|
|
65
|
+
children: [
|
|
66
|
+
D && U.error ? k("botlit.channelRoutes.errors.overview", "Route totals could not be loaded.") : "",
|
|
67
|
+
W.error ? k("botlit.channelRoutes.errors.connectors", "Connector names could not be loaded; some may show as unknown and the connector filter may be incomplete.") : "",
|
|
68
|
+
G.error ? k("botlit.channelRoutes.errors.bots", "Bot names could not be loaded; some may show as unknown and search by bot name may miss routes.") : ""
|
|
69
|
+
].filter(Boolean).join(" ")
|
|
70
|
+
}), /* @__PURE__ */ y(s, {
|
|
71
|
+
variant: "outline",
|
|
72
|
+
size: "sm",
|
|
73
|
+
onClick: () => {
|
|
74
|
+
U.error && U.refetch(), W.error && W.refetch(), G.error && G.refetch();
|
|
75
|
+
},
|
|
76
|
+
children: k("botlit.common.retry", "Retry")
|
|
77
|
+
})]
|
|
78
|
+
}),
|
|
79
|
+
D && U.data && /* @__PURE__ */ b("div", {
|
|
80
|
+
className: "grid grid-cols-2 gap-4 sm:grid-cols-3",
|
|
81
|
+
children: [
|
|
82
|
+
/* @__PURE__ */ b(v, {
|
|
83
|
+
treatment: "glass",
|
|
84
|
+
glow: !0,
|
|
85
|
+
className: "p-4",
|
|
86
|
+
children: [/* @__PURE__ */ y("p", {
|
|
87
|
+
className: "text-sm text-text-secondary",
|
|
88
|
+
children: k("botlit.channelRoutes.summary.active", "Active routes")
|
|
89
|
+
}), /* @__PURE__ */ y("p", {
|
|
90
|
+
className: "mt-1 text-2xl font-semibold tabular-nums text-text-primary",
|
|
91
|
+
children: U.data.activeRouteCount
|
|
92
|
+
})]
|
|
93
|
+
}),
|
|
94
|
+
/* @__PURE__ */ b(v, {
|
|
95
|
+
treatment: "metric",
|
|
96
|
+
className: "p-4",
|
|
97
|
+
children: [/* @__PURE__ */ y("p", {
|
|
98
|
+
className: "text-sm text-text-secondary",
|
|
99
|
+
children: k("botlit.channelRoutes.summary.total", "All routes")
|
|
100
|
+
}), /* @__PURE__ */ y("p", {
|
|
101
|
+
className: "mt-1 text-2xl font-semibold tabular-nums text-text-primary",
|
|
102
|
+
children: U.data.routeCount
|
|
103
|
+
})]
|
|
104
|
+
}),
|
|
105
|
+
/* @__PURE__ */ b(v, {
|
|
106
|
+
treatment: "metric",
|
|
107
|
+
className: "col-span-2 p-4 sm:col-span-1",
|
|
108
|
+
children: [/* @__PURE__ */ y("p", {
|
|
109
|
+
className: "text-sm text-text-secondary",
|
|
110
|
+
children: k("botlit.channelRoutes.summary.unrouted", "Unanswered inbound messages")
|
|
111
|
+
}), /* @__PURE__ */ y("p", {
|
|
112
|
+
className: "mt-1 text-2xl font-semibold tabular-nums text-text-primary",
|
|
113
|
+
children: U.data.unroutedMessageCount
|
|
114
|
+
})]
|
|
115
|
+
})
|
|
116
|
+
]
|
|
117
|
+
}),
|
|
118
|
+
/* @__PURE__ */ b("div", {
|
|
119
|
+
className: "flex flex-wrap items-end gap-3",
|
|
120
|
+
children: [
|
|
121
|
+
/* @__PURE__ */ b("div", {
|
|
122
|
+
className: "relative min-w-56 flex-1 max-w-md",
|
|
123
|
+
children: [/* @__PURE__ */ y(ce, {
|
|
124
|
+
"aria-hidden": "true",
|
|
125
|
+
className: "absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-text-secondary"
|
|
126
|
+
}), /* @__PURE__ */ y(m, {
|
|
127
|
+
"aria-label": k("botlit.channelRoutes.search", "Search routes"),
|
|
128
|
+
placeholder: k("botlit.channelRoutes.searchPlaceholder", "Search routes..."),
|
|
129
|
+
value: j,
|
|
130
|
+
onChange: (e) => M(e.target.value),
|
|
131
|
+
className: "pl-9"
|
|
132
|
+
})]
|
|
133
|
+
}),
|
|
134
|
+
/* @__PURE__ */ b("label", {
|
|
135
|
+
className: "grid gap-1 text-xs text-text-secondary",
|
|
136
|
+
children: [k("botlit.channelRoutes.filters.connector", "Connector"), /* @__PURE__ */ b("select", {
|
|
137
|
+
className: E,
|
|
138
|
+
value: N,
|
|
139
|
+
onChange: (e) => P(e.target.value),
|
|
140
|
+
children: [/* @__PURE__ */ y("option", {
|
|
141
|
+
value: "",
|
|
142
|
+
children: k("botlit.channelRoutes.filters.allConnectors", "All connectors")
|
|
143
|
+
}), W.data.map((e) => /* @__PURE__ */ y("option", {
|
|
144
|
+
value: e.id,
|
|
145
|
+
children: e.name
|
|
146
|
+
}, e.id))]
|
|
147
|
+
})]
|
|
148
|
+
}),
|
|
149
|
+
/* @__PURE__ */ b("label", {
|
|
150
|
+
className: "grid gap-1 text-xs text-text-secondary",
|
|
151
|
+
children: [k("botlit.channelRoutes.filters.status", "Status"), /* @__PURE__ */ b("select", {
|
|
152
|
+
className: E,
|
|
153
|
+
value: F,
|
|
154
|
+
onChange: (e) => I(e.target.value),
|
|
155
|
+
children: [
|
|
156
|
+
/* @__PURE__ */ y("option", {
|
|
157
|
+
value: "all",
|
|
158
|
+
children: k("botlit.channelRoutes.filters.allStatuses", "On and off")
|
|
159
|
+
}),
|
|
160
|
+
/* @__PURE__ */ y("option", {
|
|
161
|
+
value: "active",
|
|
162
|
+
children: k("botlit.channelRoutes.status.on", "On")
|
|
163
|
+
}),
|
|
164
|
+
/* @__PURE__ */ y("option", {
|
|
165
|
+
value: "inactive",
|
|
166
|
+
children: k("botlit.channelRoutes.status.off", "Off")
|
|
167
|
+
})
|
|
168
|
+
]
|
|
169
|
+
})]
|
|
170
|
+
}),
|
|
171
|
+
/* @__PURE__ */ y("div", {
|
|
172
|
+
className: "ml-auto",
|
|
173
|
+
children: $
|
|
174
|
+
})
|
|
175
|
+
]
|
|
176
|
+
}),
|
|
177
|
+
H.loading ? /* @__PURE__ */ y("div", {
|
|
178
|
+
className: "space-y-3",
|
|
179
|
+
children: [
|
|
180
|
+
1,
|
|
181
|
+
2,
|
|
182
|
+
3
|
|
183
|
+
].map((e) => /* @__PURE__ */ y("div", { className: "h-24 rounded-lg bg-bg-sunken motion-safe:animate-vc-shimmer" }, e))
|
|
184
|
+
}) : H.error ? /* @__PURE__ */ y(f, {
|
|
185
|
+
resource: k("botlit.channelRoutes.resource", "channel routes"),
|
|
186
|
+
error: H.error,
|
|
187
|
+
onRetry: () => void H.refetch()
|
|
188
|
+
}) : X.length > 0 ? /* @__PURE__ */ y("ul", {
|
|
189
|
+
className: "space-y-3",
|
|
190
|
+
"aria-label": k("botlit.channelRoutes.listLabel", "Routes"),
|
|
191
|
+
children: X.map((e) => /* @__PURE__ */ y("li", { children: /* @__PURE__ */ y(c, { children: /* @__PURE__ */ b(l, {
|
|
192
|
+
className: "flex flex-wrap items-center justify-between gap-4 py-4",
|
|
193
|
+
children: [/* @__PURE__ */ b("div", {
|
|
194
|
+
className: "flex items-center gap-4",
|
|
195
|
+
children: [/* @__PURE__ */ y("div", {
|
|
196
|
+
className: "rounded-lg bg-action-primary-bg/10 p-3",
|
|
197
|
+
children: /* @__PURE__ */ y(se, {
|
|
198
|
+
"aria-hidden": "true",
|
|
199
|
+
className: "h-5 w-5 text-primary"
|
|
200
|
+
})
|
|
201
|
+
}), /* @__PURE__ */ b("div", { children: [/* @__PURE__ */ b("div", {
|
|
202
|
+
className: "flex items-center gap-2",
|
|
203
|
+
children: [/* @__PURE__ */ y("h3", {
|
|
204
|
+
className: "font-medium text-text-primary",
|
|
205
|
+
children: J(e)
|
|
206
|
+
}), /* @__PURE__ */ y(o, {
|
|
207
|
+
variant: e.isActive ? "success" : "outline",
|
|
208
|
+
children: e.isActive ? k("botlit.channelRoutes.status.on", "On") : k("botlit.channelRoutes.status.off", "Off")
|
|
209
|
+
})]
|
|
210
|
+
}), /* @__PURE__ */ b("div", {
|
|
211
|
+
className: "mt-1 flex flex-wrap items-center gap-4 text-sm text-text-secondary",
|
|
212
|
+
children: [
|
|
213
|
+
/* @__PURE__ */ b(x, {
|
|
214
|
+
to: A(`channels/${e.connectorId}`),
|
|
215
|
+
className: "flex items-center gap-1 hover:text-text-primary hover:underline",
|
|
216
|
+
children: [/* @__PURE__ */ y(oe, {
|
|
217
|
+
"aria-hidden": "true",
|
|
218
|
+
size: 14
|
|
219
|
+
}), K(e.connectorId)]
|
|
220
|
+
}),
|
|
221
|
+
/* @__PURE__ */ b(x, {
|
|
222
|
+
to: A(`bots/${e.appId}`),
|
|
223
|
+
className: "flex items-center gap-1 hover:text-text-primary hover:underline",
|
|
224
|
+
children: [/* @__PURE__ */ y(S, {
|
|
225
|
+
"aria-hidden": "true",
|
|
226
|
+
size: 14
|
|
227
|
+
}), q(e)]
|
|
228
|
+
}),
|
|
229
|
+
/* @__PURE__ */ y("span", {
|
|
230
|
+
className: "font-mono text-xs",
|
|
231
|
+
children: e.locationId
|
|
232
|
+
})
|
|
233
|
+
]
|
|
234
|
+
})] })]
|
|
235
|
+
}), /* @__PURE__ */ b("div", {
|
|
236
|
+
className: "flex items-center gap-3",
|
|
237
|
+
children: [/* @__PURE__ */ y("span", {
|
|
238
|
+
className: "text-sm text-text-secondary",
|
|
239
|
+
children: a(e.updatedAt)
|
|
240
|
+
}), /* @__PURE__ */ y(i, {
|
|
241
|
+
permission: r.CHANNEL_UPDATE,
|
|
242
|
+
children: /* @__PURE__ */ y(s, {
|
|
243
|
+
variant: "outline",
|
|
244
|
+
size: "sm",
|
|
245
|
+
leftIcon: e.isActive ? /* @__PURE__ */ y(ae, { size: 14 }) : /* @__PURE__ */ y(w, { size: 14 }),
|
|
246
|
+
isLoading: z === e.id,
|
|
247
|
+
onClick: () => void ue(e),
|
|
248
|
+
children: e.isActive ? k("botlit.channelRoutes.actions.turnOff", "Turn off") : k("botlit.channelRoutes.actions.turnOn", "Turn on")
|
|
249
|
+
})
|
|
250
|
+
})]
|
|
251
|
+
})]
|
|
252
|
+
}) }) }, e.id))
|
|
253
|
+
}) : /* @__PURE__ */ y(d, {
|
|
254
|
+
illustration: "empty-search",
|
|
255
|
+
title: Z ? k("botlit.channelRoutes.empty.filteredTitle", "No routes match") : k("botlit.channels.empty.routes.title", "No routes configured"),
|
|
256
|
+
description: Z ? k("botlit.channelRoutes.empty.filteredDescription", "No loaded route matches the search and filters. Change them, or load more routes.") : k("botlit.channels.empty.routes.description", "Create routes to connect channel locations to specific bots."),
|
|
257
|
+
action: Z ? void 0 : $
|
|
258
|
+
}),
|
|
259
|
+
/* @__PURE__ */ y(h, {
|
|
260
|
+
hasMore: H.hasMore && !H.loading,
|
|
261
|
+
loadingMore: H.loadingMore,
|
|
262
|
+
onLoadMore: () => void H.loadMore(),
|
|
263
|
+
loadedCount: H.data.length
|
|
264
|
+
}),
|
|
265
|
+
/* @__PURE__ */ y(u, {
|
|
266
|
+
open: L,
|
|
267
|
+
onOpenChange: R,
|
|
268
|
+
onCreated: Q
|
|
269
|
+
})
|
|
270
|
+
]
|
|
271
|
+
});
|
|
272
|
+
};
|
|
273
|
+
export { D as ChannelRoutesPanel };
|
|
274
|
+
|
|
275
|
+
//# sourceMappingURL=ChannelRoutesPanel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChannelRoutesPanel.js","names":["Route","Route$1","selectClassName","ChannelRoutesPanel","t","useTr","useBotlit","search","setSearch","useState","connectorFilter","setConnectorFilter","statusFilter","setStatusFilter","createOpen","setCreateOpen","togglingId","setTogglingId","routeFilter","useMemo","routes","useChannelRoutes","overview","useChannelOverview","connectors","useAllChannelConnectors","bots","useAllBots","updateRoute","useUpdateChannelRoute","connectorName","row","id","botName","route","routeMetadataString","locationLabel","query","visibleRoutes","filtersApplied","refreshAll","onRoutesChanged","toggleRoute","toast","err","graphqlErrorMessage","createButton","BotmanorPermissionGate","BOTMANOR_PERMISSIONS","Button","Plus","showSummary","GlassCard","Search","Input","connector","i","ErrorState","Card","CardContent","Badge","Link","getPath","Radio","AppWindow","formatRelativeTime","PowerOff","Power","EmptyState","LoadMore","CreateChannelRouteDialog"],"sources":["../../../src/botlit/components/ChannelRoutesPanel.tsx"],"sourcesContent":["/**\n * Channel Routes panel\n * @module botlit/components\n *\n * The one routes list behind both the Routes tab on /channels and the\n * /channels/routes page (BOFF-12562), so they never disagree.\n *\n * - Totals come from the service (`channelOverview`), not from the number of\n * loaded rows; the list pages with \"Load more\" (BOFF-12569).\n * - Filters (connector, on/off) are applied by the service; search narrows\n * the loaded rows by location, connector or bot name (BOFF-12570).\n * - Each route can be turned off and on (BOFF-12566).\n * - \"Create route\" opens the shared create-route dialog (BOFF-12562).\n */\n\nimport type { FC } from 'react';\nimport { useMemo, useState } from 'react';\nimport { Link } from 'react-router';\nimport { AppWindow, Plus, Power, PowerOff, Radio, Route, Search } from 'lucide-react';\nimport { GlassCard } from '@burdenoff/fe-libs/ui';\nimport { toast } from 'sonner';\nimport { useTr } from '../../shared/hooks/useTr';\nimport {\n routeMetadataString,\n useAllBots,\n useAllChannelConnectors,\n useChannelOverview,\n useChannelRoutes,\n useUpdateChannelRoute,\n type ChannelRouteRecord,\n} from '../hooks';\nimport { BOTMANOR_PERMISSIONS, BotmanorPermissionGate } from '../permissions';\nimport { useBotlit } from '../providers/BotlitProvider';\nimport { graphqlErrorMessage } from '../utils/errors';\nimport { formatRelativeTime } from '../utils/formatters';\nimport { Badge } from './Badge';\nimport { Button } from './Button';\nimport { Card, CardContent } from './Card';\nimport { CreateChannelRouteDialog } from './CreateChannelRouteDialog';\nimport { EmptyState } from './EmptyState';\nimport { ErrorState } from './ErrorState';\nimport { Input } from './Input';\nimport { LoadMore } from './LoadMore';\n\ntype RouteStatusFilter = 'all' | 'active' | 'inactive';\n\nconst selectClassName =\n 'h-10 rounded-md border border-border-default bg-bg-surface px-3 py-2 text-sm';\n\ninterface ChannelRoutesPanelProps {\n /** Show the totals row (the Routes page does; the tab shows them in its label). */\n showSummary?: boolean;\n /** Called after a route is created or toggled, so the host can refresh its own counts. */\n onRoutesChanged?: () => void;\n}\n\nexport const ChannelRoutesPanel: FC<ChannelRoutesPanelProps> = ({\n showSummary = true,\n onRoutesChanged,\n}) => {\n const t = useTr();\n const { getPath } = useBotlit();\n const [search, setSearch] = useState('');\n const [connectorFilter, setConnectorFilter] = useState('');\n const [statusFilter, setStatusFilter] = useState<RouteStatusFilter>('all');\n const [createOpen, setCreateOpen] = useState(false);\n const [togglingId, setTogglingId] = useState<string | null>(null);\n\n const routeFilter = useMemo(\n () => ({\n connectorId: connectorFilter || undefined,\n isActive: statusFilter === 'all' ? undefined : statusFilter === 'active',\n }),\n [connectorFilter, statusFilter]\n );\n const routes = useChannelRoutes(routeFilter);\n const overview = useChannelOverview();\n const connectors = useAllChannelConnectors();\n const bots = useAllBots();\n const [updateRoute] = useUpdateChannelRoute();\n\n const connectorName = (id: string) =>\n connectors.data.find((row) => row.id === id)?.name ??\n t('botlit.channelRoutes.unknownConnector', 'Unknown connector');\n const botName = (route: ChannelRouteRecord) =>\n bots.data.find((row) => row.id === route.appId)?.name ??\n routeMetadataString(route, 'appName') ??\n t('botlit.channelRoutes.unknownBot', 'Unknown bot');\n const locationLabel = (route: ChannelRouteRecord) =>\n routeMetadataString(route, 'locationName') ?? route.locationId;\n\n const query = search.trim().toLowerCase();\n const visibleRoutes = query\n ? routes.data.filter((route) =>\n [route.locationId, locationLabel(route), connectorName(route.connectorId), botName(route)]\n .join(' ')\n .toLowerCase()\n .includes(query)\n )\n : routes.data;\n const filtersApplied = Boolean(query || connectorFilter || statusFilter !== 'all');\n\n const refreshAll = () => {\n void routes.refetch();\n void overview.refetch();\n onRoutesChanged?.();\n };\n\n const toggleRoute = async (route: ChannelRouteRecord) => {\n setTogglingId(route.id);\n try {\n await updateRoute({ routeId: route.id, input: { isActive: !route.isActive } });\n toast.success(\n route.isActive\n ? t('botlit.channelRoutes.toggle.off', 'Route turned off: {{location}}', {\n location: locationLabel(route),\n })\n : t('botlit.channelRoutes.toggle.on', 'Route turned on: {{location}}', {\n location: locationLabel(route),\n })\n );\n refreshAll();\n } catch (err) {\n toast.error(\n graphqlErrorMessage(\n err,\n t('botlit.channelRoutes.toggle.failed', 'The route could not be changed.')\n )\n );\n } finally {\n setTogglingId(null);\n }\n };\n\n const createButton = (\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.CHANNEL_CREATE}>\n <Button leftIcon={<Plus size={16} />} onClick={() => setCreateOpen(true)}>\n {t('botlit.channels.actions.createRoute', 'Create Route')}\n </Button>\n </BotmanorPermissionGate>\n );\n\n return (\n <div className=\"space-y-6\">\n {/* Totals, connector and bot names come from their own queries: a failure\n is said and can be retried, never shown as empty or \"Unknown\" data. */}\n {(Boolean(showSummary && overview.error) || connectors.error || bots.error) && (\n <div\n role=\"alert\"\n className=\"flex flex-wrap items-center justify-between gap-3 rounded-lg border border-status-warning-border bg-status-warning-bg-subtle px-4 py-3 text-sm\"\n >\n <span className=\"text-text-primary\">\n {[\n showSummary && overview.error\n ? t('botlit.channelRoutes.errors.overview', 'Route totals could not be loaded.')\n : '',\n connectors.error\n ? t(\n 'botlit.channelRoutes.errors.connectors',\n 'Connector names could not be loaded; some may show as unknown and the connector filter may be incomplete.'\n )\n : '',\n bots.error\n ? t(\n 'botlit.channelRoutes.errors.bots',\n 'Bot names could not be loaded; some may show as unknown and search by bot name may miss routes.'\n )\n : '',\n ]\n .filter(Boolean)\n .join(' ')}\n </span>\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={() => {\n if (overview.error) void overview.refetch();\n if (connectors.error) void connectors.refetch();\n if (bots.error) void bots.refetch();\n }}\n >\n {t('botlit.common.retry', 'Retry')}\n </Button>\n </div>\n )}\n\n {showSummary && overview.data && (\n <div className=\"grid grid-cols-2 gap-4 sm:grid-cols-3\">\n <GlassCard treatment=\"glass\" glow className=\"p-4\">\n <p className=\"text-sm text-text-secondary\">\n {t('botlit.channelRoutes.summary.active', 'Active routes')}\n </p>\n <p className=\"mt-1 text-2xl font-semibold tabular-nums text-text-primary\">\n {overview.data.activeRouteCount}\n </p>\n </GlassCard>\n <GlassCard treatment=\"metric\" className=\"p-4\">\n <p className=\"text-sm text-text-secondary\">\n {t('botlit.channelRoutes.summary.total', 'All routes')}\n </p>\n <p className=\"mt-1 text-2xl font-semibold tabular-nums text-text-primary\">\n {overview.data.routeCount}\n </p>\n </GlassCard>\n <GlassCard treatment=\"metric\" className=\"col-span-2 p-4 sm:col-span-1\">\n <p className=\"text-sm text-text-secondary\">\n {t('botlit.channelRoutes.summary.unrouted', 'Unanswered inbound messages')}\n </p>\n <p className=\"mt-1 text-2xl font-semibold tabular-nums text-text-primary\">\n {overview.data.unroutedMessageCount}\n </p>\n </GlassCard>\n </div>\n )}\n\n <div className=\"flex flex-wrap items-end gap-3\">\n <div className=\"relative min-w-56 flex-1 max-w-md\">\n <Search\n aria-hidden=\"true\"\n className=\"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-text-secondary\"\n />\n <Input\n aria-label={t('botlit.channelRoutes.search', 'Search routes')}\n placeholder={t('botlit.channelRoutes.searchPlaceholder', 'Search routes...')}\n value={search}\n onChange={(e) => setSearch(e.target.value)}\n className=\"pl-9\"\n />\n </div>\n <label className=\"grid gap-1 text-xs text-text-secondary\">\n {t('botlit.channelRoutes.filters.connector', 'Connector')}\n <select\n className={selectClassName}\n value={connectorFilter}\n onChange={(e) => setConnectorFilter(e.target.value)}\n >\n <option value=\"\">\n {t('botlit.channelRoutes.filters.allConnectors', 'All connectors')}\n </option>\n {connectors.data.map((connector) => (\n <option key={connector.id} value={connector.id}>\n {connector.name}\n </option>\n ))}\n </select>\n </label>\n <label className=\"grid gap-1 text-xs text-text-secondary\">\n {t('botlit.channelRoutes.filters.status', 'Status')}\n <select\n className={selectClassName}\n value={statusFilter}\n onChange={(e) => setStatusFilter(e.target.value as RouteStatusFilter)}\n >\n <option value=\"all\">\n {t('botlit.channelRoutes.filters.allStatuses', 'On and off')}\n </option>\n <option value=\"active\">{t('botlit.channelRoutes.status.on', 'On')}</option>\n <option value=\"inactive\">{t('botlit.channelRoutes.status.off', 'Off')}</option>\n </select>\n </label>\n <div className=\"ml-auto\">{createButton}</div>\n </div>\n\n {routes.loading ? (\n <div className=\"space-y-3\">\n {[1, 2, 3].map((i) => (\n <div key={i} className=\"h-24 rounded-lg bg-bg-sunken motion-safe:animate-vc-shimmer\" />\n ))}\n </div>\n ) : routes.error ? (\n <ErrorState\n resource={t('botlit.channelRoutes.resource', 'channel routes')}\n error={routes.error}\n onRetry={() => void routes.refetch()}\n />\n ) : visibleRoutes.length > 0 ? (\n <ul className=\"space-y-3\" aria-label={t('botlit.channelRoutes.listLabel', 'Routes')}>\n {visibleRoutes.map((route) => (\n <li key={route.id}>\n <Card>\n <CardContent className=\"flex flex-wrap items-center justify-between gap-4 py-4\">\n <div className=\"flex items-center gap-4\">\n <div className=\"rounded-lg bg-action-primary-bg/10 p-3\">\n <Route aria-hidden=\"true\" className=\"h-5 w-5 text-primary\" />\n </div>\n <div>\n <div className=\"flex items-center gap-2\">\n <h3 className=\"font-medium text-text-primary\">{locationLabel(route)}</h3>\n <Badge variant={route.isActive ? 'success' : 'outline'}>\n {route.isActive\n ? t('botlit.channelRoutes.status.on', 'On')\n : t('botlit.channelRoutes.status.off', 'Off')}\n </Badge>\n </div>\n <div className=\"mt-1 flex flex-wrap items-center gap-4 text-sm text-text-secondary\">\n <Link\n to={getPath(`channels/${route.connectorId}`)}\n className=\"flex items-center gap-1 hover:text-text-primary hover:underline\"\n >\n <Radio aria-hidden=\"true\" size={14} />\n {connectorName(route.connectorId)}\n </Link>\n <Link\n to={getPath(`bots/${route.appId}`)}\n className=\"flex items-center gap-1 hover:text-text-primary hover:underline\"\n >\n <AppWindow aria-hidden=\"true\" size={14} />\n {botName(route)}\n </Link>\n <span className=\"font-mono text-xs\">{route.locationId}</span>\n </div>\n </div>\n </div>\n <div className=\"flex items-center gap-3\">\n <span className=\"text-sm text-text-secondary\">\n {formatRelativeTime(route.updatedAt)}\n </span>\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.CHANNEL_UPDATE}>\n <Button\n variant=\"outline\"\n size=\"sm\"\n leftIcon={route.isActive ? <PowerOff size={14} /> : <Power size={14} />}\n isLoading={togglingId === route.id}\n onClick={() => void toggleRoute(route)}\n >\n {route.isActive\n ? t('botlit.channelRoutes.actions.turnOff', 'Turn off')\n : t('botlit.channelRoutes.actions.turnOn', 'Turn on')}\n </Button>\n </BotmanorPermissionGate>\n </div>\n </CardContent>\n </Card>\n </li>\n ))}\n </ul>\n ) : (\n <EmptyState\n illustration=\"empty-search\"\n title={\n filtersApplied\n ? t('botlit.channelRoutes.empty.filteredTitle', 'No routes match')\n : t('botlit.channels.empty.routes.title', 'No routes configured')\n }\n description={\n filtersApplied\n ? t(\n 'botlit.channelRoutes.empty.filteredDescription',\n 'No loaded route matches the search and filters. Change them, or load more routes.'\n )\n : t(\n 'botlit.channels.empty.routes.description',\n 'Create routes to connect channel locations to specific bots.'\n )\n }\n action={filtersApplied ? undefined : createButton}\n />\n )}\n\n <LoadMore\n // Hidden while a filter change reloads page one: an append now would\n // use the previous filter's offset.\n hasMore={routes.hasMore && !routes.loading}\n loadingMore={routes.loadingMore}\n onLoadMore={() => void routes.loadMore()}\n loadedCount={routes.data.length}\n />\n\n <CreateChannelRouteDialog\n open={createOpen}\n onOpenChange={setCreateOpen}\n onCreated={refreshAll}\n />\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,IAAME,IACJ,gFASWC,KAAmD,EAC9D,iBAAc,IACd,yBACI;CACJ,IAAMC,IAAIC,EAAM,GACV,EAAE,eAAYC,EAAU,GACxB,CAACC,GAAQC,KAAaC,EAAS,EAAE,GACjC,CAACC,GAAiBC,KAAsBF,EAAS,EAAE,GACnD,CAACG,GAAcC,KAAmBJ,EAA4B,KAAK,GACnE,CAACK,GAAYC,KAAiBN,EAAS,EAAK,GAC5C,CAACO,GAAYC,KAAiBR,EAAwB,IAAI,GAE1DS,IAAcC,SACX;EACL,aAAaT,KAAmB,KAAA;EAChC,UAAUE,MAAiB,QAAQ,KAAA,IAAYA,MAAiB;CAClE,IACA,CAACF,GAAiBE,CAAY,CAChC,GACMQ,IAASC,GAAiBH,CAAW,GACrCI,IAAWC,GAAmB,GAC9BC,IAAaC,GAAwB,GACrCC,IAAOC,EAAW,GAClB,CAACC,MAAeC,GAAsB,GAEtCC,KAAiB,MACrBN,EAAW,KAAK,MAAM,MAAQO,EAAI,OAAOC,CAAE,CAAC,EAAE,QAC9C5B,EAAE,yCAAyC,mBAAmB,GAC1D6B,KAAW,MACfP,EAAK,KAAK,MAAM,MAAQK,EAAI,OAAOG,EAAM,KAAK,CAAC,EAAE,QACjDC,EAAoBD,GAAO,SAAS,KACpC9B,EAAE,mCAAmC,aAAa,GAC9CgC,KAAiB,MACrBD,EAAoBD,GAAO,cAAc,KAAKA,EAAM,YAEhDG,IAAQ9B,EAAO,KAAK,CAAC,CAAC,YAAY,GAClC+B,IAAgBD,IAClBjB,EAAO,KAAK,QAAQ,MAClB;EAACc,EAAM;EAAYE,EAAcF,CAA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AAA,CAAA,CACF;KACL,CAAA,GAAA,kBAAC,OAAD;MAAK,WAAU;MAAf,UAAA,CACE,kBAAC,QAAD;OAAM,WAAU;OACb,UAAA+B,EAAmB/B,EAAM,SAAS;MAC/B,CAAA,GACN,kBAACa,GAAD;OAAwB,YAAYC,EAAqB;OACvD,UAAA,kBAACC,GAAD;QACE,SAAQ;QACR,MAAK;QACL,UAAUf,EAAM,WAAW,kBAACgC,IAAD,EAAU,MAAM,GAAK,CAAA,IAAI,kBAACC,GAAD,EAAO,MAAM,GAAK,CAAA;QACtE,WAAWnD,MAAekB,EAAM;QAChC,eAAe,KAAKQ,GAAYR,CAAK;QAEpC,UAAAA,EAAM,WACH9B,EAAE,wCAAwC,UAAU,IACpDA,EAAE,uCAAuC,SAAS;OAChD,CAAA;MACc,CAAA,CACrB;KACM,CAAA,CAAA;IACT,CAAA,EAAA,CAAA,EACJ,GAvDK8B,EAAM,EAuDX,CACL;GACC,CAAA,IAEJ,kBAACkC,GAAD;IACE,cAAa;IACb,OACE7B,IACInC,EAAE,4CAA4C,iBAAiB,IAC/DA,EAAE,sCAAsC,sBAAsB;IAEpE,aACEmC,IACInC,EACE,kDACA,mFACF,IACAA,EACE,4CACA,8DACF;IAEN,QAAQmC,IAAiB,KAAA,IAAYO;GACtC,CAAA;GAGH,kBAACuB,GAAD;IAGE,SAASjD,EAAO,WAAW,CAACA,EAAO;IACnC,aAAaA,EAAO;IACpB,kBAAkB,KAAKA,EAAO,SAAS;IACvC,aAAaA,EAAO,KAAK;GAC1B,CAAA;GAED,kBAACkD,GAAD;IACE,MAAMxD;IACN,cAAcC;IACd,WAAWyB;GACZ,CAAA;EACE;;AAET"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ChannelRouteRecord } from '../hooks';
|
|
3
|
+
/** The service stores at most this many characters for a location. */
|
|
4
|
+
export declare const ROUTE_LOCATION_MAX_LENGTH = 500;
|
|
5
|
+
interface CreateChannelRouteDialogProps {
|
|
6
|
+
open: boolean;
|
|
7
|
+
onOpenChange: (open: boolean) => void;
|
|
8
|
+
/** Set when the dialog is opened from one connector: the route is for it. */
|
|
9
|
+
connectorId?: string;
|
|
10
|
+
onCreated?: (route: ChannelRouteRecord) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare const CreateChannelRouteDialog: FC<CreateChannelRouteDialogProps>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { useTr as e } from "../../shared/hooks/useTr.js";
|
|
2
|
+
import "../hooks/index.js";
|
|
3
|
+
import { useAllBots as t } from "../hooks/useBots.js";
|
|
4
|
+
import { confirmAction as n } from "../utils/confirmAction.js";
|
|
5
|
+
import { graphqlErrorMessage as r } from "../utils/errors.js";
|
|
6
|
+
import { Button as i } from "./Button.js";
|
|
7
|
+
import { useAllChannelConnectors as a, useCreateChannelRoute as o } from "../hooks/useChannels.js";
|
|
8
|
+
import { FormField as s, Input as c } from "./Input.js";
|
|
9
|
+
import { useId as l, useMemo as u, useState as d } from "react";
|
|
10
|
+
import { ResponsiveDialog as f, ResponsiveDialogContent as p, ResponsiveDialogDescription as m, ResponsiveDialogFooter as h, ResponsiveDialogHeader as g, ResponsiveDialogTitle as _ } from "@burdenoff/fe-libs/ui";
|
|
11
|
+
import { jsx as v, jsxs as y } from "react/jsx-runtime";
|
|
12
|
+
import { toast as b } from "sonner";
|
|
13
|
+
var x = "flex h-10 w-full rounded-md border border-border-default bg-bg-surface px-3 py-2 text-sm", S = (e) => e.open ? /* @__PURE__ */ v(C, { ...e }) : null, C = ({ onOpenChange: S, connectorId: C, onCreated: w }) => {
|
|
14
|
+
let T = e(), E = l(), D = u(() => ({
|
|
15
|
+
connectorId: C ?? "",
|
|
16
|
+
locationId: "*",
|
|
17
|
+
locationName: "",
|
|
18
|
+
botId: "",
|
|
19
|
+
isActive: !0
|
|
20
|
+
}), [C]), [O, k] = d(D), [A, j] = d(!1), [M, N] = d(null), P = a(), F = t(), [I, L] = o(), R = O.locationId.trim(), z = {};
|
|
21
|
+
O.connectorId || (z.connectorId = T("botlit.channelRoutes.create.errors.connectorRequired", "Choose the channel connector this route belongs to.")), R ? R.length > 500 && (z.locationId = T("botlit.channelRoutes.create.errors.locationTooLong", "The location can be at most {{max}} characters.", { max: 500 })) : z.locationId = T("botlit.channelRoutes.create.errors.locationRequired", "Enter the location this route answers, or * for every location."), O.botId || (z.botId = T("botlit.channelRoutes.create.errors.botRequired", "Choose the bot that answers messages on this location."));
|
|
22
|
+
let B = Object.keys(z).length > 0, V = JSON.stringify(O) !== JSON.stringify(D), H = async () => {
|
|
23
|
+
(!V || L.loading || await n({
|
|
24
|
+
title: T("botlit.channelRoutes.create.discard.title", "Discard this route?"),
|
|
25
|
+
message: T("botlit.channelRoutes.create.discard.message", "The route has not been created. Close the form and lose what you entered?"),
|
|
26
|
+
confirmLabel: T("botlit.common.discard", "Discard"),
|
|
27
|
+
cancelLabel: T("botlit.common.keepEditing", "Keep editing")
|
|
28
|
+
})) && S(!1);
|
|
29
|
+
}, U = async (e) => {
|
|
30
|
+
if (e.preventDefault(), j(!0), N(null), B || L.loading) return;
|
|
31
|
+
let t = P.data.find((e) => e.id === O.connectorId), n = F.data.find((e) => e.id === O.botId);
|
|
32
|
+
try {
|
|
33
|
+
let e = await I({
|
|
34
|
+
connectorId: O.connectorId,
|
|
35
|
+
locationId: R,
|
|
36
|
+
appId: O.botId,
|
|
37
|
+
isActive: O.isActive,
|
|
38
|
+
metadata: {
|
|
39
|
+
locationName: O.locationName.trim() || R,
|
|
40
|
+
appName: n?.name,
|
|
41
|
+
connectorName: t?.name
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
b.success(T("botlit.channelRoutes.create.success", "Route created: {{location}} goes to {{bot}}", {
|
|
45
|
+
location: O.locationName.trim() || R,
|
|
46
|
+
bot: n?.name ?? O.botId
|
|
47
|
+
})), S(!1), e && w?.(e);
|
|
48
|
+
} catch (e) {
|
|
49
|
+
N(r(e, T("botlit.channelRoutes.create.errors.failed", "The route could not be created.")));
|
|
50
|
+
}
|
|
51
|
+
}, W = (e) => `${E}-${e}`, G = (e) => A ? z[e] : void 0;
|
|
52
|
+
return /* @__PURE__ */ v(f, {
|
|
53
|
+
open: !0,
|
|
54
|
+
onOpenChange: (e) => e ? void 0 : void H(),
|
|
55
|
+
children: /* @__PURE__ */ y(p, { children: [/* @__PURE__ */ y(g, { children: [/* @__PURE__ */ v(_, { children: T("botlit.channelRoutes.create.title", "Create route") }), /* @__PURE__ */ v(m, { children: T("botlit.channelRoutes.create.description", "Choose which bot answers messages that arrive at a location on a channel connector.") })] }), /* @__PURE__ */ y("form", {
|
|
56
|
+
noValidate: !0,
|
|
57
|
+
className: "space-y-4",
|
|
58
|
+
onSubmit: (e) => void U(e),
|
|
59
|
+
children: [
|
|
60
|
+
C === void 0 && /* @__PURE__ */ v(s, {
|
|
61
|
+
label: T("botlit.channelRoutes.create.connector", "Channel connector"),
|
|
62
|
+
htmlFor: W("connector"),
|
|
63
|
+
required: !0,
|
|
64
|
+
error: G("connectorId"),
|
|
65
|
+
children: /* @__PURE__ */ y("select", {
|
|
66
|
+
id: W("connector"),
|
|
67
|
+
className: x,
|
|
68
|
+
value: O.connectorId,
|
|
69
|
+
"aria-invalid": !!G("connectorId"),
|
|
70
|
+
onChange: (e) => k({
|
|
71
|
+
...O,
|
|
72
|
+
connectorId: e.target.value
|
|
73
|
+
}),
|
|
74
|
+
children: [/* @__PURE__ */ v("option", {
|
|
75
|
+
value: "",
|
|
76
|
+
children: P.loading ? T("botlit.common.loading", "Loading...") : P.data.length > 0 ? T("botlit.channelRoutes.create.connectorPlaceholder", "Select a connector...") : T("botlit.channelRoutes.create.noConnectors", "No connectors yet. Add a channel first.")
|
|
77
|
+
}), P.data.map((e) => /* @__PURE__ */ v("option", {
|
|
78
|
+
value: e.id,
|
|
79
|
+
children: e.name
|
|
80
|
+
}, e.id))]
|
|
81
|
+
})
|
|
82
|
+
}),
|
|
83
|
+
/* @__PURE__ */ y("div", {
|
|
84
|
+
className: "grid gap-4 sm:grid-cols-2",
|
|
85
|
+
children: [/* @__PURE__ */ v(s, {
|
|
86
|
+
label: T("botlit.channelRoutes.create.location", "Location ID"),
|
|
87
|
+
htmlFor: W("location"),
|
|
88
|
+
description: T("botlit.channelRoutes.create.locationHint", "* for every location, or a platform channel ID"),
|
|
89
|
+
required: !0,
|
|
90
|
+
error: G("locationId"),
|
|
91
|
+
children: /* @__PURE__ */ v(c, {
|
|
92
|
+
id: W("location"),
|
|
93
|
+
value: O.locationId,
|
|
94
|
+
maxLength: 500,
|
|
95
|
+
"aria-invalid": !!G("locationId"),
|
|
96
|
+
onChange: (e) => k({
|
|
97
|
+
...O,
|
|
98
|
+
locationId: e.target.value
|
|
99
|
+
})
|
|
100
|
+
})
|
|
101
|
+
}), /* @__PURE__ */ v(s, {
|
|
102
|
+
label: T("botlit.channelRoutes.create.locationName", "Location name"),
|
|
103
|
+
htmlFor: W("location-name"),
|
|
104
|
+
description: T("botlit.channelRoutes.create.locationNameHint", "Optional label"),
|
|
105
|
+
children: /* @__PURE__ */ v(c, {
|
|
106
|
+
id: W("location-name"),
|
|
107
|
+
value: O.locationName,
|
|
108
|
+
maxLength: 200,
|
|
109
|
+
onChange: (e) => k({
|
|
110
|
+
...O,
|
|
111
|
+
locationName: e.target.value
|
|
112
|
+
})
|
|
113
|
+
})
|
|
114
|
+
})]
|
|
115
|
+
}),
|
|
116
|
+
/* @__PURE__ */ v(s, {
|
|
117
|
+
label: T("botlit.channelRoutes.create.bot", "Bot"),
|
|
118
|
+
htmlFor: W("bot"),
|
|
119
|
+
required: !0,
|
|
120
|
+
error: G("botId"),
|
|
121
|
+
children: /* @__PURE__ */ y("select", {
|
|
122
|
+
id: W("bot"),
|
|
123
|
+
className: x,
|
|
124
|
+
value: O.botId,
|
|
125
|
+
"aria-invalid": !!G("botId"),
|
|
126
|
+
onChange: (e) => k({
|
|
127
|
+
...O,
|
|
128
|
+
botId: e.target.value
|
|
129
|
+
}),
|
|
130
|
+
children: [/* @__PURE__ */ v("option", {
|
|
131
|
+
value: "",
|
|
132
|
+
children: F.loading ? T("botlit.common.loading", "Loading...") : F.data.length > 0 ? T("botlit.channelRoutes.create.botPlaceholder", "Select a bot...") : T("botlit.channelRoutes.create.noBots", "No bots yet. Create a bot first.")
|
|
133
|
+
}), F.data.map((e) => /* @__PURE__ */ v("option", {
|
|
134
|
+
value: e.id,
|
|
135
|
+
children: e.name
|
|
136
|
+
}, e.id))]
|
|
137
|
+
})
|
|
138
|
+
}),
|
|
139
|
+
/* @__PURE__ */ y("label", {
|
|
140
|
+
className: "flex items-start gap-2 text-sm",
|
|
141
|
+
children: [/* @__PURE__ */ v("input", {
|
|
142
|
+
type: "checkbox",
|
|
143
|
+
className: "mt-1",
|
|
144
|
+
checked: O.isActive,
|
|
145
|
+
onChange: (e) => k({
|
|
146
|
+
...O,
|
|
147
|
+
isActive: e.target.checked
|
|
148
|
+
})
|
|
149
|
+
}), /* @__PURE__ */ y("span", { children: [/* @__PURE__ */ v("span", {
|
|
150
|
+
className: "font-medium",
|
|
151
|
+
children: T("botlit.channelRoutes.create.active", "Turn the route on now")
|
|
152
|
+
}), /* @__PURE__ */ v("span", {
|
|
153
|
+
className: "block text-text-secondary",
|
|
154
|
+
children: T("botlit.channelRoutes.create.activeHint", "A route that is off is ignored until you turn it on.")
|
|
155
|
+
})] })]
|
|
156
|
+
}),
|
|
157
|
+
(P.error || F.error) && /* @__PURE__ */ v("p", {
|
|
158
|
+
role: "alert",
|
|
159
|
+
className: "text-sm text-status-error-text",
|
|
160
|
+
children: T("botlit.channelRoutes.create.errors.optionsUnavailable", "Connectors or bots could not be loaded. Close the form and try again.")
|
|
161
|
+
}),
|
|
162
|
+
M && /* @__PURE__ */ v("p", {
|
|
163
|
+
role: "alert",
|
|
164
|
+
className: "text-sm text-status-error-text",
|
|
165
|
+
children: M
|
|
166
|
+
}),
|
|
167
|
+
A && B && /* @__PURE__ */ v("p", {
|
|
168
|
+
role: "alert",
|
|
169
|
+
className: "text-sm text-status-error-text",
|
|
170
|
+
children: T("botlit.channelRoutes.create.errors.summary", "Fill in the highlighted fields to create the route.")
|
|
171
|
+
}),
|
|
172
|
+
/* @__PURE__ */ y(h, { children: [/* @__PURE__ */ v(i, {
|
|
173
|
+
type: "button",
|
|
174
|
+
variant: "outline",
|
|
175
|
+
onClick: () => void H(),
|
|
176
|
+
children: T("botlit.common.cancel", "Cancel")
|
|
177
|
+
}), /* @__PURE__ */ v(i, {
|
|
178
|
+
type: "submit",
|
|
179
|
+
isLoading: L.loading,
|
|
180
|
+
children: T("botlit.channelRoutes.create.submit", "Create route")
|
|
181
|
+
})] })
|
|
182
|
+
]
|
|
183
|
+
})] })
|
|
184
|
+
});
|
|
185
|
+
};
|
|
186
|
+
export { S as CreateChannelRouteDialog };
|
|
187
|
+
|
|
188
|
+
//# sourceMappingURL=CreateChannelRouteDialog.js.map
|