strapi-plugin-app-version
Version:
This plugin displays the version in the Strapi settings
42 lines (41 loc) • 1.85 kB
JavaScript
;
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 index = require("./index-BECAJuEt.js");
const designSystem = require("@strapi/design-system");
const icons = require("@strapi/icons");
const react = require("react");
const HomePage = () => {
const { get } = admin.getFetchClient();
const [isLoading, setIsLoading] = react.useState(true);
const [version, setVersion] = react.useState(void 0);
react.useEffect(() => {
setIsLoading(true);
get(`/${index.PLUGIN_ID}/config/version`).then(({ data }) => {
setVersion(data.version);
}).catch((error) => {
console.error("Failed to fetch version:", error);
setVersion("unknown");
}).finally(() => {
setIsLoading(false);
});
}, []);
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.EmptyStateLayout, { icon: isLoading ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, {}) : /* @__PURE__ */ jsxRuntime.jsx(icons.Code, { style: { width: "60px", height: "60px" } }), content: `Version: ${version}` }) })
] });
};
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.App = App;