strapi-plugin-app-version
Version:
This plugin displays the version in the Strapi settings
74 lines (73 loc) • 1.94 kB
JavaScript
import { useRef, useEffect } from "react";
const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
const v = glob[path];
if (v) {
return typeof v === "function" ? v() : Promise.resolve(v);
}
return new Promise((_, reject) => {
(typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
reject.bind(
null,
new Error(
"Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "")
)
)
);
});
};
const strapi = {
name: "app-version"
};
const packageJson = {
strapi
};
const PLUGIN_ID = packageJson.strapi.name;
const Initializer = ({ setPlugin }) => {
const ref = useRef(setPlugin);
useEffect(() => {
ref.current(PLUGIN_ID);
}, []);
return null;
};
const index = {
register(app) {
app.registerPlugin({
id: PLUGIN_ID,
initializer: Initializer,
isReady: false,
name: PLUGIN_ID
});
},
bootstrap(app) {
app.addSettingsLink("global", {
id: `${PLUGIN_ID}.plugin.name`,
to: `/settings/${PLUGIN_ID}`,
intlLabel: {
id: `${PLUGIN_ID}.plugin.name`,
defaultMessage: "App Version"
},
// @ts-expect-error component type mismatch
Component: async () => {
const { App } = await import("./App-cUNCg1jv.mjs");
return App;
},
permissions: []
});
},
registerTrads({ locales }) {
return Promise.all(
locales.map(async (locale) => {
try {
const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => import("./en-Byx4XI2L.mjs") }), `./translations/${locale}.json`, 3);
return { data, locale };
} catch {
return { data: {}, locale };
}
})
);
}
};
export {
PLUGIN_ID as P,
index as i
};