@strawbinary-io/api-video-strapi-5-plugin
Version:
A powerful Strapi plugin to easily manage your videos and integrate them in your project
98 lines (97 loc) • 3.42 kB
JavaScript
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxRuntime = require("react/jsx-runtime");
const React = require("react");
const admin = require("@strapi/strapi/admin");
const designSystem = require("@strapi/design-system");
require("react-dom/client");
const icons = require("@strapi/icons");
const rulesEngine = require("./rulesEngine-B1IxUHbK.js");
require("react-router-dom");
require("@strapi/icons/symbols");
require("react-intl");
const index$1 = require("./index-DcHw4rkp.js");
const Settings = () => {
const [settings, setSettings] = React.useState({
apiKey: "",
defaultPublic: true
});
const { toggleNotification } = admin.useNotification();
const getSettings = async () => {
const settings2 = await index$1.settingsRequests.get();
setSettings(settings2.data);
};
React.useEffect(() => {
getSettings();
}, []);
const handleChange = (event) => {
setSettings({ ...settings, apiKey: event.target.value });
};
const handleSetPublic = (event) => {
setSettings({ ...settings, defaultPublic: event.target.checked });
};
const handleOnSubmit = async () => {
const response = await index$1.settingsRequests.update(settings);
if (response) {
toggleNotification({
type: "success",
message: "Changes saved"
});
} else {
toggleNotification({
type: "warning",
message: "Please enter valid settings"
});
}
};
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
/* @__PURE__ */ jsxRuntime.jsx(
rulesEngine.Layouts.Header,
{
title: "api.video plugin settings",
primaryAction: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { type: "submit", onClick: handleOnSubmit, startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Check, {}), size: "L", children: "Save" })
}
),
/* @__PURE__ */ jsxRuntime.jsx(rulesEngine.Layouts.Content, { children: /* @__PURE__ */ jsxRuntime.jsxs(
designSystem.Box,
{
background: "neutral0",
hasRadius: true,
shadow: "filterShadow",
paddingTop: 6,
paddingBottom: 6,
paddingLeft: 7,
paddingRight: 7,
children: [
/* @__PURE__ */ jsxRuntime.jsx(
index$1.FieldComp,
{
name: "API Key",
label: "API Key",
value: settings.apiKey,
placeholder: "Enter your API Key",
description: "Generated in the api.video's dashboard and used for authenticating API calls.",
detailsLink: "https://dashboard.api.video",
isPassword: true,
onChange: handleChange
}
),
/* @__PURE__ */ jsxRuntime.jsx("br", {}),
/* @__PURE__ */ jsxRuntime.jsx(
index$1.Toggle,
{
label: "Default Video Privacy",
checked: settings.defaultPublic,
required: true,
onLabel: "Public",
offLabel: "Private",
onChange: handleSetPublic
}
)
]
}
) })
] });
};
const index = () => /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Protect, { permissions: [{ action: "plugin::api-video-strapi-5-plugin.settings.read", subject: null }], children: /* @__PURE__ */ jsxRuntime.jsx(Settings, {}) });
exports.default = index;