@burdenoff/microfe-botmanor 2026.1112.3 → 2026.1115.1
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/ActionMenu.d.ts +18 -0
- package/dist/botlit/components/ActionMenu.js +76 -0
- package/dist/botlit/components/ActionMenu.js.map +1 -0
- package/dist/botlit/components/BotFormFields.d.ts +35 -0
- package/dist/botlit/components/BotFormFields.js +261 -0
- package/dist/botlit/components/BotFormFields.js.map +1 -0
- package/dist/botlit/components/Input.js +4 -0
- package/dist/botlit/components/Input.js.map +1 -1
- package/dist/botlit/components/index.d.ts +1 -0
- package/dist/botlit/hooks/useBots.js +3 -2
- package/dist/botlit/hooks/useBots.js.map +1 -1
- package/dist/botlit/pages/BotDetailPage.js +428 -551
- package/dist/botlit/pages/BotDetailPage.js.map +1 -1
- package/dist/botlit/pages/BotsListPage.js +260 -237
- package/dist/botlit/pages/BotsListPage.js.map +1 -1
- package/dist/botlit/utils/botIdentity.d.ts +34 -0
- package/dist/botlit/utils/botIdentity.js +36 -0
- package/dist/botlit/utils/botIdentity.js.map +1 -0
- package/dist/botlit/utils/breadcrumb.d.ts +12 -0
- package/dist/botlit/utils/breadcrumb.js +13 -0
- package/dist/botlit/utils/breadcrumb.js.map +1 -0
- package/dist/botlit/utils/confirmAction.d.ts +17 -0
- package/dist/botlit/utils/confirmAction.js +14 -0
- package/dist/botlit/utils/confirmAction.js.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BotsListPage.js","names":["BotsListPage","t","useTr","useBotlit","useBotlitStore","bots","useBots","botFilter","deleteBot","useDeleteBot","menuOpen","setMenuOpen","useState","handleSearch","handleDelete","confirmMsg","bot","native","nativeConfirm","toast","isNative","nativeNotify","err","message","PageLayout","BotmanorPermissionGate","BOTMANOR_PERMISSIONS","Button","Plus","navigateTo","PagePurpose","Bot","GlassCard","b","formatNumber","sum","Search","Input","viewMode","setViewMode","Grid3X3","List","loading","cn","i","Card","CardContent","StatusBadge","e","MoreVertical","Edit","Workflow","Trash2","formatRelativeTime","Link","getPath","EmptyState","LoadMore","loadMore"],"sources":["../../../src/botlit/pages/BotsListPage.tsx"],"sourcesContent":["/**\n * Bots List Page\n * @module botlit/pages\n */\n\nimport type { FC } from 'react';\nimport { useState } from 'react';\nimport { Link } from 'react-router';\nimport {\n Plus,\n Search,\n Grid3X3,\n List,\n MoreVertical,\n Bot,\n Trash2,\n Edit,\n Workflow,\n} from 'lucide-react';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { toast } from 'sonner';\nimport { isNative, nativeConfirm, nativeImpact, nativeNotify } from '../../utils/nativeBridge';\nimport { PagePurpose, GlassCard } from '@burdenoff/fe-libs/ui';\nimport { PageLayout } from '../components/PageLayout';\nimport { Card, CardContent } from '../components/Card';\nimport { Button } from '../components/Button';\nimport { Input } from '../components/Input';\nimport { StatusBadge } from '../components/Badge';\nimport { EmptyState } from '../components/EmptyState';\nimport { LoadMore } from '../components/LoadMore';\nimport { useBots, useDeleteBot } from '../hooks/useBots';\nimport { useBotlitStore } from '../store/botlitStore';\nimport { useBotlit } from '../providers/BotlitProvider';\nimport { formatRelativeTime, formatNumber } from '../utils/formatters';\nimport { cn } from '../utils/cn';\nimport { BOTMANOR_PERMISSIONS, BotmanorPermissionGate } from '../permissions';\n// Real GraphQL BotApp fields: id, name, slug, description, type, status, visibility, icon, routingStrategy, defaultAgentId, executionCount, createdAt, tagIds\n\nexport const BotsListPage: FC = () => {\n const t = useTr();\n const { navigateTo, getPath } = useBotlit();\n const { viewMode, setViewMode, botFilter, updateBotFilter } = useBotlitStore();\n const { data: bots, loading, hasMore, loadingMore, loadMore } = useBots(botFilter);\n const [deleteBot] = useDeleteBot();\n const [menuOpen, setMenuOpen] = useState<string | null>(null);\n\n const handleSearch = (e: React.ChangeEvent<HTMLInputElement>) => {\n updateBotFilter({ search: e.target.value });\n };\n\n const handleDelete = async (bot: { id: string; name: string }) => {\n const confirmMsg = `${t('botlit.botsList.delete.confirmPrefix', 'Are you sure you want to delete')} \"${bot.name}\"?`;\n const native = await nativeConfirm({\n title: 'Delete bot?',\n message: confirmMsg,\n okButtonTitle: 'Delete',\n cancelButtonTitle: 'Cancel',\n });\n const ok = native === null ? confirm(confirmMsg) : native;\n if (ok) {\n nativeImpact('medium');\n try {\n await deleteBot(bot.id);\n toast.success(\n `${t('botlit.botsList.delete.successPrefix', 'Bot')} \"${bot.name}\" ${t('botlit.botsList.delete.successSuffix', 'deleted successfully')}`\n );\n if (isNative()) void nativeNotify('success');\n } catch (err: unknown) {\n const message =\n err instanceof Error\n ? err.message\n : t('botlit.botsList.delete.error', 'Failed to delete bot');\n toast.error(message);\n if (isNative()) void nativeNotify('error');\n }\n }\n setMenuOpen(null);\n };\n\n return (\n <PageLayout\n title={t('botlit.botsList.title', 'Bots')}\n description={t('botlit.botsList.description', 'Manage your AI-powered bots')}\n actions={\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.APP_CREATE}>\n <Button leftIcon={<Plus size={16} />} onClick={() => navigateTo('bots/new')}>\n {t('botlit.botsList.actions.createBot', 'Create Bot')}\n </Button>\n </BotmanorPermissionGate>\n }\n >\n <div className=\"space-y-6\">\n <PagePurpose icon={<Bot size={18} />}>\n {t(\n 'botlit.botsList.purpose',\n 'A bot is the deployable, user-facing surface for your AI — it wraps one or more agents and exposes them to people through chat, channels (Slack, web widget, WhatsApp) and APIs. Create a bot here when you are ready to put an agent in front of real users, then connect channels and watch its executions.'\n )}\n </PagePurpose>\n\n {/* Summary */}\n {bots && bots.length > 0 ? (\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.botsList.summary.total', 'Total bots')}\n </p>\n <p className=\"mt-1 text-2xl font-semibold tabular-nums text-text-primary\">\n {bots.length}\n </p>\n </GlassCard>\n <GlassCard treatment=\"metric\" className=\"p-4\">\n <p className=\"text-sm text-text-secondary\">\n {t('botlit.botsList.summary.active', 'Active')}\n </p>\n <p className=\"mt-1 text-2xl font-semibold tabular-nums text-text-primary\">\n {bots.filter((b: { status?: string }) => b.status === 'ACTIVE').length}\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.botsList.summary.executions', 'Total executions')}\n </p>\n <p className=\"mt-1 text-2xl font-semibold tabular-nums text-text-primary\">\n {formatNumber(bots.reduce((sum, bot) => sum + (bot.executionCount ?? 0), 0))}\n </p>\n </GlassCard>\n </div>\n ) : null}\n\n {/* Toolbar */}\n <div className=\"flex items-center justify-between gap-4\">\n <div className=\"relative flex-1 max-w-md\">\n <Search className=\"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-text-secondary\" />\n <Input\n placeholder={t('botlit.botsList.searchPlaceholder', 'Search bots...')}\n value={botFilter.search || ''}\n onChange={handleSearch}\n className=\"pl-9\"\n />\n </div>\n <div className=\"flex items-center gap-2\">\n <Button\n variant={viewMode === 'grid' ? 'secondary' : 'ghost'}\n size=\"icon\"\n onClick={() => setViewMode('grid')}\n >\n <Grid3X3 size={18} />\n </Button>\n <Button\n variant={viewMode === 'list' ? 'secondary' : 'ghost'}\n size=\"icon\"\n onClick={() => setViewMode('list')}\n >\n <List size={18} />\n </Button>\n </div>\n </div>\n\n {/* Content */}\n {loading ? (\n <div\n className={cn(\n 'gap-4',\n viewMode === 'grid'\n ? 'grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3'\n : 'flex flex-col'\n )}\n >\n {[1, 2, 3, 4, 5, 6].map((i) => (\n <div\n key={i}\n className=\"h-48 bg-bg-sunken motion-safe:animate-vc-shimmer rounded-lg\"\n />\n ))}\n </div>\n ) : bots.length > 0 ? (\n viewMode === 'grid' ? (\n <div className=\"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4\">\n {bots.map((bot) => (\n <Card\n key={bot.id}\n className=\"group hover:shadow-md transition-shadow cursor-pointer relative\"\n onClick={() => navigateTo(`bots/${bot.id}`)}\n >\n <CardContent className=\"pt-6\">\n <div className=\"flex items-start justify-between\">\n <div className=\"flex items-center gap-3\">\n <span className=\"text-4xl\">{bot.icon || '🤖'}</span>\n <div>\n <h3 className=\"font-semibold text-text-primary\">{bot.name}</h3>\n <StatusBadge status={bot.status} />\n </div>\n </div>\n <div className=\"relative\">\n <Button\n variant=\"ghost\"\n size=\"icon\"\n className=\"opacity-0 group-hover:opacity-100 transition-opacity\"\n onClick={(e) => {\n e.stopPropagation();\n setMenuOpen(menuOpen === bot.id ? null : bot.id);\n }}\n >\n <MoreVertical size={16} />\n </Button>\n {menuOpen === bot.id && (\n <div className=\"absolute right-0 top-full mt-1 w-48 bg-popover border border-border-subtle rounded-md shadow-lg z-10\">\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.APP_UPDATE}>\n <button\n className=\"w-full px-4 py-2 text-left text-sm hover:bg-accent flex items-center gap-2\"\n onClick={(e) => {\n e.stopPropagation();\n navigateTo(`bots/${bot.id}/edit`);\n setMenuOpen(null);\n }}\n >\n <Edit size={16} />\n {t('botlit.botsList.menu.editBot', 'Edit Bot')}\n </button>\n </BotmanorPermissionGate>\n <button\n className=\"w-full px-4 py-2 text-left text-sm hover:bg-accent flex items-center gap-2\"\n onClick={(e) => {\n e.stopPropagation();\n navigateTo(`bots/${bot.id}?tab=workflow`);\n setMenuOpen(null);\n }}\n >\n <Workflow size={16} />\n {t('botlit.botsList.menu.design', 'Design workflow')}\n </button>\n <button\n className=\"w-full px-4 py-2 text-left text-sm hover:bg-accent flex items-center gap-2\"\n onClick={(e) => {\n e.stopPropagation();\n navigateTo(`bots/${bot.id}/agents`);\n setMenuOpen(null);\n }}\n >\n <Bot size={16} />\n {t('botlit.botsList.menu.viewAgents', 'View Agents')}\n </button>\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.APP_DELETE}>\n <button\n className=\"w-full px-4 py-2 text-left text-sm hover:bg-accent text-status-error-text flex items-center gap-2\"\n onClick={(e) => {\n e.stopPropagation();\n handleDelete(bot);\n }}\n >\n <Trash2 size={16} />\n {t('botlit.common.delete', 'Delete')}\n </button>\n </BotmanorPermissionGate>\n </div>\n )}\n </div>\n </div>\n <p className=\"mt-3 text-sm text-text-secondary line-clamp-2\">\n {bot.description}\n </p>\n <div className=\"mt-4 flex items-center gap-4 text-xs text-text-secondary\">\n <span className=\"flex items-center gap-1\">\n <Bot size={14} />\n {bot.executionCount || 0} {t('botlit.common.executions', 'executions')}\n </span>\n </div>\n <div className=\"mt-3 pt-3 border-t border-border-subtle flex items-center justify-between gap-2\">\n <span className=\"text-xs text-text-secondary\">\n {t('botlit.botsList.createdLabel', 'Created')}{' '}\n {formatRelativeTime(bot.createdAt)}\n </span>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n leftIcon={<Workflow size={14} />}\n onClick={(e) => {\n e.stopPropagation();\n navigateTo(`bots/${bot.id}?tab=workflow`);\n }}\n >\n {t('botlit.botsList.actions.design', 'Design')}\n </Button>\n </div>\n </CardContent>\n </Card>\n ))}\n </div>\n ) : (\n <div className=\"space-y-2\">\n {bots.map((bot) => (\n <Card\n key={bot.id}\n className=\"hover:shadow-md transition-shadow cursor-pointer\"\n onClick={() => navigateTo(`bots/${bot.id}`)}\n >\n <CardContent className=\"py-4\">\n <div className=\"flex items-center justify-between\">\n <div className=\"flex items-center gap-4\">\n <span className=\"text-3xl\">{bot.icon || '🤖'}</span>\n <div>\n <div className=\"flex items-center gap-2\">\n <h3 className=\"font-semibold text-text-primary\">{bot.name}</h3>\n <StatusBadge status={bot.status} />\n </div>\n <p className=\"text-sm text-text-secondary line-clamp-1\">\n {bot.description}\n </p>\n </div>\n </div>\n <div className=\"flex items-center gap-6 text-sm text-text-secondary\">\n <span>\n {formatNumber(bot.executionCount)}{' '}\n {t('botlit.common.executions', 'executions')}\n </span>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n leftIcon={<Workflow size={14} />}\n onClick={(e) => {\n e.stopPropagation();\n navigateTo(`bots/${bot.id}?tab=workflow`);\n }}\n >\n {t('botlit.botsList.actions.design', 'Design')}\n </Button>\n <Button variant=\"ghost\" size=\"sm\">\n <Link to={getPath(`bots/${bot.id}`)}>\n {t('botlit.common.view', 'View')}\n </Link>\n </Button>\n </div>\n </div>\n </CardContent>\n </Card>\n ))}\n </div>\n )\n ) : (\n <EmptyState\n illustration=\"empty-agents\"\n title={t('botlit.botsList.empty.title', 'No bots yet')}\n description={t(\n 'botlit.botsList.empty.description',\n 'Create your first AI-powered bot to get started with building agents and automations.'\n )}\n action={\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.APP_CREATE}>\n <Button leftIcon={<Plus size={16} />} onClick={() => navigateTo('bots/new')}>\n {t('botlit.botsList.actions.createBot', 'Create Bot')}\n </Button>\n </BotmanorPermissionGate>\n }\n />\n )}\n <LoadMore\n hasMore={hasMore}\n loadingMore={loadingMore}\n onLoadMore={() => void loadMore()}\n loadedCount={bots.length}\n />\n </div>\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAsCA,IAAaA,UAAyB;CACpC,IAAMC,IAAIC,EAAM,GACV,EAAE,eAAY,eAAYC,EAAU,GACpC,EAAE,aAAU,gBAAa,cAAW,uBAAoBC,EAAe,GACvE,EAAE,MAAMC,GAAM,YAAS,YAAS,gBAAa,gBAAaC,EAAQC,CAAS,GAC3E,CAACC,KAAaC,EAAa,GAC3B,CAACC,GAAUC,KAAeC,EAAwB,IAAI,GAEtDC,KAAgB,MAA2C;EAC/D,EAAgB,EAAE,QAAQ,EAAE,OAAO,MAAM,CAAC;CAC5C,GAEMC,KAAe,OAAO,MAAsC;EAChE,IAAMC,IAAa,GAAGd,EAAE,wCAAwC,iCAAiC,EAAE,IAAIe,EAAI,KAAK,KAC1GC,IAAS,MAAMC,EAAc;GACjC,OAAO;GACP,SAASH;GACT,eA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AAgB,GAClBnB,EAAW,QAAQb,EAAI,GAAG,cAAc;WAC1C;WAEC,UAAAf,EAAE,kCAAkC,QAAQ;UACvC,CAAA;UACR,kBAAC0B,GAAD;WAAQ,SAAQ;WAAQ,MAAK;WAC3B,UAAA,kBAAC2B,GAAD;YAAM,IAAIC,EAAQ,QAAQvC,EAAI,IAAI;YAC/B,UAAAf,EAAE,sBAAsB,MAAM;WAC3B,CAAA;UACA,CAAA;SACL;QACF,CAAA,CAAA;;MACM,CAAA;KACT,GA1CCe,EAAI,EA0CL,CACP;IACE,CAAA,IAGP,kBAACwC,GAAD;KACE,cAAa;KACb,OAAOvD,EAAE,+BAA+B,aAAa;KACrD,aAAaA,EACX,qCACA,uFACF;KACA,QACE,kBAACwB,GAAD;MAAwB,YAAYC,EAAqB;MACvD,UAAA,kBAACC,GAAD;OAAQ,UAAU,kBAACC,GAAD,EAAM,MAAM,GAAK,CAAA;OAAG,eAAeC,EAAW,UAAU;OACvE,UAAA5B,EAAE,qCAAqC,YAAY;MAC9C,CAAA;KACc,CAAA;IAE3B,CAAA;IAEH,kBAACwD,GAAD;KACW;KACI;KACb,kBAAkB,KAAKC,EAAS;KAChC,aAAarD,EAAK;IACnB,CAAA;GACE;;CACK,CAAA;AAEhB"}
|
|
1
|
+
{"version":3,"file":"BotsListPage.js","names":["STRETCHED_LINK","BotsListPage","t","useTr","can","useBotmanorCan","useBotlit","useBotlitStore","bots","useBots","botFilter","botCounts","useBotAppCounts","deleteBot","useDeleteBot","search","handleSearch","handleDelete","confirmAction","bot","toast","isNative","nativeNotify","refetch","err","message","menuItemsFor","items","BOTMANOR_PERMISSIONS","Edit","navigateTo","Workflow","Bot","Trash2","executionsLabel","n","count","formatNumber","showEmptyState","loading","error","createBotButton","BotmanorPermissionGate","Button","Plus","counts","PageLayout","PagePurpose","GlassCard","Search","Input","viewMode","setViewMode","Grid3X3","List","cn","i","ErrorState","Card","CardContent","Link","getPath","StatusBadge","ActionMenu","formatRelativeTime","EmptyState","updateBotFilter","LoadMore","loadMore"],"sources":["../../../src/botlit/pages/BotsListPage.tsx"],"sourcesContent":["/**\n * Bots List Page\n * @module botlit/pages\n *\n * States (BOFF-12435, 12436, 12443, 12444):\n * - loading: skeletons announced as a busy status region\n * - failed: an error state with retry, never the empty state\n * - no bots: first-step guidance and the only \"Create Bot\" button\n * - no search results: says so and offers to clear the search\n * - populated: grid or list, every row a real link, with an accessible menu\n */\n\nimport type { FC } from 'react';\nimport { Link } from 'react-router';\nimport { Plus, Search, Grid3X3, List, Bot, Trash2, Edit, Workflow } from 'lucide-react';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { toast } from 'sonner';\nimport { isNative, nativeImpact, nativeNotify } from '../../utils/nativeBridge';\nimport { PagePurpose, GlassCard } from '@burdenoff/fe-libs/ui';\nimport { PageLayout } from '../components/PageLayout';\nimport { Card, CardContent } from '../components/Card';\nimport { Button } from '../components/Button';\nimport { Input } from '../components/Input';\nimport { StatusBadge } from '../components/Badge';\nimport { EmptyState } from '../components/EmptyState';\nimport { ErrorState } from '../components/ErrorState';\nimport { ActionMenu, type ActionMenuItem } from '../components/ActionMenu';\nimport { LoadMore } from '../components/LoadMore';\nimport { useBotAppCounts, useBots, useDeleteBot } from '../hooks/useBots';\nimport { useBotlitStore } from '../store/botlitStore';\nimport { useBotlit } from '../providers/BotlitProvider';\nimport { formatRelativeTime, formatNumber } from '../utils/formatters';\nimport { confirmAction } from '../utils/confirmAction';\nimport { cn } from '../utils/cn';\nimport { BOTMANOR_PERMISSIONS, BotmanorPermissionGate, useBotmanorCan } from '../permissions';\n// Real GraphQL BotApp fields: id, name, slug, description, type, status, visibility, icon, routingStrategy, defaultAgentId, executionCount, createdAt, tagIds\n\n/** Makes the whole card the click target while the name stays the one real link. */\nconst STRETCHED_LINK =\n 'after:absolute after:inset-0 after:content-[\"\"] focus-visible:outline-none focus-visible:after:ring-2 focus-visible:after:ring-primary focus-visible:after:rounded-lg';\n\nexport const BotsListPage: FC = () => {\n const t = useTr();\n const can = useBotmanorCan();\n const { navigateTo, getPath } = useBotlit();\n const { viewMode, setViewMode, botFilter, updateBotFilter } = useBotlitStore();\n const {\n data: bots,\n loading,\n error,\n refetch,\n hasMore,\n loadingMore,\n loadMore,\n } = useBots(botFilter);\n const botCounts = useBotAppCounts();\n const [deleteBot] = useDeleteBot();\n\n const search = (botFilter.search ?? '').trim();\n\n const handleSearch = (e: React.ChangeEvent<HTMLInputElement>) => {\n updateBotFilter({ search: e.target.value });\n };\n\n const handleDelete = async (bot: { id: string; name: string }) => {\n const confirmed = await confirmAction({\n title: t('botlit.botsList.delete.title', 'Delete bot?'),\n message: t(\n 'botlit.botsList.delete.confirm',\n 'Are you sure you want to delete \"{{name}}\"? Its channels will stop answering and this cannot be undone.',\n { name: bot.name }\n ),\n confirmLabel: t('botlit.common.delete', 'Delete'),\n cancelLabel: t('botlit.common.cancel', 'Cancel'),\n });\n if (!confirmed) return;\n\n nativeImpact('medium');\n try {\n const deleted = await deleteBot(bot.id);\n if (!deleted) {\n toast.error(t('botlit.botsList.delete.notDeleted', 'The bot could not be deleted.'));\n if (isNative()) void nativeNotify('error');\n return;\n }\n toast.success(\n t('botlit.botsList.delete.success', 'Bot \"{{name}}\" deleted successfully', {\n name: bot.name,\n })\n );\n if (isNative()) void nativeNotify('success');\n // The mutation only reports success; reload so the card actually leaves the page.\n await refetch();\n void botCounts.refetch();\n } catch (err: unknown) {\n const message =\n err instanceof Error\n ? err.message\n : t('botlit.botsList.delete.error', 'Failed to delete bot');\n toast.error(message);\n if (isNative()) void nativeNotify('error');\n }\n };\n\n const menuItemsFor = (bot: { id: string; name: string }): ActionMenuItem[] => {\n const items: ActionMenuItem[] = [];\n if (can(BOTMANOR_PERMISSIONS.APP_UPDATE)) {\n items.push({\n key: 'edit',\n label: t('botlit.botsList.menu.editBot', 'Edit Bot'),\n icon: <Edit size={16} aria-hidden=\"true\" />,\n onSelect: () => navigateTo(`bots/${bot.id}/edit`),\n });\n }\n items.push(\n {\n key: 'design',\n label: t('botlit.botsList.menu.design', 'Design workflow'),\n icon: <Workflow size={16} aria-hidden=\"true\" />,\n onSelect: () => navigateTo(`bots/${bot.id}?tab=workflow`),\n },\n {\n key: 'agents',\n label: t('botlit.botsList.menu.viewAgents', 'View Agents'),\n icon: <Bot size={16} aria-hidden=\"true\" />,\n onSelect: () => navigateTo(`bots/${bot.id}/agents`),\n }\n );\n if (can(BOTMANOR_PERMISSIONS.APP_DELETE)) {\n items.push({\n key: 'delete',\n label: t('botlit.common.delete', 'Delete'),\n icon: <Trash2 size={16} aria-hidden=\"true\" />,\n destructive: true,\n onSelect: () => void handleDelete(bot),\n });\n }\n return items;\n };\n\n const executionsLabel = (count: number | null | undefined) => {\n const n = count ?? 0;\n return n === 1\n ? t('botlit.common.executionsOne', '{{count}} execution', { count: formatNumber(n) })\n : t('botlit.common.executionsOther', '{{count}} executions', { count: formatNumber(n) });\n };\n\n const showEmptyState = !loading && !error && bots.length === 0 && search === '';\n const createBotButton = (\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.APP_CREATE}>\n <Button leftIcon={<Plus size={16} />} onClick={() => navigateTo('bots/new')}>\n {t('botlit.botsList.actions.createBot', 'Create Bot')}\n </Button>\n </BotmanorPermissionGate>\n );\n\n const counts = botCounts.data;\n\n return (\n <PageLayout\n title={t('botlit.botsList.title', 'Bots')}\n description={t('botlit.botsList.description', 'Manage your AI-powered bots')}\n // The empty state carries its own \"Create Bot\"; showing both is a duplicate.\n actions={showEmptyState ? undefined : createBotButton}\n >\n <div className=\"space-y-6\">\n <PagePurpose icon={<Bot size={18} />}>\n {t(\n 'botlit.botsList.purpose',\n 'A bot is the deployable, user-facing surface for your AI — it wraps one or more agents and exposes them to people through chat, channels (Slack, web widget, WhatsApp) and APIs. Create a bot here when you are ready to put an agent in front of real users, then connect channels and watch its executions.'\n )}\n </PagePurpose>\n\n {/* Summary: exact workspace counts, independent of the search term */}\n {counts && counts.total - counts.archived > 0 ? (\n <div\n className=\"grid grid-cols-2 gap-4\"\n role=\"group\"\n aria-label={t('botlit.botsList.summary.title', 'Bot totals')}\n >\n <GlassCard treatment=\"metric\" className=\"p-4\">\n <p className=\"text-sm text-text-secondary\">\n {t('botlit.botsList.summary.total', 'Total bots')}\n </p>\n <p className=\"mt-1 text-2xl font-semibold tabular-nums text-text-primary\">\n {formatNumber(counts.total - counts.archived)}\n </p>\n </GlassCard>\n <GlassCard treatment=\"metric\" className=\"p-4\">\n <p className=\"text-sm text-text-secondary\">\n {t('botlit.botsList.summary.active', 'Active')}\n </p>\n <p className=\"mt-1 text-2xl font-semibold tabular-nums text-text-primary\">\n {formatNumber(counts.active)}\n </p>\n </GlassCard>\n </div>\n ) : null}\n\n {/* Toolbar */}\n <div className=\"flex items-center justify-between gap-4\">\n <div className=\"relative flex-1 max-w-md\">\n <Search\n className=\"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-text-secondary\"\n aria-hidden=\"true\"\n />\n <Input\n id=\"bots-search\"\n type=\"search\"\n aria-label={t('botlit.botsList.search.label', 'Search bots')}\n placeholder={t('botlit.botsList.searchPlaceholder', 'Search bots...')}\n value={botFilter.search || ''}\n onChange={handleSearch}\n className=\"pl-9\"\n />\n </div>\n <div\n className=\"flex items-center gap-2\"\n role=\"group\"\n aria-label={t('botlit.botsList.view.label', 'Layout')}\n >\n <Button\n variant={viewMode === 'grid' ? 'secondary' : 'ghost'}\n size=\"icon\"\n aria-label={t('botlit.botsList.view.grid', 'Grid view')}\n title={t('botlit.botsList.view.grid', 'Grid view')}\n aria-pressed={viewMode === 'grid'}\n onClick={() => setViewMode('grid')}\n >\n <Grid3X3 size={18} aria-hidden=\"true\" />\n </Button>\n <Button\n variant={viewMode === 'list' ? 'secondary' : 'ghost'}\n size=\"icon\"\n aria-label={t('botlit.botsList.view.list', 'List view')}\n title={t('botlit.botsList.view.list', 'List view')}\n aria-pressed={viewMode === 'list'}\n onClick={() => setViewMode('list')}\n >\n <List size={18} aria-hidden=\"true\" />\n </Button>\n </div>\n </div>\n\n {/* Content */}\n {loading ? (\n <div\n role=\"status\"\n aria-busy=\"true\"\n aria-label={t('botlit.common.loading', 'Loading')}\n className={cn(\n 'gap-4',\n viewMode === 'grid'\n ? 'grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3'\n : 'flex flex-col'\n )}\n >\n {[1, 2, 3, 4, 5, 6].map((i) => (\n <div\n key={i}\n className=\"h-48 bg-bg-sunken motion-safe:animate-vc-shimmer rounded-lg\"\n />\n ))}\n </div>\n ) : error ? (\n <ErrorState\n resource={t('botlit.botsList.resource', 'bots')}\n error={error}\n onRetry={() => void refetch()}\n />\n ) : bots.length > 0 ? (\n viewMode === 'grid' ? (\n <ul className=\"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4\">\n {bots.map((bot) => (\n <li key={bot.id}>\n <Card className=\"group relative h-full hover:shadow-md transition-shadow\">\n <CardContent className=\"pt-6\">\n <div className=\"flex items-start justify-between\">\n <div className=\"flex items-center gap-3\">\n <span className=\"text-4xl\" aria-hidden=\"true\">\n {bot.icon || '🤖'}\n </span>\n <div>\n <h3 className=\"font-semibold text-text-primary\">\n <Link to={getPath(`bots/${bot.id}`)} className={STRETCHED_LINK}>\n {bot.name}\n </Link>\n </h3>\n <StatusBadge status={bot.status} />\n </div>\n </div>\n <div className=\"relative z-10\">\n <ActionMenu\n label={t('botlit.botsList.menu.actionsFor', 'Actions for {{name}}', {\n name: bot.name,\n })}\n items={menuItemsFor(bot)}\n />\n </div>\n </div>\n <p className=\"mt-3 text-sm text-text-secondary line-clamp-2\">\n {bot.description}\n </p>\n <div className=\"mt-4 flex items-center gap-4 text-xs text-text-secondary\">\n <span className=\"flex items-center gap-1\">\n <Bot size={14} aria-hidden=\"true\" />\n {executionsLabel(bot.executionCount)}\n </span>\n </div>\n <div className=\"mt-3 pt-3 border-t border-border-subtle flex items-center justify-between gap-2\">\n <span className=\"text-xs text-text-secondary\">\n {t('botlit.botsList.createdLabel', 'Created')}{' '}\n {formatRelativeTime(bot.createdAt)}\n </span>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n className=\"relative z-10\"\n leftIcon={<Workflow size={14} aria-hidden=\"true\" />}\n aria-label={t('botlit.botsList.actions.designFor', 'Design {{name}}', {\n name: bot.name,\n })}\n onClick={() => navigateTo(`bots/${bot.id}?tab=workflow`)}\n >\n {t('botlit.botsList.actions.design', 'Design')}\n </Button>\n </div>\n </CardContent>\n </Card>\n </li>\n ))}\n </ul>\n ) : (\n <ul className=\"space-y-2\">\n {bots.map((bot) => (\n <li key={bot.id}>\n <Card className=\"group relative hover:shadow-md transition-shadow\">\n <CardContent className=\"py-4\">\n <div className=\"flex items-center justify-between gap-4\">\n <div className=\"flex items-center gap-4\">\n <span className=\"text-3xl\" aria-hidden=\"true\">\n {bot.icon || '🤖'}\n </span>\n <div>\n <div className=\"flex items-center gap-2\">\n <h3 className=\"font-semibold text-text-primary\">\n <Link to={getPath(`bots/${bot.id}`)} className={STRETCHED_LINK}>\n {bot.name}\n </Link>\n </h3>\n <StatusBadge status={bot.status} />\n </div>\n <p className=\"text-sm text-text-secondary line-clamp-1\">\n {bot.description}\n </p>\n </div>\n </div>\n <div className=\"flex items-center gap-4 text-sm text-text-secondary\">\n <span>{executionsLabel(bot.executionCount)}</span>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n className=\"relative z-10\"\n leftIcon={<Workflow size={14} aria-hidden=\"true\" />}\n aria-label={t('botlit.botsList.actions.designFor', 'Design {{name}}', {\n name: bot.name,\n })}\n onClick={() => navigateTo(`bots/${bot.id}?tab=workflow`)}\n >\n {t('botlit.botsList.actions.design', 'Design')}\n </Button>\n <div className=\"relative z-10\">\n <ActionMenu\n label={t('botlit.botsList.menu.actionsFor', 'Actions for {{name}}', {\n name: bot.name,\n })}\n items={menuItemsFor(bot)}\n />\n </div>\n </div>\n </div>\n </CardContent>\n </Card>\n </li>\n ))}\n </ul>\n )\n ) : search !== '' ? (\n <EmptyState\n illustration=\"empty-agents\"\n title={t('botlit.botsList.noResults.title', 'No bots match \"{{query}}\"', {\n query: search,\n })}\n description={t(\n 'botlit.botsList.noResults.description',\n 'Check the spelling or try a different search term.'\n )}\n action={\n <Button variant=\"outline\" onClick={() => updateBotFilter({ search: '' })}>\n {t('botlit.botsList.noResults.clear', 'Clear search')}\n </Button>\n }\n />\n ) : (\n <EmptyState\n illustration=\"empty-agents\"\n title={t('botlit.botsList.empty.title', 'No bots yet')}\n description={t(\n 'botlit.botsList.empty.description',\n 'A bot puts your agents in front of real users. Create an agent first, then create a bot to connect it to channels.'\n )}\n action={createBotButton}\n />\n )}\n <LoadMore\n hasMore={hasMore}\n loadingMore={loadingMore}\n onLoadMore={() => void loadMore()}\n loadedCount={bots.length}\n />\n </div>\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,IAAMA,IACJ,2KAEWC,UAAyB;CACpC,IAAMC,IAAIC,EAAM,GACVC,IAAMC,EAAe,GACrB,EAAE,eAAY,eAAYC,EAAU,GACpC,EAAE,aAAU,gBAAa,cAAW,uBAAoBC,EAAe,GACvE,EACJ,MAAMC,GACN,YACA,UACA,YACA,YACA,iBACA,iBACEC,EAAQC,CAAS,GACfC,IAAYC,GAAgB,GAC5B,CAACC,MAAaC,EAAa,GAE3BC,KAAUL,EAAU,UAAU,GAAA,CAAI,KAAK,GAEvCM,MAAgB,MAA2C;EAC/D,EAAgB,EAAE,QAAQ,EAAE,OAAO,MAAM,CAAC;CAC5C,GAEMC,KAAe,OAAO,MAAsC;EAWhE,IAAK,MAVmBC,EAAc;GACpC,OAAOhB,EAAE,gCAAgC,aAAa;GACtD,SAASA,EACP,kCACA,6GACA,EAAE,MAAMiB,EAAI,KAAK,CACnB;GACA,cAAcjB,EAAE,wBAAwB,QAAQ;GAChD,aAAaA,EAAE,wBAAwB,QAAQ;EACjD,CAAC,GAGD;KAAa,QAAQ;GACrB,IAAI;IAEF,IAAI,CAAC,MADiBW,GAAUM,EAAI,EAAE,GACxB;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;IAYH,kBAACiE,GAAD;KACW;KACI;KACb,kBAAkB,KAAKC,GAAS;KAChC,aAAa5D,EAAK;IACnB,CAAA;GACE;;CACK,CAAA;AAEhB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bot name and slug rules (BOFF-12439)
|
|
3
|
+
* @module botlit/utils
|
|
4
|
+
*
|
|
5
|
+
* One definition of what a valid bot name and slug are, shared by the create
|
|
6
|
+
* form, the edit form and (mirrored in `wspace-botmanor-svc`) the API, so the
|
|
7
|
+
* client preview and the server never disagree.
|
|
8
|
+
*
|
|
9
|
+
* Slug format: lowercase ASCII letters and digits separated by single hyphens,
|
|
10
|
+
* at most 64 characters, e.g. `support-bot`. Accented Latin letters are folded
|
|
11
|
+
* to their base letter (`café` -> `cafe`); characters with no ASCII form (for
|
|
12
|
+
* example other scripts) are dropped, which can leave nothing, so the form asks
|
|
13
|
+
* for an explicit slug in that case instead of submitting an empty one.
|
|
14
|
+
*/
|
|
15
|
+
export declare const BOT_NAME_MAX_LENGTH = 100;
|
|
16
|
+
export declare const BOT_SLUG_MAX_LENGTH = 64;
|
|
17
|
+
/** Lowercase letters and digits, single hyphens between groups, no edge hyphens. */
|
|
18
|
+
export declare const BOT_SLUG_PATTERN: RegExp;
|
|
19
|
+
/** Slugs the platform keeps for itself because they collide with route names. */
|
|
20
|
+
export declare const RESERVED_BOT_SLUGS: ReadonlySet<string>;
|
|
21
|
+
/** Turns free text into a slug. Returns an empty string when nothing usable remains. */
|
|
22
|
+
export declare function slugify(input: string, maxLength?: number): string;
|
|
23
|
+
export type BotIdentityError = 'nameRequired' | 'nameTooLong' | 'slugRequired' | 'slugTooLong' | 'slugInvalid' | 'slugReserved';
|
|
24
|
+
export interface BotIdentityErrors {
|
|
25
|
+
name?: BotIdentityError;
|
|
26
|
+
slug?: BotIdentityError;
|
|
27
|
+
}
|
|
28
|
+
/** English fallbacks, keyed so callers translate through `useTr`. */
|
|
29
|
+
export declare const BOT_IDENTITY_MESSAGES: Record<BotIdentityError, string>;
|
|
30
|
+
/**
|
|
31
|
+
* Validates a bot's name and slug. An empty slug is fine when one can be
|
|
32
|
+
* derived from the name; it is an error when the name has no usable letters.
|
|
33
|
+
*/
|
|
34
|
+
export declare function validateBotIdentity(name: string, slug: string): BotIdentityErrors;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
var e = /^[a-z0-9]+(?:-[a-z0-9]+)*$/, t = /* @__PURE__ */ new Set([
|
|
2
|
+
"new",
|
|
3
|
+
"edit",
|
|
4
|
+
"create",
|
|
5
|
+
"admin",
|
|
6
|
+
"api",
|
|
7
|
+
"agents",
|
|
8
|
+
"channels",
|
|
9
|
+
"settings"
|
|
10
|
+
]);
|
|
11
|
+
function n(e) {
|
|
12
|
+
let t = 0, n = e.length;
|
|
13
|
+
for (; t < n && e[t] === "-";) t += 1;
|
|
14
|
+
for (; n > t && e[n - 1] === "-";) --n;
|
|
15
|
+
return e.slice(t, n);
|
|
16
|
+
}
|
|
17
|
+
function r(e, t = 64) {
|
|
18
|
+
return n(n(e.normalize("NFKD").replace(/\p{M}/gu, "").toLowerCase().replace(/[^a-z0-9]+/g, "-")).slice(0, t));
|
|
19
|
+
}
|
|
20
|
+
var i = {
|
|
21
|
+
nameRequired: "Enter a name for the bot.",
|
|
22
|
+
nameTooLong: "Use at most 100 characters for the name.",
|
|
23
|
+
slugRequired: "Enter a slug using letters, numbers and hyphens.",
|
|
24
|
+
slugTooLong: "Use at most 64 characters for the slug.",
|
|
25
|
+
slugInvalid: "Use only lowercase letters, numbers and single hyphens, for example support-bot.",
|
|
26
|
+
slugReserved: "This slug is reserved. Choose another one."
|
|
27
|
+
};
|
|
28
|
+
function a(n, i) {
|
|
29
|
+
let a = {}, o = n.trim();
|
|
30
|
+
o.length === 0 ? a.name = "nameRequired" : o.length > 100 && (a.name = "nameTooLong");
|
|
31
|
+
let s = i.trim() === "" ? r(o) : i.trim();
|
|
32
|
+
return s === "" ? a.slug = "slugRequired" : s.length > 64 ? a.slug = "slugTooLong" : e.test(s) ? t.has(s) && (a.slug = "slugReserved") : a.slug = "slugInvalid", a;
|
|
33
|
+
}
|
|
34
|
+
export { i as BOT_IDENTITY_MESSAGES, e as BOT_SLUG_PATTERN, t as RESERVED_BOT_SLUGS, r as slugify, a as validateBotIdentity };
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=botIdentity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"botIdentity.js","names":["BOT_SLUG_PATTERN","RESERVED_BOT_SLUGS","trimHyphens","start","end","value","slugify","input","maxLength","BOT_IDENTITY_MESSAGES","validateBotIdentity","errors","trimmedName","name","effectiveSlug","slug"],"sources":["../../../src/botlit/utils/botIdentity.ts"],"sourcesContent":["/**\n * Bot name and slug rules (BOFF-12439)\n * @module botlit/utils\n *\n * One definition of what a valid bot name and slug are, shared by the create\n * form, the edit form and (mirrored in `wspace-botmanor-svc`) the API, so the\n * client preview and the server never disagree.\n *\n * Slug format: lowercase ASCII letters and digits separated by single hyphens,\n * at most 64 characters, e.g. `support-bot`. Accented Latin letters are folded\n * to their base letter (`café` -> `cafe`); characters with no ASCII form (for\n * example other scripts) are dropped, which can leave nothing, so the form asks\n * for an explicit slug in that case instead of submitting an empty one.\n */\n\nexport const BOT_NAME_MAX_LENGTH = 100;\nexport const BOT_SLUG_MAX_LENGTH = 64;\n\n/** Lowercase letters and digits, single hyphens between groups, no edge hyphens. */\nexport const BOT_SLUG_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;\n\n/** Slugs the platform keeps for itself because they collide with route names. */\nexport const RESERVED_BOT_SLUGS: ReadonlySet<string> = new Set([\n 'new',\n 'edit',\n 'create',\n 'admin',\n 'api',\n 'agents',\n 'channels',\n 'settings',\n]);\n\n/** Removes leading and trailing hyphens in one linear pass (no backtracking regex on user input). */\nfunction trimHyphens(value: string): string {\n let start = 0;\n let end = value.length;\n while (start < end && value[start] === '-') start += 1;\n while (end > start && value[end - 1] === '-') end -= 1;\n return value.slice(start, end);\n}\n\n/** Turns free text into a slug. Returns an empty string when nothing usable remains. */\nexport function slugify(input: string, maxLength: number = BOT_SLUG_MAX_LENGTH): string {\n const folded = trimHyphens(\n input\n .normalize('NFKD')\n .replace(/\\p{M}/gu, '')\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n );\n return trimHyphens(folded.slice(0, maxLength));\n}\n\nexport type BotIdentityError =\n 'nameRequired' | 'nameTooLong' | 'slugRequired' | 'slugTooLong' | 'slugInvalid' | 'slugReserved';\n\nexport interface BotIdentityErrors {\n name?: BotIdentityError;\n slug?: BotIdentityError;\n}\n\n/** English fallbacks, keyed so callers translate through `useTr`. */\nexport const BOT_IDENTITY_MESSAGES: Record<BotIdentityError, string> = {\n nameRequired: 'Enter a name for the bot.',\n nameTooLong: `Use at most ${BOT_NAME_MAX_LENGTH} characters for the name.`,\n slugRequired: 'Enter a slug using letters, numbers and hyphens.',\n slugTooLong: `Use at most ${BOT_SLUG_MAX_LENGTH} characters for the slug.`,\n slugInvalid: 'Use only lowercase letters, numbers and single hyphens, for example support-bot.',\n slugReserved: 'This slug is reserved. Choose another one.',\n};\n\n/**\n * Validates a bot's name and slug. An empty slug is fine when one can be\n * derived from the name; it is an error when the name has no usable letters.\n */\nexport function validateBotIdentity(name: string, slug: string): BotIdentityErrors {\n const errors: BotIdentityErrors = {};\n const trimmedName = name.trim();\n\n if (trimmedName.length === 0) errors.name = 'nameRequired';\n else if (trimmedName.length > BOT_NAME_MAX_LENGTH) errors.name = 'nameTooLong';\n\n const effectiveSlug = slug.trim() === '' ? slugify(trimmedName) : slug.trim();\n if (effectiveSlug === '') errors.slug = 'slugRequired';\n else if (effectiveSlug.length > BOT_SLUG_MAX_LENGTH) errors.slug = 'slugTooLong';\n else if (!BOT_SLUG_PATTERN.test(effectiveSlug)) errors.slug = 'slugInvalid';\n else if (RESERVED_BOT_SLUGS.has(effectiveSlug)) errors.slug = 'slugReserved';\n\n return errors;\n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URL. An ID-like segment is shown as a
|
|
6
|
+
* truncated ID unless the page registers a display name for it. The registry
|
|
7
|
+
* lives on `window.__breadcrumbRegistry`, installed by the shell's
|
|
8
|
+
* `AutoBreadcrumbs`; it is read at call time because the MFE can render before
|
|
9
|
+
* the shell has installed it. Safe to call outside the shell (a no-op).
|
|
10
|
+
*/
|
|
11
|
+
export declare function registerBreadcrumbName(id: string, name: string): void;
|
|
12
|
+
export declare function unregisterBreadcrumbName(id: string): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/botlit/utils/breadcrumb.ts
|
|
2
|
+
function e() {
|
|
3
|
+
if (typeof window < "u") return window.__breadcrumbRegistry;
|
|
4
|
+
}
|
|
5
|
+
function t(t, n) {
|
|
6
|
+
e()?.register?.(t, n);
|
|
7
|
+
}
|
|
8
|
+
function n(t) {
|
|
9
|
+
e()?.unregister?.(t);
|
|
10
|
+
}
|
|
11
|
+
export { t as registerBreadcrumbName, n as unregisterBreadcrumbName };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=breadcrumb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"breadcrumb.js","names":["registry","registerBreadcrumbName","id","name","unregisterBreadcrumbName"],"sources":["../../../src/botlit/utils/breadcrumb.ts"],"sourcesContent":["/**\n * Breadcrumb name registration (BOFF-12442)\n * @module botlit/utils\n *\n * The shell builds breadcrumbs from the URL. An ID-like segment is shown as a\n * truncated ID unless the page registers a display name for it. The registry\n * lives on `window.__breadcrumbRegistry`, installed by the shell's\n * `AutoBreadcrumbs`; it is read at call time because the MFE can render before\n * the shell has installed it. Safe to call outside the shell (a no-op).\n */\n\ninterface BreadcrumbRegistry {\n register: (id: string, name: string) => void;\n unregister: (id: string) => void;\n}\n\nfunction registry(): BreadcrumbRegistry | undefined {\n if (typeof window === 'undefined') return undefined;\n return (window as unknown as { __breadcrumbRegistry?: BreadcrumbRegistry }).__breadcrumbRegistry;\n}\n\nexport function registerBreadcrumbName(id: string, name: string): void {\n registry()?.register?.(id, name);\n}\n\nexport function unregisterBreadcrumbName(id: string): void {\n registry()?.unregister?.(id);\n}\n"],"mappings":";AAgBA,SAASA,IAA2C;CAClD,IAAI,OAAO,SAAW,KACtB,OAAQ,OAAoE;AAC9E;AAEA,SAAgBC,EAAuB,GAAY,GAAoB;CACrE,EAAS,CAAC,EAAE,WAAWC,GAAIC,CAAI;AACjC;AAEA,SAAgBC,EAAyB,GAAkB;CACzD,EAAS,CAAC,EAAE,aAAaF,CAAE;AAC7B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One confirmation mechanism for destructive actions (BOFF-12444)
|
|
3
|
+
* @module botlit/utils
|
|
4
|
+
*
|
|
5
|
+
* The Bots list used the native-app confirm sheet and the bot detail page used
|
|
6
|
+
* the browser's `confirm()`, so the same delete behaved differently. Every
|
|
7
|
+
* caller now goes through this helper: the native sheet when running inside the
|
|
8
|
+
* mobile shell, the browser dialog otherwise. Callers pass already-translated
|
|
9
|
+
* strings, so the dialog is localised like the rest of the page.
|
|
10
|
+
*/
|
|
11
|
+
export interface ConfirmActionOptions {
|
|
12
|
+
title: string;
|
|
13
|
+
message: string;
|
|
14
|
+
confirmLabel: string;
|
|
15
|
+
cancelLabel: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function confirmAction(options: ConfirmActionOptions): Promise<boolean>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { nativeConfirm as e } from "../../utils/nativeBridge.js";
|
|
2
|
+
// src/botlit/utils/confirmAction.ts
|
|
3
|
+
async function t(t) {
|
|
4
|
+
let n = await e({
|
|
5
|
+
title: t.title,
|
|
6
|
+
message: t.message,
|
|
7
|
+
okButtonTitle: t.confirmLabel,
|
|
8
|
+
cancelButtonTitle: t.cancelLabel
|
|
9
|
+
});
|
|
10
|
+
return n === null ? window.confirm(t.message) : n;
|
|
11
|
+
}
|
|
12
|
+
export { t as confirmAction };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=confirmAction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"confirmAction.js","names":["confirmAction","native","nativeConfirm","options"],"sources":["../../../src/botlit/utils/confirmAction.ts"],"sourcesContent":["/**\n * One confirmation mechanism for destructive actions (BOFF-12444)\n * @module botlit/utils\n *\n * The Bots list used the native-app confirm sheet and the bot detail page used\n * the browser's `confirm()`, so the same delete behaved differently. Every\n * caller now goes through this helper: the native sheet when running inside the\n * mobile shell, the browser dialog otherwise. Callers pass already-translated\n * strings, so the dialog is localised like the rest of the page.\n */\n\nimport { nativeConfirm } from '../../utils/nativeBridge';\n\nexport interface ConfirmActionOptions {\n title: string;\n message: string;\n confirmLabel: string;\n cancelLabel: string;\n}\n\nexport async function confirmAction(options: ConfirmActionOptions): Promise<boolean> {\n const native = await nativeConfirm({\n title: options.title,\n message: options.message,\n okButtonTitle: options.confirmLabel,\n cancelButtonTitle: options.cancelLabel,\n });\n return native === null ? window.confirm(options.message) : native;\n}\n"],"mappings":";;AAoBA,eAAsBA,EAAc,GAAiD;CACnF,IAAMC,IAAS,MAAMC,EAAc;EACjC,OAAOC,EAAQ;EACf,SAASA,EAAQ;EACjB,eAAeA,EAAQ;EACvB,mBAAmBA,EAAQ;CAC7B,CAAC;CACD,OAAOF,MAAW,OAAO,OAAO,QAAQE,EAAQ,OAAO,IAAIF;AAC7D"}
|
package/package.json
CHANGED