strapi-plugin-app-version
Version:
This plugin displays the version in the Strapi settings
42 lines (41 loc) • 1.56 kB
JavaScript
import { jsxs, jsx } from "react/jsx-runtime";
import { getFetchClient, Page, Layouts } from "@strapi/strapi/admin";
import { Routes, Route } from "react-router-dom";
import { P as PLUGIN_ID } from "./index-Brkh8NGG.mjs";
import { EmptyStateLayout, Loader } from "@strapi/design-system";
import { Code } from "@strapi/icons";
import { useState, useEffect } from "react";
const HomePage = () => {
const { get } = getFetchClient();
const [isLoading, setIsLoading] = useState(true);
const [version, setVersion] = useState(void 0);
useEffect(() => {
setIsLoading(true);
get(`/${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__ */ jsxs(Page.Main, { children: [
/* @__PURE__ */ jsx(
Layouts.Header,
{
title: "App Version"
}
),
/* @__PURE__ */ jsx(Layouts.Content, { children: /* @__PURE__ */ jsx(EmptyStateLayout, { icon: isLoading ? /* @__PURE__ */ jsx(Loader, {}) : /* @__PURE__ */ jsx(Code, { style: { width: "60px", height: "60px" } }), content: `Version: ${version}` }) })
] });
};
const App = () => {
return /* @__PURE__ */ jsxs(Routes, { children: [
/* @__PURE__ */ jsx(Route, { index: true, element: /* @__PURE__ */ jsx(HomePage, {}) }),
/* @__PURE__ */ jsx(Route, { path: "*", element: /* @__PURE__ */ jsx(Page.Error, {}) })
] });
};
export {
App
};