@filerobot-strapi/content-plugin
Version:
Scaleflex DAM normalizes, resizes, optimizes and distributes your images rocket fast around the world.
594 lines (593 loc) • 28.4 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 reactIntl = require("react-intl");
const designSystem = require("@strapi/design-system");
const react = require("react");
const index = require("./index-CthcW2rc.js");
require("@filerobot/core/dist/style.min.css");
require("@filerobot/explorer/dist/style.min.css");
const Filerobot = require("@filerobot/core");
const Explorer = require("@filerobot/explorer");
const XHRUpload = require("@filerobot/xhr-upload");
const ProgressPanel = require("@filerobot/progress-panel");
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
const Filerobot__default = /* @__PURE__ */ _interopDefault(Filerobot);
const Explorer__default = /* @__PURE__ */ _interopDefault(Explorer);
const XHRUpload__default = /* @__PURE__ */ _interopDefault(XHRUpload);
const ProgressPanel__default = /* @__PURE__ */ _interopDefault(ProgressPanel);
var sprintf = {};
(function(exports$1) {
!function() {
var re = {
not_type: /[^T]/,
not_primitive: /[^v]/,
number: /[diefg]/,
numeric_arg: /[bcdiefguxX]/,
json: /[j]/,
text: /^[^\x25]+/,
modulo: /^\x25{2}/,
placeholder: /^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,
key: /^([a-z_][a-z_\d]*)/i,
key_access: /^\.([a-z_][a-z_\d]*)/i,
index_access: /^\[(\d+)\]/,
sign: /^[+-]/
};
function sprintf2(key) {
return sprintf_format(sprintf_parse(key), arguments);
}
function vsprintf(fmt, argv) {
return sprintf2.apply(null, [fmt].concat(argv || []));
}
function sprintf_format(parse_tree, argv) {
var cursor = 1, tree_length = parse_tree.length, arg, output = "", i, k, ph, pad, pad_character, pad_length, is_positive, sign;
for (i = 0; i < tree_length; i++) {
if (typeof parse_tree[i] === "string") {
output += parse_tree[i];
} else if (typeof parse_tree[i] === "object") {
ph = parse_tree[i];
if (ph.keys) {
arg = argv[cursor];
for (k = 0; k < ph.keys.length; k++) {
if (arg == void 0) {
throw new Error(sprintf2('[sprintf] Cannot access property "%s" of undefined value "%s"', ph.keys[k], ph.keys[k - 1]));
}
arg = arg[ph.keys[k]];
}
} else if (ph.param_no) {
arg = argv[ph.param_no];
} else {
arg = argv[cursor++];
}
if (re.not_type.test(ph.type) && re.not_primitive.test(ph.type) && arg instanceof Function) {
arg = arg();
}
if (re.numeric_arg.test(ph.type) && (typeof arg !== "number" && isNaN(arg))) {
throw new TypeError(sprintf2("[sprintf] expecting number but found %T", arg));
}
if (re.number.test(ph.type)) {
is_positive = arg >= 0;
}
switch (ph.type) {
case "b":
arg = parseInt(arg, 10).toString(2);
break;
case "c":
arg = String.fromCharCode(parseInt(arg, 10));
break;
case "d":
case "i":
arg = parseInt(arg, 10);
break;
case "j":
arg = JSON.stringify(arg, null, ph.width ? parseInt(ph.width) : 0);
break;
case "e":
arg = ph.precision ? parseFloat(arg).toExponential(ph.precision) : parseFloat(arg).toExponential();
break;
case "f":
arg = ph.precision ? parseFloat(arg).toFixed(ph.precision) : parseFloat(arg);
break;
case "g":
arg = ph.precision ? String(Number(arg.toPrecision(ph.precision))) : parseFloat(arg);
break;
case "o":
arg = (parseInt(arg, 10) >>> 0).toString(8);
break;
case "s":
arg = String(arg);
arg = ph.precision ? arg.substring(0, ph.precision) : arg;
break;
case "t":
arg = String(!!arg);
arg = ph.precision ? arg.substring(0, ph.precision) : arg;
break;
case "T":
arg = Object.prototype.toString.call(arg).slice(8, -1).toLowerCase();
arg = ph.precision ? arg.substring(0, ph.precision) : arg;
break;
case "u":
arg = parseInt(arg, 10) >>> 0;
break;
case "v":
arg = arg.valueOf();
arg = ph.precision ? arg.substring(0, ph.precision) : arg;
break;
case "x":
arg = (parseInt(arg, 10) >>> 0).toString(16);
break;
case "X":
arg = (parseInt(arg, 10) >>> 0).toString(16).toUpperCase();
break;
}
if (re.json.test(ph.type)) {
output += arg;
} else {
if (re.number.test(ph.type) && (!is_positive || ph.sign)) {
sign = is_positive ? "+" : "-";
arg = arg.toString().replace(re.sign, "");
} else {
sign = "";
}
pad_character = ph.pad_char ? ph.pad_char === "0" ? "0" : ph.pad_char.charAt(1) : " ";
pad_length = ph.width - (sign + arg).length;
pad = ph.width ? pad_length > 0 ? pad_character.repeat(pad_length) : "" : "";
output += ph.align ? sign + arg + pad : pad_character === "0" ? sign + pad + arg : pad + sign + arg;
}
}
}
return output;
}
var sprintf_cache = /* @__PURE__ */ Object.create(null);
function sprintf_parse(fmt) {
if (sprintf_cache[fmt]) {
return sprintf_cache[fmt];
}
var _fmt = fmt, match, parse_tree = [], arg_names = 0;
while (_fmt) {
if ((match = re.text.exec(_fmt)) !== null) {
parse_tree.push(match[0]);
} else if ((match = re.modulo.exec(_fmt)) !== null) {
parse_tree.push("%");
} else if ((match = re.placeholder.exec(_fmt)) !== null) {
if (match[2]) {
arg_names |= 1;
var field_list = [], replacement_field = match[2], field_match = [];
if ((field_match = re.key.exec(replacement_field)) !== null) {
field_list.push(field_match[1]);
while ((replacement_field = replacement_field.substring(field_match[0].length)) !== "") {
if ((field_match = re.key_access.exec(replacement_field)) !== null) {
field_list.push(field_match[1]);
} else if ((field_match = re.index_access.exec(replacement_field)) !== null) {
field_list.push(field_match[1]);
} else {
throw new SyntaxError("[sprintf] failed to parse named argument key");
}
}
} else {
throw new SyntaxError("[sprintf] failed to parse named argument key");
}
match[2] = field_list;
} else {
arg_names |= 2;
}
if (arg_names === 3) {
throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");
}
parse_tree.push(
{
placeholder: match[0],
param_no: match[1],
keys: match[2],
sign: match[3],
pad_char: match[4],
align: match[5],
width: match[6],
precision: match[7],
type: match[8]
}
);
} else {
throw new SyntaxError("[sprintf] unexpected placeholder");
}
_fmt = _fmt.substring(match[0].length);
}
return sprintf_cache[fmt] = parse_tree;
}
{
exports$1["sprintf"] = sprintf2;
exports$1["vsprintf"] = vsprintf;
}
if (typeof window !== "undefined") {
window["sprintf"] = sprintf2;
window["vsprintf"] = vsprintf;
}
}();
})(sprintf);
const Configurations = (props) => {
const filerobotApiDomain = "https://api.filerobot.com";
const intl = reactIntl.useIntl();
const config = props.config;
const { get, post, put } = admin.useFetchClient();
const [cname, setCname] = react.useState(config.cname ? config.cname : "");
const [token, setToken] = react.useState(config.token ? config.token : "");
const [secTemp, setSecTemp] = react.useState(config.sec_temp ? config.sec_temp : "");
const [folder, setFolder] = react.useState(config.folder ? config.folder : "");
const [success, setSuccess] = react.useState(false);
const [error, setError] = react.useState(false);
const [syncMessage, setSyncMessage] = react.useState(false);
const [disabledAllButtons, setDisabledAllButtons] = react.useState(false);
const [up, setUp] = react.useState(0);
const [down, setDown] = react.useState(0);
const saveConfiguration = async () => {
const config2 = {
cname,
token,
sec_temp: secTemp,
folder
};
setDisabledAllButtons(true);
await fetch(filerobotApiDomain + "/" + token + "/key/" + secTemp).then(async (response) => {
if (response.status === 200) {
await put(`/${index.PLUGIN_ID}/update-config`, config2).then((data) => {
setSuccess(true);
});
} else {
setError(true);
}
setDisabledAllButtons(false);
setTimeout(() => {
setError(false);
setSuccess(false);
}, 4e3);
});
};
const getNewSassKey = async (config2) => {
let sassReqHeaders = new Headers();
sassReqHeaders.append("Content-Type", "application/json");
const sassReqOpt = {
method: "GET",
headers: sassReqHeaders
};
const sassRes = await fetch(`${filerobotApiDomain}/${config2.token}/key/${config2.sec_temp}`, sassReqOpt);
if (sassRes.status !== 200) {
return false;
}
const sassInfo = await sassRes.json();
if (sassInfo.status !== "success") {
return false;
}
const sass = sassInfo.key;
if (typeof Storage !== "undefined") {
sessionStorage.setItem("sassKey", sass);
}
return sass;
};
const getSass = async (config2) => {
let sass;
sass = await getNewSassKey(config2);
return sass;
};
const getSyncStatus = async () => {
const localMedia = await get(`/${index.PLUGIN_ID}/db-files`);
const configsData = await get(`/${index.PLUGIN_ID}/config`);
const configs = configsData.data;
const sass = await getSass(configs);
if (!sass) {
setSyncMessage(intl.formatMessage({ id: `${index.PLUGIN_ID}.notification.error.check_sectmp_issue` }));
return {
localMedia: false,
filerobotMedia: false
};
}
let headers = new Headers();
headers.append("Content-Type", "application/json");
headers.append("X-Filerobot-Key", sass);
const requestOptions = {
method: "GET",
headers
};
const filerobotDirectory = configs.folder.charAt(0) === "/" ? configs.folder : `/${configs.folder}`;
const filerobotResponse = await fetch(`${filerobotApiDomain}/${configs.token}/v5/files?folder=${filerobotDirectory}`, requestOptions);
if (filerobotResponse.status !== 200) {
setSyncMessage(intl.formatMessage({ id: `${index.PLUGIN_ID}.notification.error.sync_status` }));
return {
localMedia: false,
filerobotMedia: false
};
}
const filerobotResponseJson = await filerobotResponse.json();
const filerobotMedia = filerobotResponseJson.files;
return {
localMedia,
filerobotMedia
};
};
const syncStatus = async () => {
setDisabledAllButtons(true);
const { localMedia, filerobotMedia } = await getSyncStatus();
if (localMedia === false && filerobotMedia === false) {
setSyncMessage(intl.formatMessage({ id: `${index.PLUGIN_ID}.notification.error.wrong_sectmp` }));
}
const toSyncUp = localMedia.data.nonFilerobot;
const alreadyDown = localMedia.data.filerobot;
const alreadyDownHashs = alreadyDown.map((x) => x["hash"]);
const filerobotMediaHashs = filerobotMedia.map((x) => x["hash"]["sha1"]);
const toSyncDown = filerobotMediaHashs.filter((x) => !alreadyDownHashs.includes(x));
setSyncMessage(sprintf.sprintf(intl.formatMessage({ id: `${index.PLUGIN_ID}.notification.success.sync_status` }), toSyncUp.length, toSyncDown.length));
setDisabledAllButtons(false);
setTimeout(() => {
setSyncMessage(false);
}, 5e3);
};
const triggerSync = async () => {
setDisabledAllButtons(true);
const { localMedia, filerobotMedia } = await getSyncStatus();
const toSyncUp = localMedia.data.nonFilerobot;
const alreadyDown = localMedia.data.filerobot;
const downResult = await syncDown(filerobotMedia, alreadyDown);
const upResult = await syncUp(toSyncUp);
setSyncMessage(sprintf.sprintf(intl.formatMessage({ id: `${index.PLUGIN_ID}.notification.success.sync_results` }), downResult, upResult));
setDisabledAllButtons(false);
};
const syncDown = async (filerobotMedia, alreadyDown) => {
const alreadyDownHashs = alreadyDown.map((x) => x["hash"]);
const filerobotMediaHashs = filerobotMedia.map((x) => x["hash"]["sha1"]);
const toSyncDown = filerobotMediaHashs.filter((x) => !alreadyDownHashs.includes(x));
let count = 0;
await Promise.all(filerobotMedia.map(async (index$1) => {
if (!alreadyDownHashs.includes(index$1.hash.sha1)) {
const result = await post(`/${index.PLUGIN_ID}/record-file`, { file: index$1, action: "sync-down", config });
if (result) {
count++;
}
const percentage = toSyncDown.length === 0 ? 100 : Math.ceil(count / toSyncDown.length * 100);
setDown(percentage);
}
}));
return `${count} / ${toSyncDown.length}`;
};
const syncUp = async (toSyncUp) => {
let count = 0;
await Promise.all(toSyncUp.map(async (index$1) => {
const result = await post(`/${index.PLUGIN_ID}/sync-up`, { file: index$1, config });
if (result) {
count++;
}
const percentage = toSyncUp.length === 0 ? 100 : Math.ceil(count / toSyncUp.length * 100);
setUp(percentage);
}));
return `${count} / ${toSyncUp.length}`;
};
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { spacing: 4, padding: 4, children: [
success && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Alert, { title: "Successfully", onClose: () => setSuccess(false), closeLabel: "Close alert", variant: "success", children: "Configuration updated" }),
error && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Alert, { title: "Failed", onClose: () => setError(false), closeLabel: "Close alert", variant: "danger", children: "Please check your configuration setting" }),
syncMessage && /* @__PURE__ */ jsxRuntime.jsx(
designSystem.Alert,
{
title: "Synchronization",
onClose: () => setSyncMessage(false),
closeLabel: "Close alert",
variant: "default",
children: syncMessage
}
),
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 2, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { children: [
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: "CNAME" }),
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Input, { type: "text", placeholder: "CNAME", value: cname, onChange: (e) => {
setCname(e.target.value);
} })
] }) }),
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 2, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { children: [
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: "Token" }),
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Input, { type: "text", placeholder: "Token", value: token, onChange: (e) => {
setToken(e.target.value);
} })
] }) }),
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 2, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { children: [
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: "Security Template" }),
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Input, { type: "text", placeholder: "Security Template", value: secTemp, onChange: (e) => {
setSecTemp(e.target.value);
} })
] }) }),
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 2, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { children: [
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: "Folder" }),
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Input, { type: "text", placeholder: "Folder", value: folder, onChange: (e) => {
setFolder(e.target.value);
} })
] }) }),
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 2, textAlign: "center", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { disabled: disabledAllButtons, onClick: () => saveConfiguration(), children: "Save configuration" }) }),
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { spacing: 4, textAlign: "center", children: [
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { disabled: disabledAllButtons, margin: 2, onClick: () => syncStatus(), variant: "secondary", children: "Synchronization Status" }),
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { disabled: disabledAllButtons, margin: 2, onClick: () => triggerSync(), variant: "secondary", children: "Trigger Synchronization" })
] }),
up !== 0 && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { spacing: 2, children: [
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: "Sync up" }),
/* @__PURE__ */ jsxRuntime.jsx(designSystem.ProgressBar, { value: up, children: syncMessage })
] }),
down !== 0 && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { spacing: 2, children: [
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: "Sync down" }),
/* @__PURE__ */ jsxRuntime.jsx(designSystem.ProgressBar, { value: down, children: syncMessage })
] })
] });
};
const FMAW = (props) => {
window.process = {
env: {
REACT_APP_GITLAB_REVIEW_ENV: false
}
};
const { post } = admin.useFetchClient();
const intl = reactIntl.useIntl();
const config = props.config;
const filerobot = react.useRef(null);
const [success, setSuccess] = react.useState(false);
react.useEffect(() => {
if (config.token === "" || config.sec_temp === "") {
return;
}
filerobot.current = Filerobot__default.default({
securityTemplateID: config.sec_temp,
container: config.token
}).use(ProgressPanel__default.default, {
target: "#sfx-widget-progress-panel"
}).use(Explorer__default.default, {
config: {
rootFolderPath: config.folder
},
target: "#scaleflex-dam-widget",
inline: true,
width: "100%",
height: "700px",
disableExportButton: true,
hideExportButtonIcon: true,
dismissUrlPathQueryUpdate: true,
disableDownloadButton: false,
preventExportDefaultBehavior: true,
hideDownloadButtonIcon: true,
preventDownloadDefaultBehavior: true,
showProgressDetails: true,
locale: {
strings: {
mutualizedExportButtonLabel: intl.formatMessage({ id: `${index.PLUGIN_ID}.label.button.fmaw.export` }),
mutualizedDownloadButton: intl.formatMessage({ id: `${index.PLUGIN_ID}.label.button.fmaw.export` })
}
}
}).use(XHRUpload__default.default).on("export", async (files, popupExportSuccessMsgFn, downloadFilesPackagedFn, downloadFileFn) => {
console.log(files);
await recordMedia(files, "export", config);
}).on("complete", async ({ failed, uploadID, successful }) => {
if (successful) {
await recordMedia(successful, "complete", config);
}
});
return () => {
filerobot.current.close();
};
}, [config]);
const recordMedia = async (files, action, config2) => {
let isSuccess = false;
for (const file of files) {
const index$1 = files.indexOf(file);
await post(`/${index.PLUGIN_ID}/record-file`, { method: "POST", file, action, config: config2 });
isSuccess = files.length - 1 === index$1;
}
setSuccess(isSuccess);
setTimeout(() => {
setSuccess(false);
}, 4e3);
};
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
success && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: 2, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Alert, { title: "Successfully", onClose: () => setSuccess(false), closeLabel: "Close alert", variant: "success", children: "Item(s) added to Strapi Media" }) }),
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: 2, id: "scaleflex-dam-widget" }),
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { id: "sfx-widget-progress-panel" }),
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 10 })
] });
};
const Media = () => {
reactIntl.useIntl();
const [media, setMedia] = react.useState([]);
const [totalRecords, setTotalRecords] = react.useState(0);
const [currentPage, setCurrentPage] = react.useState(1);
const [pageCount, setPageCount] = react.useState(0);
const [loadingPage, setLoadingPage] = react.useState(true);
const recordPerPage = 10;
const { get } = admin.useFetchClient();
const handlePageChange = async (pageNumber) => {
setCurrentPage(pageNumber);
let listMedia = await get(`/${index.PLUGIN_ID}/media?limit=${recordPerPage}&offset=${pageNumber - 1}`);
setMedia(listMedia.data);
};
react.useEffect(() => {
const countMedia = async () => {
try {
const itemCounts = await get(`/${index.PLUGIN_ID}/media-count`);
setTotalRecords(itemCounts.data);
setPageCount(Math.ceil(itemCounts.data / recordPerPage));
} catch (err) {
console.error(err);
}
};
countMedia();
const fetchMedia = async () => {
try {
const response = await get(`/${index.PLUGIN_ID}/media?limit=${recordPerPage}&offset=${currentPage - 1}`);
setMedia(response.data);
} catch (err) {
console.error(err);
} finally {
setLoadingPage(false);
}
};
fetchMedia();
}, [get]);
console.log(media);
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
loadingPage && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 10, children: "fetching data..." }),
!loadingPage && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { padding: 4, children: [
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Table, { colCount: 5, rowCount: recordPerPage, children: [
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: "ID" }) }),
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: "Image" }) }),
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: "Name" }) }),
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: "Provider" }) })
] }) }),
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: media.map((entry, index2) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", children: entry.id }) }),
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx("img", { src: entry.url, alt: "", style: { width: "80px", borderRadius: "6px", height: "80px", objectFit: "cover" } }) }),
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", children: entry.name }) }),
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", children: entry.provider }) })
] }, index2)) })
] }),
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: 5, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", children: [
currentPage > 1 && currentPage <= pageCount && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: () => handlePageChange(currentPage - 1), variant: "default", children: "Prev Page" }),
currentPage < pageCount && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
currentPage === 1 && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, {}),
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: () => handlePageChange(currentPage + 1), variant: "default", children: "Next Page" })
] })
] }) })
] })
] });
};
const HomePage = () => {
const { get } = admin.useFetchClient();
const [config, setConfig] = react.useState(null);
const [loading, setLoading] = react.useState(true);
react.useEffect(() => {
const fetchData = async () => {
try {
const response = await get(`/${index.PLUGIN_ID}/config`);
setConfig(response.data);
} catch (err) {
console.error(err);
} finally {
setLoading(false);
}
};
fetchData();
}, [get]);
if (loading)
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: "fetching configuration..." });
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Main, { children: [
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingLeft: 8, paddingTop: 5, paddingRight: 8, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", children: "Scaleflex DAM" }) }),
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 8, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tabs.Root, { defaultValue: "configurations", children: [
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tabs.List, { "aria-label": "Scaleflex DAM Managemement", children: [
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Tabs.Trigger, { value: "configurations", children: "Configurations" }),
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Tabs.Trigger, { value: "asset_manager", children: "Asset Manager" }),
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Tabs.Trigger, { value: "media", children: "Media" })
] }),
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Tabs.Content, { value: "configurations", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { color: "neutral800", padding: 4, background: "neutral0", children: /* @__PURE__ */ jsxRuntime.jsx(Configurations, { config }) }) }),
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Tabs.Content, { value: "asset_manager", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { color: "neutral800", padding: 4, background: "neutral0", children: /* @__PURE__ */ jsxRuntime.jsx(FMAW, { config }) }) }),
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Tabs.Content, { value: "media", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { color: "neutral800", padding: 4, background: "neutral0", children: /* @__PURE__ */ jsxRuntime.jsx(Media, {}) }) })
] }) })
] });
};
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;