strapi-plugin-app-version
Version:
This plugin displays the version in the Strapi settings
65 lines (64 loc) • 3.13 kB
JavaScript
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxRuntime = require("react/jsx-runtime");
const admin = require("@strapi/strapi/admin");
const reactRouterDom = require("react-router-dom");
const react = require("react");
const designSystem = require("@strapi/design-system");
const icons = require("@strapi/icons");
const index = require("./index-DIV9lCc4.js");
const HomePage = () => {
const { get } = admin.getFetchClient();
const [isLoading, setIsLoading] = react.useState(true);
const [config, setConfig] = react.useState(void 0);
react.useEffect(() => {
setIsLoading(true);
get(`/${index.PLUGIN_ID}/config`).then(({ data }) => {
setConfig(data);
}).catch((error) => {
console.error("Failed to fetch version:", error);
setConfig({ version: "unknown" });
}).finally(() => {
setIsLoading(false);
});
}, []);
const dateFormatter = react.useMemo(() => Intl.DateTimeFormat(navigator.languages && navigator.languages.length ? navigator.languages[0] : navigator.language, {
year: "numeric",
month: "long",
day: "numeric",
hour: "2-digit",
minute: "2-digit",
second: "2-digit"
}), []);
return /* @__PURE__ */ jsxRuntime.jsxs(admin.Page.Main, { children: [
/* @__PURE__ */ jsxRuntime.jsx(
admin.Layouts.Header,
{
title: "App Version"
}
),
/* @__PURE__ */ jsxRuntime.jsx(admin.Layouts.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Card, { padding: 8, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", gap: 2, children: isLoading ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, {}) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 4, children: [
/* @__PURE__ */ jsxRuntime.jsx(icons.Code, { width: 60, height: 60 }),
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "beta", children: [
"Version: ",
config?.version
] })
] }),
(config?.date || config?.url) && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { style: { marginTop: "3rem" }, direction: "column", gap: 6, children: [
config?.date && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "delta", children: [
"Date: ",
dateFormatter.format(new Date(config.date))
] }),
config?.url && /* @__PURE__ */ jsxRuntime.jsx(designSystem.LinkButton, { variant: "tertiary", href: config.url, isExternal: true, endIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.ExternalLink, {}), children: "More information" })
] })
] }) }) }) })
] });
};
const App = () => {
return /* @__PURE__ */ jsxRuntime.jsxs(reactRouterDom.Routes, { children: [
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { index: true, element: /* @__PURE__ */ jsxRuntime.jsx(HomePage, {}) }),
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "*", element: /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Error, {}) })
] });
};
exports.default = App;