mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-25 16:33:12 +09:00
Merge pull request #1140 from bbassie/fix/remove-web-plugin-column
Remove the web UI status column from the plugin pages
This commit is contained in:
2 files changed
+37
-92
No files matched your search
@@ -48,70 +48,40 @@ function PluginMachines(props: PluginMachinesProps) {
|
|||||||
type ControllerPluginProps = {
|
type ControllerPluginProps = {
|
||||||
pluginMeta: PluginWebApi,
|
pluginMeta: PluginWebApi,
|
||||||
pluginInfo?: lib.PluginWebEnvInfo,
|
pluginInfo?: lib.PluginWebEnvInfo,
|
||||||
loadedPlugin?: lib.PluginWebEnvInfo,
|
|
||||||
title: string,
|
title: string,
|
||||||
};
|
};
|
||||||
|
|
||||||
/** What the controller and web UI have loaded of the plugin */
|
|
||||||
function ControllerPlugin(props: ControllerPluginProps) {
|
function ControllerPlugin(props: ControllerPluginProps) {
|
||||||
const { pluginMeta, pluginInfo, loadedPlugin } = props;
|
const { pluginMeta, pluginInfo } = props;
|
||||||
const pluginError = pluginMeta.web.error ?? pluginInfo?.error;
|
const pkg = pluginInfo?.package;
|
||||||
const hasWebModule = Boolean(pluginMeta.web.main || pluginMeta.web.error);
|
const pluginError = pluginMeta.enabled ? pluginMeta.web.error ?? pluginInfo?.error : undefined;
|
||||||
if (!loadedPlugin) {
|
const homepageUrl = lib.safeExternalUrl(pkg?.homepage);
|
||||||
return <>
|
|
||||||
<Descriptions bordered size="small" title={props.title}>
|
|
||||||
<Descriptions.Item label="Version">{pluginMeta.version}</Descriptions.Item>
|
|
||||||
<Descriptions.Item label="Loaded in Web UI" span={2}>
|
|
||||||
{hasWebModule ? "No" : "No web module"}
|
|
||||||
</Descriptions.Item>
|
|
||||||
</Descriptions>
|
|
||||||
{pluginError && <Alert
|
|
||||||
style={{
|
|
||||||
marginTop: "1em",
|
|
||||||
}}
|
|
||||||
message={pluginError}
|
|
||||||
description={
|
|
||||||
"The web interface was unable to load the web module for this plugin. This is "+
|
|
||||||
"usually due to an incorrect or missing web build for the plugin. Due to the "+
|
|
||||||
"module not being loaded, the configs and web controls defined by this plugin may "+
|
|
||||||
"not be available in the web interface."
|
|
||||||
}
|
|
||||||
type="error"
|
|
||||||
showIcon
|
|
||||||
/>}
|
|
||||||
</>;
|
|
||||||
}
|
|
||||||
|
|
||||||
const homepageUrl = lib.safeExternalUrl(loadedPlugin.package.homepage);
|
|
||||||
return <>
|
return <>
|
||||||
<Descriptions bordered size="small" title={props.title}>
|
<Descriptions bordered size="small" title={props.title}>
|
||||||
<Descriptions.Item label="Version">{pluginMeta.version}</Descriptions.Item>
|
<Descriptions.Item label="Version" span={3}>{pluginMeta.version}</Descriptions.Item>
|
||||||
<Descriptions.Item label="Loaded in Web UI" span={2}>Yes</Descriptions.Item>
|
{pluginInfo?.description ? <Descriptions.Item label="Description" span={3}>
|
||||||
<Descriptions.Item label="Description" span={3}>{loadedPlugin.description}</Descriptions.Item>
|
{pluginInfo.description}
|
||||||
{loadedPlugin.package.homepage ? <Descriptions.Item label="Homepage" span={3}>
|
|
||||||
{homepageUrl
|
|
||||||
? <a href={homepageUrl}>{loadedPlugin.package.homepage}</a>
|
|
||||||
: loadedPlugin.package.homepage}
|
|
||||||
</Descriptions.Item> : null}
|
</Descriptions.Item> : null}
|
||||||
{loadedPlugin.package.author ? <Descriptions.Item label="Author" span={3}>
|
{pkg?.homepage ? <Descriptions.Item label="Homepage" span={3}>
|
||||||
{loadedPlugin.package.author}
|
{homepageUrl ? <a href={homepageUrl}>{pkg.homepage}</a> : pkg.homepage}
|
||||||
</Descriptions.Item> : null}
|
</Descriptions.Item> : null}
|
||||||
<Descriptions.Item label="License" span={3}>{loadedPlugin.package.license}</Descriptions.Item>
|
{pkg?.author ? <Descriptions.Item label="Author" span={3}>{pkg.author}</Descriptions.Item> : null}
|
||||||
|
{pkg?.license ? <Descriptions.Item label="License" span={3}>{pkg.license}</Descriptions.Item> : null}
|
||||||
</Descriptions>
|
</Descriptions>
|
||||||
{pluginMeta.version !== loadedPlugin.package.version ? <Alert
|
{pluginError && <Alert
|
||||||
style={{
|
style={{
|
||||||
marginTop: "1em",
|
marginTop: "1em",
|
||||||
}}
|
}}
|
||||||
message="Version missmatch detected"
|
message={pluginError}
|
||||||
description={
|
description={
|
||||||
`The version of the web interface module for this plugin (${loadedPlugin.package.version}) `+
|
"The web interface was unable to load the web module for this plugin. This is "+
|
||||||
`does not match the version running on the controller (${pluginMeta.version}), `+
|
"usually due to an incorrect or missing web build for the plugin. Due to the "+
|
||||||
"spurious errors may occur. This usually happens when the plugin is updated but the "+
|
"module not being loaded, the configs and web controls defined by this plugin may "+
|
||||||
"controller has not been restarted yet, but may also be due to an outdated build."
|
"not be available in the web interface."
|
||||||
}
|
}
|
||||||
type="warning"
|
type="error"
|
||||||
showIcon
|
showIcon
|
||||||
/> : null}
|
/>}
|
||||||
</>;
|
</>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,7 +130,6 @@ export default function PluginViewPage() {
|
|||||||
? <ControllerPlugin
|
? <ControllerPlugin
|
||||||
pluginMeta={pluginMeta}
|
pluginMeta={pluginMeta}
|
||||||
pluginInfo={pluginInfo}
|
pluginInfo={pluginInfo}
|
||||||
loadedPlugin={control.loadedPlugins.get(pluginName)}
|
|
||||||
title={pluginTitle}
|
title={pluginTitle}
|
||||||
/>
|
/>
|
||||||
: <Descriptions bordered size="small" title={pluginTitle}>
|
: <Descriptions bordered size="small" title={pluginTitle}>
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
import React, { useContext, useEffect, useState } from "react";
|
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 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 notify from "../util/notify";
|
||||||
import { useAccount } from "../model/account";
|
import { useAccount } from "../model/account";
|
||||||
@@ -28,8 +27,7 @@ type PluginRow = {
|
|||||||
title: string;
|
title: string;
|
||||||
/** Not present for plugins the controller hasn't loaded */
|
/** Not present for plugins the controller hasn't loaded */
|
||||||
meta?: PluginWebApi;
|
meta?: PluginWebApi;
|
||||||
info?: PluginWebEnvInfo;
|
webError?: string;
|
||||||
package?: any;
|
|
||||||
status?: PluginStatus;
|
status?: PluginStatus;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -38,31 +36,15 @@ function pluginPath(plugin: PluginRow) {
|
|||||||
return `/plugins/${encodeURIComponent(plugin.meta?.name ?? plugin.key)}/view`;
|
return `/plugins/${encodeURIComponent(plugin.meta?.name ?? plugin.key)}/view`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function WebUiStatus(props: { plugin: PluginRow }) {
|
/** Shown with the versions when the plugin's web code failed to load */
|
||||||
const control = useContext(ControlContext);
|
function WebError(props: { error: string }) {
|
||||||
const { meta } = props.plugin;
|
return <div>
|
||||||
if (!meta) {
|
<Tooltip title={props.error}>
|
||||||
return <Typography.Text type="secondary">Not on controller</Typography.Text>;
|
<Typography.Text type="danger"><CloseCircleFilled /> Web interface failed to load</Typography.Text>
|
||||||
}
|
</Tooltip>
|
||||||
if (!meta.enabled) {
|
</div>;
|
||||||
return <><InfoCircleFilled style={{ color: "#1668dc" }} /> Disabled on controller</>;
|
|
||||||
}
|
|
||||||
if (!meta.web.main && !meta.web.error) {
|
|
||||||
return <Typography.Text type="secondary">No web module</Typography.Text>;
|
|
||||||
}
|
|
||||||
if (!meta.web.error && !control.pluginInfos.has(meta.name)) {
|
|
||||||
return <><InfoCircleFilled style={{ color: "#1668dc" }} /> Reload page to load</>;
|
|
||||||
}
|
|
||||||
if (!props.plugin.package) {
|
|
||||||
return <><CloseCircleFilled style={{ color: "#dc4446" }} /> Error loading module</>;
|
|
||||||
}
|
|
||||||
if (props.plugin.package.version !== meta.version) {
|
|
||||||
return <><CloseCircleFilled style={{ color: "#dc4446" }} /> Version mis-matched</>;
|
|
||||||
}
|
|
||||||
return <>Loaded {meta.version}</>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export default function PluginsPage() {
|
export default function PluginsPage() {
|
||||||
const control = useContext(ControlContext);
|
const control = useContext(ControlContext);
|
||||||
const account = useAccount();
|
const account = useAccount();
|
||||||
@@ -95,14 +77,12 @@ export default function PluginsPage() {
|
|||||||
let tableContents: PluginRow[] = [];
|
let tableContents: PluginRow[] = [];
|
||||||
for (let meta of pluginList) {
|
for (let meta of pluginList) {
|
||||||
const key = pluginStatusKey(meta);
|
const key = pluginStatusKey(meta);
|
||||||
const loaded = control.loadedPlugins.get(meta.name);
|
const info = control.pluginInfos.get(meta.name);
|
||||||
const info = loaded ?? control.pluginInfos.get(meta.name);
|
|
||||||
tableContents.push({
|
tableContents.push({
|
||||||
key,
|
key,
|
||||||
title: info ? info.title : meta.name,
|
title: info ? info.title : meta.name,
|
||||||
meta,
|
meta,
|
||||||
info,
|
webError: meta.enabled ? meta.web.error ?? info?.error : undefined,
|
||||||
package: loaded?.package,
|
|
||||||
status: statuses.get(key),
|
status: statuses.get(key),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -151,16 +131,12 @@ export default function PluginsPage() {
|
|||||||
{
|
{
|
||||||
title: "Versions",
|
title: "Versions",
|
||||||
key: "versions",
|
key: "versions",
|
||||||
render: (_, plugin) => (plugin.status
|
render: (_, plugin) => <>
|
||||||
? <PluginVersions status={plugin.status} latest={latestOf(plugin)} />
|
{plugin.status
|
||||||
: plugin.meta?.version
|
? <PluginVersions status={plugin.status} latest={latestOf(plugin)} />
|
||||||
),
|
: plugin.meta?.version}
|
||||||
},
|
{plugin.webError && <WebError error={plugin.webError} />}
|
||||||
{
|
</>,
|
||||||
title: "Web UI Status",
|
|
||||||
key: "web",
|
|
||||||
render: (_, plugin) => <WebUiStatus plugin={plugin} />,
|
|
||||||
responsive: ["sm"],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "actions",
|
key: "actions",
|
||||||
|
|||||||
Reference in new issue
Block a user