mirror of
https://github.com/BrenBroZAYT/gameyfin.git
synced 2026-06-15 08:15:37 +00:00
Implement Enum support for ConfigProperties in frontend and backend
This commit is contained in:
@@ -2,9 +2,18 @@ import ConfigEntryDto from "Frontend/generated/de/grimsi/gameyfin/config/dto/Con
|
||||
import React from "react";
|
||||
import Input from "Frontend/components/general/Input";
|
||||
import CheckboxInput from "Frontend/components/general/CheckboxInput";
|
||||
import SelectInput from "Frontend/components/general/SelectInput";
|
||||
|
||||
export default function ConfigFormField({configElement, ...props}: any) {
|
||||
function inputElement(configElement: ConfigEntryDto) {
|
||||
|
||||
if (configElement.allowedValues != null && configElement.allowedValues.length > 0) {
|
||||
return (
|
||||
<SelectInput label={configElement.description} name={configElement.key}
|
||||
values={configElement.allowedValues} {...props}/>
|
||||
);
|
||||
}
|
||||
|
||||
switch (configElement.type) {
|
||||
case "Boolean":
|
||||
return (
|
||||
|
||||
@@ -74,6 +74,38 @@ function SsoMangementLayout({getConfig, formik}: any) {
|
||||
);
|
||||
}
|
||||
|
||||
const validationSchema = Yup.object({});
|
||||
const validationSchema = Yup.object({
|
||||
sso: Yup.object({
|
||||
oidc: Yup.object({
|
||||
enabled: Yup.boolean(),
|
||||
"auto-register-new-users": Yup.boolean().required(),
|
||||
"match-existing-users-by": Yup.string().required(),
|
||||
"client-id": Yup.string().when("enabled", ([enabled], schema) =>
|
||||
enabled ? schema.required("Client ID is required") : schema
|
||||
),
|
||||
"client-secret": Yup.string().when("enabled", ([enabled], schema) =>
|
||||
enabled ? schema.required("Client Secret is required") : schema
|
||||
),
|
||||
"issuer-url": Yup.string().when("enabled", ([enabled], schema) =>
|
||||
enabled ? schema.required("Issuer URL is required") : schema
|
||||
),
|
||||
"authorize-url": Yup.string().when("enabled", ([enabled], schema) =>
|
||||
enabled ? schema.required("Authorize URL is required") : schema
|
||||
),
|
||||
"token-url": Yup.string().when("enabled", ([enabled], schema) =>
|
||||
enabled ? schema.required("Token URL is required") : schema
|
||||
),
|
||||
"userinfo-url": Yup.string().when("enabled", ([enabled], schema) =>
|
||||
enabled ? schema.required("Userinfo URL is required") : schema
|
||||
),
|
||||
"logout-url": Yup.string().when("enabled", ([enabled], schema) =>
|
||||
enabled ? schema.required("Logout URL is required") : schema
|
||||
),
|
||||
"jwks-url": Yup.string().when("enabled", ([enabled], schema) =>
|
||||
enabled ? schema.required("JWKS URL is required") : schema
|
||||
)
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
export const SsoManagement = withConfigPage(SsoMangementLayout, "Single Sign-On", "sso", validationSchema);
|
||||
@@ -0,0 +1,28 @@
|
||||
import {useField} from "formik";
|
||||
import {Select, SelectItem} from "@nextui-org/react";
|
||||
|
||||
// @ts-ignore
|
||||
const SelectInput = ({label, values, ...props}) => {
|
||||
// @ts-ignore
|
||||
const [field] = useField(props);
|
||||
|
||||
return (
|
||||
<div className="flex flex-row flex-1 items-center gap-2 my-2">
|
||||
<Select
|
||||
{...field}
|
||||
{...props}
|
||||
id={field.name}
|
||||
label={label}
|
||||
defaultSelectedKeys={[field.value]}
|
||||
>
|
||||
{values.map((value: string) => (
|
||||
<SelectItem key={value} value={value}>
|
||||
{value.toLowerCase()}
|
||||
</SelectItem>
|
||||
))}
|
||||
</Select>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default SelectInput;
|
||||
Reference in New Issue
Block a user