Files
Reims-Go/frontend/src/components/PluginViewHost.tsx
T
NwflowerandClaude Opus 5.5 50c03a0835 perf(frontend): load the settings and plugin texts on demand again
App.tsx imported a one-line helper from SchemaForm, which pulled both text
domains into the startup bundle. The i18n test now follows the real import
graph instead of a hand-kept file list, so it catches this. npm test runs
every test file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 21:38:17 -07:00

72 lines
2.1 KiB
TypeScript

import React from 'react'
import { locText, t } from '../i18n'
import { Locale, ViewContribution } from '../types'
import { Button } from '../ui/controls'
import { Modal } from '../ui/dialog'
import { PluginPanelFrame } from './PluginPanelFrame'
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>
)
}