Files
Reims-Go/frontend/src/components/PluginViewHost.tsx
T
NwflowerandClaude Opus 5.5 fa3e1e2889 feat: add plugin views and expand the sandboxed page bridge
Plugins can add pages to the sidebar, VM tabs, Settings and dialogs. Their
pages can now use host forms and navigation, VM and settings access,
authorized file I/O, task progress, controlled HTTP requests, events and
private storage.

Plugin pages cannot change allow_ai_access, which stays the user's per-VM
consent. Closing a page cancels its unfinished tasks, and running plugin
tasks no longer block changing the data folder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-02 23:11:23 -07:00

73 lines
2.2 KiB
TypeScript

import React from 'react'
import { t } from '../i18n'
import { Locale, ViewContribution } from '../types'
import { Button } from '../ui/controls'
import { Modal } from '../ui/dialog'
import { PluginPanelFrame } from './PluginPanelFrame'
import { locText } from './SchemaForm'
interface Props {
view: ViewContribution
locale: Locale
appearance: 'light' | 'dark'
assetToken: string
vm?: string
dialog?: boolean
metadata?: { title?: string; badge?: { text: string; tone: string } }
onMetadata: (metadata: { title?: string; badge?: { text: string; tone: string } }) => void
onOpenView: (view: ViewContribution, vm?: string) => void
onCloseView: () => { closed: boolean }
onNavigate: (target: { page?: string; vm?: string }) => void
}
export const PluginViewHost: React.FC<Props> = ({
view, locale, appearance, assetToken, vm, dialog, metadata, onMetadata, onOpenView, onCloseView, onNavigate,
}) => {
const title = metadata?.title || locText(view.title, locale, view.id)
const badge = metadata?.badge
const panel = {
id: view.id,
pluginId: view.pluginId,
title: view.title,
entry: view.entry,
slot: '',
height: 640,
}
const frame = (
<PluginPanelFrame
locale={locale}
panel={panel}
assetToken={assetToken}
appearance={appearance}
headless
maxHeight={720}
minWidth={view.minWidth}
viewLocation={view.location}
vm={vm}
onOpenView={onOpenView}
onCloseView={onCloseView}
onNavigate={onNavigate}
onMetadata={onMetadata}
/>
)
if (dialog) {
return (
<Modal title={title} subtitle={badge?.text} closeLabel={t(locale, 'close')} onClose={onCloseView}>
{frame}
</Modal>
)
}
return (
<section className="page plugin-view-page">
<header className="page-head">
<div className="page-title">
<h1>{title}</h1>
{badge && <span className={`badge rg-p-badge badge-${badge.tone === 'ok' ? 'ok' : badge.tone === 'warn' ? 'warn' : badge.tone === 'error' ? 'error' : 'idle'}`}>{badge.text}</span>}
</div>
<Button onClick={onCloseView}>{t(locale, 'close')}</Button>
</header>
{frame}
</section>
)
}