import React, { Fragment } from "react"; import { Descriptions, Grid, Tooltip, Typography, Space } from "antd"; import ExclamationCircleOutlined from "@ant-design/icons/ExclamationCircleOutlined"; import FileUnknownOutlined from "@ant-design/icons/FileUnknownOutlined"; import FileExclamationOutlined from "@ant-design/icons/FileExclamationOutlined"; import FileSyncOutlined from "@ant-design/icons/FileSyncOutlined"; import * as lib from "@clusterio/lib"; const { useBreakpoint } = Grid; type ModDetailsProps = { mod: T; mods?: lib.ModRecord[]; actions?: (mod: T) => React.JSX.Element; }; export default function ModDetails(props: ModDetailsProps) { let screens = useBreakpoint(); let mod: Partial & Partial = props.mod; if ("info" in mod) { // Add the mod info if present in a mod record mod = { ...mod, ...mod.info }; } const depWarnings = new Map(); if (mod.dependencies && props.mods) { for (const dependency of mod.dependencies) { depWarnings.set(dependency.name, dependency.checkUnsatisfiedReason(props.mods)); } } return {mod.error && Error} span={2} > {mod.error === "missing" && "The given version of this mod is missing from the controller storage."} {mod.error === "bad_checksum" && "Checksum of the mod in the controller storage does not match the checksum provided " + "by this mod pack." } } {props.actions && !screens.lg && {props.actions(props.mod)} } {Boolean(mod.title) && {mod.title}} {Boolean(mod.version) && {mod.version} } {Boolean(mod.description) && {mod.description} } {Boolean(mod.author) && {mod.author}} {`https://mods.factorio.com/mod/${mod.name}`} {Boolean(mod.contact) && {mod.contact}} {Boolean(mod.homepage) && {mod.homepage}} {mod.name} {Boolean(mod.factorioVersion) && {mod.warning === "wrong_factorio_version" && {" "} } {mod.factorioVersion} } {Boolean(mod.filename) && {mod.filename}} {mod.size !== undefined && {lib.formatBytes(mod.size)} } {Boolean(mod.sha1) && {mod.sha1}} {mod.dependencies && mod.dependencies.length && {mod.dependencies .filter(e => e.type !== "hidden") .map((e, i) => {depWarnings.get(e.name) === "incompatible" && {" "} } {depWarnings.get(e.name) === "missing_dependency" && {" "} } {depWarnings.get(e.name) === "wrong_version" && {" "} } {e.spec}
) }
}
; }