diff --git a/packages/web_ui/src/components/PluginViewPage.tsx b/packages/web_ui/src/components/PluginViewPage.tsx index 48adc2b0..2b0b7352 100644 --- a/packages/web_ui/src/components/PluginViewPage.tsx +++ b/packages/web_ui/src/components/PluginViewPage.tsx @@ -48,70 +48,40 @@ function PluginMachines(props: PluginMachinesProps) { type ControllerPluginProps = { pluginMeta: PluginWebApi, pluginInfo?: lib.PluginWebEnvInfo, - loadedPlugin?: lib.PluginWebEnvInfo, title: string, }; -/** What the controller and web UI have loaded of the plugin */ function ControllerPlugin(props: ControllerPluginProps) { - const { pluginMeta, pluginInfo, loadedPlugin } = props; - const pluginError = pluginMeta.web.error ?? pluginInfo?.error; - const hasWebModule = Boolean(pluginMeta.web.main || pluginMeta.web.error); - if (!loadedPlugin) { - return <> - - {pluginMeta.version} - - {hasWebModule ? "No" : "No web module"} - - - {pluginError && } - ; - } - - const homepageUrl = lib.safeExternalUrl(loadedPlugin.package.homepage); + const { pluginMeta, pluginInfo } = props; + const pkg = pluginInfo?.package; + const pluginError = pluginMeta.enabled ? pluginMeta.web.error ?? pluginInfo?.error : undefined; + const homepageUrl = lib.safeExternalUrl(pkg?.homepage); return <> - {pluginMeta.version} - Yes - {loadedPlugin.description} - {loadedPlugin.package.homepage ? - {homepageUrl - ? {loadedPlugin.package.homepage} - : loadedPlugin.package.homepage} + {pluginMeta.version} + {pluginInfo?.description ? + {pluginInfo.description} : null} - {loadedPlugin.package.author ? - {loadedPlugin.package.author} + {pkg?.homepage ? + {homepageUrl ? {pkg.homepage} : pkg.homepage} : null} - {loadedPlugin.package.license} + {pkg?.author ? {pkg.author} : null} + {pkg?.license ? {pkg.license} : null} - {pluginMeta.version !== loadedPlugin.package.version ? : null} + />} ; } @@ -160,7 +130,6 @@ export default function PluginViewPage() { ? : diff --git a/packages/web_ui/src/components/PluginsPage.tsx b/packages/web_ui/src/components/PluginsPage.tsx index e8b4121e..52e7d85c 100644 --- a/packages/web_ui/src/components/PluginsPage.tsx +++ b/packages/web_ui/src/components/PluginsPage.tsx @@ -1,9 +1,8 @@ import React, { useContext, useEffect, useState } from "react"; -import { Space, Table, Typography } from "antd"; +import { Space, Table, Tooltip, Typography } from "antd"; import CloseCircleFilled from "@ant-design/icons/CloseCircleFilled"; -import InfoCircleFilled from "@ant-design/icons/InfoCircleFilled"; -import type { PluginWebApi, PluginWebEnvInfo } from "@clusterio/lib"; +import type { PluginWebApi } from "@clusterio/lib"; import notify from "../util/notify"; import { useAccount } from "../model/account"; @@ -28,8 +27,7 @@ type PluginRow = { title: string; /** Not present for plugins the controller hasn't loaded */ meta?: PluginWebApi; - info?: PluginWebEnvInfo; - package?: any; + webError?: string; status?: PluginStatus; }; @@ -38,31 +36,15 @@ function pluginPath(plugin: PluginRow) { return `/plugins/${encodeURIComponent(plugin.meta?.name ?? plugin.key)}/view`; } -function WebUiStatus(props: { plugin: PluginRow }) { - const control = useContext(ControlContext); - const { meta } = props.plugin; - if (!meta) { - return Not on controller; - } - if (!meta.enabled) { - return <> Disabled on controller; - } - if (!meta.web.main && !meta.web.error) { - return No web module; - } - if (!meta.web.error && !control.pluginInfos.has(meta.name)) { - return <> Reload page to load; - } - if (!props.plugin.package) { - return <> Error loading module; - } - if (props.plugin.package.version !== meta.version) { - return <> Version mis-matched; - } - return <>Loaded {meta.version}; +/** Shown with the versions when the plugin's web code failed to load */ +function WebError(props: { error: string }) { + return
+ + Web interface failed to load + +
; } - export default function PluginsPage() { const control = useContext(ControlContext); const account = useAccount(); @@ -95,14 +77,12 @@ export default function PluginsPage() { let tableContents: PluginRow[] = []; for (let meta of pluginList) { const key = pluginStatusKey(meta); - const loaded = control.loadedPlugins.get(meta.name); - const info = loaded ?? control.pluginInfos.get(meta.name); + const info = control.pluginInfos.get(meta.name); tableContents.push({ key, title: info ? info.title : meta.name, meta, - info, - package: loaded?.package, + webError: meta.enabled ? meta.web.error ?? info?.error : undefined, status: statuses.get(key), }); } @@ -151,16 +131,12 @@ export default function PluginsPage() { { title: "Versions", key: "versions", - render: (_, plugin) => (plugin.status - ? - : plugin.meta?.version - ), - }, - { - title: "Web UI Status", - key: "web", - render: (_, plugin) => , - responsive: ["sm"], + render: (_, plugin) => <> + {plugin.status + ? + : plugin.meta?.version} + {plugin.webError && } + , }, { key: "actions",