mirror of
https://github.com/certimate-go/certimate.git
synced 2026-09-24 23:10:13 +08:00
refactor(ui): clean code
This commit is contained in:
@@ -1,25 +1,28 @@
|
||||
import { startTransition, useCallback, useEffect, useRef, useState } from "react";
|
||||
import { startTransition, useCallback, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { IconX } from "@tabler/icons-react";
|
||||
import { useControllableValue, useGetState } from "ahooks";
|
||||
import { App, Button, Drawer, Flex } from "antd";
|
||||
import { App, Button, Drawer, Flex, Form } from "antd";
|
||||
|
||||
import AccessProviderPicker from "@/components/provider/AccessProviderPicker";
|
||||
import Show from "@/components/Show";
|
||||
import { type AccessModel } from "@/domain/access";
|
||||
import { ACCESS_USAGES } from "@/domain/provider";
|
||||
import { useTriggerElement, useZustandShallowSelector } from "@/hooks";
|
||||
import { useAccessesStore } from "@/stores/access";
|
||||
import { getErrMsg } from "@/utils/error";
|
||||
|
||||
import AccessForm, { type AccessFormInstance, type AccessFormProps } from "./AccessForm";
|
||||
import AccessForm, { type AccessFormModes, type AccessFormProps, type AccessFormUsages } from "./AccessForm";
|
||||
|
||||
export interface AccessEditDrawerProps {
|
||||
afterClose?: () => void;
|
||||
afterSubmit?: (record: AccessModel) => void;
|
||||
data?: AccessFormProps["initialValues"];
|
||||
loading?: boolean;
|
||||
mode: AccessFormProps["mode"];
|
||||
mode: AccessFormModes;
|
||||
open?: boolean;
|
||||
trigger?: React.ReactNode;
|
||||
usage?: AccessFormProps["usage"];
|
||||
usage?: AccessFormUsages;
|
||||
onOpenChange?: (open: boolean) => void;
|
||||
}
|
||||
|
||||
@@ -38,25 +41,29 @@ const AccessEditDrawer = ({ afterClose, afterSubmit, mode, data, loading, trigge
|
||||
|
||||
const triggerEl = useTriggerElement(trigger, { onClick: () => setOpen(true) });
|
||||
|
||||
const formRef = useRef<AccessFormInstance>(null);
|
||||
const providerFilter = AccessForm.useProviderFilterByUsage(usage);
|
||||
|
||||
const [formInst] = Form.useForm();
|
||||
const [formPending, setFormPending] = useState(false);
|
||||
|
||||
const [footerShow, setFooterShow] = useState(!!data?.provider);
|
||||
useEffect(() => {
|
||||
setFooterShow(!!data?.provider);
|
||||
}, [data?.provider]);
|
||||
const fieldProvider = Form.useWatch<string>("provider", { form: formInst, preserve: true });
|
||||
|
||||
const handleProviderPick = (value: string) => {
|
||||
formInst.setFieldValue("provider", value);
|
||||
};
|
||||
|
||||
const handleOkClick = async () => {
|
||||
setFormPending(true);
|
||||
try {
|
||||
await formRef.current!.validateFields();
|
||||
await formInst.validateFields();
|
||||
} catch (err) {
|
||||
setFormPending(false);
|
||||
throw err;
|
||||
}
|
||||
|
||||
try {
|
||||
let values: AccessModel = formRef.current!.getFieldsValue();
|
||||
let values: AccessModel = formInst.getFieldsValue(true);
|
||||
values.reserve = usage === "ca" ? "ca" : usage === "notification" ? "notif" : void 0;
|
||||
|
||||
if (mode === "create") {
|
||||
if (data?.id) {
|
||||
@@ -91,10 +98,6 @@ const AccessEditDrawer = ({ afterClose, afterSubmit, mode, data, loading, trigge
|
||||
setOpen(false);
|
||||
};
|
||||
|
||||
const handleFormValuesChange: AccessFormProps["onValuesChange"] = (values) => {
|
||||
setFooterShow(!!values.provider);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
{triggerEl}
|
||||
@@ -105,7 +108,7 @@ const AccessEditDrawer = ({ afterClose, afterSubmit, mode, data, loading, trigge
|
||||
closeIcon={false}
|
||||
destroyOnHidden
|
||||
footer={
|
||||
footerShow ? (
|
||||
fieldProvider ? (
|
||||
<Flex className="px-2" justify="end" gap="small">
|
||||
<Button onClick={handleCancelClick}>{t("common.button.cancel")}</Button>
|
||||
<Button loading={formPending} type="primary" onClick={handleOkClick}>
|
||||
@@ -137,7 +140,20 @@ const AccessEditDrawer = ({ afterClose, afterSubmit, mode, data, loading, trigge
|
||||
}
|
||||
onClose={handleCancelClick}
|
||||
>
|
||||
<AccessForm ref={formRef} disabled={formPending} initialValues={data} mode={mode} usage={usage} onValuesChange={handleFormValuesChange} />
|
||||
<Show when={!fieldProvider && !data?.provider}>
|
||||
<AccessProviderPicker
|
||||
autoFocus
|
||||
gap="large"
|
||||
placeholder={t("access.form.provider.search.placeholder")}
|
||||
showOptionTags={usage == null || (usage === "dns-hosting" ? { [ACCESS_USAGES.DNS]: true, [ACCESS_USAGES.HOSTING]: true } : false)}
|
||||
onFilter={providerFilter}
|
||||
onSelect={handleProviderPick}
|
||||
/>
|
||||
</Show>
|
||||
|
||||
<div style={{ display: fieldProvider || data?.provider ? "block" : "none" }}>
|
||||
<AccessForm form={formInst} disabled={formPending} initialValues={data} mode={mode} usage={usage} />
|
||||
</div>
|
||||
</Drawer>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -1,111 +1,104 @@
|
||||
import { forwardRef, useImperativeHandle, useMemo, useState } from "react";
|
||||
import { useMemo } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import AccessProviderPicker from "@/components/provider/AccessProviderPicker";
|
||||
import AccessProviderSelect from "@/components/provider/AccessProviderSelect";
|
||||
import Show from "@/components/Show";
|
||||
import { type AccessModel } from "@/domain/access";
|
||||
import { ACCESS_PROVIDERS, ACCESS_USAGES, type AccessProvider } from "@/domain/provider";
|
||||
import { useAntdForm, useAntdFormName } from "@/hooks";
|
||||
import { ACCESS_PROVIDERS, ACCESS_USAGES } from "@/domain/provider";
|
||||
import { useAntdForm } from "@/hooks";
|
||||
|
||||
import AccessForm1PanelConfig from "./AccessForm1PanelConfig";
|
||||
import AccessFormACMECAConfig from "./AccessFormACMECAConfig";
|
||||
import AccessFormACMEHttpReqConfig from "./AccessFormACMEHttpReqConfig";
|
||||
import AccessFormAliyunConfig from "./AccessFormAliyunConfig";
|
||||
import AccessFormAPISIXConfig from "./AccessFormAPISIXConfig";
|
||||
import AccessFormAWSConfig from "./AccessFormAWSConfig";
|
||||
import AccessFormAzureConfig from "./AccessFormAzureConfig";
|
||||
import AccessFormBaiduCloudConfig from "./AccessFormBaiduCloudConfig";
|
||||
import AccessFormBaishanConfig from "./AccessFormBaishanConfig";
|
||||
import AccessFormBaotaPanelConfig from "./AccessFormBaotaPanelConfig";
|
||||
import AccessFormBaotaWAFConfig from "./AccessFormBaotaWAFConfig";
|
||||
import AccessFormBunnyConfig from "./AccessFormBunnyConfig";
|
||||
import AccessFormBytePlusConfig from "./AccessFormBytePlusConfig";
|
||||
import AccessFormCacheFlyConfig from "./AccessFormCacheFlyConfig";
|
||||
import AccessFormCdnflyConfig from "./AccessFormCdnflyConfig";
|
||||
import AccessFormCloudflareConfig from "./AccessFormCloudflareConfig";
|
||||
import AccessFormClouDNSConfig from "./AccessFormClouDNSConfig";
|
||||
import AccessFormCMCCCloudConfig from "./AccessFormCMCCCloudConfig";
|
||||
import AccessFormConstellixConfig from "./AccessFormConstellixConfig";
|
||||
import AccessFormCTCCCloudConfig from "./AccessFormCTCCCloudConfig";
|
||||
import AccessFormDeSECConfig from "./AccessFormDeSECConfig";
|
||||
import AccessFormDigitalOceanConfig from "./AccessFormDigitalOceanConfig";
|
||||
import AccessFormDingTalkBotConfig from "./AccessFormDingTalkBotConfig";
|
||||
import AccessFormDiscordBotConfig from "./AccessFormDiscordBotConfig";
|
||||
import AccessFormDNSLAConfig from "./AccessFormDNSLAConfig";
|
||||
import AccessFormDogeCloudConfig from "./AccessFormDogeCloudConfig";
|
||||
import AccessFormDuckDNSConfig from "./AccessFormDuckDNSConfig";
|
||||
import AccessFormDynv6Config from "./AccessFormDynv6Config";
|
||||
import AccessFormEdgioConfig from "./AccessFormEdgioConfig";
|
||||
import AccessFormEmailConfig from "./AccessFormEmailConfig";
|
||||
import AccessFormFlexCDNConfig from "./AccessFormFlexCDNConfig";
|
||||
import AccessFormGcoreConfig from "./AccessFormGcoreConfig";
|
||||
import AccessFormGnameConfig from "./AccessFormGnameConfig";
|
||||
import AccessFormGoDaddyConfig from "./AccessFormGoDaddyConfig";
|
||||
import AccessFormGoEdgeConfig from "./AccessFormGoEdgeConfig";
|
||||
import AccessFormGoogleTrustServicesConfig from "./AccessFormGoogleTrustServicesConfig";
|
||||
import AccessFormHetznerConfig from "./AccessFormHetznerConfig";
|
||||
import AccessFormHuaweiCloudConfig from "./AccessFormHuaweiCloudConfig";
|
||||
import AccessFormJDCloudConfig from "./AccessFormJDCloudConfig";
|
||||
import AccessFormKongConfig from "./AccessFormKongConfig";
|
||||
import AccessFormKubernetesConfig from "./AccessFormKubernetesConfig";
|
||||
import AccessFormLarkBotConfig from "./AccessFormLarkBotConfig";
|
||||
import AccessFormLeCDNConfig from "./AccessFormLeCDNConfig";
|
||||
import AccessFormMattermostConfig from "./AccessFormMattermostConfig";
|
||||
import AccessFormNamecheapConfig from "./AccessFormNamecheapConfig";
|
||||
import AccessFormNameDotComConfig from "./AccessFormNameDotComConfig";
|
||||
import AccessFormNameSiloConfig from "./AccessFormNameSiloConfig";
|
||||
import AccessFormNetcupConfig from "./AccessFormNetcupConfig";
|
||||
import AccessFormNetlifyConfig from "./AccessFormNetlifyConfig";
|
||||
import AccessFormNS1Config from "./AccessFormNS1Config";
|
||||
import AccessFormPorkbunConfig from "./AccessFormPorkbunConfig";
|
||||
import AccessFormPowerDNSConfig from "./AccessFormPowerDNSConfig";
|
||||
import AccessFormProxmoxVEConfig from "./AccessFormProxmoxVEConfig";
|
||||
import AccessFormQiniuConfig from "./AccessFormQiniuConfig";
|
||||
import AccessFormRainYunConfig from "./AccessFormRainYunConfig";
|
||||
import AccessFormRatPanelConfig from "./AccessFormRatPanelConfig";
|
||||
import AccessFormSafeLineConfig from "./AccessFormSafeLineConfig";
|
||||
import AccessFormSlackBotConfig from "./AccessFormSlackBotConfig";
|
||||
import AccessFormSpaceshipConfig from "./AccessFormSpaceshipConfig";
|
||||
import AccessFormSSHConfig from "./AccessFormSSHConfig";
|
||||
import AccessFormSSLComConfig from "./AccessFormSSLComConfig";
|
||||
import AccessFormTelegramBotConfig from "./AccessFormTelegramBotConfig";
|
||||
import AccessFormTencentCloudConfig from "./AccessFormTencentCloudConfig";
|
||||
import AccessFormUCloudConfig from "./AccessFormUCloudConfig";
|
||||
import AccessFormUniCloudConfig from "./AccessFormUniCloudConfig";
|
||||
import AccessFormUpyunConfig from "./AccessFormUpyunConfig";
|
||||
import AccessFormVercelConfig from "./AccessFormVercelConfig";
|
||||
import AccessFormVolcEngineConfig from "./AccessFormVolcEngineConfig";
|
||||
import AccessFormWangsuConfig from "./AccessFormWangsuConfig";
|
||||
import AccessFormWebhookConfig from "./AccessFormWebhookConfig";
|
||||
import AccessFormWeComBotConfig from "./AccessFormWeComBotConfig";
|
||||
import AccessFormWestcnConfig from "./AccessFormWestcnConfig";
|
||||
import AccessFormZeroSSLConfig from "./AccessFormZeroSSLConfig";
|
||||
import { FormNestedFieldsContextProvider } from "./forms/_context";
|
||||
import { useProviderFilterByUsage } from "./forms/_hooks";
|
||||
import AccessConfigFieldsProvider1Panel from "./forms/AccessConfigFieldsProvider1Panel";
|
||||
import AccessConfigFieldsProviderACMECA from "./forms/AccessConfigFieldsProviderACMECA";
|
||||
import AccessConfigFieldsProviderACMEHttpReq from "./forms/AccessConfigFieldsProviderACMEHttpReq";
|
||||
import AccessConfigFieldsProviderAliyun from "./forms/AccessConfigFieldsProviderAliyun";
|
||||
import AccessConfigFieldsProviderAPISIX from "./forms/AccessConfigFieldsProviderAPISIX";
|
||||
import AccessConfigFieldsProviderAWS from "./forms/AccessConfigFieldsProviderAWS";
|
||||
import AccessConfigFieldsProviderAzure from "./forms/AccessConfigFieldsProviderAzure";
|
||||
import AccessConfigFieldsProviderBaiduCloud from "./forms/AccessConfigFieldsProviderBaiduCloud";
|
||||
import AccessConfigFieldsProviderBaishan from "./forms/AccessConfigFieldsProviderBaishan";
|
||||
import AccessConfigFieldsProviderBaotaPanel from "./forms/AccessConfigFieldsProviderBaotaPanel";
|
||||
import AccessConfigFieldsProviderBaotaWAF from "./forms/AccessConfigFieldsProviderBaotaWAF";
|
||||
import AccessConfigFieldsProviderBunny from "./forms/AccessConfigFieldsProviderBunny";
|
||||
import AccessConfigFieldsProviderBytePlus from "./forms/AccessConfigFieldsProviderBytePlus";
|
||||
import AccessConfigFieldsProviderCacheFly from "./forms/AccessConfigFieldsProviderCacheFly";
|
||||
import AccessConfigFieldsProviderCdnfly from "./forms/AccessConfigFieldsProviderCdnfly";
|
||||
import AccessConfigFieldsProviderCloudflare from "./forms/AccessConfigFieldsProviderCloudflare";
|
||||
import AccessConfigFieldsProviderClouDNS from "./forms/AccessConfigFieldsProviderClouDNS";
|
||||
import AccessConfigFieldsProviderCMCCCloud from "./forms/AccessConfigFieldsProviderCMCCCloud";
|
||||
import AccessConfigFieldsProviderConstellix from "./forms/AccessConfigFieldsProviderConstellix";
|
||||
import AccessConfigFieldsProviderCTCCCloud from "./forms/AccessConfigFieldsProviderCTCCCloud";
|
||||
import AccessConfigFieldsProviderDeSEC from "./forms/AccessConfigFieldsProviderDeSEC";
|
||||
import AccessConfigFieldsProviderDigitalOcean from "./forms/AccessConfigFieldsProviderDigitalOcean";
|
||||
import AccessConfigFieldsProviderDingTalkBot from "./forms/AccessConfigFieldsProviderDingTalkBot";
|
||||
import AccessConfigFieldsProviderDiscordBot from "./forms/AccessConfigFieldsProviderDiscordBot";
|
||||
import AccessConfigFieldsProviderDNSLA from "./forms/AccessConfigFieldsProviderDNSLA";
|
||||
import AccessConfigFieldsProviderDogeCloud from "./forms/AccessConfigFieldsProviderDogeCloud";
|
||||
import AccessConfigFieldsProviderDuckDNS from "./forms/AccessConfigFieldsProviderDuckDNS";
|
||||
import AccessConfigFieldsProviderDynv6 from "./forms/AccessConfigFieldsProviderDynv6";
|
||||
import AccessConfigFieldsProviderEdgio from "./forms/AccessConfigFieldsProviderEdgio";
|
||||
import AccessConfigFieldsProviderEmail from "./forms/AccessConfigFieldsProviderEmail";
|
||||
import AccessConfigFieldsProviderFlexCDN from "./forms/AccessConfigFieldsProviderFlexCDN";
|
||||
import AccessConfigFieldsProviderGcore from "./forms/AccessConfigFieldsProviderGcore";
|
||||
import AccessConfigFieldsProviderGname from "./forms/AccessConfigFieldsProviderGname";
|
||||
import AccessConfigFieldsProviderGoDaddy from "./forms/AccessConfigFieldsProviderGoDaddy";
|
||||
import AccessConfigFieldsProviderGoEdge from "./forms/AccessConfigFieldsProviderGoEdge";
|
||||
import AccessConfigFieldsProviderGoogleTrustServices from "./forms/AccessConfigFieldsProviderGoogleTrustServices";
|
||||
import AccessConfigFieldsProviderHetzner from "./forms/AccessConfigFieldsProviderHetzner";
|
||||
import AccessConfigFieldsProviderHuaweiCloud from "./forms/AccessConfigFieldsProviderHuaweiCloud";
|
||||
import AccessConfigFieldsProviderJDCloud from "./forms/AccessConfigFieldsProviderJDCloud";
|
||||
import AccessConfigFieldsProviderKong from "./forms/AccessConfigFieldsProviderKong";
|
||||
import AccessConfigFieldsProviderKubernetes from "./forms/AccessConfigFieldsProviderKubernetes";
|
||||
import AccessConfigFieldsProviderLarkBot from "./forms/AccessConfigFieldsProviderLarkBot";
|
||||
import AccessConfigFieldsProviderLeCDN from "./forms/AccessConfigFieldsProviderLeCDN";
|
||||
import AccessConfigFieldsProviderMattermost from "./forms/AccessConfigFieldsProviderMattermost";
|
||||
import AccessConfigFieldsProviderNamecheap from "./forms/AccessConfigFieldsProviderNamecheap";
|
||||
import AccessConfigFieldsProviderNameDotCom from "./forms/AccessConfigFieldsProviderNameDotCom";
|
||||
import AccessConfigFieldsProviderNameSilo from "./forms/AccessConfigFieldsProviderNameSilo";
|
||||
import AccessConfigFieldsProviderNetcup from "./forms/AccessConfigFieldsProviderNetcup";
|
||||
import AccessConfigFieldsProviderNetlify from "./forms/AccessConfigFieldsProviderNetlify";
|
||||
import AccessConfigFieldsProviderNS1 from "./forms/AccessConfigFieldsProviderNS1";
|
||||
import AccessConfigFieldsProviderPorkbun from "./forms/AccessConfigFieldsProviderPorkbun";
|
||||
import AccessConfigFieldsProviderPowerDNS from "./forms/AccessConfigFieldsProviderPowerDNS";
|
||||
import AccessConfigFieldsProviderProxmoxVE from "./forms/AccessConfigFieldsProviderProxmoxVE";
|
||||
import AccessConfigFieldsProviderQiniu from "./forms/AccessConfigFieldsProviderQiniu";
|
||||
import AccessConfigFieldsProviderRainYun from "./forms/AccessConfigFieldsProviderRainYun";
|
||||
import AccessConfigFieldsProviderRatPanel from "./forms/AccessConfigFieldsProviderRatPanel";
|
||||
import AccessConfigFieldsProviderSafeLine from "./forms/AccessConfigFieldsProviderSafeLine";
|
||||
import AccessConfigFieldsProviderSlackBot from "./forms/AccessConfigFieldsProviderSlackBot";
|
||||
import AccessConfigFieldsProviderSpaceship from "./forms/AccessConfigFieldsProviderSpaceship";
|
||||
import AccessConfigFieldsProviderSSH from "./forms/AccessConfigFieldsProviderSSH";
|
||||
import AccessConfigFieldsProviderSSLCom from "./forms/AccessConfigFieldsProviderSSLCom";
|
||||
import AccessConfigFieldsProviderTelegramBot from "./forms/AccessConfigFieldsProviderTelegramBot";
|
||||
import AccessConfigFieldsProviderTencentCloud from "./forms/AccessConfigFieldsProviderTencentCloud";
|
||||
import AccessConfigFieldsProviderUCloud from "./forms/AccessConfigFieldsProviderUCloud";
|
||||
import AccessConfigFieldsProviderUniCloud from "./forms/AccessConfigFieldsProviderUniCloud";
|
||||
import AccessConfigFieldsProviderUpyun from "./forms/AccessConfigFieldsProviderUpyun";
|
||||
import AccessConfigFieldsProviderVercel from "./forms/AccessConfigFieldsProviderVercel";
|
||||
import AccessConfigFieldsProviderVolcEngine from "./forms/AccessConfigFieldsProviderVolcEngine";
|
||||
import AccessConfigFieldsProviderWangsu from "./forms/AccessConfigFieldsProviderWangsu";
|
||||
import AccessConfigFieldsProviderWebhook from "./forms/AccessConfigFieldsProviderWebhook";
|
||||
import AccessConfigFieldsProviderWeComBot from "./forms/AccessConfigFieldsProviderWeComBot";
|
||||
import AccessConfigFieldsProviderWestcn from "./forms/AccessConfigFieldsProviderWestcn";
|
||||
import AccessConfigFieldsProviderZeroSSL from "./forms/AccessConfigFieldsProviderZeroSSL";
|
||||
|
||||
type AccessFormFieldValues = Partial<MaybeModelRecord<AccessModel>>;
|
||||
type AccessFormModes = "create" | "edit";
|
||||
type AccessFormUsages = "dns" | "hosting" | "dns-hosting" | "ca" | "notification";
|
||||
export type AccessFormModes = "create" | "edit";
|
||||
export type AccessFormUsages = "dns" | "hosting" | "dns-hosting" | "ca" | "notification";
|
||||
|
||||
export interface AccessFormProps {
|
||||
className?: string;
|
||||
style?: React.CSSProperties;
|
||||
mode: AccessFormModes;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormFieldValues;
|
||||
initialValues?: Nullish<MaybeModelRecord<AccessModel>>;
|
||||
form: FormInstance;
|
||||
mode: AccessFormModes;
|
||||
usage?: AccessFormUsages;
|
||||
onValuesChange?: (values: AccessFormFieldValues) => void;
|
||||
}
|
||||
|
||||
export interface AccessFormInstance {
|
||||
getFieldsValue: () => ReturnType<FormInstance<AccessFormFieldValues>["getFieldsValue"]>;
|
||||
resetFields: FormInstance<AccessFormFieldValues>["resetFields"];
|
||||
validateFields: FormInstance<AccessFormFieldValues>["validateFields"];
|
||||
}
|
||||
|
||||
const AccessForm = forwardRef<AccessFormInstance, AccessFormProps>(({ className, style, mode, disabled, initialValues, usage, onValuesChange }, ref) => {
|
||||
const AccessForm = ({ className, style, disabled, initialValues, mode, usage, ...props }: AccessFormProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
@@ -119,280 +112,282 @@ const AccessForm = forwardRef<AccessFormInstance, AccessFormProps>(({ className,
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const { form: formInst, formProps } = useAntdForm({
|
||||
form: props.form,
|
||||
name: "accessForm",
|
||||
initialValues: initialValues,
|
||||
});
|
||||
|
||||
const providerFilter = useMemo(() => {
|
||||
switch (usage) {
|
||||
case "dns":
|
||||
return (_: string, option: AccessProvider) => option.usages.includes(ACCESS_USAGES.DNS);
|
||||
case "hosting":
|
||||
return (_: string, option: AccessProvider) => option.usages.includes(ACCESS_USAGES.HOSTING);
|
||||
case "dns-hosting":
|
||||
return (_: string, option: AccessProvider) => option.usages.includes(ACCESS_USAGES.DNS) || option.usages.includes(ACCESS_USAGES.HOSTING);
|
||||
case "ca":
|
||||
return (_: string, option: AccessProvider) => option.usages.includes(ACCESS_USAGES.CA);
|
||||
case "notification":
|
||||
return (_: string, option: AccessProvider) => option.usages.includes(ACCESS_USAGES.NOTIFICATION);
|
||||
default:
|
||||
console.warn(`[certimate] unsupported provider usage: '${usage}'`);
|
||||
}
|
||||
}, [usage]);
|
||||
const providerFilter = useProviderFilterByUsage(usage);
|
||||
|
||||
const fieldProvider = Form.useWatch<z.infer<typeof formSchema>["provider"]>("provider", formInst);
|
||||
const [fieldProviderPicked, setFieldProviderPicked] = useState<string>(initialValues?.provider); // bugfix: Form.useWatch 在条件渲染下不生效,这里用单独的变量存放 Picker 组件选择的值
|
||||
|
||||
const [nestedFormInst] = Form.useForm();
|
||||
const nestedFormName = useAntdFormName({ form: nestedFormInst, name: "accessConfigForm" });
|
||||
const nestedFormEl = useMemo(() => {
|
||||
const nestedFormProps = {
|
||||
form: nestedFormInst,
|
||||
formName: nestedFormName,
|
||||
disabled: disabled,
|
||||
initialValues: initialValues?.config,
|
||||
};
|
||||
const fieldProvider = Form.useWatch<string>("provider", { form: formInst, preserve: true });
|
||||
|
||||
const nestedProviderConfigFields = useMemo(() => {
|
||||
/*
|
||||
注意:如果追加新的子组件,请保持以 ASCII 排序。
|
||||
NOTICE: If you add new child component, please keep ASCII order.
|
||||
*/
|
||||
注意:如果追加新的子组件,请保持以 ASCII 排序。
|
||||
NOTICE: If you add new child component, please keep ASCII order.
|
||||
*/
|
||||
switch (fieldProvider) {
|
||||
case ACCESS_PROVIDERS["1PANEL"]:
|
||||
return <AccessForm1PanelConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.ACMECA:
|
||||
return <AccessFormACMECAConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.ACMEHTTPREQ:
|
||||
return <AccessFormACMEHttpReqConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.ALIYUN:
|
||||
return <AccessFormAliyunConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.APISIX:
|
||||
return <AccessFormAPISIXConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.AWS:
|
||||
return <AccessFormAWSConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.AZURE:
|
||||
return <AccessFormAzureConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.BAIDUCLOUD:
|
||||
return <AccessFormBaiduCloudConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.BAISHAN:
|
||||
return <AccessFormBaishanConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.BAOTAPANEL:
|
||||
return <AccessFormBaotaPanelConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.BAOTAWAF:
|
||||
return <AccessFormBaotaWAFConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.BUNNY:
|
||||
return <AccessFormBunnyConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.BYTEPLUS:
|
||||
return <AccessFormBytePlusConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.CACHEFLY:
|
||||
return <AccessFormCacheFlyConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.CDNFLY:
|
||||
return <AccessFormCdnflyConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.CLOUDFLARE:
|
||||
return <AccessFormCloudflareConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.CLOUDNS:
|
||||
return <AccessFormClouDNSConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.CMCCCLOUD:
|
||||
return <AccessFormCMCCCloudConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.CONSTELLIX:
|
||||
return <AccessFormConstellixConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.CTCCCLOUD:
|
||||
return <AccessFormCTCCCloudConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.DESEC:
|
||||
return <AccessFormDeSECConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.DIGITALOCEAN:
|
||||
return <AccessFormDigitalOceanConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.DINGTALKBOT:
|
||||
return <AccessFormDingTalkBotConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.DISCORDBOT:
|
||||
return <AccessFormDiscordBotConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.DNSLA:
|
||||
return <AccessFormDNSLAConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.DOGECLOUD:
|
||||
return <AccessFormDogeCloudConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.DUCKDNS:
|
||||
return <AccessFormDuckDNSConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.DYNV6:
|
||||
return <AccessFormDynv6Config {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.EDGIO:
|
||||
return <AccessFormEdgioConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.EMAIL:
|
||||
return <AccessFormEmailConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.FLEXCDN:
|
||||
return <AccessFormFlexCDNConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.GCORE:
|
||||
return <AccessFormGcoreConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.GNAME:
|
||||
return <AccessFormGnameConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.GODADDY:
|
||||
return <AccessFormGoDaddyConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.GOEDGE:
|
||||
return <AccessFormGoEdgeConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.GOOGLETRUSTSERVICES:
|
||||
return <AccessFormGoogleTrustServicesConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.HETZNER:
|
||||
return <AccessFormHetznerConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.HUAWEICLOUD:
|
||||
return <AccessFormHuaweiCloudConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.JDCLOUD:
|
||||
return <AccessFormJDCloudConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.KONG:
|
||||
return <AccessFormKongConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.KUBERNETES:
|
||||
return <AccessFormKubernetesConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.LARKBOT:
|
||||
return <AccessFormLarkBotConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.LECDN:
|
||||
return <AccessFormLeCDNConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.MATTERMOST:
|
||||
return <AccessFormMattermostConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.NAMECHEAP:
|
||||
return <AccessFormNamecheapConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.NAMEDOTCOM:
|
||||
return <AccessFormNameDotComConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.NAMESILO:
|
||||
return <AccessFormNameSiloConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.NETCUP:
|
||||
return <AccessFormNetcupConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.NETLIFY:
|
||||
return <AccessFormNetlifyConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.NS1:
|
||||
return <AccessFormNS1Config {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.PORKBUN:
|
||||
return <AccessFormPorkbunConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.POWERDNS:
|
||||
return <AccessFormPowerDNSConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.PROXMOXVE:
|
||||
return <AccessFormProxmoxVEConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.QINIU:
|
||||
return <AccessFormQiniuConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.RAINYUN:
|
||||
return <AccessFormRainYunConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.RATPANEL:
|
||||
return <AccessFormRatPanelConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.SAFELINE:
|
||||
return <AccessFormSafeLineConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.SLACKBOT:
|
||||
return <AccessFormSlackBotConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.SPACESHIP:
|
||||
return <AccessFormSpaceshipConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.SSH:
|
||||
return <AccessFormSSHConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.TELEGRAMBOT:
|
||||
return <AccessFormTelegramBotConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.SSLCOM:
|
||||
return <AccessFormSSLComConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.TENCENTCLOUD:
|
||||
return <AccessFormTencentCloudConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.UCLOUD:
|
||||
return <AccessFormUCloudConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.UNICLOUD:
|
||||
return <AccessFormUniCloudConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.UPYUN:
|
||||
return <AccessFormUpyunConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.VERCEL:
|
||||
return <AccessFormVercelConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.VOLCENGINE:
|
||||
return <AccessFormVolcEngineConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.WANGSU:
|
||||
return <AccessFormWangsuConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.WEBHOOK:
|
||||
return (
|
||||
<AccessFormWebhookConfig
|
||||
usage={usage === "notification" ? "notification" : usage === "hosting" || usage === "dns-hosting" ? "deployment" : "none"}
|
||||
{...nestedFormProps}
|
||||
/>
|
||||
);
|
||||
case ACCESS_PROVIDERS.WECOMBOT:
|
||||
return <AccessFormWeComBotConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.WESTCN:
|
||||
return <AccessFormWestcnConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.ZEROSSL:
|
||||
return <AccessFormZeroSSLConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS["1PANEL"]: {
|
||||
return <AccessConfigFieldsProvider1Panel />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.ACMECA: {
|
||||
return <AccessConfigFieldsProviderACMECA />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.ACMEHTTPREQ: {
|
||||
return <AccessConfigFieldsProviderACMEHttpReq />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.ALIYUN: {
|
||||
return <AccessConfigFieldsProviderAliyun />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.APISIX: {
|
||||
return <AccessConfigFieldsProviderAPISIX />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.AWS: {
|
||||
return <AccessConfigFieldsProviderAWS />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.AZURE: {
|
||||
return <AccessConfigFieldsProviderAzure />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.BAIDUCLOUD: {
|
||||
return <AccessConfigFieldsProviderBaiduCloud />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.BAISHAN: {
|
||||
return <AccessConfigFieldsProviderBaishan />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.BAOTAPANEL: {
|
||||
return <AccessConfigFieldsProviderBaotaPanel />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.BAOTAWAF: {
|
||||
return <AccessConfigFieldsProviderBaotaWAF />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.BUNNY: {
|
||||
return <AccessConfigFieldsProviderBunny />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.BYTEPLUS: {
|
||||
return <AccessConfigFieldsProviderBytePlus />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.CACHEFLY: {
|
||||
return <AccessConfigFieldsProviderCacheFly />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.CDNFLY: {
|
||||
return <AccessConfigFieldsProviderCdnfly />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.CLOUDFLARE: {
|
||||
return <AccessConfigFieldsProviderCloudflare />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.CLOUDNS: {
|
||||
return <AccessConfigFieldsProviderClouDNS />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.CMCCCLOUD: {
|
||||
return <AccessConfigFieldsProviderCMCCCloud />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.CONSTELLIX: {
|
||||
return <AccessConfigFieldsProviderConstellix />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.CTCCCLOUD: {
|
||||
return <AccessConfigFieldsProviderCTCCCloud />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.DESEC: {
|
||||
return <AccessConfigFieldsProviderDeSEC />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.DIGITALOCEAN: {
|
||||
return <AccessConfigFieldsProviderDigitalOcean />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.DINGTALKBOT: {
|
||||
return <AccessConfigFieldsProviderDingTalkBot />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.DISCORDBOT: {
|
||||
return <AccessConfigFieldsProviderDiscordBot />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.DNSLA: {
|
||||
return <AccessConfigFieldsProviderDNSLA />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.DOGECLOUD: {
|
||||
return <AccessConfigFieldsProviderDogeCloud />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.DUCKDNS: {
|
||||
return <AccessConfigFieldsProviderDuckDNS />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.DYNV6: {
|
||||
return <AccessConfigFieldsProviderDynv6 />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.EDGIO: {
|
||||
return <AccessConfigFieldsProviderEdgio />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.EMAIL: {
|
||||
return <AccessConfigFieldsProviderEmail />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.FLEXCDN: {
|
||||
return <AccessConfigFieldsProviderFlexCDN />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.GCORE: {
|
||||
return <AccessConfigFieldsProviderGcore />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.GNAME: {
|
||||
return <AccessConfigFieldsProviderGname />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.GODADDY: {
|
||||
return <AccessConfigFieldsProviderGoDaddy />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.GOEDGE: {
|
||||
return <AccessConfigFieldsProviderGoEdge />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.GOOGLETRUSTSERVICES: {
|
||||
return <AccessConfigFieldsProviderGoogleTrustServices />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.HETZNER: {
|
||||
return <AccessConfigFieldsProviderHetzner />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.HUAWEICLOUD: {
|
||||
return <AccessConfigFieldsProviderHuaweiCloud />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.JDCLOUD: {
|
||||
return <AccessConfigFieldsProviderJDCloud />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.KONG: {
|
||||
return <AccessConfigFieldsProviderKong />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.KUBERNETES: {
|
||||
return <AccessConfigFieldsProviderKubernetes />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.LARKBOT: {
|
||||
return <AccessConfigFieldsProviderLarkBot />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.LECDN: {
|
||||
return <AccessConfigFieldsProviderLeCDN />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.MATTERMOST: {
|
||||
return <AccessConfigFieldsProviderMattermost />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.NAMECHEAP: {
|
||||
return <AccessConfigFieldsProviderNamecheap />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.NAMEDOTCOM: {
|
||||
return <AccessConfigFieldsProviderNameDotCom />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.NAMESILO: {
|
||||
return <AccessConfigFieldsProviderNameSilo />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.NETCUP: {
|
||||
return <AccessConfigFieldsProviderNetcup />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.NETLIFY: {
|
||||
return <AccessConfigFieldsProviderNetlify />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.NS1: {
|
||||
return <AccessConfigFieldsProviderNS1 />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.PORKBUN: {
|
||||
return <AccessConfigFieldsProviderPorkbun />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.POWERDNS: {
|
||||
return <AccessConfigFieldsProviderPowerDNS />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.PROXMOXVE: {
|
||||
return <AccessConfigFieldsProviderProxmoxVE />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.QINIU: {
|
||||
return <AccessConfigFieldsProviderQiniu />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.RAINYUN: {
|
||||
return <AccessConfigFieldsProviderRainYun />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.RATPANEL: {
|
||||
return <AccessConfigFieldsProviderRatPanel />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.SAFELINE: {
|
||||
return <AccessConfigFieldsProviderSafeLine />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.SLACKBOT: {
|
||||
return <AccessConfigFieldsProviderSlackBot />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.SPACESHIP: {
|
||||
return <AccessConfigFieldsProviderSpaceship />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.SSH: {
|
||||
return <AccessConfigFieldsProviderSSH disabled={disabled} />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.TELEGRAMBOT: {
|
||||
return <AccessConfigFieldsProviderTelegramBot />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.SSLCOM: {
|
||||
return <AccessConfigFieldsProviderSSLCom />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.TENCENTCLOUD: {
|
||||
return <AccessConfigFieldsProviderTencentCloud />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.UCLOUD: {
|
||||
return <AccessConfigFieldsProviderUCloud />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.UNICLOUD: {
|
||||
return <AccessConfigFieldsProviderUniCloud />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.UPYUN: {
|
||||
return <AccessConfigFieldsProviderUpyun />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.VERCEL: {
|
||||
return <AccessConfigFieldsProviderVercel />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.VOLCENGINE: {
|
||||
return <AccessConfigFieldsProviderVolcEngine />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.WANGSU: {
|
||||
return <AccessConfigFieldsProviderWangsu />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.WEBHOOK: {
|
||||
const webhookUsage = usage === "notification" ? "notification" : usage === "hosting" || usage === "dns-hosting" ? "deployment" : "none";
|
||||
return <AccessConfigFieldsProviderWebhook usage={webhookUsage} />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.WECOMBOT: {
|
||||
return <AccessConfigFieldsProviderWeComBot />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.WESTCN: {
|
||||
return <AccessConfigFieldsProviderWestcn />;
|
||||
}
|
||||
case ACCESS_PROVIDERS.ZEROSSL: {
|
||||
return <AccessConfigFieldsProviderZeroSSL />;
|
||||
}
|
||||
}
|
||||
}, [usage, disabled, initialValues?.config, fieldProvider, nestedFormInst, nestedFormName]);
|
||||
|
||||
const handleProviderPick = (value: string) => {
|
||||
setFieldProviderPicked(value);
|
||||
formInst.setFieldValue("provider", value);
|
||||
onValuesChange?.(formInst.getFieldsValue(true));
|
||||
};
|
||||
|
||||
const handleFormProviderChange = (name: string) => {
|
||||
if (name === nestedFormName) {
|
||||
formInst.setFieldValue("config", nestedFormInst.getFieldsValue());
|
||||
onValuesChange?.(formInst.getFieldsValue(true));
|
||||
}
|
||||
};
|
||||
|
||||
const handleFormChange = (_: unknown, values: AccessFormFieldValues) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
useImperativeHandle(ref, () => {
|
||||
return {
|
||||
getFieldsValue: () => {
|
||||
const values = formInst.getFieldsValue(true);
|
||||
values.config = nestedFormInst.getFieldsValue();
|
||||
values.reserve = usage === "ca" ? "ca" : usage === "notification" ? "notif" : void 0;
|
||||
return values;
|
||||
},
|
||||
resetFields: (fields) => {
|
||||
formInst.resetFields(fields);
|
||||
|
||||
if (!!fields && fields.includes("config")) {
|
||||
nestedFormInst.resetFields(fields);
|
||||
}
|
||||
},
|
||||
validateFields: (nameList, config) => {
|
||||
const t1 = formInst.validateFields(nameList, config);
|
||||
const t2 = nestedFormInst.validateFields(void 0, config);
|
||||
return Promise.all([t1, t2]).then(() => t1);
|
||||
},
|
||||
} as AccessFormInstance;
|
||||
});
|
||||
}, [disabled, usage, fieldProvider]);
|
||||
|
||||
return (
|
||||
<Form.Provider onFormChange={handleFormProviderChange}>
|
||||
<div className={className} style={style}>
|
||||
<Form {...formProps} disabled={disabled} layout="vertical" scrollToFirstError onValuesChange={handleFormChange}>
|
||||
<Show
|
||||
when={!!fieldProvider || !!fieldProviderPicked}
|
||||
fallback={
|
||||
<AccessProviderPicker
|
||||
autoFocus
|
||||
placeholder={t("access.form.provider.search.placeholder")}
|
||||
showOptionTags={usage == null || (usage === "dns-hosting" ? { [ACCESS_USAGES.DNS]: true, [ACCESS_USAGES.HOSTING]: true } : false)}
|
||||
onFilter={providerFilter}
|
||||
onSelect={handleProviderPick}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<Form.Item name="name" label={t("access.form.name.label")} rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.name.placeholder")} />
|
||||
</Form.Item>
|
||||
<Form
|
||||
className={className}
|
||||
style={style}
|
||||
{...formProps}
|
||||
clearOnDestroy={true}
|
||||
disabled={disabled}
|
||||
form={formInst}
|
||||
layout="vertical"
|
||||
preserve={false}
|
||||
scrollToFirstError
|
||||
>
|
||||
<Form.Item name="name" label={t("access.form.name.label")} rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.name.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="provider"
|
||||
label={t("access.form.provider.label")}
|
||||
extra={usage === "dns-hosting" ? <span dangerouslySetInnerHTML={{ __html: t("access.form.provider.help") }}></span> : null}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<AccessProviderSelect
|
||||
disabled={mode !== "create"}
|
||||
placeholder={t("access.form.provider.placeholder")}
|
||||
showOptionTags={usage == null || (usage === "dns-hosting" ? { [ACCESS_USAGES.DNS]: true, [ACCESS_USAGES.HOSTING]: true } : false)}
|
||||
showSearch={!disabled}
|
||||
onFilter={providerFilter}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Show>
|
||||
</Form>
|
||||
<Form.Item
|
||||
name="provider"
|
||||
label={t("access.form.provider.label")}
|
||||
extra={usage === "dns-hosting" ? <span dangerouslySetInnerHTML={{ __html: t("access.form.provider.help") }}></span> : null}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<AccessProviderSelect
|
||||
disabled={mode !== "create"}
|
||||
placeholder={t("access.form.provider.placeholder")}
|
||||
showOptionTags={usage == null || (usage === "dns-hosting" ? { [ACCESS_USAGES.DNS]: true, [ACCESS_USAGES.HOSTING]: true } : false)}
|
||||
showSearch={!disabled}
|
||||
onFilter={providerFilter}
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
{nestedFormEl}
|
||||
</div>
|
||||
</Form.Provider>
|
||||
<FormNestedFieldsContextProvider value={{ parentNamePath: "config" }}>{nestedProviderConfigFields}</FormNestedFieldsContextProvider>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
const _default = Object.assign(AccessForm, {
|
||||
useProviderFilterByUsage,
|
||||
});
|
||||
|
||||
export default AccessForm;
|
||||
export default _default;
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input, Select, Switch } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigFor1Panel } from "@/domain/access";
|
||||
|
||||
type AccessForm1PanelConfigFieldValues = Nullish<AccessConfigFor1Panel>;
|
||||
|
||||
export interface AccessForm1PanelConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessForm1PanelConfigFieldValues;
|
||||
onValuesChange?: (values: AccessForm1PanelConfigFieldValues) => void;
|
||||
}
|
||||
|
||||
const initFormModel = (): AccessForm1PanelConfigFieldValues => {
|
||||
return {
|
||||
serverUrl: "http://<your-host-addr>:20410/",
|
||||
apiVersion: "v1",
|
||||
apiKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessForm1PanelConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessForm1PanelConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
serverUrl: z.url(t("common.errmsg.url_invalid")),
|
||||
apiVersion: z.string().nonempty(t("access.form.1panel_api_version.placeholder")),
|
||||
apiKey: z
|
||||
.string()
|
||||
.min(1, t("access.form.1panel_api_key.placeholder"))
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
allowInsecureConnections: z.boolean().nullish(),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item name="serverUrl" label={t("access.form.1panel_server_url.label")} rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.1panel_server_url.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="apiVersion" label={t("access.form.1panel_api_version.label")} rules={[formRule]}>
|
||||
<Select options={["v1", "v2"].map((s) => ({ label: s, value: s }))} placeholder={t("access.form.1panel_api_version.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="apiKey"
|
||||
label={t("access.form.1panel_api_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.1panel_api_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.1panel_api_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="allowInsecureConnections" label={t("access.form.common_allow_insecure_conns.label")} rules={[formRule]}>
|
||||
<Switch
|
||||
checkedChildren={t("access.form.common_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.common_allow_insecure_conns.switch.off")}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessForm1PanelConfig;
|
||||
@@ -1,71 +0,0 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input, Switch } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForAPISIX } from "@/domain/access";
|
||||
|
||||
type AccessFormAPISIXConfigFieldValues = Nullish<AccessConfigForAPISIX>;
|
||||
|
||||
export interface AccessFormAPISIXConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormAPISIXConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormAPISIXConfigFieldValues) => void;
|
||||
}
|
||||
|
||||
const initFormModel = (): AccessFormAPISIXConfigFieldValues => {
|
||||
return {
|
||||
serverUrl: "http://<your-host-addr>:9180/",
|
||||
apiKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormAPISIXConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormAPISIXConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
serverUrl: z.url(t("common.errmsg.url_invalid")),
|
||||
apiKey: z.string().nonempty(t("access.form.apisix_api_key.placeholder")),
|
||||
allowInsecureConnections: z.boolean().nullish(),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item name="serverUrl" label={t("access.form.apisix_server_url.label")} rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.apisix_server_url.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="apiKey"
|
||||
label={t("access.form.apisix_api_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.apisix_api_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.apisix_api_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="allowInsecureConnections" label={t("access.form.common_allow_insecure_conns.label")} rules={[formRule]}>
|
||||
<Switch
|
||||
checkedChildren={t("access.form.common_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.common_allow_insecure_conns.switch.off")}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormAPISIXConfig;
|
||||
@@ -1,55 +0,0 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForBaishan } from "@/domain/access";
|
||||
|
||||
type AccessFormBaishanConfigFieldValues = Nullish<AccessConfigForBaishan>;
|
||||
|
||||
export interface AccessFormBaishanConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormBaishanConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormBaishanConfigFieldValues) => void;
|
||||
}
|
||||
|
||||
const initFormModel = (): AccessFormBaishanConfigFieldValues => {
|
||||
return {
|
||||
apiToken: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormBaishanConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormBaishanConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
apiToken: z
|
||||
.string()
|
||||
.min(1, t("access.form.baishan_api_token.placeholder"))
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item name="apiToken" label={t("access.form.baishan_api_token.label")} rules={[formRule]}>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.baishan_api_token.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormBaishanConfig;
|
||||
@@ -1,71 +0,0 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input, Switch } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForBaotaPanel } from "@/domain/access";
|
||||
|
||||
type AccessFormBaotaPanelConfigFieldValues = Nullish<AccessConfigForBaotaPanel>;
|
||||
|
||||
export interface AccessFormBaotaPanelConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormBaotaPanelConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormBaotaPanelConfigFieldValues) => void;
|
||||
}
|
||||
|
||||
const initFormModel = (): AccessFormBaotaPanelConfigFieldValues => {
|
||||
return {
|
||||
serverUrl: "http://<your-host-addr>:8888/",
|
||||
apiKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormBaotaPanelConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormBaotaPanelConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
serverUrl: z.url(t("common.errmsg.url_invalid")),
|
||||
apiKey: z.string().nonempty(t("access.form.baotapanel_api_key.placeholder")),
|
||||
allowInsecureConnections: z.boolean().nullish(),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item name="serverUrl" label={t("access.form.baotapanel_server_url.label")} rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.baotapanel_server_url.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="apiKey"
|
||||
label={t("access.form.baotapanel_api_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.baotapanel_api_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.baotapanel_api_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="allowInsecureConnections" label={t("access.form.common_allow_insecure_conns.label")} rules={[formRule]}>
|
||||
<Switch
|
||||
checkedChildren={t("access.form.common_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.common_allow_insecure_conns.switch.off")}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormBaotaPanelConfig;
|
||||
@@ -1,71 +0,0 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input, Switch } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForBaotaWAF } from "@/domain/access";
|
||||
|
||||
type AccessFormBaotaWAFConfigFieldValues = Nullish<AccessConfigForBaotaWAF>;
|
||||
|
||||
export interface AccessFormBaotaWAFConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormBaotaWAFConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormBaotaWAFConfigFieldValues) => void;
|
||||
}
|
||||
|
||||
const initFormModel = (): AccessFormBaotaWAFConfigFieldValues => {
|
||||
return {
|
||||
serverUrl: "http://<your-host-addr>:8379/",
|
||||
apiKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormBaotaWAFConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormBaotaWAFConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
serverUrl: z.url(t("common.errmsg.url_invalid")),
|
||||
apiKey: z.string().nonempty(t("access.form.baotawaf_api_key.placeholder")),
|
||||
allowInsecureConnections: z.boolean().nullish(),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item name="serverUrl" label={t("access.form.baotawaf_server_url.label")} rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.baotawaf_server_url.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="apiKey"
|
||||
label={t("access.form.baotawaf_api_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.baotawaf_api_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.baotawaf_api_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="allowInsecureConnections" label={t("access.form.common_allow_insecure_conns.label")} rules={[formRule]}>
|
||||
<Switch
|
||||
checkedChildren={t("access.form.common_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.common_allow_insecure_conns.switch.off")}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormBaotaWAFConfig;
|
||||
@@ -1,57 +0,0 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForBunny } from "@/domain/access";
|
||||
|
||||
type AccessFormBunnyConfigFieldValues = Nullish<AccessConfigForBunny>;
|
||||
|
||||
export interface AccessFormBunnyConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormBunnyConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormBunnyConfigFieldValues) => void;
|
||||
}
|
||||
|
||||
const initFormModel = (): AccessFormBunnyConfigFieldValues => {
|
||||
return {
|
||||
apiKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormBunnyConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormBunnyConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
apiKey: z.string().nonempty(t("access.form.bunny_api_key.placeholder")),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="apiKey"
|
||||
label={t("access.form.bunny_api_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.bunny_api_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.bunny_api_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormBunnyConfig;
|
||||
@@ -1,52 +0,0 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForCacheFly } from "@/domain/access";
|
||||
|
||||
type AccessFormCacheFlyConfigFieldValues = Nullish<AccessConfigForCacheFly>;
|
||||
|
||||
export interface AccessFormCacheFlyConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormCacheFlyConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormCacheFlyConfigFieldValues) => void;
|
||||
}
|
||||
|
||||
const initFormModel = (): AccessFormCacheFlyConfigFieldValues => {
|
||||
return {
|
||||
apiToken: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormCacheFlyConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormCacheFlyConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
apiToken: z.string().nonempty(t("access.form.cachefly_api_token.placeholder")),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item name="apiToken" label={t("access.form.cachefly_api_token.label")} rules={[formRule]}>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.cachefly_api_token.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormCacheFlyConfig;
|
||||
@@ -1,67 +0,0 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
import { type AccessConfigForConstellix } from "@/domain/access";
|
||||
|
||||
type AccessFormConstellixConfigFieldValues = Nullish<AccessConfigForConstellix>;
|
||||
|
||||
export interface AccessFormConstellixConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormConstellixConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormConstellixConfigFieldValues) => void;
|
||||
}
|
||||
|
||||
const initFormModel = (): AccessFormConstellixConfigFieldValues => {
|
||||
return {
|
||||
apiKey: "",
|
||||
secretKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormConstellixConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange: onValuesChange }: AccessFormConstellixConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
apiKey: z.string().nonempty(t("access.form.constellix_api_key.placeholder")),
|
||||
secretKey: z.string().nonempty(t("access.form.constellix_secret_key.placeholder")),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="apiKey"
|
||||
label={t("access.form.constellix_api_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.constellix_api_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.constellix_api_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="secretKey"
|
||||
label={t("access.form.constellix_secret_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.constellix_secret_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.constellix_secret_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormConstellixConfig;
|
||||
@@ -1,60 +0,0 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForDeSEC } from "@/domain/access";
|
||||
|
||||
type AccessFormDeSECConfigFieldValues = Nullish<AccessConfigForDeSEC>;
|
||||
|
||||
export interface AccessFormDeSECConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormDeSECConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormDeSECConfigFieldValues) => void;
|
||||
}
|
||||
|
||||
const initFormModel = (): AccessFormDeSECConfigFieldValues => {
|
||||
return {
|
||||
token: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormDeSECConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormDeSECConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
token: z
|
||||
.string()
|
||||
.min(1, t("access.form.desec_token.placeholder"))
|
||||
.max(256, t("common.errmsg.string_max", { max: 256 })),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="token"
|
||||
label={t("access.form.desec_token.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.desec_token.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.desec_token.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormDeSECConfig;
|
||||
@@ -1,57 +0,0 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForDigitalOcean } from "@/domain/access";
|
||||
|
||||
type AccessFormDigitalOceanConfigFieldValues = Nullish<AccessConfigForDigitalOcean>;
|
||||
|
||||
export interface AccessFormDigitalOceanConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormDigitalOceanConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormDigitalOceanConfigFieldValues) => void;
|
||||
}
|
||||
|
||||
const initFormModel = (): AccessFormDigitalOceanConfigFieldValues => {
|
||||
return {
|
||||
accessToken: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormDigitalOceanConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormDigitalOceanConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
accessToken: z.string().nonempty(t("access.form.digitalocean_access_token.placeholder")),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="accessToken"
|
||||
label={t("access.form.digitalocean_access_token.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.digitalocean_access_token.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.digitalocean_access_token.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormDigitalOceanConfig;
|
||||
@@ -1,68 +0,0 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForDingTalkBot } from "@/domain/access";
|
||||
|
||||
type AccessFormDingTalkBotConfigFieldValues = Nullish<AccessConfigForDingTalkBot>;
|
||||
|
||||
export interface AccessFormDingTalkBotConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormDingTalkBotConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormDingTalkBotConfigFieldValues) => void;
|
||||
}
|
||||
|
||||
const initFormModel = (): AccessFormDingTalkBotConfigFieldValues => {
|
||||
return {
|
||||
webhookUrl: "",
|
||||
secret: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormDingTalkBotConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormDingTalkBotConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
webhookUrl: z.url(t("common.errmsg.url_invalid")),
|
||||
secret: z.string().nonempty(t("access.form.dingtalkbot_secret.placeholder")),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="webhookUrl"
|
||||
label={t("access.form.dingtalkbot_webhook_url.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.dingtalkbot_webhook_url.tooltip") }}></span>}
|
||||
>
|
||||
<Input placeholder={t("access.form.dingtalkbot_webhook_url.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="secret"
|
||||
label={t("access.form.dingtalkbot_secret.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.dingtalkbot_secret.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.dingtalkbot_secret.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormDingTalkBotConfig;
|
||||
@@ -1,57 +0,0 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForDuckDNS } from "@/domain/access";
|
||||
|
||||
type AccessFormDuckDNSConfigFieldValues = Nullish<AccessConfigForDuckDNS>;
|
||||
|
||||
export interface AccessFormDuckDNSConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormDuckDNSConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormDuckDNSConfigFieldValues) => void;
|
||||
}
|
||||
|
||||
const initFormModel = (): AccessFormDuckDNSConfigFieldValues => {
|
||||
return {
|
||||
token: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormDuckDNSConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormDuckDNSConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
token: z.string().nonempty(t("access.form.duckdns_token.placeholder")),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="token"
|
||||
label={t("access.form.duckdns_token.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.duckdns_token.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.duckdns_token.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormDuckDNSConfig;
|
||||
@@ -1,60 +0,0 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForDynv6 } from "@/domain/access";
|
||||
|
||||
type AccessFormDynv6ConfigFieldValues = Nullish<AccessConfigForDynv6>;
|
||||
|
||||
export interface AccessFormDynv6ConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormDynv6ConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormDynv6ConfigFieldValues) => void;
|
||||
}
|
||||
|
||||
const initFormModel = (): AccessFormDynv6ConfigFieldValues => {
|
||||
return {
|
||||
httpToken: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormDynv6Config = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormDynv6ConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
httpToken: z
|
||||
.string()
|
||||
.min(1, t("access.form.dynv6_http_token.placeholder"))
|
||||
.max(256, t("common.errmsg.string_max", { max: 256 })),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="httpToken"
|
||||
label={t("access.form.dynv6_http_token.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.dynv6_http_token.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.dynv6_http_token.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormDynv6Config;
|
||||
@@ -1,60 +0,0 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForGcore } from "@/domain/access";
|
||||
|
||||
type AccessFormGcoreConfigFieldValues = Nullish<AccessConfigForGcore>;
|
||||
|
||||
export interface AccessFormGcoreConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormGcoreConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormGcoreConfigFieldValues) => void;
|
||||
}
|
||||
|
||||
const initFormModel = (): AccessFormGcoreConfigFieldValues => {
|
||||
return {
|
||||
apiToken: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormGcoreConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormGcoreConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
apiToken: z
|
||||
.string()
|
||||
.min(1, t("access.form.gcore_api_token.placeholder"))
|
||||
.max(256, t("common.errmsg.string_max", { max: 256 })),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="apiToken"
|
||||
label={t("access.form.gcore_api_token.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.gcore_api_token.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.gcore_api_token.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormGcoreConfig;
|
||||
@@ -1,57 +0,0 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForHetzner } from "@/domain/access";
|
||||
|
||||
type AccessFormHetznerConfigFieldValues = Nullish<AccessConfigForHetzner>;
|
||||
|
||||
export interface AccessFormHetznerConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormHetznerConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormHetznerConfigFieldValues) => void;
|
||||
}
|
||||
|
||||
const initFormModel = (): AccessFormHetznerConfigFieldValues => {
|
||||
return {
|
||||
apiToken: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormHetznerConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormHetznerConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
apiToken: z.string().nonempty(t("access.form.hetzner_api_token.placeholder")),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="apiToken"
|
||||
label={t("access.form.hetzner_api_token.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.hetzner_api_token.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.hetzner_api_token.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormHetznerConfig;
|
||||
@@ -1,71 +0,0 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input, Switch } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForKong } from "@/domain/access";
|
||||
|
||||
type AccessFormKongConfigFieldValues = Nullish<AccessConfigForKong>;
|
||||
|
||||
export interface AccessFormKongConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormKongConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormKongConfigFieldValues) => void;
|
||||
}
|
||||
|
||||
const initFormModel = (): AccessFormKongConfigFieldValues => {
|
||||
return {
|
||||
serverUrl: "http://<your-host-addr>:8001/",
|
||||
apiToken: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormKongConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormKongConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
serverUrl: z.url(t("common.errmsg.url_invalid")),
|
||||
apiToken: z.string().nullish(),
|
||||
allowInsecureConnections: z.boolean().nullish(),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item name="serverUrl" label={t("access.form.kong_server_url.label")} rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.kong_server_url.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="apiToken"
|
||||
label={t("access.form.kong_api_token.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.kong_api_token.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password allowClear autoComplete="new-password" placeholder={t("access.form.kong_api_token.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="allowInsecureConnections" label={t("access.form.common_allow_insecure_conns.label")} rules={[formRule]}>
|
||||
<Switch
|
||||
checkedChildren={t("access.form.common_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.common_allow_insecure_conns.switch.off")}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormKongConfig;
|
||||
@@ -1,59 +0,0 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import TextFileInput from "@/components/TextFileInput";
|
||||
import { type AccessConfigForKubernetes } from "@/domain/access";
|
||||
|
||||
type AccessFormKubernetesConfigFieldValues = Nullish<AccessConfigForKubernetes>;
|
||||
|
||||
export interface AccessFormKubernetesConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormKubernetesConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormKubernetesConfigFieldValues) => void;
|
||||
}
|
||||
|
||||
const initFormModel = (): AccessFormKubernetesConfigFieldValues => {
|
||||
return {};
|
||||
};
|
||||
|
||||
const AccessFormKubernetesConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormKubernetesConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
kubeConfig: z
|
||||
.string()
|
||||
.max(20480, t("common.errmsg.string_max", { max: 20480 }))
|
||||
.nullish(),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="kubeConfig"
|
||||
label={t("access.form.k8s_kubeconfig.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.k8s_kubeconfig.tooltip") }}></span>}
|
||||
>
|
||||
<TextFileInput allowClear autoSize={{ minRows: 3, maxRows: 10 }} placeholder={t("access.form.k8s_kubeconfig.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormKubernetesConfig;
|
||||
@@ -1,57 +0,0 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForLarkBot } from "@/domain/access";
|
||||
|
||||
type AccessFormLarkBotConfigFieldValues = Nullish<AccessConfigForLarkBot>;
|
||||
|
||||
export interface AccessFormLarkBotConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormLarkBotConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormLarkBotConfigFieldValues) => void;
|
||||
}
|
||||
|
||||
const initFormModel = (): AccessFormLarkBotConfigFieldValues => {
|
||||
return {
|
||||
webhookUrl: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormLarkBotConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormLarkBotConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
webhookUrl: z.url(t("common.errmsg.url_invalid")),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="webhookUrl"
|
||||
label={t("access.form.larkbot_webhook_url.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.larkbot_webhook_url.tooltip") }}></span>}
|
||||
>
|
||||
<Input placeholder={t("access.form.larkbot_webhook_url.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormLarkBotConfig;
|
||||
@@ -1,83 +0,0 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input, Radio, Select, Switch } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForLeCDN } from "@/domain/access";
|
||||
|
||||
type AccessFormLeCDNConfigFieldValues = Nullish<AccessConfigForLeCDN>;
|
||||
|
||||
export interface AccessFormLeCDNConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormLeCDNConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormLeCDNConfigFieldValues) => void;
|
||||
}
|
||||
|
||||
const initFormModel = (): AccessFormLeCDNConfigFieldValues => {
|
||||
return {
|
||||
serverUrl: "http://<your-host-addr>:5090/",
|
||||
apiVersion: "v3",
|
||||
apiRole: "user",
|
||||
username: "",
|
||||
password: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormLeCDNConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormLeCDNConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
serverUrl: z.url(t("common.errmsg.url_invalid")),
|
||||
role: z.literal(["client", "master"], t("access.form.lecdn_api_role.placeholder")),
|
||||
username: z.string().nonempty(t("access.form.lecdn_username.placeholder")),
|
||||
password: z.string().nonempty(t("access.form.lecdn_password.placeholder")),
|
||||
allowInsecureConnections: z.boolean().nullish(),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item name="serverUrl" label={t("access.form.lecdn_server_url.label")} rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.lecdn_server_url.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="apiVersion" label={t("access.form.lecdn_api_version.label")} rules={[formRule]}>
|
||||
<Select options={["v3"].map((s) => ({ label: s, value: s }))} placeholder={t("access.form.lecdn_api_version.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="apiRole" label={t("access.form.lecdn_api_role.label")} rules={[formRule]}>
|
||||
<Radio.Group options={["user", "master"].map((s) => ({ label: t(`access.form.lecdn_api_role.option.${s}.label`), value: s }))} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="username" label={t("access.form.lecdn_username.label")} rules={[formRule]}>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.lecdn_username.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="password" label={t("access.form.lecdn_password.label")} rules={[formRule]}>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.lecdn_password.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="allowInsecureConnections" label={t("access.form.common_allow_insecure_conns.label")} rules={[formRule]}>
|
||||
<Switch
|
||||
checkedChildren={t("access.form.common_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.common_allow_insecure_conns.switch.off")}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormLeCDNConfig;
|
||||
@@ -1,60 +0,0 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForNS1 } from "@/domain/access";
|
||||
|
||||
type AccessFormNS1ConfigFieldValues = Nullish<AccessConfigForNS1>;
|
||||
|
||||
export interface AccessFormNS1ConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormNS1ConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormNS1ConfigFieldValues) => void;
|
||||
}
|
||||
|
||||
const initFormModel = (): AccessFormNS1ConfigFieldValues => {
|
||||
return {
|
||||
apiKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormNS1Config = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormNS1ConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
apiKey: z
|
||||
.string()
|
||||
.min(1, t("access.form.ns1_api_key.placeholder"))
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="apiKey"
|
||||
label={t("access.form.ns1_api_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.ns1_api_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.ns1_api_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormNS1Config;
|
||||
@@ -1,60 +0,0 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForNameSilo } from "@/domain/access";
|
||||
|
||||
type AccessFormNameSiloConfigFieldValues = Nullish<AccessConfigForNameSilo>;
|
||||
|
||||
export interface AccessFormNameSiloConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormNameSiloConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormNameSiloConfigFieldValues) => void;
|
||||
}
|
||||
|
||||
const initFormModel = (): AccessFormNameSiloConfigFieldValues => {
|
||||
return {
|
||||
apiKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormNameSiloConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormNameSiloConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
apiKey: z
|
||||
.string()
|
||||
.min(1, t("access.form.namesilo_api_key.placeholder"))
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="apiKey"
|
||||
label={t("access.form.namesilo_api_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.namesilo_api_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.namesilo_api_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormNameSiloConfig;
|
||||
@@ -1,57 +0,0 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForNetlify } from "@/domain/access";
|
||||
|
||||
type AccessFormNetlifyConfigFieldValues = Nullish<AccessConfigForNetlify>;
|
||||
|
||||
export interface AccessFormNetlifyConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormNetlifyConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormNetlifyConfigFieldValues) => void;
|
||||
}
|
||||
|
||||
const initFormModel = (): AccessFormNetlifyConfigFieldValues => {
|
||||
return {
|
||||
apiToken: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormNetlifyConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormNetlifyConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
apiToken: z.string().nonempty(t("access.form.netlify_api_token.placeholder")),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="apiToken"
|
||||
label={t("access.form.netlify_api_token.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.netlify_api_token.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.netlify_api_token.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormNetlifyConfig;
|
||||
@@ -1,74 +0,0 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input, Switch } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForPowerDNS } from "@/domain/access";
|
||||
|
||||
type AccessFormPowerDNSConfigFieldValues = Nullish<AccessConfigForPowerDNS>;
|
||||
|
||||
export interface AccessFormPowerDNSConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormPowerDNSConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormPowerDNSConfigFieldValues) => void;
|
||||
}
|
||||
|
||||
const initFormModel = (): AccessFormPowerDNSConfigFieldValues => {
|
||||
return {
|
||||
serverUrl: "http://<your-host-addr>:8082/",
|
||||
apiKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormPowerDNSConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormPowerDNSConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
serverUrl: z.url(t("common.errmsg.url_invalid")),
|
||||
apiKey: z
|
||||
.string()
|
||||
.min(1, t("access.form.powerdns_api_key.placeholder"))
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
allowInsecureConnections: z.boolean().nullish(),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item name="serverUrl" label={t("access.form.powerdns_server_url.label")} rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.powerdns_server_url.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="apiKey"
|
||||
label={t("access.form.powerdns_api_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.powerdns_api_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.powerdns_api_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="allowInsecureConnections" label={t("access.form.common_allow_insecure_conns.label")} rules={[formRule]}>
|
||||
<Switch
|
||||
checkedChildren={t("access.form.common_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.common_allow_insecure_conns.switch.off")}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormPowerDNSConfig;
|
||||
@@ -1,60 +0,0 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForRainYun } from "@/domain/access";
|
||||
|
||||
type AccessFormRainYunConfigFieldValues = Nullish<AccessConfigForRainYun>;
|
||||
|
||||
export interface AccessFormRainYunConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormRainYunConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormRainYunConfigFieldValues) => void;
|
||||
}
|
||||
|
||||
const initFormModel = (): AccessFormRainYunConfigFieldValues => {
|
||||
return {
|
||||
apiKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormRainYunConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormRainYunConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
apiKey: z
|
||||
.string()
|
||||
.min(1, t("access.form.rainyun_api_key.placeholder"))
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="apiKey"
|
||||
label={t("access.form.rainyun_api_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.rainyun_api_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.rainyun_api_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormRainYunConfig;
|
||||
@@ -1,291 +0,0 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { IconCircleArrowDown, IconCircleArrowUp, IconCircleMinus, IconCirclePlus } from "@tabler/icons-react";
|
||||
import { Button, Collapse, Form, type FormInstance, Input, InputNumber, Radio } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import Show from "@/components/Show";
|
||||
import TextFileInput from "@/components/TextFileInput";
|
||||
import { type AccessConfigForSSH } from "@/domain/access";
|
||||
import { validDomainName, validIPv4Address, validIPv6Address, validPortNumber } from "@/utils/validators";
|
||||
|
||||
type AccessFormSSHConfigFieldValues = Nullish<AccessConfigForSSH>;
|
||||
|
||||
export interface AccessFormSSHConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormSSHConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormSSHConfigFieldValues) => void;
|
||||
}
|
||||
|
||||
const AUTH_METHOD_NONE = "none" as const;
|
||||
const AUTH_METHOD_PASSWORD = "password" as const;
|
||||
const AUTH_METHOD_KEY = "key" as const;
|
||||
|
||||
const initFormModel = (): AccessFormSSHConfigFieldValues => {
|
||||
return {
|
||||
host: "127.0.0.1",
|
||||
port: 22,
|
||||
authMethod: AUTH_METHOD_PASSWORD,
|
||||
username: "root",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormSSHConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormSSHConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
host: z.string().refine((v) => validDomainName(v) || validIPv4Address(v) || validIPv6Address(v), t("common.errmsg.host_invalid")),
|
||||
port: z.preprocess(
|
||||
(v) => Number(v),
|
||||
z
|
||||
.number()
|
||||
.int(t("access.form.ssh_port.placeholder"))
|
||||
.refine((v) => validPortNumber(v), t("common.errmsg.port_invalid"))
|
||||
),
|
||||
authMethod: z.literal([AUTH_METHOD_NONE, AUTH_METHOD_PASSWORD, AUTH_METHOD_KEY], t("access.form.ssh_auth_method.placeholder")),
|
||||
username: z
|
||||
.string()
|
||||
.min(1, t("access.form.ssh_username.placeholder"))
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
password: z
|
||||
.string()
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 }))
|
||||
.nullish()
|
||||
.refine((v) => {
|
||||
if (fieldAuthMethod !== AUTH_METHOD_PASSWORD) return true;
|
||||
return !!v?.trim();
|
||||
}, t("access.form.ssh_password.placeholder")),
|
||||
key: z
|
||||
.string()
|
||||
.max(20480, t("common.errmsg.string_max", { max: 20480 }))
|
||||
.nullish()
|
||||
.refine((v) => {
|
||||
if (fieldAuthMethod !== AUTH_METHOD_KEY) return true;
|
||||
return !!v?.trim();
|
||||
}, t("access.form.ssh_key.placeholder")),
|
||||
keyPassphrase: z
|
||||
.string()
|
||||
.max(20480, t("common.errmsg.string_max", { max: 20480 }))
|
||||
.nullish()
|
||||
.refine((v) => !v || formInst.getFieldValue("key"), t("access.form.ssh_key.placeholder")),
|
||||
jumpServers: z
|
||||
.array(
|
||||
z.object({
|
||||
host: z.string().refine((v) => validDomainName(v) || validIPv4Address(v) || validIPv6Address(v), t("common.errmsg.host_invalid")),
|
||||
port: z.preprocess(
|
||||
(v) => Number(v),
|
||||
z
|
||||
.number()
|
||||
.int(t("access.form.ssh_port.placeholder"))
|
||||
.refine((v) => validPortNumber(v), t("common.errmsg.port_invalid"))
|
||||
),
|
||||
authMethod: z.literal([AUTH_METHOD_NONE, AUTH_METHOD_PASSWORD, AUTH_METHOD_KEY], t("access.form.ssh_auth_method.placeholder")),
|
||||
username: z
|
||||
.string()
|
||||
.min(1, t("access.form.ssh_username.placeholder"))
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
password: z
|
||||
.string()
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 }))
|
||||
.nullish(),
|
||||
key: z
|
||||
.string()
|
||||
.max(20480, t("common.errmsg.string_max", { max: 20480 }))
|
||||
.nullish(),
|
||||
keyPassphrase: z
|
||||
.string()
|
||||
.max(20480, t("common.errmsg.string_max", { max: 20480 }))
|
||||
.nullish(),
|
||||
}),
|
||||
{ error: t("access.form.ssh_jump_servers.errmsg.invalid") }
|
||||
)
|
||||
.nullish(),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const fieldAuthMethod = Form.useWatch("authMethod", formInst);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<div className="flex space-x-2">
|
||||
<div className="w-2/3">
|
||||
<Form.Item name="host" label={t("access.form.ssh_host.label")} rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.ssh_host.placeholder")} />
|
||||
</Form.Item>
|
||||
</div>
|
||||
|
||||
<div className="w-1/3">
|
||||
<Form.Item name="port" label={t("access.form.ssh_port.label")} rules={[formRule]}>
|
||||
<InputNumber style={{ width: "100%" }} min={1} max={65535} placeholder={t("access.form.ssh_port.placeholder")} />
|
||||
</Form.Item>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Form.Item name="authMethod" label={t("access.form.ssh_auth_method.label")} rules={[formRule]}>
|
||||
<Radio.Group
|
||||
options={[AUTH_METHOD_NONE, AUTH_METHOD_PASSWORD, AUTH_METHOD_KEY].map((s) => ({
|
||||
key: s,
|
||||
label: t(`access.form.ssh_auth_method.option.${s}.label`),
|
||||
value: s,
|
||||
}))}
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="username" label={t("access.form.ssh_username.label")} rules={[formRule]}>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.ssh_username.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Show when={fieldAuthMethod === AUTH_METHOD_PASSWORD}>
|
||||
<Form.Item name="password" label={t("access.form.ssh_password.label")} rules={[formRule]}>
|
||||
<Input.Password allowClear autoComplete="new-password" placeholder={t("access.form.ssh_password.placeholder")} />
|
||||
</Form.Item>
|
||||
</Show>
|
||||
|
||||
<Show when={fieldAuthMethod === AUTH_METHOD_KEY}>
|
||||
<Form.Item name="key" label={t("access.form.ssh_key.label")} rules={[formRule]}>
|
||||
<TextFileInput allowClear autoSize={{ minRows: 1, maxRows: 5 }} placeholder={t("access.form.ssh_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="keyPassphrase" label={t("access.form.ssh_key_passphrase.label")} rules={[formRule]}>
|
||||
<Input.Password allowClear autoComplete="new-password" placeholder={t("access.form.ssh_key_passphrase.placeholder")} />
|
||||
</Form.Item>
|
||||
</Show>
|
||||
|
||||
<Form.Item name="jumpServers" label={t("access.form.ssh_jump_servers.label")} rules={[formRule]}>
|
||||
<Form.List name="jumpServers">
|
||||
{(fields, { add, remove, move }) => (
|
||||
<div className="flex flex-col gap-2">
|
||||
{fields?.length > 0 ? (
|
||||
<Collapse
|
||||
items={fields.map((field, index) => {
|
||||
const Label = () => {
|
||||
const host = Form.useWatch(["jumpServers", field.name, "host"], formInst);
|
||||
const port = Form.useWatch(["jumpServers", field.name, "port"], formInst);
|
||||
const addr = !!host && !!port ? `${host}:${port}` : host ? host : port ? `:${port}` : "unknown";
|
||||
return (
|
||||
<span className="select-none">
|
||||
[{t("access.form.ssh_jump_servers.item.label")} {field.name + 1}] {addr}
|
||||
</span>
|
||||
);
|
||||
};
|
||||
|
||||
const Fields = () => {
|
||||
const authMethod = Form.useWatch(["jumpServers", field.name, "authMethod"], formInst);
|
||||
return (
|
||||
<>
|
||||
<div className="flex space-x-2">
|
||||
<div className="w-2/3">
|
||||
<Form.Item name={[field.name, "host"]} label={t("access.form.ssh_host.label")} rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.ssh_host.placeholder")} />
|
||||
</Form.Item>
|
||||
</div>
|
||||
<div className="w-1/3">
|
||||
<Form.Item name={[field.name, "port"]} label={t("access.form.ssh_port.label")} rules={[formRule]}>
|
||||
<InputNumber style={{ width: "100%" }} placeholder={t("access.form.ssh_port.placeholder")} min={1} max={65535} />
|
||||
</Form.Item>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Form.Item name={[field.name, "authMethod"]} label={t("access.form.ssh_auth_method.label")} rules={[formRule]}>
|
||||
<Radio.Group
|
||||
options={[AUTH_METHOD_NONE, AUTH_METHOD_PASSWORD, AUTH_METHOD_KEY].map((s) => ({
|
||||
key: s,
|
||||
label: t(`access.form.ssh_auth_method.option.${s}.label`),
|
||||
value: s,
|
||||
}))}
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name={[field.name, "username"]} label={t("access.form.ssh_username.label")} rules={[formRule]}>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.ssh_username.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Show when={authMethod === AUTH_METHOD_PASSWORD}>
|
||||
<Form.Item name={[field.name, "password"]} label={t("access.form.ssh_password.label")} rules={[formRule]}>
|
||||
<Input.Password allowClear autoComplete="new-password" placeholder={t("access.form.ssh_password.placeholder")} />
|
||||
</Form.Item>
|
||||
</Show>
|
||||
|
||||
<Show when={authMethod === AUTH_METHOD_KEY}>
|
||||
<Form.Item name={[field.name, "key"]} label={t("access.form.ssh_key.label")} rules={[formRule]}>
|
||||
<TextFileInput allowClear autoSize={{ minRows: 1, maxRows: 5 }} placeholder={t("access.form.ssh_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name={[field.name, "keyPassphrase"]} label={t("access.form.ssh_key_passphrase.label")} rules={[formRule]}>
|
||||
<Input.Password allowClear autoComplete="new-password" placeholder={t("access.form.ssh_key_passphrase.placeholder")} />
|
||||
</Form.Item>
|
||||
</Show>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
return {
|
||||
key: field.key,
|
||||
label: <Label />,
|
||||
extra: (
|
||||
<div className="flex items-center justify-end">
|
||||
<Button
|
||||
icon={<IconCircleArrowUp size="1.25em" />}
|
||||
color="default"
|
||||
disabled={disabled || index === 0}
|
||||
size="small"
|
||||
type="text"
|
||||
onClick={(e) => {
|
||||
move(index, index - 1);
|
||||
e.stopPropagation();
|
||||
}}
|
||||
/>
|
||||
<Button
|
||||
icon={<IconCircleArrowDown size="1.25em" />}
|
||||
color="default"
|
||||
disabled={disabled || index === fields.length - 1}
|
||||
size="small"
|
||||
type="text"
|
||||
onClick={(e) => {
|
||||
move(index, index + 1);
|
||||
e.stopPropagation();
|
||||
}}
|
||||
/>
|
||||
<Button
|
||||
icon={<IconCircleMinus size="1.25em" />}
|
||||
color="default"
|
||||
disabled={disabled}
|
||||
size="small"
|
||||
type="text"
|
||||
onClick={(e) => {
|
||||
remove(field.name);
|
||||
e.stopPropagation();
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
),
|
||||
children: <Fields />,
|
||||
};
|
||||
})}
|
||||
/>
|
||||
) : null}
|
||||
<Button className="w-full" type="dashed" icon={<IconCirclePlus size="1.25em" />} onClick={() => add(initFormModel())}>
|
||||
{t("access.form.ssh_jump_servers.add")}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</Form.List>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormSSHConfig;
|
||||
@@ -1,74 +0,0 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input, Switch } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForSafeLine } from "@/domain/access";
|
||||
|
||||
type AccessFormSafeLineConfigFieldValues = Nullish<AccessConfigForSafeLine>;
|
||||
|
||||
export interface AccessFormSafeLineConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormSafeLineConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormSafeLineConfigFieldValues) => void;
|
||||
}
|
||||
|
||||
const initFormModel = (): AccessFormSafeLineConfigFieldValues => {
|
||||
return {
|
||||
serverUrl: "http://<your-host-addr>:9443/",
|
||||
apiToken: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormSafeLineConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormSafeLineConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
serverUrl: z.url(t("common.errmsg.url_invalid")),
|
||||
apiToken: z
|
||||
.string()
|
||||
.min(1, t("access.form.safeline_api_token.placeholder"))
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
allowInsecureConnections: z.boolean().nullish(),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item name="serverUrl" label={t("access.form.safeline_server_url.label")} rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.safeline_server_url.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="apiToken"
|
||||
label={t("access.form.safeline_api_token.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.safeline_api_token.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.safeline_api_token.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="allowInsecureConnections" label={t("access.form.common_allow_insecure_conns.label")} rules={[formRule]}>
|
||||
<Switch
|
||||
checkedChildren={t("access.form.common_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.common_allow_insecure_conns.switch.off")}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormSafeLineConfig;
|
||||
@@ -1,68 +0,0 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForSpaceship } from "@/domain/access";
|
||||
|
||||
type AccessFormSpaceshipConfigFieldValues = Nullish<AccessConfigForSpaceship>;
|
||||
|
||||
export interface AccessFormSpaceshipConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormSpaceshipConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormSpaceshipConfigFieldValues) => void;
|
||||
}
|
||||
|
||||
const initFormModel = (): AccessFormSpaceshipConfigFieldValues => {
|
||||
return {
|
||||
apiKey: "",
|
||||
apiSecret: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormSpaceshipConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormSpaceshipConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
apiKey: z.string().nonempty(t("access.form.spaceship_api_key.placeholder")),
|
||||
apiSecret: z.string().nonempty(t("access.form.spaceship_api_secret.placeholder")),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="apiKey"
|
||||
label={t("access.form.spaceship_api_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.spaceship_api_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.spaceship_api_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="apiSecret"
|
||||
label={t("access.form.spaceship_api_secret.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.spaceship_api_secret.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.spaceship_api_secret.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormSpaceshipConfig;
|
||||
@@ -1,68 +0,0 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForUniCloud } from "@/domain/access";
|
||||
|
||||
type AccessFormUniCloudConfigFieldValues = Nullish<AccessConfigForUniCloud>;
|
||||
|
||||
export interface AccessFormUniCloudConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormUniCloudConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormUniCloudConfigFieldValues) => void;
|
||||
}
|
||||
|
||||
const initFormModel = (): AccessFormUniCloudConfigFieldValues => {
|
||||
return {
|
||||
username: "",
|
||||
password: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormUniCloudConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormUniCloudConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
username: z.string().nonempty(t("access.form.unicloud_username.placeholder")),
|
||||
password: z.string().nonempty(t("access.form.unicloud_password.placeholder")),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="username"
|
||||
label={t("access.form.unicloud_username.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.unicloud_username.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.unicloud_username.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="password"
|
||||
label={t("access.form.unicloud_password.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.unicloud_password.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.unicloud_password.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormUniCloudConfig;
|
||||
@@ -1,57 +0,0 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForWeComBot } from "@/domain/access";
|
||||
|
||||
type AccessFormWeComBotConfigFieldValues = Nullish<AccessConfigForWeComBot>;
|
||||
|
||||
export interface AccessFormWeComBotConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormWeComBotConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormWeComBotConfigFieldValues) => void;
|
||||
}
|
||||
|
||||
const initFormModel = (): AccessFormWeComBotConfigFieldValues => {
|
||||
return {
|
||||
webhookUrl: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormWeComBotConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormWeComBotConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
webhookUrl: z.url(t("common.errmsg.url_invalid")),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="webhookUrl"
|
||||
label={t("access.form.wecombot_webhook_url.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.wecombot_webhook_url.tooltip") }}></span>}
|
||||
>
|
||||
<Input placeholder={t("access.form.wecombot_webhook_url.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormWeComBotConfig;
|
||||
@@ -0,0 +1,90 @@
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input, Select, Switch } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
const AccessConfigFormFieldsProvider1Panel = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "serverUrl"]}
|
||||
initialValue={initialValues.serverUrl}
|
||||
label={t("access.form.1panel_server_url.label")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<Input placeholder={t("access.form.1panel_server_url.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "apiVersion"]}
|
||||
initialValue={initialValues.apiVersion}
|
||||
label={t("access.form.1panel_api_version.label")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<Select options={["v1", "v2"].map((s) => ({ label: s, value: s }))} placeholder={t("access.form.1panel_api_version.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "apiKey"]}
|
||||
initialValue={initialValues.apiKey}
|
||||
label={t("access.form.1panel_api_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.1panel_api_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.1panel_api_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "allowInsecureConnections"]}
|
||||
initialValue={initialValues.allowInsecureConnections}
|
||||
label={t("access.form.common_allow_insecure_conns.label")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<Switch
|
||||
checkedChildren={t("access.form.common_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.common_allow_insecure_conns.switch.off")}
|
||||
/>
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
serverUrl: "http://<your-host-addr>:20410/",
|
||||
apiVersion: "v1",
|
||||
apiKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
return z.object({
|
||||
serverUrl: z.url(t("common.errmsg.url_invalid")),
|
||||
apiVersion: z.string().nonempty(t("access.form.1panel_api_version.placeholder")),
|
||||
apiKey: z
|
||||
.string()
|
||||
.min(1, t("access.form.1panel_api_key.placeholder"))
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
allowInsecureConnections: z.boolean().nullish(),
|
||||
});
|
||||
};
|
||||
|
||||
const _default = Object.assign(AccessConfigFormFieldsProvider1Panel, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+38
-41
@@ -1,51 +1,25 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForACMECA } from "@/domain/access";
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
type AccessFormACMECAConfigFieldValues = Nullish<AccessConfigForACMECA>;
|
||||
|
||||
export interface AccessFormACMECAConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormACMECAConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormACMECAConfigFieldValues) => void;
|
||||
}
|
||||
|
||||
const initFormModel = (): AccessFormACMECAConfigFieldValues => {
|
||||
return {
|
||||
endpoint: "https://example.com/acme/directory",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormACMECAConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormACMECAConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const AccessConfigFormFieldsProviderACMECA = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
endpoint: z.url(t("common.errmsg.url_invalid")),
|
||||
eabKid: z.string().nullish(),
|
||||
eabHmacKey: z.string().nullish(),
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<>
|
||||
<Form.Item
|
||||
name="endpoint"
|
||||
name={[parentNamePath, "endpoint"]}
|
||||
initialValue={initialValues.endpoint}
|
||||
label={t("access.form.acmeca_endpoint.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.acmeca_endpoint.tooltip") }}></span>}
|
||||
@@ -54,7 +28,8 @@ const AccessFormACMECAConfig = ({ form: formInst, formName, disabled, initialVal
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="eabKid"
|
||||
name={[parentNamePath, "eabKid"]}
|
||||
initialValue={initialValues.eabKid}
|
||||
label={t("access.form.acmeca_eab_kid.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.acmeca_eab_kid.tooltip") }}></span>}
|
||||
@@ -63,15 +38,37 @@ const AccessFormACMECAConfig = ({ form: formInst, formName, disabled, initialVal
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="eabHmacKey"
|
||||
name={[parentNamePath, "eabHmacKey"]}
|
||||
initialValue={initialValues.eabHmacKey}
|
||||
label={t("access.form.acmeca_eab_hmac_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.acmeca_eab_hmac_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password allowClear autoComplete="new-password" placeholder={t("access.form.acmeca_eab_hmac_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormACMECAConfig;
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
endpoint: "https://example.com/acme/directory",
|
||||
};
|
||||
};
|
||||
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
return z.object({
|
||||
endpoint: z.url(t("common.errmsg.url_invalid")),
|
||||
eabKid: z.string().nullish(),
|
||||
eabHmacKey: z.string().nullish(),
|
||||
});
|
||||
};
|
||||
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderACMECA, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+48
-50
@@ -1,59 +1,25 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input, Select } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input, Select } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForACMEHttpReq } from "@/domain/access";
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
type AccessFormACMEHttpReqConfigFieldValues = Nullish<AccessConfigForACMEHttpReq>;
|
||||
|
||||
export interface AccessFormACMEHttpReqConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormACMEHttpReqConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormACMEHttpReqConfigFieldValues) => void;
|
||||
}
|
||||
|
||||
const initFormModel = (): AccessFormACMEHttpReqConfigFieldValues => {
|
||||
return {
|
||||
endpoint: "https://example.com/api/",
|
||||
mode: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormACMEHttpReqConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormACMEHttpReqConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const AccessConfigFormFieldsProviderACMEHttpReq = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
endpoint: z.url(t("common.errmsg.url_invalid")),
|
||||
mode: z.string().nullish(),
|
||||
username: z
|
||||
.string()
|
||||
.max(256, t("common.errmsg.string_max", { max: 256 }))
|
||||
.nullish(),
|
||||
password: z
|
||||
.string()
|
||||
.max(256, t("common.errmsg.string_max", { max: 256 }))
|
||||
.nullish(),
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<>
|
||||
<Form.Item
|
||||
name="endpoint"
|
||||
name={[parentNamePath, "endpoint"]}
|
||||
initialValue={initialValues.endpoint}
|
||||
label={t("access.form.acmehttpreq_endpoint.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.acmehttpreq_endpoint.tooltip") }}></span>}
|
||||
@@ -62,7 +28,8 @@ const AccessFormACMEHttpReqConfig = ({ form: formInst, formName, disabled, initi
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="mode"
|
||||
name={[parentNamePath, "mode"]}
|
||||
initialValue={initialValues.mode}
|
||||
label={t("access.form.acmehttpreq_mode.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.acmehttpreq_mode.tooltip") }}></span>}
|
||||
@@ -77,7 +44,8 @@ const AccessFormACMEHttpReqConfig = ({ form: formInst, formName, disabled, initi
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="username"
|
||||
name={[parentNamePath, "username"]}
|
||||
initialValue={initialValues.username}
|
||||
label={t("access.form.acmehttpreq_username.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.acmehttpreq_username.tooltip") }}></span>}
|
||||
@@ -86,15 +54,45 @@ const AccessFormACMEHttpReqConfig = ({ form: formInst, formName, disabled, initi
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="password"
|
||||
name={[parentNamePath, "password"]}
|
||||
initialValue={initialValues.password}
|
||||
label={t("access.form.acmehttpreq_password.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.acmehttpreq_password.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password allowClear autoComplete="new-password" placeholder={t("access.form.acmehttpreq_password.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormACMEHttpReqConfig;
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
endpoint: "https://example.com/api/",
|
||||
mode: "",
|
||||
};
|
||||
};
|
||||
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
return z.object({
|
||||
endpoint: z.url(t("common.errmsg.url_invalid")),
|
||||
mode: z.string().nullish(),
|
||||
username: z
|
||||
.string()
|
||||
.max(256, t("common.errmsg.string_max", { max: 256 }))
|
||||
.nullish(),
|
||||
password: z
|
||||
.string()
|
||||
.max(256, t("common.errmsg.string_max", { max: 256 }))
|
||||
.nullish(),
|
||||
});
|
||||
};
|
||||
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderACMEHttpReq, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
@@ -0,0 +1,76 @@
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input, Switch } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
const AccessConfigFormFieldsProviderAPISIX = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "serverUrl"]}
|
||||
initialValue={initialValues.serverUrl}
|
||||
label={t("access.form.apisix_server_url.label")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<Input placeholder={t("access.form.apisix_server_url.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "apiKey"]}
|
||||
initialValue={initialValues.apiKey}
|
||||
label={t("access.form.apisix_api_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.apisix_api_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.apisix_api_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "allowInsecureConnections"]}
|
||||
initialValue={initialValues.allowInsecureConnections}
|
||||
label={t("access.form.common_allow_insecure_conns.label")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<Switch
|
||||
checkedChildren={t("access.form.common_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.common_allow_insecure_conns.switch.off")}
|
||||
/>
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
serverUrl: "http://<your-host-addr>:9180/",
|
||||
apiKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
return z.object({
|
||||
serverUrl: z.url(t("common.errmsg.url_invalid")),
|
||||
apiKey: z.string().nonempty(t("access.form.apisix_api_key.placeholder")),
|
||||
allowInsecureConnections: z.boolean().nullish(),
|
||||
});
|
||||
};
|
||||
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderAPISIX, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+46
-50
@@ -1,31 +1,56 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForAWS } from "@/domain/access";
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
type AccessFormAWSConfigFieldValues = Nullish<AccessConfigForAWS>;
|
||||
const AccessConfigFormFieldsProviderAWS = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
export interface AccessFormAWSConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormAWSConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormAWSConfigFieldValues) => void;
|
||||
}
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
const initFormModel = (): AccessFormAWSConfigFieldValues => {
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "accessKeyId"]}
|
||||
initialValue={initialValues.accessKeyId}
|
||||
label={t("access.form.aws_access_key_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.aws_access_key_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.aws_access_key_id.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "secretAccessKey"]}
|
||||
initialValue={initialValues.secretAccessKey}
|
||||
label={t("access.form.aws_secret_access_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.aws_secret_access_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.aws_secret_access_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
accessKeyId: "",
|
||||
secretAccessKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormAWSConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormAWSConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
const formSchema = z.object({
|
||||
return z.object({
|
||||
accessKeyId: z
|
||||
.string()
|
||||
.min(1, t("access.form.aws_access_key_id.placeholder"))
|
||||
@@ -35,40 +60,11 @@ const AccessFormAWSConfig = ({ form: formInst, formName, disabled, initialValues
|
||||
.min(1, t("access.form.aws_secret_access_key.placeholder"))
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="accessKeyId"
|
||||
label={t("access.form.aws_access_key_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.aws_access_key_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.aws_access_key_id.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="secretAccessKey"
|
||||
label={t("access.form.aws_secret_access_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.aws_secret_access_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.aws_secret_access_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormAWSConfig;
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderAWS, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+56
-59
@@ -1,31 +1,66 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForAliyun } from "@/domain/access";
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
type AccessFormAliyunConfigFieldValues = Nullish<AccessConfigForAliyun>;
|
||||
const AccessConfigFormFieldsProviderAliyun = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
export interface AccessFormAliyunConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormAliyunConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormAliyunConfigFieldValues) => void;
|
||||
}
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
const initFormModel = (): AccessFormAliyunConfigFieldValues => {
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "accessKeyId"]}
|
||||
initialValue={initialValues.accessKeyId}
|
||||
label={t("access.form.aliyun_access_key_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.aliyun_access_key_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.aliyun_access_key_id.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "accessKeySecret"]}
|
||||
initialValue={initialValues.accessKeySecret}
|
||||
label={t("access.form.aliyun_access_key_secret.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.aliyun_access_key_secret.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.aliyun_access_key_secret.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "resourceGroupId"]}
|
||||
initialValue={initialValues.resourceGroupId}
|
||||
label={t("access.form.aliyun_resource_group_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.aliyun_resource_group_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input allowClear autoComplete="new-password" placeholder={t("access.form.aliyun_resource_group_id.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
accessKeyId: "",
|
||||
accessKeySecret: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormAliyunConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange: onValuesChange }: AccessFormAliyunConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
const formSchema = z.object({
|
||||
return z.object({
|
||||
accessKeyId: z
|
||||
.string()
|
||||
.min(1, t("access.form.aliyun_access_key_id.placeholder"))
|
||||
@@ -36,49 +71,11 @@ const AccessFormAliyunConfig = ({ form: formInst, formName, disabled, initialVal
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
resourceGroupId: z.string().nullish(),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="accessKeyId"
|
||||
label={t("access.form.aliyun_access_key_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.aliyun_access_key_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.aliyun_access_key_id.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="accessKeySecret"
|
||||
label={t("access.form.aliyun_access_key_secret.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.aliyun_access_key_secret.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.aliyun_access_key_secret.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="resourceGroupId"
|
||||
label={t("access.form.aliyun_resource_group_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.aliyun_resource_group_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input allowClear autoComplete="new-password" placeholder={t("access.form.aliyun_resource_group_id.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormAliyunConfig;
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderAliyun, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+70
-72
@@ -1,21 +1,70 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { AutoComplete, Form, type FormInstance, Input } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { AutoComplete, Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForAzure } from "@/domain/access";
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
type AccessFormAzureConfigFieldValues = Nullish<AccessConfigForAzure>;
|
||||
const AccessConfigFormFieldsProviderAzure = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
export interface AccessFormAzureConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormAzureConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormAzureConfigFieldValues) => void;
|
||||
}
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
const initFormModel = (): AccessFormAzureConfigFieldValues => {
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "tenantId"]}
|
||||
initialValue={initialValues.tenantId}
|
||||
label={t("access.form.azure_tenant_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.azure_tenant_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.azure_tenant_id.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "clientId"]}
|
||||
initialValue={initialValues.clientId}
|
||||
label={t("access.form.azure_client_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.azure_client_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.azure_client_id.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "clientSecret"]}
|
||||
initialValue={initialValues.clientSecret}
|
||||
label={t("access.form.azure_client_secret.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.azure_client_secret.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.azure_client_secret.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "cloudName"]}
|
||||
initialValue={initialValues.cloudName}
|
||||
label={t("access.form.azure_cloud_name.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.azure_cloud_name.tooltip") }}></span>}
|
||||
>
|
||||
<AutoComplete
|
||||
options={["public", "azureusgovernment", "azurechina"].map((value) => ({ value }))}
|
||||
placeholder={t("access.form.azure_cloud_name.placeholder")}
|
||||
filterOption={(inputValue, option) => option!.value.toLowerCase().includes(inputValue.toLowerCase())}
|
||||
/>
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
tenantId: "",
|
||||
clientId: "",
|
||||
@@ -23,10 +72,10 @@ const initFormModel = (): AccessFormAzureConfigFieldValues => {
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormAzureConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormAzureConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
const formSchema = z.object({
|
||||
return z.object({
|
||||
tenantId: z
|
||||
.string()
|
||||
.min(1, t("access.form.azure_tenant_id.placeholder"))
|
||||
@@ -41,62 +90,11 @@ const AccessFormAzureConfig = ({ form: formInst, formName, disabled, initialValu
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
cloudName: z.string().nullish(),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="tenantId"
|
||||
label={t("access.form.azure_tenant_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.azure_tenant_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.azure_tenant_id.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="clientId"
|
||||
label={t("access.form.azure_client_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.azure_client_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.azure_client_id.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="clientSecret"
|
||||
label={t("access.form.azure_client_secret.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.azure_client_secret.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.azure_client_secret.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="cloudName"
|
||||
label={t("access.form.azure_cloud_name.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.azure_cloud_name.tooltip") }}></span>}
|
||||
>
|
||||
<AutoComplete
|
||||
options={["public", "azureusgovernment", "azurechina"].map((value) => ({ value }))}
|
||||
placeholder={t("access.form.azure_cloud_name.placeholder")}
|
||||
filterOption={(inputValue, option) => option!.value.toLowerCase().includes(inputValue.toLowerCase())}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormAzureConfig;
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderAzure, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+46
-50
@@ -1,31 +1,56 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForBaiduCloud } from "@/domain/access";
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
type AccessFormBaiduCloudConfigFieldValues = Nullish<AccessConfigForBaiduCloud>;
|
||||
const AccessConfigFormFieldsProviderBaiduCloud = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
export interface AccessFormBaiduCloudConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormBaiduCloudConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormBaiduCloudConfigFieldValues) => void;
|
||||
}
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
const initFormModel = (): AccessFormBaiduCloudConfigFieldValues => {
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "accessKeyId"]}
|
||||
initialValue={initialValues.accessKeyId}
|
||||
label={t("access.form.baiducloud_access_key_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.baiducloud_access_key_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.baiducloud_access_key_id.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "secretAccessKey"]}
|
||||
initialValue={initialValues.secretAccessKey}
|
||||
label={t("access.form.baiducloud_secret_access_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.baiducloud_secret_access_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.baiducloud_secret_access_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
accessKeyId: "",
|
||||
secretAccessKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormBaiduCloudConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormBaiduCloudConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
const formSchema = z.object({
|
||||
return z.object({
|
||||
accessKeyId: z
|
||||
.string()
|
||||
.min(1, t("access.form.baiducloud_access_key_id.placeholder"))
|
||||
@@ -35,40 +60,11 @@ const AccessFormBaiduCloudConfig = ({ form: formInst, formName, disabled, initia
|
||||
.min(1, t("access.form.baiducloud_secret_access_key.placeholder"))
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="accessKeyId"
|
||||
label={t("access.form.baiducloud_access_key_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.baiducloud_access_key_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.baiducloud_access_key_id.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="secretAccessKey"
|
||||
label={t("access.form.baiducloud_secret_access_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.baiducloud_secret_access_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.baiducloud_secret_access_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormBaiduCloudConfig;
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderBaiduCloud, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
@@ -0,0 +1,49 @@
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
const AccessConfigFormFieldsProviderBaishan = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form.Item name={[parentNamePath, "apiToken"]} initialValue={initialValues.apiToken} label={t("access.form.baishan_api_token.label")} rules={[formRule]}>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.baishan_api_token.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
apiToken: "",
|
||||
};
|
||||
};
|
||||
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
return z.object({
|
||||
apiToken: z
|
||||
.string()
|
||||
.min(1, t("access.form.baishan_api_token.placeholder"))
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
});
|
||||
};
|
||||
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderBaishan, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
@@ -0,0 +1,76 @@
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input, Switch } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
const AccessConfigFormFieldsProviderBaotaPanel = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "serverUrl"]}
|
||||
initialValue={initialValues.serverUrl}
|
||||
label={t("access.form.baotapanel_server_url.label")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<Input placeholder={t("access.form.baotapanel_server_url.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "apiKey"]}
|
||||
initialValue={initialValues.apiKey}
|
||||
label={t("access.form.baotapanel_api_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.baotapanel_api_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.baotapanel_api_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "allowInsecureConnections"]}
|
||||
initialValue={initialValues.allowInsecureConnections}
|
||||
label={t("access.form.common_allow_insecure_conns.label")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<Switch
|
||||
checkedChildren={t("access.form.common_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.common_allow_insecure_conns.switch.off")}
|
||||
/>
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
serverUrl: "http://<your-host-addr>:8888/",
|
||||
apiKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
return z.object({
|
||||
serverUrl: z.url(t("common.errmsg.url_invalid")),
|
||||
apiKey: z.string().nonempty(t("access.form.baotapanel_api_key.placeholder")),
|
||||
allowInsecureConnections: z.boolean().nullish(),
|
||||
});
|
||||
};
|
||||
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderBaotaPanel, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
@@ -0,0 +1,76 @@
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input, Switch } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
const AccessConfigFormFieldsProviderBaotaWAF = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "serverUrl"]}
|
||||
initialValue={initialValues.serverUrl}
|
||||
label={t("access.form.baotawaf_server_url.label")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<Input placeholder={t("access.form.baotawaf_server_url.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "apiKey"]}
|
||||
initialValue={initialValues.apiKey}
|
||||
label={t("access.form.baotawaf_api_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.baotawaf_api_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.baotawaf_api_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "allowInsecureConnections"]}
|
||||
initialValue={initialValues.allowInsecureConnections}
|
||||
label={t("access.form.common_allow_insecure_conns.label")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<Switch
|
||||
checkedChildren={t("access.form.common_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.common_allow_insecure_conns.switch.off")}
|
||||
/>
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
serverUrl: "http://<your-host-addr>:8379/",
|
||||
apiKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
return z.object({
|
||||
serverUrl: z.url(t("common.errmsg.url_invalid")),
|
||||
apiKey: z.string().nonempty(t("access.form.baotawaf_api_key.placeholder")),
|
||||
allowInsecureConnections: z.boolean().nullish(),
|
||||
});
|
||||
};
|
||||
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderBaotaWAF, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
@@ -0,0 +1,52 @@
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
const AccessConfigFormFieldsProviderBunny = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "apiKey"]}
|
||||
initialValue={initialValues.apiKey}
|
||||
label={t("access.form.bunny_api_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.bunny_api_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.bunny_api_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
apiKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
return z.object({
|
||||
apiKey: z.string().nonempty(t("access.form.bunny_api_key.placeholder")),
|
||||
});
|
||||
};
|
||||
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderBunny, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+46
-50
@@ -1,31 +1,56 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForBytePlus } from "@/domain/access";
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
type AccessFormBytePlusConfigFieldValues = Nullish<AccessConfigForBytePlus>;
|
||||
const AccessConfigFormFieldsProviderBytePlus = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
export interface AccessFormBytePlusConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormBytePlusConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormBytePlusConfigFieldValues) => void;
|
||||
}
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
const initFormModel = (): AccessFormBytePlusConfigFieldValues => {
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "accessKey"]}
|
||||
initialValue={initialValues.accessKey}
|
||||
label={t("access.form.byteplus_access_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.byteplus_access_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.byteplus_access_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "secretKey"]}
|
||||
initialValue={initialValues.secretKey}
|
||||
label={t("access.form.byteplus_secret_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.byteplus_secret_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.byteplus_secret_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
accessKey: "",
|
||||
secretKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormBytePlusConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormBytePlusConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
const formSchema = z.object({
|
||||
return z.object({
|
||||
accessKey: z
|
||||
.string()
|
||||
.min(1, t("access.form.byteplus_access_key.placeholder"))
|
||||
@@ -35,40 +60,11 @@ const AccessFormBytePlusConfig = ({ form: formInst, formName, disabled, initialV
|
||||
.min(1, t("access.form.byteplus_secret_key.placeholder"))
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="accessKey"
|
||||
label={t("access.form.byteplus_access_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.byteplus_access_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.byteplus_access_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="secretKey"
|
||||
label={t("access.form.byteplus_secret_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.byteplus_secret_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.byteplus_secret_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormBytePlusConfig;
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderBytePlus, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+47
-50
@@ -1,30 +1,56 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
import { type AccessConfigForCMCCCloud } from "@/domain/access";
|
||||
|
||||
type AccessFormCMCCCloudConfigFieldValues = Nullish<AccessConfigForCMCCCloud>;
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
export interface AccessFormCMCCCloudConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormCMCCCloudConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormCMCCCloudConfigFieldValues) => void;
|
||||
}
|
||||
const AccessConfigFormFieldsProviderCMCCCloud = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const initFormModel = (): AccessFormCMCCCloudConfigFieldValues => {
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "accessKeyId"]}
|
||||
initialValue={initialValues.accessKeyId}
|
||||
label={t("access.form.cmcccloud_access_key_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.cmcccloud_access_key_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.cmcccloud_access_key_id.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "accessKeySecret"]}
|
||||
initialValue={initialValues.accessKeySecret}
|
||||
label={t("access.form.cmcccloud_access_key_secret.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.cmcccloud_access_key_secret.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.cmcccloud_access_key_secret.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
accessKeyId: "",
|
||||
accessKeySecret: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormCMCCCloudConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange: onValuesChange }: AccessFormCMCCCloudConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
const formSchema = z.object({
|
||||
return z.object({
|
||||
accessKeyId: z
|
||||
.string()
|
||||
.min(1, t("access.form.cmcccloud_access_key_id.placeholder"))
|
||||
@@ -34,40 +60,11 @@ const AccessFormCMCCCloudConfig = ({ form: formInst, formName, disabled, initial
|
||||
.min(1, t("access.form.cmcccloud_access_key_secret.placeholder"))
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="accessKeyId"
|
||||
label={t("access.form.cmcccloud_access_key_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.cmcccloud_access_key_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.cmcccloud_access_key_id.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="accessKeySecret"
|
||||
label={t("access.form.cmcccloud_access_key_secret.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.cmcccloud_access_key_secret.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.cmcccloud_access_key_secret.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormCMCCCloudConfig;
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderCMCCCloud, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+47
-50
@@ -1,30 +1,56 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
import { type AccessConfigForCTCCCloud } from "@/domain/access";
|
||||
|
||||
type AccessFormCTCCCloudConfigFieldValues = Nullish<AccessConfigForCTCCCloud>;
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
export interface AccessFormCTCCCloudConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormCTCCCloudConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormCTCCCloudConfigFieldValues) => void;
|
||||
}
|
||||
const AccessConfigFormFieldsProviderCTCCCloud = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const initFormModel = (): AccessFormCTCCCloudConfigFieldValues => {
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "accessKeyId"]}
|
||||
initialValue={initialValues.accessKeyId}
|
||||
label={t("access.form.ctcccloud_access_key_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.ctcccloud_access_key_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.ctcccloud_access_key_id.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "secretAccessKey"]}
|
||||
initialValue={initialValues.secretAccessKey}
|
||||
label={t("access.form.ctcccloud_secret_access_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.ctcccloud_secret_access_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.ctcccloud_secret_access_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
accessKeyId: "",
|
||||
secretAccessKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormCTCCCloudConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange: onValuesChange }: AccessFormCTCCCloudConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
const formSchema = z.object({
|
||||
return z.object({
|
||||
accessKeyId: z
|
||||
.string()
|
||||
.min(1, t("access.form.ctcccloud_access_key_id.placeholder"))
|
||||
@@ -34,40 +60,11 @@ const AccessFormCTCCCloudConfig = ({ form: formInst, formName, disabled, initial
|
||||
.min(1, t("access.form.ctcccloud_secret_access_key.placeholder"))
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="accessKeyId"
|
||||
label={t("access.form.ctcccloud_access_key_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.ctcccloud_access_key_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.ctcccloud_access_key_id.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="secretAccessKey"
|
||||
label={t("access.form.ctcccloud_secret_access_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.ctcccloud_secret_access_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.ctcccloud_secret_access_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormCTCCCloudConfig;
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderCTCCCloud, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
@@ -0,0 +1,46 @@
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
const AccessConfigFormFieldsProviderCacheFly = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form.Item name={[parentNamePath, "apiToken"]} initialValue={initialValues.apiToken} label={t("access.form.cachefly_api_token.label")} rules={[formRule]}>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.cachefly_api_token.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
apiToken: "",
|
||||
};
|
||||
};
|
||||
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
return z.object({
|
||||
apiToken: z.string().nonempty(t("access.form.cachefly_api_token.placeholder")),
|
||||
});
|
||||
};
|
||||
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderCacheFly, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+67
-61
@@ -1,21 +1,67 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input, Switch } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input, Switch } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForCdnfly } from "@/domain/access";
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
type AccessFormCdnflyConfigFieldValues = Nullish<AccessConfigForCdnfly>;
|
||||
const AccessConfigFormFieldsProviderCdnfly = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
export interface AccessFormCdnflyConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormCdnflyConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormCdnflyConfigFieldValues) => void;
|
||||
}
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
const initFormModel = (): AccessFormCdnflyConfigFieldValues => {
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "serverUrl"]}
|
||||
initialValue={initialValues.serverUrl}
|
||||
label={t("access.form.cdnfly_server_url.label")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<Input placeholder={t("access.form.cdnfly_server_url.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "apiKey"]}
|
||||
initialValue={initialValues.apiKey}
|
||||
label={t("access.form.cdnfly_api_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.cdnfly_api_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.cdnfly_api_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "apiSecret"]}
|
||||
initialValue={initialValues.apiSecret}
|
||||
label={t("access.form.cdnfly_api_secret.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.cdnfly_api_secret.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.cdnfly_api_secret.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "allowInsecureConnections"]}
|
||||
initialValue={initialValues.allowInsecureConnections}
|
||||
label={t("access.form.common_allow_insecure_conns.label")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<Switch
|
||||
checkedChildren={t("access.form.common_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.common_allow_insecure_conns.switch.off")}
|
||||
/>
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
serverUrl: "http://<your-host-addr>:88/",
|
||||
apiKey: "",
|
||||
@@ -23,10 +69,10 @@ const initFormModel = (): AccessFormCdnflyConfigFieldValues => {
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormCdnflyConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormCdnflyConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
const formSchema = z.object({
|
||||
return z.object({
|
||||
serverUrl: z.url(t("common.errmsg.url_invalid")),
|
||||
apiKey: z
|
||||
.string()
|
||||
@@ -38,51 +84,11 @@ const AccessFormCdnflyConfig = ({ form: formInst, formName, disabled, initialVal
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
allowInsecureConnections: z.boolean().nullish(),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item name="serverUrl" label={t("access.form.cdnfly_server_url.label")} rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.cdnfly_server_url.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="apiKey"
|
||||
label={t("access.form.cdnfly_api_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.cdnfly_api_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.cdnfly_api_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="apiSecret"
|
||||
label={t("access.form.cdnfly_api_secret.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.cdnfly_api_secret.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.cdnfly_api_secret.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="allowInsecureConnections" label={t("access.form.common_allow_insecure_conns.label")} rules={[formRule]}>
|
||||
<Switch
|
||||
checkedChildren={t("access.form.common_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.common_allow_insecure_conns.switch.off")}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormCdnflyConfig;
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderCdnfly, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+46
-50
@@ -1,31 +1,56 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForClouDNS } from "@/domain/access";
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
type AccessFormClouDNSConfigFieldValues = Nullish<AccessConfigForClouDNS>;
|
||||
const AccessConfigFormFieldsProviderClouDNS = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
export interface AccessFormClouDNSConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormClouDNSConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormClouDNSConfigFieldValues) => void;
|
||||
}
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
const initFormModel = (): AccessFormClouDNSConfigFieldValues => {
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "authId"]}
|
||||
initialValue={initialValues.authId}
|
||||
label={t("access.form.cloudns_auth_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.cloudns_auth_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.cloudns_auth_id.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "authPassword"]}
|
||||
initialValue={initialValues.authPassword}
|
||||
label={t("access.form.cloudns_auth_password.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.cloudns_auth_password.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.cloudns_auth_password.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
authId: "",
|
||||
authPassword: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormClouDNSConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormClouDNSConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
const formSchema = z.object({
|
||||
return z.object({
|
||||
authId: z
|
||||
.string()
|
||||
.min(1, t("access.form.cloudns_auth_id.placeholder"))
|
||||
@@ -35,40 +60,11 @@ const AccessFormClouDNSConfig = ({ form: formInst, formName, disabled, initialVa
|
||||
.min(1, t("access.form.cloudns_auth_password.placeholder"))
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="authId"
|
||||
label={t("access.form.cloudns_auth_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.cloudns_auth_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.cloudns_auth_id.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="authPassword"
|
||||
label={t("access.form.cloudns_auth_password.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.cloudns_auth_password.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.cloudns_auth_password.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormClouDNSConfig;
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderClouDNS, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+46
-50
@@ -1,30 +1,55 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForCloudflare } from "@/domain/access";
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
type AccessFormCloudflareConfigFieldValues = Nullish<AccessConfigForCloudflare>;
|
||||
const AccessConfigFormFieldsProviderCloudflare = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
export interface AccessFormCloudflareConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormCloudflareConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormCloudflareConfigFieldValues) => void;
|
||||
}
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
const initFormModel = (): AccessFormCloudflareConfigFieldValues => {
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "dnsApiToken"]}
|
||||
initialValue={initialValues.dnsApiToken}
|
||||
label={t("access.form.cloudflare_dns_api_token.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.cloudflare_dns_api_token.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.cloudflare_dns_api_token.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "zoneApiToken"]}
|
||||
initialValue={initialValues.zoneApiToken}
|
||||
label={t("access.form.cloudflare_zone_api_token.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.cloudflare_zone_api_token.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password allowClear autoComplete="new-password" placeholder={t("access.form.cloudflare_zone_api_token.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
dnsApiToken: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormCloudflareConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormCloudflareConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
const formSchema = z.object({
|
||||
return z.object({
|
||||
dnsApiToken: z
|
||||
.string()
|
||||
.min(1, t("access.form.cloudflare_dns_api_token.placeholder"))
|
||||
@@ -34,40 +59,11 @@ const AccessFormCloudflareConfig = ({ form: formInst, formName, disabled, initia
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 }))
|
||||
.nullish(),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="dnsApiToken"
|
||||
label={t("access.form.cloudflare_dns_api_token.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.cloudflare_dns_api_token.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.cloudflare_dns_api_token.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="zoneApiToken"
|
||||
label={t("access.form.cloudflare_zone_api_token.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.cloudflare_zone_api_token.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password allowClear autoComplete="new-password" placeholder={t("access.form.cloudflare_zone_api_token.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormCloudflareConfig;
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderCloudflare, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
@@ -0,0 +1,64 @@
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
const AccessConfigFormFieldsProviderConstellix = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "apiKey"]}
|
||||
initialValue={initialValues.apiKey}
|
||||
label={t("access.form.constellix_api_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.constellix_api_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.constellix_api_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "secretKey"]}
|
||||
initialValue={initialValues.secretKey}
|
||||
label={t("access.form.constellix_secret_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.constellix_secret_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.constellix_secret_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
apiKey: "",
|
||||
secretKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
return z.object({
|
||||
apiKey: z.string().nonempty(t("access.form.constellix_api_key.placeholder")),
|
||||
secretKey: z.string().nonempty(t("access.form.constellix_secret_key.placeholder")),
|
||||
});
|
||||
};
|
||||
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderConstellix, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+46
-50
@@ -1,31 +1,56 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForDNSLA } from "@/domain/access";
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
type AccessFormDNSLAConfigFieldValues = Nullish<AccessConfigForDNSLA>;
|
||||
const AccessConfigFormFieldsProviderDNSLA = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
export interface AccessFormDNSLAConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormDNSLAConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormDNSLAConfigFieldValues) => void;
|
||||
}
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
const initFormModel = (): AccessFormDNSLAConfigFieldValues => {
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "apiId"]}
|
||||
initialValue={initialValues.apiId}
|
||||
label={t("access.form.dnsla_api_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.dnsla_api_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.dnsla_api_id.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "apiSecret"]}
|
||||
initialValue={initialValues.apiSecret}
|
||||
label={t("access.form.dnsla_api_secret.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.dnsla_api_secret.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.dnsla_api_secret.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
apiId: "",
|
||||
apiSecret: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormDNSLAConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange: onValuesChange }: AccessFormDNSLAConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
const formSchema = z.object({
|
||||
return z.object({
|
||||
apiId: z
|
||||
.string()
|
||||
.min(1, t("access.form.dnsla_api_id.placeholder"))
|
||||
@@ -35,40 +60,11 @@ const AccessFormDNSLAConfig = ({ form: formInst, formName, disabled, initialValu
|
||||
.min(1, t("access.form.dnsla_api_secret.placeholder"))
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="apiId"
|
||||
label={t("access.form.dnsla_api_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.dnsla_api_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.dnsla_api_id.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="apiSecret"
|
||||
label={t("access.form.dnsla_api_secret.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.dnsla_api_secret.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.dnsla_api_secret.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormDNSLAConfig;
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderDNSLA, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
@@ -0,0 +1,55 @@
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
const AccessConfigFormFieldsProviderDeSEC = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "token"]}
|
||||
initialValue={initialValues.token}
|
||||
label={t("access.form.desec_token.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.desec_token.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.desec_token.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
token: "",
|
||||
};
|
||||
};
|
||||
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
return z.object({
|
||||
token: z
|
||||
.string()
|
||||
.min(1, t("access.form.desec_token.placeholder"))
|
||||
.max(256, t("common.errmsg.string_max", { max: 256 })),
|
||||
});
|
||||
};
|
||||
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderDeSEC, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
@@ -0,0 +1,52 @@
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
const AccessConfigFormFieldsProviderDigitalOcean = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "accessToken"]}
|
||||
initialValue={initialValues.accessToken}
|
||||
label={t("access.form.digitalocean_access_token.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.digitalocean_access_token.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.digitalocean_access_token.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
accessToken: "",
|
||||
};
|
||||
};
|
||||
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
return z.object({
|
||||
accessToken: z.string().nonempty(t("access.form.digitalocean_access_token.placeholder")),
|
||||
});
|
||||
};
|
||||
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderDigitalOcean, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
@@ -0,0 +1,64 @@
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
const AccessConfigFormFieldsProviderDingTalkBot = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "webhookUrl"]}
|
||||
initialValue={initialValues.webhookUrl}
|
||||
label={t("access.form.dingtalkbot_webhook_url.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.dingtalkbot_webhook_url.tooltip") }}></span>}
|
||||
>
|
||||
<Input placeholder={t("access.form.dingtalkbot_webhook_url.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "secret"]}
|
||||
initialValue={initialValues.secret}
|
||||
label={t("access.form.dingtalkbot_secret.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.dingtalkbot_secret.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.dingtalkbot_secret.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
webhookUrl: "",
|
||||
secret: "",
|
||||
};
|
||||
};
|
||||
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
return z.object({
|
||||
webhookUrl: z.url(t("common.errmsg.url_invalid")),
|
||||
secret: z.string().nonempty(t("access.form.dingtalkbot_secret.placeholder")),
|
||||
});
|
||||
};
|
||||
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderDingTalkBot, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+38
-42
@@ -1,53 +1,25 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForDiscordBot } from "@/domain/access";
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
type AccessFormDiscordBotConfigFieldValues = Nullish<AccessConfigForDiscordBot>;
|
||||
|
||||
export interface AccessFormDiscordBotConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormDiscordBotConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormDiscordBotConfigFieldValues) => void;
|
||||
}
|
||||
|
||||
const initFormModel = (): AccessFormDiscordBotConfigFieldValues => {
|
||||
return {
|
||||
botToken: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormDiscordBotConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormDiscordBotConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const AccessConfigFormFieldsProviderDiscordBot = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
botToken: z
|
||||
.string()
|
||||
.min(1, t("access.form.discordbot_token.placeholder"))
|
||||
.max(256, t("common.errmsg.string_max", { max: 256 })),
|
||||
channelId: z.string().nullish(),
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<>
|
||||
<Form.Item
|
||||
name="botToken"
|
||||
name={[parentNamePath, "botToken"]}
|
||||
initialValue={initialValues.botToken}
|
||||
label={t("access.form.discordbot_token.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.discordbot_token.tooltip") }}></span>}
|
||||
@@ -56,7 +28,8 @@ const AccessFormDiscordBotConfig = ({ form: formInst, formName, disabled, initia
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="channelId"
|
||||
name={[parentNamePath, "channelId"]}
|
||||
initialValue={initialValues.channelId}
|
||||
label={t("access.form.discordbot_channel_id.label")}
|
||||
extra={t("access.form.discordbot_channel_id.help")}
|
||||
rules={[formRule]}
|
||||
@@ -64,8 +37,31 @@ const AccessFormDiscordBotConfig = ({ form: formInst, formName, disabled, initia
|
||||
>
|
||||
<Input allowClear placeholder={t("access.form.discordbot_channel_id.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormDiscordBotConfig;
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
botToken: "",
|
||||
};
|
||||
};
|
||||
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
return z.object({
|
||||
botToken: z
|
||||
.string()
|
||||
.min(1, t("access.form.discordbot_token.placeholder"))
|
||||
.max(256, t("common.errmsg.string_max", { max: 256 })),
|
||||
channelId: z.string().nullish(),
|
||||
});
|
||||
};
|
||||
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderDiscordBot, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+46
-50
@@ -1,31 +1,56 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForDogeCloud } from "@/domain/access";
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
type AccessFormDogeCloudConfigFieldValues = Nullish<AccessConfigForDogeCloud>;
|
||||
const AccessConfigFormFieldsProviderDogeCloud = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
export interface AccessFormDogeCloudConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormDogeCloudConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormDogeCloudConfigFieldValues) => void;
|
||||
}
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
const initFormModel = (): AccessFormDogeCloudConfigFieldValues => {
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "accessKey"]}
|
||||
initialValue={initialValues.accessKey}
|
||||
label={t("access.form.dogecloud_access_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.dogecloud_access_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.dogecloud_access_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "secretKey"]}
|
||||
initialValue={initialValues.secretKey}
|
||||
label={t("access.form.dogecloud_secret_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.dogecloud_secret_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.dogecloud_secret_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
accessKey: "",
|
||||
secretKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormDogeCloudConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormDogeCloudConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
const formSchema = z.object({
|
||||
return z.object({
|
||||
accessKey: z
|
||||
.string()
|
||||
.min(1, t("access.form.dogecloud_access_key.placeholder"))
|
||||
@@ -35,40 +60,11 @@ const AccessFormDogeCloudConfig = ({ form: formInst, formName, disabled, initial
|
||||
.min(1, t("access.form.dogecloud_secret_key.placeholder"))
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="accessKey"
|
||||
label={t("access.form.dogecloud_access_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.dogecloud_access_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.dogecloud_access_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="secretKey"
|
||||
label={t("access.form.dogecloud_secret_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.dogecloud_secret_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.dogecloud_secret_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormDogeCloudConfig;
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderDogeCloud, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
@@ -0,0 +1,52 @@
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
const AccessConfigFormFieldsProviderDuckDNS = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "token"]}
|
||||
initialValue={initialValues.token}
|
||||
label={t("access.form.duckdns_token.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.duckdns_token.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.duckdns_token.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
token: "",
|
||||
};
|
||||
};
|
||||
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
return z.object({
|
||||
token: z.string().nonempty(t("access.form.duckdns_token.placeholder")),
|
||||
});
|
||||
};
|
||||
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderDuckDNS, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
@@ -0,0 +1,55 @@
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
const AccessConfigFormFieldsProviderDynv6 = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "httpToken"]}
|
||||
initialValue={initialValues.httpToken}
|
||||
label={t("access.form.dynv6_http_token.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.dynv6_http_token.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.dynv6_http_token.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
httpToken: "",
|
||||
};
|
||||
};
|
||||
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
return z.object({
|
||||
httpToken: z
|
||||
.string()
|
||||
.min(1, t("access.form.dynv6_http_token.placeholder"))
|
||||
.max(256, t("common.errmsg.string_max", { max: 256 })),
|
||||
});
|
||||
};
|
||||
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderDynv6, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+46
-50
@@ -1,31 +1,56 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForEdgio } from "@/domain/access";
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
type AccessFormEdgioConfigFieldValues = Nullish<AccessConfigForEdgio>;
|
||||
const AccessConfigFormFieldsProviderEdgio = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
export interface AccessFormEdgioConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormEdgioConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormEdgioConfigFieldValues) => void;
|
||||
}
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
const initFormModel = (): AccessFormEdgioConfigFieldValues => {
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "clientId"]}
|
||||
initialValue={initialValues.clientId}
|
||||
label={t("access.form.edgio_client_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.edgio_client_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.edgio_client_id.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "clientSecret"]}
|
||||
initialValue={initialValues.clientSecret}
|
||||
label={t("access.form.edgio_client_secret.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.edgio_client_secret.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.edgio_client_secret.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
clientId: "",
|
||||
clientSecret: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormEdgioConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormEdgioConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
const formSchema = z.object({
|
||||
return z.object({
|
||||
clientId: z
|
||||
.string()
|
||||
.min(1, t("access.form.edgio_client_id.placeholder"))
|
||||
@@ -35,40 +60,11 @@ const AccessFormEdgioConfig = ({ form: formInst, formName, disabled, initialValu
|
||||
.min(1, t("access.form.edgio_client_secret.placeholder"))
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="clientId"
|
||||
label={t("access.form.edgio_client_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.edgio_client_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.edgio_client_id.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="clientSecret"
|
||||
label={t("access.form.edgio_client_secret.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.edgio_client_secret.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.edgio_client_secret.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormEdgioConfig;
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderEdgio, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+100
-83
@@ -1,22 +1,101 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input, InputNumber, Switch } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input, InputNumber, Switch } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForEmail } from "@/domain/access";
|
||||
import { validEmailAddress, validPortNumber } from "@/utils/validators";
|
||||
|
||||
type AccessFormEmailConfigFieldValues = Nullish<AccessConfigForEmail>;
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
export interface AccessFormEmailConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormEmailConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormEmailConfigFieldValues) => void;
|
||||
}
|
||||
const AccessConfigFormFieldsProviderEmail = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const initFormModel = (): AccessFormEmailConfigFieldValues => {
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const formInst = Form.useFormInstance();
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
const handleTlsSwitchChange = (checked: boolean) => {
|
||||
const oldPort = formInst.getFieldValue("smtpPort");
|
||||
const newPort = checked && (oldPort == null || oldPort === 25) ? 465 : !checked && (oldPort == null || oldPort === 465) ? 25 : oldPort;
|
||||
if (newPort !== oldPort) {
|
||||
formInst.setFieldValue("smtpPort", newPort);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="flex space-x-2">
|
||||
<div className="w-3/5">
|
||||
<Form.Item
|
||||
name={[parentNamePath, "smtpHost"]}
|
||||
initialValue={initialValues.smtpHost}
|
||||
label={t("access.form.email_smtp_host.label")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<Input placeholder={t("access.form.email_smtp_host.placeholder")} />
|
||||
</Form.Item>
|
||||
</div>
|
||||
|
||||
<div className="w-2/5">
|
||||
<Form.Item
|
||||
name={[parentNamePath, "smtpPort"]}
|
||||
initialValue={initialValues.smtpPort}
|
||||
label={t("access.form.email_smtp_port.label")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<InputNumber style={{ width: "100%" }} placeholder={t("access.form.email_smtp_port.placeholder")} min={1} max={65535} />
|
||||
</Form.Item>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Form.Item name={[parentNamePath, "smtpTls"]} initialValue={initialValues.smtpTls} label={t("access.form.email_smtp_tls.label")} rules={[formRule]}>
|
||||
<Switch onChange={handleTlsSwitchChange} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name={[parentNamePath, "username"]} initialValue={initialValues.username} label={t("access.form.email_username.label")} rules={[formRule]}>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.email_username.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name={[parentNamePath, "password"]} initialValue={initialValues.password} label={t("access.form.email_password.label")} rules={[formRule]}>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.email_password.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "senderAddress"]}
|
||||
initialValue={initialValues.senderAddress}
|
||||
label={t("access.form.email_sender_address.label")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<Input type="email" allowClear placeholder={t("access.form.email_sender_address.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "senderName"]}
|
||||
initialValue={initialValues.senderName}
|
||||
label={t("access.form.email_sender_name.label")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<Input allowClear placeholder={t("access.form.email_sender_name.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "receiverAddress"]}
|
||||
initialValue={initialValues.receiverAddress}
|
||||
label={t("access.form.email_receiver_address.label")}
|
||||
extra={t("access.form.email_receiver_address.help")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<Input type="email" allowClear placeholder={t("access.form.email_receiver_address.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
smtpHost: "",
|
||||
smtpPort: 465,
|
||||
@@ -29,10 +108,10 @@ const initFormModel = (): AccessFormEmailConfigFieldValues => {
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormEmailConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormEmailConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
const formSchema = z.object({
|
||||
return z.object({
|
||||
smtpHost: z
|
||||
.string()
|
||||
.min(1, t("access.form.email_smtp_host.placeholder"))
|
||||
@@ -60,73 +139,11 @@ const AccessFormEmailConfig = ({ form: formInst, formName, disabled, initialValu
|
||||
return validEmailAddress(v);
|
||||
}, t("common.errmsg.email_invalid")),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleTlsSwitchChange = (checked: boolean) => {
|
||||
const oldPort = formInst.getFieldValue("smtpPort");
|
||||
const newPort = checked && (oldPort == null || oldPort === 25) ? 465 : !checked && (oldPort == null || oldPort === 465) ? 25 : oldPort;
|
||||
if (newPort !== oldPort) {
|
||||
formInst.setFieldValue("smtpPort", newPort);
|
||||
}
|
||||
};
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<div className="flex space-x-2">
|
||||
<div className="w-3/5">
|
||||
<Form.Item name="smtpHost" label={t("access.form.email_smtp_host.label")} rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.email_smtp_host.placeholder")} />
|
||||
</Form.Item>
|
||||
</div>
|
||||
|
||||
<div className="w-2/5">
|
||||
<Form.Item name="smtpPort" label={t("access.form.email_smtp_port.label")} rules={[formRule]}>
|
||||
<InputNumber style={{ width: "100%" }} placeholder={t("access.form.email_smtp_port.placeholder")} min={1} max={65535} />
|
||||
</Form.Item>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Form.Item name="smtpTls" label={t("access.form.email_smtp_tls.label")} rules={[formRule]}>
|
||||
<Switch onChange={handleTlsSwitchChange} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="username" label={t("access.form.email_username.label")} rules={[formRule]}>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.email_username.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="password" label={t("access.form.email_password.label")} rules={[formRule]}>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.email_password.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="senderAddress" label={t("access.form.email_sender_address.label")} rules={[formRule]}>
|
||||
<Input type="email" allowClear placeholder={t("access.form.email_sender_address.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="senderName" label={t("access.form.email_sender_name.label")} rules={[formRule]}>
|
||||
<Input allowClear placeholder={t("access.form.email_sender_name.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="receiverAddress"
|
||||
label={t("access.form.email_receiver_address.label")}
|
||||
extra={t("access.form.email_receiver_address.help")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<Input type="email" allowClear placeholder={t("access.form.email_receiver_address.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormEmailConfig;
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderEmail, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+54
-48
@@ -1,64 +1,38 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input, Radio, Switch } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input, Radio, Switch } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForFlexCDN } from "@/domain/access";
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
type AccessFormFlexCDNConfigFieldValues = Nullish<AccessConfigForFlexCDN>;
|
||||
|
||||
export interface AccessFormFlexCDNConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormFlexCDNConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormFlexCDNConfigFieldValues) => void;
|
||||
}
|
||||
|
||||
const initFormModel = (): AccessFormFlexCDNConfigFieldValues => {
|
||||
return {
|
||||
serverUrl: "http://<your-host-addr>:8000/",
|
||||
apiRole: "user",
|
||||
accessKeyId: "",
|
||||
accessKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormFlexCDNConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormFlexCDNConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const AccessConfigFormFieldsProviderFlexCDN = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
serverUrl: z.url(t("common.errmsg.url_invalid")),
|
||||
role: z.literal(["user", "admin"], t("access.form.flexcdn_api_role.placeholder")),
|
||||
accessKeyId: z.string().nonempty(t("access.form.flexcdn_access_key_id.placeholder")),
|
||||
accessKey: z.string().nonempty(t("access.form.flexcdn_access_key.placeholder")),
|
||||
allowInsecureConnections: z.boolean().nullish(),
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item name="serverUrl" label={t("access.form.flexcdn_server_url.label")} rules={[formRule]}>
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "serverUrl"]}
|
||||
initialValue={initialValues.serverUrl}
|
||||
label={t("access.form.flexcdn_server_url.label")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<Input placeholder={t("access.form.flexcdn_server_url.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="apiRole" label={t("access.form.flexcdn_api_role.label")} rules={[formRule]}>
|
||||
<Form.Item name={[parentNamePath, "apiRole"]} initialValue={initialValues.apiRole} label={t("access.form.flexcdn_api_role.label")} rules={[formRule]}>
|
||||
<Radio.Group options={["user", "admin"].map((s) => ({ label: t(`access.form.flexcdn_api_role.option.${s}.label`), value: s }))} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="accessKeyId"
|
||||
name={[parentNamePath, "accessKeyId"]}
|
||||
initialValue={initialValues.accessKeyId}
|
||||
label={t("access.form.flexcdn_access_key_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.flexcdn_access_key_id.tooltip") }}></span>}
|
||||
@@ -67,7 +41,8 @@ const AccessFormFlexCDNConfig = ({ form: formInst, formName, disabled, initialVa
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="accessKey"
|
||||
name={[parentNamePath, "accessKey"]}
|
||||
initialValue={initialValues.accessKey}
|
||||
label={t("access.form.flexcdn_access_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.flexcdn_access_key.tooltip") }}></span>}
|
||||
@@ -75,14 +50,45 @@ const AccessFormFlexCDNConfig = ({ form: formInst, formName, disabled, initialVa
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.flexcdn_access_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="allowInsecureConnections" label={t("access.form.common_allow_insecure_conns.label")} rules={[formRule]}>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "allowInsecureConnections"]}
|
||||
initialValue={initialValues.allowInsecureConnections}
|
||||
label={t("access.form.common_allow_insecure_conns.label")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<Switch
|
||||
checkedChildren={t("access.form.common_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.common_allow_insecure_conns.switch.off")}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormFlexCDNConfig;
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
serverUrl: "http://<your-host-addr>:8000/",
|
||||
apiRole: "user",
|
||||
accessKeyId: "",
|
||||
accessKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
return z.object({
|
||||
serverUrl: z.url(t("common.errmsg.url_invalid")),
|
||||
apiRole: z.literal(["user", "admin"], t("access.form.flexcdn_api_role.placeholder")),
|
||||
accessKeyId: z.string().nonempty(t("access.form.flexcdn_access_key_id.placeholder")),
|
||||
accessKey: z.string().nonempty(t("access.form.flexcdn_access_key.placeholder")),
|
||||
allowInsecureConnections: z.boolean().nullish(),
|
||||
});
|
||||
};
|
||||
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderFlexCDN, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
@@ -0,0 +1,55 @@
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
const AccessConfigFormFieldsProviderGcore = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "apiToken"]}
|
||||
initialValue={initialValues.apiToken}
|
||||
label={t("access.form.gcore_api_token.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.gcore_api_token.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.gcore_api_token.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
apiToken: "",
|
||||
};
|
||||
};
|
||||
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
return z.object({
|
||||
apiToken: z
|
||||
.string()
|
||||
.min(1, t("access.form.gcore_api_token.placeholder"))
|
||||
.max(256, t("common.errmsg.string_max", { max: 256 })),
|
||||
});
|
||||
};
|
||||
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderGcore, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+46
-50
@@ -1,31 +1,56 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForGname } from "@/domain/access";
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
type AccessFormGnameConfigFieldValues = Nullish<AccessConfigForGname>;
|
||||
const AccessConfigFormFieldsProviderGname = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
export interface AccessFormGnameConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormGnameConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormGnameConfigFieldValues) => void;
|
||||
}
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
const initFormModel = (): AccessFormGnameConfigFieldValues => {
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "appId"]}
|
||||
initialValue={initialValues.appId}
|
||||
label={t("access.form.gname_app_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.gname_app_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.gname_app_id.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "appKey"]}
|
||||
initialValue={initialValues.appKey}
|
||||
label={t("access.form.gname_app_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.gname_app_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.gname_app_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
appId: "",
|
||||
appKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormGnameConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormGnameConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
const formSchema = z.object({
|
||||
return z.object({
|
||||
appId: z
|
||||
.string()
|
||||
.min(1, t("access.form.gname_app_id.placeholder"))
|
||||
@@ -35,40 +60,11 @@ const AccessFormGnameConfig = ({ form: formInst, formName, disabled, initialValu
|
||||
.min(1, t("access.form.gname_app_key.placeholder"))
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="appId"
|
||||
label={t("access.form.gname_app_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.gname_app_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.gname_app_id.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="appKey"
|
||||
label={t("access.form.gname_app_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.gname_app_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.gname_app_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormGnameConfig;
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderGname, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+46
-50
@@ -1,31 +1,56 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForGoDaddy } from "@/domain/access";
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
type AccessFormGoDaddyConfigFieldValues = Nullish<AccessConfigForGoDaddy>;
|
||||
const AccessConfigFormFieldsProviderGoDaddy = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
export interface AccessFormGoDaddyConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormGoDaddyConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormGoDaddyConfigFieldValues) => void;
|
||||
}
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
const initFormModel = (): AccessFormGoDaddyConfigFieldValues => {
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "apiKey"]}
|
||||
initialValue={initialValues.apiKey}
|
||||
label={t("access.form.godaddy_api_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.godaddy_api_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.godaddy_api_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "apiSecret"]}
|
||||
initialValue={initialValues.apiSecret}
|
||||
label={t("access.form.godaddy_api_secret.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.godaddy_api_secret.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.godaddy_api_secret.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
apiKey: "",
|
||||
apiSecret: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormGoDaddyConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormGoDaddyConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
const formSchema = z.object({
|
||||
return z.object({
|
||||
apiKey: z
|
||||
.string()
|
||||
.min(1, t("access.form.godaddy_api_key.placeholder"))
|
||||
@@ -35,40 +60,11 @@ const AccessFormGoDaddyConfig = ({ form: formInst, formName, disabled, initialVa
|
||||
.min(1, t("access.form.godaddy_api_secret.placeholder"))
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="apiKey"
|
||||
label={t("access.form.godaddy_api_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.godaddy_api_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.godaddy_api_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="apiSecret"
|
||||
label={t("access.form.godaddy_api_secret.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.godaddy_api_secret.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.godaddy_api_secret.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormGoDaddyConfig;
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderGoDaddy, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+54
-48
@@ -1,64 +1,38 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input, Radio, Switch } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input, Radio, Switch } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForGoEdge } from "@/domain/access";
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
type AccessFormGoEdgeConfigFieldValues = Nullish<AccessConfigForGoEdge>;
|
||||
|
||||
export interface AccessFormGoEdgeConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormGoEdgeConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormGoEdgeConfigFieldValues) => void;
|
||||
}
|
||||
|
||||
const initFormModel = (): AccessFormGoEdgeConfigFieldValues => {
|
||||
return {
|
||||
serverUrl: "http://<your-host-addr>:7788/",
|
||||
apiRole: "user",
|
||||
accessKeyId: "",
|
||||
accessKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormGoEdgeConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormGoEdgeConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const AccessConfigFormFieldsProviderGoEdge = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
serverUrl: z.url(t("common.errmsg.url_invalid")),
|
||||
role: z.literal(["user", "admin"], t("access.form.goedge_api_role.placeholder")),
|
||||
accessKeyId: z.string().nonempty(t("access.form.goedge_access_key_id.placeholder")),
|
||||
accessKey: z.string().nonempty(t("access.form.goedge_access_key.placeholder")),
|
||||
allowInsecureConnections: z.boolean().nullish(),
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item name="serverUrl" label={t("access.form.goedge_server_url.label")} rules={[formRule]}>
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "serverUrl"]}
|
||||
initialValue={initialValues.serverUrl}
|
||||
label={t("access.form.goedge_server_url.label")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<Input placeholder={t("access.form.goedge_server_url.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="apiRole" label={t("access.form.goedge_api_role.label")} rules={[formRule]}>
|
||||
<Form.Item name={[parentNamePath, "apiRole"]} initialValue={initialValues.apiRole} label={t("access.form.goedge_api_role.label")} rules={[formRule]}>
|
||||
<Radio.Group options={["user", "admin"].map((s) => ({ label: t(`access.form.goedge_api_role.option.${s}.label`), value: s }))} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="accessKeyId"
|
||||
name={[parentNamePath, "accessKeyId"]}
|
||||
initialValue={initialValues.accessKeyId}
|
||||
label={t("access.form.goedge_access_key_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.goedge_access_key_id.tooltip") }}></span>}
|
||||
@@ -67,7 +41,8 @@ const AccessFormGoEdgeConfig = ({ form: formInst, formName, disabled, initialVal
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="accessKey"
|
||||
name={[parentNamePath, "accessKey"]}
|
||||
initialValue={initialValues.accessKey}
|
||||
label={t("access.form.goedge_access_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.goedge_access_key.tooltip") }}></span>}
|
||||
@@ -75,14 +50,45 @@ const AccessFormGoEdgeConfig = ({ form: formInst, formName, disabled, initialVal
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.goedge_access_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="allowInsecureConnections" label={t("access.form.common_allow_insecure_conns.label")} rules={[formRule]}>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "allowInsecureConnections"]}
|
||||
initialValue={initialValues.allowInsecureConnections}
|
||||
label={t("access.form.common_allow_insecure_conns.label")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<Switch
|
||||
checkedChildren={t("access.form.common_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.common_allow_insecure_conns.switch.off")}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormGoEdgeConfig;
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
serverUrl: "http://<your-host-addr>:7788/",
|
||||
apiRole: "user",
|
||||
accessKeyId: "",
|
||||
accessKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
return z.object({
|
||||
serverUrl: z.url(t("common.errmsg.url_invalid")),
|
||||
apiRole: z.literal(["user", "admin"], t("access.form.goedge_api_role.placeholder")),
|
||||
accessKeyId: z.string().nonempty(t("access.form.goedge_access_key_id.placeholder")),
|
||||
accessKey: z.string().nonempty(t("access.form.goedge_access_key.placeholder")),
|
||||
allowInsecureConnections: z.boolean().nullish(),
|
||||
});
|
||||
};
|
||||
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderGoEdge, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+46
-56
@@ -1,37 +1,56 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForGoogleTrustServices } from "@/domain/access";
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
type AccessFormGoogleTrustServicesConfigFieldValues = Nullish<AccessConfigForGoogleTrustServices>;
|
||||
const AccessConfigFormFieldsProviderGoogleTrustServices = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
export interface AccessFormGoogleTrustServicesConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormGoogleTrustServicesConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormGoogleTrustServicesConfigFieldValues) => void;
|
||||
}
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
const initFormModel = (): AccessFormGoogleTrustServicesConfigFieldValues => {
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "eabKid"]}
|
||||
initialValue={initialValues.eabKid}
|
||||
label={t("access.form.googletrustservices_eab_kid.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.googletrustservices_eab_kid.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.googletrustservices_eab_kid.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "eabHmacKey"]}
|
||||
initialValue={initialValues.eabHmacKey}
|
||||
label={t("access.form.googletrustservices_eab_hmac_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.googletrustservices_eab_hmac_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.googletrustservices_eab_hmac_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
eabKid: "",
|
||||
eabHmacKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormGoogleTrustServicesConfig = ({
|
||||
form: formInst,
|
||||
formName,
|
||||
disabled,
|
||||
initialValues,
|
||||
onValuesChange,
|
||||
}: AccessFormGoogleTrustServicesConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
const formSchema = z.object({
|
||||
return z.object({
|
||||
eabKid: z
|
||||
.string()
|
||||
.min(1, t("access.form.googletrustservices_eab_kid.placeholder"))
|
||||
@@ -41,40 +60,11 @@ const AccessFormGoogleTrustServicesConfig = ({
|
||||
.min(1, t("access.form.googletrustservices_eab_hmac_key.placeholder"))
|
||||
.max(256, t("common.errmsg.string_max", { max: 256 })),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="eabKid"
|
||||
label={t("access.form.googletrustservices_eab_kid.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.googletrustservices_eab_kid.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.googletrustservices_eab_kid.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="eabHmacKey"
|
||||
label={t("access.form.googletrustservices_eab_hmac_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.googletrustservices_eab_hmac_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.googletrustservices_eab_hmac_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormGoogleTrustServicesConfig;
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderGoogleTrustServices, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
@@ -0,0 +1,52 @@
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
const AccessConfigFormFieldsProviderHetzner = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "apiToken"]}
|
||||
initialValue={initialValues.apiToken}
|
||||
label={t("access.form.hetzner_api_token.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.hetzner_api_token.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.hetzner_api_token.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
apiToken: "",
|
||||
};
|
||||
};
|
||||
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
return z.object({
|
||||
apiToken: z.string().nonempty(t("access.form.hetzner_api_token.placeholder")),
|
||||
});
|
||||
};
|
||||
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderHetzner, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+56
-59
@@ -1,31 +1,66 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForHuaweiCloud } from "@/domain/access";
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
type AccessFormHuaweiCloudConfigFieldValues = Nullish<AccessConfigForHuaweiCloud>;
|
||||
const AccessConfigFormFieldsProviderHuaweiCloud = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
export interface AccessFormHuaweiCloudConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormHuaweiCloudConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormHuaweiCloudConfigFieldValues) => void;
|
||||
}
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
const initFormModel = (): AccessFormHuaweiCloudConfigFieldValues => {
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "accessKeyId"]}
|
||||
initialValue={initialValues.accessKeyId}
|
||||
label={t("access.form.huaweicloud_access_key_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.huaweicloud_access_key_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.huaweicloud_access_key_id.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "secretAccessKey"]}
|
||||
initialValue={initialValues.secretAccessKey}
|
||||
label={t("access.form.huaweicloud_secret_access_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.huaweicloud_secret_access_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.huaweicloud_secret_access_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "enterpriseProjectId"]}
|
||||
initialValue={initialValues.enterpriseProjectId}
|
||||
label={t("access.form.huaweicloud_enterprise_project_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.huaweicloud_enterprise_project_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input allowClear autoComplete="new-password" placeholder={t("access.form.huaweicloud_enterprise_project_id.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
accessKeyId: "",
|
||||
secretAccessKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormHuaweiCloudConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormHuaweiCloudConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
const formSchema = z.object({
|
||||
return z.object({
|
||||
accessKeyId: z
|
||||
.string()
|
||||
.min(1, t("access.form.huaweicloud_access_key_id.placeholder"))
|
||||
@@ -36,49 +71,11 @@ const AccessFormHuaweiCloudConfig = ({ form: formInst, formName, disabled, initi
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
enterpriseProjectId: z.string().nullish(),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="accessKeyId"
|
||||
label={t("access.form.huaweicloud_access_key_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.huaweicloud_access_key_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.huaweicloud_access_key_id.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="secretAccessKey"
|
||||
label={t("access.form.huaweicloud_secret_access_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.huaweicloud_secret_access_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.huaweicloud_secret_access_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="enterpriseProjectId"
|
||||
label={t("access.form.huaweicloud_enterprise_project_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.huaweicloud_enterprise_project_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input allowClear autoComplete="new-password" placeholder={t("access.form.huaweicloud_enterprise_project_id.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormHuaweiCloudConfig;
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderHuaweiCloud, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+46
-50
@@ -1,31 +1,56 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForJDCloud } from "@/domain/access";
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
type AccessFormJDCloudConfigFieldValues = Nullish<AccessConfigForJDCloud>;
|
||||
const AccessConfigFormFieldsProviderJDCloud = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
export interface AccessFormJDCloudConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormJDCloudConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormJDCloudConfigFieldValues) => void;
|
||||
}
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
const initFormModel = (): AccessFormJDCloudConfigFieldValues => {
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "accessKeyId"]}
|
||||
initialValue={initialValues.accessKeyId}
|
||||
label={t("access.form.jdcloud_access_key_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.jdcloud_access_key_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.jdcloud_access_key_id.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "accessKeySecret"]}
|
||||
initialValue={initialValues.accessKeySecret}
|
||||
label={t("access.form.jdcloud_access_key_secret.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.jdcloud_access_key_secret.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.jdcloud_access_key_secret.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
accessKeyId: "",
|
||||
accessKeySecret: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormJDCloudConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange: onValuesChange }: AccessFormJDCloudConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
const formSchema = z.object({
|
||||
return z.object({
|
||||
accessKeyId: z
|
||||
.string()
|
||||
.min(1, t("access.form.jdcloud_access_key_id.placeholder"))
|
||||
@@ -35,40 +60,11 @@ const AccessFormJDCloudConfig = ({ form: formInst, formName, disabled, initialVa
|
||||
.min(1, t("access.form.jdcloud_access_key_secret.placeholder"))
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="accessKeyId"
|
||||
label={t("access.form.jdcloud_access_key_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.jdcloud_access_key_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.jdcloud_access_key_id.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="accessKeySecret"
|
||||
label={t("access.form.jdcloud_access_key_secret.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.jdcloud_access_key_secret.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.jdcloud_access_key_secret.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormJDCloudConfig;
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderJDCloud, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
@@ -0,0 +1,71 @@
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input, Switch } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
const AccessConfigFormFieldsProviderKong = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form.Item name={[parentNamePath, "serverUrl"]} initialValue={initialValues.serverUrl} label={t("access.form.kong_server_url.label")} rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.kong_server_url.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "apiToken"]}
|
||||
initialValue={initialValues.apiToken}
|
||||
label={t("access.form.kong_api_token.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.kong_api_token.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password allowClear autoComplete="new-password" placeholder={t("access.form.kong_api_token.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "allowInsecureConnections"]}
|
||||
initialValue={initialValues.allowInsecureConnections}
|
||||
label={t("access.form.common_allow_insecure_conns.label")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<Switch
|
||||
checkedChildren={t("access.form.common_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.common_allow_insecure_conns.switch.off")}
|
||||
/>
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
serverUrl: "http://<your-host-addr>:8001/",
|
||||
apiToken: "",
|
||||
};
|
||||
};
|
||||
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
return z.object({
|
||||
serverUrl: z.url(t("common.errmsg.url_invalid")),
|
||||
apiToken: z.string().nullish(),
|
||||
allowInsecureConnections: z.boolean().nullish(),
|
||||
});
|
||||
};
|
||||
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderKong, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
@@ -0,0 +1,56 @@
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import TextFileInput from "@/components/TextFileInput";
|
||||
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
const AccessConfigFormFieldsProviderKubernetes = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "kubeConfig"]}
|
||||
initialValue={initialValues.kubeConfig}
|
||||
label={t("access.form.k8s_kubeconfig.label")}
|
||||
extra={t("access.form.k8s_kubeconfig.help")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.k8s_kubeconfig.tooltip") }}></span>}
|
||||
>
|
||||
<TextFileInput allowClear autoSize={{ minRows: 3, maxRows: 10 }} placeholder={t("access.form.k8s_kubeconfig.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {};
|
||||
};
|
||||
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
return z.object({
|
||||
kubeConfig: z
|
||||
.string()
|
||||
.max(20480, t("common.errmsg.string_max", { max: 20480 }))
|
||||
.nullish(),
|
||||
});
|
||||
};
|
||||
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderKubernetes, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
@@ -0,0 +1,52 @@
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
const AccessConfigFormFieldsProviderLarkBot = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "webhookUrl"]}
|
||||
initialValue={initialValues.webhookUrl}
|
||||
label={t("access.form.larkbot_webhook_url.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.larkbot_webhook_url.tooltip") }}></span>}
|
||||
>
|
||||
<Input placeholder={t("access.form.larkbot_webhook_url.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
webhookUrl: "",
|
||||
};
|
||||
};
|
||||
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
return z.object({
|
||||
webhookUrl: z.url(t("common.errmsg.url_invalid")),
|
||||
});
|
||||
};
|
||||
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderLarkBot, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
@@ -0,0 +1,88 @@
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input, Radio, Select, Switch } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
const AccessConfigFormFieldsProviderLeCDN = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form.Item name={[parentNamePath, "serverUrl"]} initialValue={initialValues.serverUrl} label={t("access.form.lecdn_server_url.label")} rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.lecdn_server_url.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "apiVersion"]}
|
||||
initialValue={initialValues.apiVersion}
|
||||
label={t("access.form.lecdn_api_version.label")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<Select options={["v3"].map((s) => ({ label: s, value: s }))} placeholder={t("access.form.lecdn_api_version.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name={[parentNamePath, "apiRole"]} initialValue={initialValues.apiRole} label={t("access.form.lecdn_api_role.label")} rules={[formRule]}>
|
||||
<Radio.Group options={["user", "master"].map((s) => ({ label: t(`access.form.lecdn_api_role.option.${s}.label`), value: s }))} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name={[parentNamePath, "username"]} initialValue={initialValues.username} label={t("access.form.lecdn_username.label")} rules={[formRule]}>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.lecdn_username.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name={[parentNamePath, "password"]} initialValue={initialValues.password} label={t("access.form.lecdn_password.label")} rules={[formRule]}>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.lecdn_password.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "allowInsecureConnections"]}
|
||||
initialValue={initialValues.allowInsecureConnections}
|
||||
label={t("access.form.common_allow_insecure_conns.label")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<Switch
|
||||
checkedChildren={t("access.form.common_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.common_allow_insecure_conns.switch.off")}
|
||||
/>
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
serverUrl: "http://<your-host-addr>:5090/",
|
||||
apiVersion: "v3",
|
||||
apiRole: "client",
|
||||
username: "",
|
||||
password: "",
|
||||
};
|
||||
};
|
||||
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
return z.object({
|
||||
serverUrl: z.url(t("common.errmsg.url_invalid")),
|
||||
apiVersion: z.literal(["v3"], t("access.form.lecdn_api_version.placeholder")),
|
||||
apiRole: z.literal(["client", "master"], t("access.form.lecdn_api_role.placeholder")),
|
||||
username: z.string().nonempty(t("access.form.lecdn_username.placeholder")),
|
||||
password: z.string().nonempty(t("access.form.lecdn_password.placeholder")),
|
||||
allowInsecureConnections: z.boolean().nullish(),
|
||||
});
|
||||
};
|
||||
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderLeCDN, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+51
-45
@@ -1,54 +1,25 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForMattermost } from "@/domain/access";
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
type AccessFormMattermostConfigFieldValues = Nullish<AccessConfigForMattermost>;
|
||||
|
||||
export interface AccessFormMattermostConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormMattermostConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormMattermostConfigFieldValues) => void;
|
||||
}
|
||||
|
||||
const initFormModel = (): AccessFormMattermostConfigFieldValues => {
|
||||
return {
|
||||
serverUrl: "http://<your-host-addr>:8065/",
|
||||
username: "",
|
||||
password: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormMattermostConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormMattermostConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const AccessConfigFormFieldsProviderMattermost = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
serverUrl: z.url(t("common.errmsg.url_invalid")),
|
||||
username: z.string().nonempty(t("access.form.mattermost_username.placeholder")),
|
||||
password: z.string().nonempty(t("access.form.mattermost_password.placeholder")),
|
||||
channelId: z.string().nullish(),
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<>
|
||||
<Form.Item
|
||||
name="serverUrl"
|
||||
name={[parentNamePath, "serverUrl"]}
|
||||
initialValue={initialValues.serverUrl}
|
||||
label={t("access.form.mattermost_server_url.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.mattermost_server_url.tooltip") }}></span>}
|
||||
@@ -56,16 +27,27 @@ const AccessFormMattermostConfig = ({ form: formInst, formName, disabled, initia
|
||||
<Input placeholder={t("access.form.mattermost_server_url.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="username" label={t("access.form.mattermost_username.label")} rules={[formRule]}>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "username"]}
|
||||
initialValue={initialValues.username}
|
||||
label={t("access.form.mattermost_username.label")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<Input placeholder={t("access.form.mattermost_username.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="password" label={t("access.form.mattermost_password.label")} rules={[formRule]}>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "password"]}
|
||||
initialValue={initialValues.password}
|
||||
label={t("access.form.mattermost_password.label")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<Input.Password placeholder={t("access.form.mattermost_password.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="channelId"
|
||||
name={[parentNamePath, "channelId"]}
|
||||
initialValue={initialValues.channelId}
|
||||
label={t("access.form.mattermost_channel_id.label")}
|
||||
extra={t("access.form.mattermost_channel_id.help")}
|
||||
rules={[formRule]}
|
||||
@@ -73,8 +55,32 @@ const AccessFormMattermostConfig = ({ form: formInst, formName, disabled, initia
|
||||
>
|
||||
<Input allowClear placeholder={t("access.form.mattermost_channel_id.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormMattermostConfig;
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
serverUrl: "http://<your-host-addr>:8065/",
|
||||
username: "",
|
||||
password: "",
|
||||
};
|
||||
};
|
||||
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
return z.object({
|
||||
serverUrl: z.url(t("common.errmsg.url_invalid")),
|
||||
username: z.string().nonempty(t("access.form.mattermost_username.placeholder")),
|
||||
password: z.string().nonempty(t("access.form.mattermost_password.placeholder")),
|
||||
channelId: z.string().nullish(),
|
||||
});
|
||||
};
|
||||
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderMattermost, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
@@ -0,0 +1,55 @@
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
const AccessConfigFormFieldsProviderNS1 = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "apiKey"]}
|
||||
initialValue={initialValues.apiKey}
|
||||
label={t("access.form.ns1_api_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.ns1_api_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.ns1_api_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
apiKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
return z.object({
|
||||
apiKey: z
|
||||
.string()
|
||||
.min(1, t("access.form.ns1_api_key.placeholder"))
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
});
|
||||
};
|
||||
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderNS1, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+46
-50
@@ -1,31 +1,56 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForNameDotCom } from "@/domain/access";
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
type AccessFormNameDotComConfigFieldValues = Nullish<AccessConfigForNameDotCom>;
|
||||
const AccessConfigFormFieldsProviderNameDotCom = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
export interface AccessFormNameDotComConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormNameDotComConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormNameDotComConfigFieldValues) => void;
|
||||
}
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
const initFormModel = (): AccessFormNameDotComConfigFieldValues => {
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "username"]}
|
||||
initialValue={initialValues.username}
|
||||
label={t("access.form.namedotcom_username.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.namedotcom_username.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.namedotcom_username.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "apiToken"]}
|
||||
initialValue={initialValues.apiToken}
|
||||
label={t("access.form.namedotcom_api_token.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.namedotcom_api_token.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.namedotcom_api_token.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
username: "",
|
||||
apiToken: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormNameDotComConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormNameDotComConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
const formSchema = z.object({
|
||||
return z.object({
|
||||
username: z
|
||||
.string()
|
||||
.min(1, t("access.form.namedotcom_username.placeholder"))
|
||||
@@ -35,40 +60,11 @@ const AccessFormNameDotComConfig = ({ form: formInst, formName, disabled, initia
|
||||
.min(1, t("access.form.namedotcom_api_token.placeholder"))
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="username"
|
||||
label={t("access.form.namedotcom_username.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.namedotcom_username.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.namedotcom_username.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="apiToken"
|
||||
label={t("access.form.namedotcom_api_token.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.namedotcom_api_token.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.namedotcom_api_token.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormNameDotComConfig;
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderNameDotCom, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
@@ -0,0 +1,55 @@
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
const AccessConfigFormFieldsProviderNameSilo = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "apiKey"]}
|
||||
initialValue={initialValues.apiKey}
|
||||
label={t("access.form.namesilo_api_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.namesilo_api_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.namesilo_api_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
apiKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
return z.object({
|
||||
apiKey: z
|
||||
.string()
|
||||
.min(1, t("access.form.namesilo_api_key.placeholder"))
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
});
|
||||
};
|
||||
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderNameSilo, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+46
-50
@@ -1,31 +1,56 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForNamecheap } from "@/domain/access";
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
type AccessFormNamecheapConfigFieldValues = Nullish<AccessConfigForNamecheap>;
|
||||
const AccessConfigFormFieldsProviderNamecheap = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
export interface AccessFormNamecheapConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormNamecheapConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormNamecheapConfigFieldValues) => void;
|
||||
}
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
const initFormModel = (): AccessFormNamecheapConfigFieldValues => {
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "username"]}
|
||||
initialValue={initialValues.username}
|
||||
label={t("access.form.namecheap_username.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.namecheap_username.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.namecheap_username.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "apiKey"]}
|
||||
initialValue={initialValues.apiKey}
|
||||
label={t("access.form.namecheap_api_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.namecheap_api_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.namecheap_api_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
username: "",
|
||||
apiKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormNamecheapConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormNamecheapConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
const formSchema = z.object({
|
||||
return z.object({
|
||||
username: z
|
||||
.string()
|
||||
.min(1, t("access.form.namecheap_username.placeholder"))
|
||||
@@ -35,40 +60,11 @@ const AccessFormNamecheapConfig = ({ form: formInst, formName, disabled, initial
|
||||
.min(1, t("access.form.namecheap_api_key.placeholder"))
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="username"
|
||||
label={t("access.form.namecheap_username.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.namecheap_username.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.namecheap_username.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="apiKey"
|
||||
label={t("access.form.namecheap_api_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.namecheap_api_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.namecheap_api_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormNamecheapConfig;
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderNamecheap, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+40
-43
@@ -1,53 +1,25 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForNetcup } from "@/domain/access";
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
type AccessFormNetcupConfigFieldValues = Nullish<AccessConfigForNetcup>;
|
||||
|
||||
export interface AccessFormNetcupConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormNetcupConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormNetcupConfigFieldValues) => void;
|
||||
}
|
||||
|
||||
const initFormModel = (): AccessFormNetcupConfigFieldValues => {
|
||||
return {
|
||||
customerNumber: "",
|
||||
apiKey: "",
|
||||
apiPassword: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormNetcupConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormNetcupConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const AccessConfigFormFieldsProviderNetcup = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
customerNumber: z.string().nonempty(t("access.form.netcup_customer_number.placeholder")),
|
||||
apiKey: z.string().nonempty(t("access.form.netcup_api_key.placeholder")),
|
||||
apiPassword: z.string().nonempty(t("access.form.netcup_api_password.placeholder")),
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<>
|
||||
<Form.Item
|
||||
name="customerNumber"
|
||||
name={[parentNamePath, "customerNumber"]}
|
||||
initialValue={initialValues.customerNumber}
|
||||
label={t("access.form.netcup_customer_number.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.netcup_customer_number.tooltip") }}></span>}
|
||||
@@ -56,7 +28,8 @@ const AccessFormNetcupConfig = ({ form: formInst, formName, disabled, initialVal
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="apiKey"
|
||||
name={[parentNamePath, "apiKey"]}
|
||||
initialValue={initialValues.apiKey}
|
||||
label={t("access.form.netcup_api_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.netcup_api_key.tooltip") }}></span>}
|
||||
@@ -65,15 +38,39 @@ const AccessFormNetcupConfig = ({ form: formInst, formName, disabled, initialVal
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="apiPassword"
|
||||
name={[parentNamePath, "apiPassword"]}
|
||||
initialValue={initialValues.apiPassword}
|
||||
label={t("access.form.netcup_api_password.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.netcup_api_password.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.netcup_api_password.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormNetcupConfig;
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
customerNumber: "",
|
||||
apiKey: "",
|
||||
apiPassword: "",
|
||||
};
|
||||
};
|
||||
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
return z.object({
|
||||
customerNumber: z.string().nonempty(t("access.form.netcup_customer_number.placeholder")),
|
||||
apiKey: z.string().nonempty(t("access.form.netcup_api_key.placeholder")),
|
||||
apiPassword: z.string().nonempty(t("access.form.netcup_api_password.placeholder")),
|
||||
});
|
||||
};
|
||||
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderNetcup, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
@@ -0,0 +1,52 @@
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
const AccessConfigFormFieldsProviderNetlify = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "apiToken"]}
|
||||
initialValue={initialValues.apiToken}
|
||||
label={t("access.form.netlify_api_token.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.netlify_api_token.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.netlify_api_token.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
apiToken: "",
|
||||
};
|
||||
};
|
||||
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
return z.object({
|
||||
apiToken: z.string().nonempty(t("access.form.netlify_api_token.placeholder")),
|
||||
});
|
||||
};
|
||||
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderNetlify, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+46
-50
@@ -1,31 +1,56 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForPorkbun } from "@/domain/access";
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
type AccessFormPorkbunConfigFieldValues = Nullish<AccessConfigForPorkbun>;
|
||||
const AccessConfigFormFieldsProviderPorkbun = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
export interface AccessFormPorkbunConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormPorkbunConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormPorkbunConfigFieldValues) => void;
|
||||
}
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
const initFormModel = (): AccessFormPorkbunConfigFieldValues => {
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "apiKey"]}
|
||||
initialValue={initialValues.apiKey}
|
||||
label={t("access.form.porkbun_api_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.porkbun_api_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.porkbun_api_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "secretApiKey"]}
|
||||
initialValue={initialValues.secretApiKey}
|
||||
label={t("access.form.porkbun_secret_api_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.porkbun_secret_api_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.porkbun_secret_api_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
apiKey: "",
|
||||
secretApiKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormPorkbunConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormPorkbunConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
const formSchema = z.object({
|
||||
return z.object({
|
||||
apiKey: z
|
||||
.string()
|
||||
.min(1, t("access.form.porkbun_api_key.placeholder"))
|
||||
@@ -35,40 +60,11 @@ const AccessFormPorkbunConfig = ({ form: formInst, formName, disabled, initialVa
|
||||
.min(1, t("access.form.porkbun_secret_api_key.placeholder"))
|
||||
.max(256, t("common.errmsg.string_max", { max: 256 })),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="apiKey"
|
||||
label={t("access.form.porkbun_api_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.porkbun_api_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.porkbun_api_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="secretApiKey"
|
||||
label={t("access.form.porkbun_secret_api_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.porkbun_secret_api_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.porkbun_secret_api_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormPorkbunConfig;
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderPorkbun, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
@@ -0,0 +1,79 @@
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input, Switch } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
const AccessConfigFormFieldsProviderPowerDNS = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "serverUrl"]}
|
||||
initialValue={initialValues.serverUrl}
|
||||
label={t("access.form.powerdns_server_url.label")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<Input placeholder={t("access.form.powerdns_server_url.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "apiKey"]}
|
||||
initialValue={initialValues.apiKey}
|
||||
label={t("access.form.powerdns_api_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.powerdns_api_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.powerdns_api_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "allowInsecureConnections"]}
|
||||
initialValue={initialValues.allowInsecureConnections}
|
||||
label={t("access.form.common_allow_insecure_conns.label")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<Switch
|
||||
checkedChildren={t("access.form.common_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.common_allow_insecure_conns.switch.off")}
|
||||
/>
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
serverUrl: "http://<your-host-addr>:8082/",
|
||||
apiKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
return z.object({
|
||||
serverUrl: z.url(t("common.errmsg.url_invalid")),
|
||||
apiKey: z
|
||||
.string()
|
||||
.min(1, t("access.form.powerdns_api_key.placeholder"))
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
allowInsecureConnections: z.boolean().nullish(),
|
||||
});
|
||||
};
|
||||
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderPowerDNS, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+50
-44
@@ -1,57 +1,34 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input, Switch } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input, Switch } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForProxmoxVE } from "@/domain/access";
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
type AccessFormProxmoxVEConfigFieldValues = Nullish<AccessConfigForProxmoxVE>;
|
||||
|
||||
export interface AccessFormProxmoxVEConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormProxmoxVEConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormProxmoxVEConfigFieldValues) => void;
|
||||
}
|
||||
|
||||
const initFormModel = (): AccessFormProxmoxVEConfigFieldValues => {
|
||||
return {
|
||||
serverUrl: "http://<your-host-addr>:8006/",
|
||||
apiToken: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormProxmoxVEConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormProxmoxVEConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const AccessConfigFormFieldsProviderProxmoxVE = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
serverUrl: z.url(t("common.errmsg.url_invalid")),
|
||||
apiToken: z.string().nonempty(t("access.form.proxmoxve_api_token.placeholder")),
|
||||
apiTokenSecret: z.string().nullish(),
|
||||
allowInsecureConnections: z.boolean().nullish(),
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item name="serverUrl" label={t("access.form.proxmoxve_server_url.label")} rules={[formRule]}>
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "serverUrl"]}
|
||||
initialValue={initialValues.serverUrl}
|
||||
label={t("access.form.proxmoxve_server_url.label")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<Input placeholder={t("access.form.proxmoxve_server_url.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="apiToken"
|
||||
name={[parentNamePath, "apiToken"]}
|
||||
initialValue={initialValues.apiToken}
|
||||
label={t("access.form.proxmoxve_api_token.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.proxmoxve_api_token.tooltip") }}></span>}
|
||||
@@ -60,7 +37,8 @@ const AccessFormProxmoxVEConfig = ({ form: formInst, formName, disabled, initial
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="apiTokenSecret"
|
||||
name={[parentNamePath, "apiTokenSecret"]}
|
||||
initialValue={initialValues.apiTokenSecret}
|
||||
label={t("access.form.proxmoxve_api_token_secret.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.proxmoxve_api_token_secret.tooltip") }}></span>}
|
||||
@@ -68,14 +46,42 @@ const AccessFormProxmoxVEConfig = ({ form: formInst, formName, disabled, initial
|
||||
<Input.Password allowClear autoComplete="new-password" placeholder={t("access.form.proxmoxve_api_token_secret.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="allowInsecureConnections" label={t("access.form.common_allow_insecure_conns.label")} rules={[formRule]}>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "allowInsecureConnections"]}
|
||||
initialValue={initialValues.allowInsecureConnections}
|
||||
label={t("access.form.common_allow_insecure_conns.label")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<Switch
|
||||
checkedChildren={t("access.form.common_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.common_allow_insecure_conns.switch.off")}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormProxmoxVEConfig;
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
serverUrl: "http://<your-host-addr>:8006/",
|
||||
apiToken: "",
|
||||
};
|
||||
};
|
||||
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
return z.object({
|
||||
serverUrl: z.url(t("common.errmsg.url_invalid")),
|
||||
apiToken: z.string().nonempty(t("access.form.proxmoxve_api_token.placeholder")),
|
||||
apiTokenSecret: z.string().nullish(),
|
||||
allowInsecureConnections: z.boolean().nullish(),
|
||||
});
|
||||
};
|
||||
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderProxmoxVE, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+46
-50
@@ -1,31 +1,56 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForQiniu } from "@/domain/access";
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
type AccessFormQiniuConfigFieldValues = Nullish<AccessConfigForQiniu>;
|
||||
const AccessConfigFormFieldsProviderQiniu = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
export interface AccessFormQiniuConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormQiniuConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormQiniuConfigFieldValues) => void;
|
||||
}
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
const initFormModel = (): AccessFormQiniuConfigFieldValues => {
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "accessKey"]}
|
||||
initialValue={initialValues.accessKey}
|
||||
label={t("access.form.qiniu_access_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.qiniu_access_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.qiniu_access_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "secretKey"]}
|
||||
initialValue={initialValues.secretKey}
|
||||
label={t("access.form.qiniu_secret_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.qiniu_secret_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.qiniu_secret_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
accessKey: "",
|
||||
secretKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormQiniuConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormQiniuConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
const formSchema = z.object({
|
||||
return z.object({
|
||||
accessKey: z
|
||||
.string()
|
||||
.min(1, t("access.form.qiniu_access_key.placeholder"))
|
||||
@@ -35,40 +60,11 @@ const AccessFormQiniuConfig = ({ form: formInst, formName, disabled, initialValu
|
||||
.min(1, t("access.form.qiniu_secret_key.placeholder"))
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="accessKey"
|
||||
label={t("access.form.qiniu_access_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.qiniu_access_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.qiniu_access_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="secretKey"
|
||||
label={t("access.form.qiniu_secret_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.qiniu_secret_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.qiniu_secret_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormQiniuConfig;
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderQiniu, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
@@ -0,0 +1,55 @@
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
const AccessConfigFormFieldsProviderRainYun = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "apiKey"]}
|
||||
initialValue={initialValues.apiKey}
|
||||
label={t("access.form.rainyun_api_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.rainyun_api_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.rainyun_api_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
apiKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
return z.object({
|
||||
apiKey: z
|
||||
.string()
|
||||
.min(1, t("access.form.rainyun_api_key.placeholder"))
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
});
|
||||
};
|
||||
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderRainYun, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+51
-45
@@ -1,58 +1,34 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input, Switch } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input, Switch } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForRatPanel } from "@/domain/access";
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
type AccessFormRatPanelConfigFieldValues = Nullish<AccessConfigForRatPanel>;
|
||||
|
||||
export interface AccessFormRatPanelConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormRatPanelConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormRatPanelConfigFieldValues) => void;
|
||||
}
|
||||
|
||||
const initFormModel = (): AccessFormRatPanelConfigFieldValues => {
|
||||
return {
|
||||
serverUrl: "http://<your-host-addr>:8888/",
|
||||
accessTokenId: 1,
|
||||
accessToken: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormRatPanelConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormRatPanelConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const AccessConfigFormFieldsProviderRatPanel = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
serverUrl: z.url(t("common.errmsg.url_invalid")),
|
||||
accessTokenId: z.preprocess((v) => Number(v), z.number().positive(t("access.form.ratpanel_access_token_id.placeholder"))),
|
||||
accessToken: z.string().nonempty(t("access.form.ratpanel_access_token.placeholder")),
|
||||
allowInsecureConnections: z.boolean().nullish(),
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item name="serverUrl" label={t("access.form.ratpanel_server_url.label")} rules={[formRule]}>
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "serverUrl"]}
|
||||
initialValue={initialValues.serverUrl}
|
||||
label={t("access.form.ratpanel_server_url.label")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<Input placeholder={t("access.form.ratpanel_server_url.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="accessTokenId"
|
||||
name={[parentNamePath, "accessTokenId"]}
|
||||
initialValue={initialValues.accessTokenId}
|
||||
label={t("access.form.ratpanel_access_token_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.ratpanel_access_token_id.tooltip") }}></span>}
|
||||
@@ -61,7 +37,8 @@ const AccessFormRatPanelConfig = ({ form: formInst, formName, disabled, initialV
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="accessToken"
|
||||
name={[parentNamePath, "accessToken"]}
|
||||
initialValue={initialValues.accessToken}
|
||||
label={t("access.form.ratpanel_access_token.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.ratpanel_access_token.tooltip") }}></span>}
|
||||
@@ -69,14 +46,43 @@ const AccessFormRatPanelConfig = ({ form: formInst, formName, disabled, initialV
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.ratpanel_access_token.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="allowInsecureConnections" label={t("access.form.common_allow_insecure_conns.label")} rules={[formRule]}>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "allowInsecureConnections"]}
|
||||
initialValue={initialValues.allowInsecureConnections}
|
||||
label={t("access.form.common_allow_insecure_conns.label")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<Switch
|
||||
checkedChildren={t("access.form.common_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.common_allow_insecure_conns.switch.off")}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormRatPanelConfig;
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
serverUrl: "http://<your-host-addr>:8888/",
|
||||
accessTokenId: 1,
|
||||
accessToken: "",
|
||||
};
|
||||
};
|
||||
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
return z.object({
|
||||
serverUrl: z.url(t("common.errmsg.url_invalid")),
|
||||
accessTokenId: z.preprocess((v) => Number(v), z.number().positive(t("access.form.ratpanel_access_token_id.placeholder"))),
|
||||
accessToken: z.string().nonempty(t("access.form.ratpanel_access_token.placeholder")),
|
||||
allowInsecureConnections: z.boolean().nullish(),
|
||||
});
|
||||
};
|
||||
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderRatPanel, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
@@ -0,0 +1,309 @@
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { IconCircleArrowDown, IconCircleArrowUp, IconCircleMinus, IconCirclePlus } from "@tabler/icons-react";
|
||||
import { Button, Collapse, Form, Input, InputNumber, Radio } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import Show from "@/components/Show";
|
||||
import TextFileInput from "@/components/TextFileInput";
|
||||
import { validDomainName, validIPv4Address, validIPv6Address, validPortNumber } from "@/utils/validators";
|
||||
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
const AUTH_METHOD_NONE = "none" as const;
|
||||
const AUTH_METHOD_PASSWORD = "password" as const;
|
||||
const AUTH_METHOD_KEY = "key" as const;
|
||||
|
||||
const AccessConfigFormFieldsProviderSSH = ({ disabled }: { disabled?: boolean }) => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const formInst = Form.useFormInstance();
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
const fieldAuthMethod = Form.useWatch([parentNamePath, "authMethod"], formInst);
|
||||
const fieldJumpServers = Form.useWatch([parentNamePath, "jumpServers"], formInst);
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="flex space-x-2">
|
||||
<div className="w-2/3">
|
||||
<Form.Item name={[parentNamePath, "host"]} initialValue={initialValues.host} label={t("access.form.ssh_host.label")} rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.ssh_host.placeholder")} />
|
||||
</Form.Item>
|
||||
</div>
|
||||
|
||||
<div className="w-1/3">
|
||||
<Form.Item name={[parentNamePath, "port"]} initialValue={initialValues.port} label={t("access.form.ssh_port.label")} rules={[formRule]}>
|
||||
<InputNumber style={{ width: "100%" }} min={1} max={65535} placeholder={t("access.form.ssh_port.placeholder")} />
|
||||
</Form.Item>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "authMethod"]}
|
||||
initialValue={initialValues.authMethod}
|
||||
label={t("access.form.ssh_auth_method.label")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<Radio.Group
|
||||
options={[AUTH_METHOD_NONE, AUTH_METHOD_PASSWORD, AUTH_METHOD_KEY].map((s) => ({
|
||||
key: s,
|
||||
label: t(`access.form.ssh_auth_method.option.${s}.label`),
|
||||
value: s,
|
||||
}))}
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name={[parentNamePath, "username"]} initialValue={initialValues.username} label={t("access.form.ssh_username.label")} rules={[formRule]}>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.ssh_username.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Show when={fieldAuthMethod === AUTH_METHOD_PASSWORD}>
|
||||
<Form.Item name={[parentNamePath, "password"]} initialValue={initialValues.password} label={t("access.form.ssh_password.label")} rules={[formRule]}>
|
||||
<Input.Password allowClear autoComplete="new-password" placeholder={t("access.form.ssh_password.placeholder")} />
|
||||
</Form.Item>
|
||||
</Show>
|
||||
|
||||
<Show when={fieldAuthMethod === AUTH_METHOD_KEY}>
|
||||
<Form.Item name={[parentNamePath, "key"]} initialValue={initialValues.key} label={t("access.form.ssh_key.label")} rules={[formRule]}>
|
||||
<TextFileInput allowClear autoSize={{ minRows: 1, maxRows: 5 }} placeholder={t("access.form.ssh_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "keyPassphrase"]}
|
||||
initialValue={initialValues.keyPassphrase}
|
||||
label={t("access.form.ssh_key_passphrase.label")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<Input.Password allowClear autoComplete="new-password" placeholder={t("access.form.ssh_key_passphrase.placeholder")} />
|
||||
</Form.Item>
|
||||
</Show>
|
||||
|
||||
<Form.Item label={t("access.form.ssh_jump_servers.label")}>
|
||||
<Form.List name={[parentNamePath, "jumpServers"]}>
|
||||
{(fields, { add, remove, move }) => (
|
||||
<div className="flex flex-col gap-2">
|
||||
{fields?.length > 0 ? (
|
||||
<Collapse
|
||||
items={fields.map(({ key, name: index }) => {
|
||||
const subfieldHost = fieldJumpServers?.[index]?.host;
|
||||
const subfieldPort = fieldJumpServers?.[index]?.post;
|
||||
const subfieldAuthMethod = fieldJumpServers?.[index]?.authMethod;
|
||||
|
||||
const subfieldHostAndPort =
|
||||
!!subfieldHost && !!subfieldPort
|
||||
? `${subfieldHost}:${subfieldPort}`
|
||||
: subfieldHost
|
||||
? subfieldHost
|
||||
: subfieldPort
|
||||
? `:${subfieldPort}`
|
||||
: "unknown";
|
||||
|
||||
return {
|
||||
key: key,
|
||||
forceRender: true,
|
||||
label: (
|
||||
<span className="select-none">
|
||||
[{t("access.form.ssh_jump_servers.item.label")} {index + 1}] {subfieldHostAndPort}
|
||||
</span>
|
||||
),
|
||||
extra: !disabled && (
|
||||
<div className="flex items-center justify-end">
|
||||
<Button
|
||||
icon={<IconCircleArrowUp size="1.25em" />}
|
||||
color="default"
|
||||
disabled={index === 0}
|
||||
size="small"
|
||||
type="text"
|
||||
onClick={(e) => {
|
||||
move(index, index - 1);
|
||||
e.stopPropagation();
|
||||
}}
|
||||
/>
|
||||
<Button
|
||||
icon={<IconCircleArrowDown size="1.25em" />}
|
||||
color="default"
|
||||
disabled={index === fields.length - 1}
|
||||
size="small"
|
||||
type="text"
|
||||
onClick={(e) => {
|
||||
move(index, index + 1);
|
||||
e.stopPropagation();
|
||||
}}
|
||||
/>
|
||||
<Button
|
||||
icon={<IconCircleMinus size="1.25em" />}
|
||||
color="default"
|
||||
size="small"
|
||||
type="text"
|
||||
onClick={(e) => {
|
||||
remove(index);
|
||||
e.stopPropagation();
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
),
|
||||
children: (
|
||||
<>
|
||||
<div className="flex space-x-2">
|
||||
<div className="w-2/3">
|
||||
<Form.Item name={[index, "host"]} label={t("access.form.ssh_host.label")} shouldUpdate rules={[formRule]}>
|
||||
<Input placeholder={t("access.form.ssh_host.placeholder")} />
|
||||
</Form.Item>
|
||||
</div>
|
||||
<div className="w-1/3">
|
||||
<Form.Item name={[index, "port"]} label={t("access.form.ssh_port.label")} shouldUpdate rules={[formRule]}>
|
||||
<InputNumber style={{ width: "100%" }} placeholder={t("access.form.ssh_port.placeholder")} min={1} max={65535} />
|
||||
</Form.Item>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Form.Item name={[index, "authMethod"]} label={t("access.form.ssh_auth_method.label")} shouldUpdate rules={[formRule]}>
|
||||
<Radio.Group
|
||||
options={[AUTH_METHOD_NONE, AUTH_METHOD_PASSWORD, AUTH_METHOD_KEY].map((s) => ({
|
||||
key: s,
|
||||
label: t(`access.form.ssh_auth_method.option.${s}.label`),
|
||||
value: s,
|
||||
}))}
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name={[index, "username"]} label={t("access.form.ssh_username.label")} shouldUpdate rules={[formRule]}>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.ssh_username.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Show when={subfieldAuthMethod === AUTH_METHOD_PASSWORD}>
|
||||
<Form.Item name={[index, "password"]} label={t("access.form.ssh_password.label")} shouldUpdate rules={[formRule]}>
|
||||
<Input.Password allowClear autoComplete="new-password" placeholder={t("access.form.ssh_password.placeholder")} />
|
||||
</Form.Item>
|
||||
</Show>
|
||||
|
||||
<Show when={subfieldAuthMethod === AUTH_METHOD_KEY}>
|
||||
<Form.Item name={[index, "key"]} label={t("access.form.ssh_key.label")} shouldUpdate rules={[formRule]}>
|
||||
<TextFileInput allowClear autoSize={{ minRows: 1, maxRows: 5 }} placeholder={t("access.form.ssh_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name={[index, "keyPassphrase"]} label={t("access.form.ssh_key_passphrase.label")} shouldUpdate rules={[formRule]}>
|
||||
<Input.Password allowClear autoComplete="new-password" placeholder={t("access.form.ssh_key_passphrase.placeholder")} />
|
||||
</Form.Item>
|
||||
</Show>
|
||||
</>
|
||||
),
|
||||
};
|
||||
})}
|
||||
/>
|
||||
) : null}
|
||||
<Button
|
||||
className="w-full"
|
||||
type="dashed"
|
||||
icon={<IconCirclePlus size="1.25em" />}
|
||||
onClick={() => {
|
||||
add();
|
||||
setTimeout(() => {
|
||||
const jumpServer = getInitialValues();
|
||||
delete jumpServer.jumpServers;
|
||||
formInst.setFieldValue([parentNamePath, "jumpServers", (fieldJumpServers?.length ?? 0) + 1 - 1], jumpServer);
|
||||
}, 0);
|
||||
}}
|
||||
>
|
||||
{t("access.form.ssh_jump_servers.add")}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</Form.List>
|
||||
<Form.Item name={[parentNamePath, "jumpServers"]} noStyle rules={[formRule]} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
host: "127.0.0.1",
|
||||
port: 22,
|
||||
authMethod: AUTH_METHOD_PASSWORD,
|
||||
username: "root",
|
||||
};
|
||||
};
|
||||
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
const baseSchema = z
|
||||
.object({
|
||||
host: z.string().refine((v) => validDomainName(v) || validIPv4Address(v) || validIPv6Address(v), t("common.errmsg.host_invalid")),
|
||||
port: z.preprocess(
|
||||
(v) => Number(v),
|
||||
z
|
||||
.number()
|
||||
.int(t("access.form.ssh_port.placeholder"))
|
||||
.refine((v) => validPortNumber(v), t("common.errmsg.port_invalid"))
|
||||
),
|
||||
authMethod: z.literal([AUTH_METHOD_NONE, AUTH_METHOD_PASSWORD, AUTH_METHOD_KEY], t("access.form.ssh_auth_method.placeholder")),
|
||||
username: z
|
||||
.string()
|
||||
.min(1, t("access.form.ssh_username.placeholder"))
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
password: z
|
||||
.string()
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 }))
|
||||
.nullish(),
|
||||
key: z
|
||||
.string()
|
||||
.max(20480, t("common.errmsg.string_max", { max: 20480 }))
|
||||
.nullish(),
|
||||
keyPassphrase: z
|
||||
.string()
|
||||
.max(20480, t("common.errmsg.string_max", { max: 20480 }))
|
||||
.nullish(),
|
||||
})
|
||||
.superRefine((values, ctx) => {
|
||||
switch (values.authMethod) {
|
||||
case AUTH_METHOD_PASSWORD:
|
||||
{
|
||||
if (!values.password?.trim()) {
|
||||
ctx.addIssue({
|
||||
code: "custom",
|
||||
message: t("access.form.ssh_password.placeholder"),
|
||||
path: ["password"],
|
||||
});
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case AUTH_METHOD_KEY:
|
||||
{
|
||||
if (!values.key?.trim()) {
|
||||
ctx.addIssue({
|
||||
code: "custom",
|
||||
message: t("access.form.ssh_key.placeholder"),
|
||||
path: ["key"],
|
||||
});
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
return baseSchema.safeExtend({
|
||||
jumpServers: z
|
||||
.array(baseSchema, t("access.form.ssh_jump_servers.errmsg.invalid"))
|
||||
.nullish()
|
||||
.refine((v) => {
|
||||
if (v == null) return true;
|
||||
return v.every((item) => baseSchema.safeParse(item).success);
|
||||
}, t("access.form.ssh_jump_servers.errmsg.invalid")),
|
||||
});
|
||||
};
|
||||
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderSSH, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+46
-50
@@ -1,31 +1,56 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForSSLCom } from "@/domain/access";
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
type AccessFormSSLComConfigFieldValues = Nullish<AccessConfigForSSLCom>;
|
||||
const AccessConfigFormFieldsProviderSSLCom = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
export interface AccessFormSSLComConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormSSLComConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormSSLComConfigFieldValues) => void;
|
||||
}
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
const initFormModel = (): AccessFormSSLComConfigFieldValues => {
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "eabKid"]}
|
||||
initialValue={initialValues.eabKid}
|
||||
label={t("access.form.sslcom_eab_kid.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.sslcom_eab_kid.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.sslcom_eab_kid.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "eabHmacKey"]}
|
||||
initialValue={initialValues.eabHmacKey}
|
||||
label={t("access.form.sslcom_eab_hmac_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.sslcom_eab_hmac_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.sslcom_eab_hmac_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
eabKid: "",
|
||||
eabHmacKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormSSLComConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormSSLComConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
const formSchema = z.object({
|
||||
return z.object({
|
||||
eabKid: z
|
||||
.string()
|
||||
.min(1, t("access.form.sslcom_eab_kid.placeholder"))
|
||||
@@ -35,40 +60,11 @@ const AccessFormSSLComConfig = ({ form: formInst, formName, disabled, initialVal
|
||||
.min(1, t("access.form.sslcom_eab_hmac_key.placeholder"))
|
||||
.max(256, t("common.errmsg.string_max", { max: 256 })),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="eabKid"
|
||||
label={t("access.form.sslcom_eab_kid.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.sslcom_eab_kid.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.sslcom_eab_kid.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="eabHmacKey"
|
||||
label={t("access.form.sslcom_eab_hmac_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.sslcom_eab_hmac_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.sslcom_eab_hmac_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormSSLComConfig;
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderSSLCom, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
@@ -0,0 +1,79 @@
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input, Switch } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
const AccessConfigFormFieldsProviderSafeLine = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "serverUrl"]}
|
||||
initialValue={initialValues.serverUrl}
|
||||
label={t("access.form.safeline_server_url.label")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<Input placeholder={t("access.form.safeline_server_url.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "apiToken"]}
|
||||
initialValue={initialValues.apiToken}
|
||||
label={t("access.form.safeline_api_token.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.safeline_api_token.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.safeline_api_token.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "allowInsecureConnections"]}
|
||||
initialValue={initialValues.allowInsecureConnections}
|
||||
label={t("access.form.common_allow_insecure_conns.label")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<Switch
|
||||
checkedChildren={t("access.form.common_allow_insecure_conns.switch.on")}
|
||||
unCheckedChildren={t("access.form.common_allow_insecure_conns.switch.off")}
|
||||
/>
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
serverUrl: "http://<your-host-addr>:9443/",
|
||||
apiToken: "",
|
||||
};
|
||||
};
|
||||
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
return z.object({
|
||||
serverUrl: z.url(t("common.errmsg.url_invalid")),
|
||||
apiToken: z
|
||||
.string()
|
||||
.min(1, t("access.form.safeline_api_token.placeholder"))
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
allowInsecureConnections: z.boolean().nullish(),
|
||||
});
|
||||
};
|
||||
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderSafeLine, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+38
-42
@@ -1,53 +1,25 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForSlackBot } from "@/domain/access";
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
type AccessFormSlackBotConfigFieldValues = Nullish<AccessConfigForSlackBot>;
|
||||
|
||||
export interface AccessFormSlackBotConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormSlackBotConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormSlackBotConfigFieldValues) => void;
|
||||
}
|
||||
|
||||
const initFormModel = (): AccessFormSlackBotConfigFieldValues => {
|
||||
return {
|
||||
botToken: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormSlackBotConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormSlackBotConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const AccessConfigFormFieldsProviderSlackBot = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
botToken: z
|
||||
.string()
|
||||
.min(1, t("access.form.slackbot_token.placeholder"))
|
||||
.max(256, t("common.errmsg.string_max", { max: 256 })),
|
||||
channelId: z.string().nullish(),
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<>
|
||||
<Form.Item
|
||||
name="botToken"
|
||||
name={[parentNamePath, "botToken"]}
|
||||
initialValue={initialValues.botToken}
|
||||
label={t("access.form.slackbot_token.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.slackbot_token.tooltip") }}></span>}
|
||||
@@ -56,7 +28,8 @@ const AccessFormSlackBotConfig = ({ form: formInst, formName, disabled, initialV
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="channelId"
|
||||
name={[parentNamePath, "channelId"]}
|
||||
initialValue={initialValues.channelId}
|
||||
label={t("access.form.slackbot_channel_id.label")}
|
||||
extra={t("access.form.slackbot_channel_id.help")}
|
||||
rules={[formRule]}
|
||||
@@ -64,8 +37,31 @@ const AccessFormSlackBotConfig = ({ form: formInst, formName, disabled, initialV
|
||||
>
|
||||
<Input allowClear placeholder={t("access.form.slackbot_channel_id.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormSlackBotConfig;
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
botToken: "",
|
||||
};
|
||||
};
|
||||
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
return z.object({
|
||||
botToken: z
|
||||
.string()
|
||||
.min(1, t("access.form.slackbot_token.placeholder"))
|
||||
.max(256, t("common.errmsg.string_max", { max: 256 })),
|
||||
channelId: z.string().nullish(),
|
||||
});
|
||||
};
|
||||
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderSlackBot, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
@@ -0,0 +1,64 @@
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
const AccessConfigFormFieldsProviderSpaceship = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "apiKey"]}
|
||||
initialValue={initialValues.apiKey}
|
||||
label={t("access.form.spaceship_api_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.spaceship_api_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.spaceship_api_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "apiSecret"]}
|
||||
initialValue={initialValues.apiSecret}
|
||||
label={t("access.form.spaceship_api_secret.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.spaceship_api_secret.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.spaceship_api_secret.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
apiKey: "",
|
||||
apiSecret: "",
|
||||
};
|
||||
};
|
||||
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
return z.object({
|
||||
apiKey: z.string().nonempty(t("access.form.spaceship_api_key.placeholder")),
|
||||
apiSecret: z.string().nonempty(t("access.form.spaceship_api_secret.placeholder")),
|
||||
});
|
||||
};
|
||||
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderSpaceship, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+47
-51
@@ -1,30 +1,56 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForTelegramBot } from "@/domain/access";
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
type AccessFormTelegramBotConfigFieldValues = Nullish<AccessConfigForTelegramBot>;
|
||||
const AccessConfigFormFieldsProviderTelegramBot = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
export interface AccessFormTelegramBotConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormTelegramBotConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormTelegramBotConfigFieldValues) => void;
|
||||
}
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
const initFormModel = (): AccessFormTelegramBotConfigFieldValues => {
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "botToken"]}
|
||||
initialValue={initialValues.botToken}
|
||||
label={t("access.form.telegrambot_token.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.telegrambot_token.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.telegrambot_token.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "chatId"]}
|
||||
initialValue={initialValues.chatId}
|
||||
label={t("access.form.telegrambot_chat_id.label")}
|
||||
extra={t("access.form.telegrambot_chat_id.help")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.telegrambot_chat_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input allowClear placeholder={t("access.form.telegrambot_chat_id.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
botToken: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormTelegramBotConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormTelegramBotConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
const formSchema = z.object({
|
||||
return z.object({
|
||||
botToken: z
|
||||
.string()
|
||||
.min(1, t("access.form.telegrambot_token.placeholder"))
|
||||
@@ -38,41 +64,11 @@ const AccessFormTelegramBotConfig = ({ form: formInst, formName, disabled, initi
|
||||
)
|
||||
.nullish(),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="botToken"
|
||||
label={t("access.form.telegrambot_token.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.telegrambot_token.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.telegrambot_token.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="chatId"
|
||||
label={t("access.form.telegrambot_chat_id.label")}
|
||||
extra={t("access.form.telegrambot_chat_id.help")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.telegrambot_chat_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input allowClear placeholder={t("access.form.telegrambot_chat_id.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormTelegramBotConfig;
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderTelegramBot, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+46
-50
@@ -1,31 +1,56 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForTencentCloud } from "@/domain/access";
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
type AccessFormTencentCloudConfigFieldValues = Nullish<AccessConfigForTencentCloud>;
|
||||
const AccessConfigFormFieldsProviderTencentCloud = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
export interface AccessFormTencentCloudConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormTencentCloudConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormTencentCloudConfigFieldValues) => void;
|
||||
}
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
const initFormModel = (): AccessFormTencentCloudConfigFieldValues => {
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "secretId"]}
|
||||
initialValue={initialValues.secretId}
|
||||
label={t("access.form.tencentcloud_secret_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.tencentcloud_secret_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.tencentcloud_secret_id.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "secretKey"]}
|
||||
initialValue={initialValues.secretKey}
|
||||
label={t("access.form.tencentcloud_secret_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.tencentcloud_secret_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.tencentcloud_secret_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
secretId: "",
|
||||
secretKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormTencentCloudConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormTencentCloudConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
const formSchema = z.object({
|
||||
return z.object({
|
||||
secretId: z
|
||||
.string()
|
||||
.min(1, t("access.form.tencentcloud_secret_id.placeholder"))
|
||||
@@ -35,40 +60,11 @@ const AccessFormTencentCloudConfig = ({ form: formInst, formName, disabled, init
|
||||
.min(1, t("access.form.tencentcloud_secret_key.placeholder"))
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="secretId"
|
||||
label={t("access.form.tencentcloud_secret_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.tencentcloud_secret_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.tencentcloud_secret_id.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="secretKey"
|
||||
label={t("access.form.tencentcloud_secret_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.tencentcloud_secret_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.tencentcloud_secret_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormTencentCloudConfig;
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderTencentCloud, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+56
-59
@@ -1,31 +1,66 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForUCloud } from "@/domain/access";
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
type AccessFormUCloudConfigFieldValues = Nullish<AccessConfigForUCloud>;
|
||||
const AccessConfigFormFieldsProviderUCloud = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
export interface AccessFormUCloudConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormUCloudConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormUCloudConfigFieldValues) => void;
|
||||
}
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
const initFormModel = (): AccessFormUCloudConfigFieldValues => {
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "privateKey"]}
|
||||
initialValue={initialValues.privateKey}
|
||||
label={t("access.form.ucloud_private_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.ucloud_private_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.ucloud_private_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "publicKey"]}
|
||||
initialValue={initialValues.publicKey}
|
||||
label={t("access.form.ucloud_public_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.ucloud_public_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.ucloud_public_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "projectId"]}
|
||||
initialValue={initialValues.projectId}
|
||||
label={t("access.form.ucloud_project_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.ucloud_project_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input allowClear autoComplete="new-password" placeholder={t("access.form.ucloud_project_id.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
privateKey: "",
|
||||
publicKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormUCloudConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormUCloudConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
const formSchema = z.object({
|
||||
return z.object({
|
||||
privateKey: z
|
||||
.string()
|
||||
.min(1, t("access.form.ucloud_private_key.placeholder"))
|
||||
@@ -39,49 +74,11 @@ const AccessFormUCloudConfig = ({ form: formInst, formName, disabled, initialVal
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 }))
|
||||
.nullish(),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="privateKey"
|
||||
label={t("access.form.ucloud_private_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.ucloud_private_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.ucloud_private_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="publicKey"
|
||||
label={t("access.form.ucloud_public_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.ucloud_public_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.ucloud_public_key.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="projectId"
|
||||
label={t("access.form.ucloud_project_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.ucloud_project_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input allowClear autoComplete="new-password" placeholder={t("access.form.ucloud_project_id.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormUCloudConfig;
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderUCloud, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
@@ -0,0 +1,64 @@
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
const AccessConfigFormFieldsProviderUniCloud = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "username"]}
|
||||
initialValue={initialValues.username}
|
||||
label={t("access.form.unicloud_username.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.unicloud_username.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.unicloud_username.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "password"]}
|
||||
initialValue={initialValues.password}
|
||||
label={t("access.form.unicloud_password.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.unicloud_password.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.unicloud_password.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
username: "",
|
||||
password: "",
|
||||
};
|
||||
};
|
||||
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
return z.object({
|
||||
username: z.string().nonempty(t("access.form.unicloud_username.placeholder")),
|
||||
password: z.string().nonempty(t("access.form.unicloud_password.placeholder")),
|
||||
});
|
||||
};
|
||||
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderUniCloud, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+46
-50
@@ -1,31 +1,56 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForUpyun } from "@/domain/access";
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
type AccessFormUpyunConfigFieldValues = Nullish<AccessConfigForUpyun>;
|
||||
const AccessConfigFormFieldsProviderUpyun = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
export interface AccessFormUpyunConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormUpyunConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormUpyunConfigFieldValues) => void;
|
||||
}
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
const initFormModel = (): AccessFormUpyunConfigFieldValues => {
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "username"]}
|
||||
initialValue={initialValues.username}
|
||||
label={t("access.form.upyun_username.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.upyun_username.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.upyun_username.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "password"]}
|
||||
initialValue={initialValues.password}
|
||||
label={t("access.form.upyun_password.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.upyun_password.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.upyun_password.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
username: "",
|
||||
password: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormUpyunConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormUpyunConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
const formSchema = z.object({
|
||||
return z.object({
|
||||
username: z
|
||||
.string()
|
||||
.min(1, t("access.form.upyun_username.placeholder"))
|
||||
@@ -35,40 +60,11 @@ const AccessFormUpyunConfig = ({ form: formInst, formName, disabled, initialValu
|
||||
.min(1, t("access.form.upyun_password.placeholder"))
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="username"
|
||||
label={t("access.form.upyun_username.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.upyun_username.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.upyun_username.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="password"
|
||||
label={t("access.form.upyun_password.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.upyun_password.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.upyun_password.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormUpyunConfig;
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderUpyun, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+46
-50
@@ -1,30 +1,55 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForVercel } from "@/domain/access";
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
type AccessFormVercelConfigFieldValues = Nullish<AccessConfigForVercel>;
|
||||
const AccessConfigFormFieldsProviderVercel = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
export interface AccessFormVercelConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormVercelConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormVercelConfigFieldValues) => void;
|
||||
}
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
const initFormModel = (): AccessFormVercelConfigFieldValues => {
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "apiAccessToken"]}
|
||||
initialValue={initialValues.apiAccessToken}
|
||||
label={t("access.form.vercel_api_access_token.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.vercel_api_access_token.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.vercel_api_access_token.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "teamId"]}
|
||||
initialValue={initialValues.teamId}
|
||||
label={t("access.form.vercel_team_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.vercel_team_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input allowClear placeholder={t("access.form.vercel_team_id.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
apiAccessToken: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormVercelConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormVercelConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
const formSchema = z.object({
|
||||
return z.object({
|
||||
apiAccessToken: z
|
||||
.string()
|
||||
.min(1, t("access.form.vercel_api_access_token.placeholder"))
|
||||
@@ -34,40 +59,11 @@ const AccessFormVercelConfig = ({ form: formInst, formName, disabled, initialVal
|
||||
.max(256, t("common.errmsg.string_max", { max: 256 }))
|
||||
.nullish(),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="apiAccessToken"
|
||||
label={t("access.form.vercel_api_access_token.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.vercel_api_access_token.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.vercel_api_access_token.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="teamId"
|
||||
label={t("access.form.vercel_team_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.vercel_team_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input allowClear placeholder={t("access.form.vercel_team_id.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormVercelConfig;
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderVercel, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+46
-50
@@ -1,31 +1,56 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForVolcEngine } from "@/domain/access";
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
type AccessFormVolcEngineConfigFieldValues = Nullish<AccessConfigForVolcEngine>;
|
||||
const AccessConfigFormFieldsProviderVolcEngine = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
export interface AccessFormVolcEngineConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormVolcEngineConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormVolcEngineConfigFieldValues) => void;
|
||||
}
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
const initFormModel = (): AccessFormVolcEngineConfigFieldValues => {
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "accessKeyId"]}
|
||||
initialValue={initialValues.accessKeyId}
|
||||
label={t("access.form.volcengine_access_key_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.volcengine_access_key_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.volcengine_access_key_id.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "secretAccessKey"]}
|
||||
initialValue={initialValues.secretAccessKey}
|
||||
label={t("access.form.volcengine_secret_access_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.volcengine_secret_access_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.volcengine_secret_access_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
accessKeyId: "",
|
||||
secretAccessKey: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormVolcEngineConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormVolcEngineConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
const formSchema = z.object({
|
||||
return z.object({
|
||||
accessKeyId: z
|
||||
.string()
|
||||
.min(1, t("access.form.volcengine_access_key_id.placeholder"))
|
||||
@@ -35,40 +60,11 @@ const AccessFormVolcEngineConfig = ({ form: formInst, formName, disabled, initia
|
||||
.min(1, t("access.form.volcengine_secret_access_key.placeholder"))
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="accessKeyId"
|
||||
label={t("access.form.volcengine_access_key_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.volcengine_access_key_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.volcengine_access_key_id.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="secretAccessKey"
|
||||
label={t("access.form.volcengine_secret_access_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.volcengine_secret_access_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.volcengine_secret_access_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormVolcEngineConfig;
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderVolcEngine, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+56
-59
@@ -1,21 +1,56 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForWangsu } from "@/domain/access";
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
type AccessFormWangsuConfigFieldValues = Nullish<AccessConfigForWangsu>;
|
||||
const AccessConfigFormFieldsProviderWangsu = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
export interface AccessFormWangsuConfigProps {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormWangsuConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormWangsuConfigFieldValues) => void;
|
||||
}
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
const initFormModel = (): AccessFormWangsuConfigFieldValues => {
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "accessKeyId"]}
|
||||
initialValue={initialValues.accessKeyId}
|
||||
label={t("access.form.wangsu_access_key_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.wangsu_access_key_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.wangsu_access_key_id.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "accessKeySecret"]}
|
||||
initialValue={initialValues.accessKeySecret}
|
||||
label={t("access.form.wangsu_access_key_secret.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.wangsu_access_key_secret.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.wangsu_access_key_secret.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name={[parentNamePath, "apiKey"]}
|
||||
initialValue={initialValues.apiKey}
|
||||
label={t("access.form.wangsu_api_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.wangsu_api_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.wangsu_api_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
accessKeyId: "",
|
||||
accessKeySecret: "",
|
||||
@@ -23,10 +58,10 @@ const initFormModel = (): AccessFormWangsuConfigFieldValues => {
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormWangsuConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange: onValuesChange }: AccessFormWangsuConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
|
||||
const { t } = i18n;
|
||||
|
||||
const formSchema = z.object({
|
||||
return z.object({
|
||||
accessKeyId: z
|
||||
.string()
|
||||
.min(1, t("access.form.wangsu_access_key_id.placeholder"))
|
||||
@@ -40,49 +75,11 @@ const AccessFormWangsuConfig = ({ form: formInst, formName, disabled, initialVal
|
||||
.min(1, t("access.form.wangsu_api_key.placeholder"))
|
||||
.max(256, t("common.errmsg.string_max", { max: 256 })),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="accessKeyId"
|
||||
label={t("access.form.wangsu_access_key_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.wangsu_access_key_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input autoComplete="new-password" placeholder={t("access.form.wangsu_access_key_id.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="accessKeySecret"
|
||||
label={t("access.form.wangsu_access_key_secret.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.wangsu_access_key_secret.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.wangsu_access_key_secret.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="apiKey"
|
||||
label={t("access.form.wangsu_api_key.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.wangsu_api_key.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.wangsu_api_key.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormWangsuConfig;
|
||||
const _default = Object.assign(AccessConfigFormFieldsProviderWangsu, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user