mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
refactor: move constants
This commit is contained in:
@@ -4,15 +4,8 @@ import React from 'react'
|
||||
import type {Connector} from '../../api/connectors'
|
||||
import {ConnectorProvider} from '../../api/connectors'
|
||||
import {t} from 'ttag'
|
||||
import {DefaultConnectorFormItems} from "./index"
|
||||
import {providersConfig} from "../index"
|
||||
|
||||
const formItemLayoutWithOutLabel = {
|
||||
wrapperCol: {
|
||||
xs: {span: 24, offset: 0},
|
||||
sm: {span: 20, offset: 4}
|
||||
}
|
||||
}
|
||||
import DefaultConnectorFormItems from "./DefaultConnectorFormItems"
|
||||
import {formItemLayoutWithOutLabel, providersConfig} from "../index"
|
||||
|
||||
export default function AutoDnsConnectorForm({form, onCreate}: {
|
||||
form: FormInstance,
|
||||
@@ -97,7 +90,7 @@ export default function AutoDnsConnectorForm({form, onCreate}: {
|
||||
</Checkbox>
|
||||
</Form.Item>
|
||||
|
||||
<DefaultConnectorFormItems tosLink={providersConfig()[ConnectorProvider.AutoDNS].tosLink}/>
|
||||
<DefaultConnectorFormItems tosLink={providersConfig[ConnectorProvider.AutoDNS].tosLink}/>
|
||||
</Form>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import {Button, Checkbox, Form, Input, Typography} from "antd"
|
||||
import {t} from "ttag"
|
||||
import React from "react"
|
||||
|
||||
export function DefaultConnectorFormItems({tosLink}: { tosLink: string }) {
|
||||
export default function DefaultConnectorFormItems({tosLink}: { tosLink: string }) {
|
||||
return <>
|
||||
<Form.Item name="provider" noStyle>
|
||||
<Input type="hidden" />
|
||||
@@ -47,7 +47,7 @@ export function DefaultConnectorFormItems({tosLink}: { tosLink: string }) {
|
||||
</Form.Item>
|
||||
|
||||
|
||||
<Form.Item style={{marginTop: '5vh', textAlign: 'center'}}>
|
||||
<Form.Item style={{marginTop: '5em', textAlign: 'center'}}>
|
||||
<Button type='primary' htmlType='submit'>
|
||||
{t`Create`}
|
||||
</Button>
|
||||
@@ -4,7 +4,7 @@ import React from 'react'
|
||||
import type {Connector} from '../../api/connectors'
|
||||
import {ConnectorProvider} from '../../api/connectors'
|
||||
import {t} from 'ttag'
|
||||
import {DefaultConnectorFormItems} from "./index"
|
||||
import DefaultConnectorFormItems from "./DefaultConnectorFormItems"
|
||||
import {providersConfig} from "../index"
|
||||
|
||||
const formItemLayoutWithOutLabel = {
|
||||
@@ -48,7 +48,7 @@ export default function GandiConnectorForm({form, onCreate}: {
|
||||
>
|
||||
<Input autoComplete='off' placeholder='xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'/>
|
||||
</Form.Item>
|
||||
<DefaultConnectorFormItems tosLink={providersConfig()[ConnectorProvider.Gandi].tosLink}/>
|
||||
<DefaultConnectorFormItems tosLink={providersConfig[ConnectorProvider.Gandi].tosLink}/>
|
||||
|
||||
</Form>
|
||||
)
|
||||
|
||||
@@ -4,15 +4,8 @@ import React from 'react'
|
||||
import type {Connector} from '../../api/connectors'
|
||||
import {ConnectorProvider} from '../../api/connectors'
|
||||
import {t} from 'ttag'
|
||||
import {DefaultConnectorFormItems} from "./index"
|
||||
import {providersConfig} from "../index"
|
||||
|
||||
const formItemLayoutWithOutLabel = {
|
||||
wrapperCol: {
|
||||
xs: {span: 24, offset: 0},
|
||||
sm: {span: 20, offset: 4}
|
||||
}
|
||||
}
|
||||
import DefaultConnectorFormItems from "./DefaultConnectorFormItems"
|
||||
import {formItemLayoutWithOutLabel, providersConfig} from "../index"
|
||||
|
||||
export default function NamecheapConnectorForm({form, onCreate}: {
|
||||
form: FormInstance,
|
||||
@@ -43,7 +36,7 @@ export default function NamecheapConnectorForm({form, onCreate}: {
|
||||
>
|
||||
<Input autoComplete='off'/>
|
||||
</Form.Item>
|
||||
<DefaultConnectorFormItems tosLink={providersConfig()[ConnectorProvider.Namecheap].tosLink}/>
|
||||
<DefaultConnectorFormItems tosLink={providersConfig[ConnectorProvider.Namecheap].tosLink}/>
|
||||
</Form>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -4,15 +4,8 @@ import React from 'react'
|
||||
import type {Connector} from '../../api/connectors'
|
||||
import {ConnectorProvider} from '../../api/connectors'
|
||||
import {t} from 'ttag'
|
||||
import {DefaultConnectorFormItems} from "./index"
|
||||
import {providersConfig} from "../index"
|
||||
|
||||
const formItemLayoutWithOutLabel = {
|
||||
wrapperCol: {
|
||||
xs: {span: 24, offset: 0},
|
||||
sm: {span: 20, offset: 4}
|
||||
}
|
||||
}
|
||||
import DefaultConnectorFormItems from "./DefaultConnectorFormItems"
|
||||
import {formItemLayoutWithOutLabel, providersConfig} from "../index"
|
||||
|
||||
export default function NamecomConnectorForm({form, onCreate}: {
|
||||
form: FormInstance,
|
||||
@@ -47,7 +40,7 @@ export default function NamecomConnectorForm({form, onCreate}: {
|
||||
>
|
||||
<Input autoComplete='off'/>
|
||||
</Form.Item>
|
||||
<DefaultConnectorFormItems tosLink={providersConfig()[ConnectorProvider["Name.com"]].tosLink}/>
|
||||
<DefaultConnectorFormItems tosLink={providersConfig[ConnectorProvider["Name.com"]].tosLink}/>
|
||||
</Form>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -5,15 +5,8 @@ import type {FormInstance} from "antd"
|
||||
import {Form, Input, Popconfirm, Select} from "antd"
|
||||
import type {Connector} from "../../api/connectors"
|
||||
import {ConnectorProvider} from "../../api/connectors"
|
||||
import {DefaultConnectorFormItems} from "./index"
|
||||
import {providersConfig} from "../index"
|
||||
|
||||
const formItemLayoutWithOutLabel = {
|
||||
wrapperCol: {
|
||||
xs: {span: 24, offset: 0},
|
||||
sm: {span: 20, offset: 4}
|
||||
}
|
||||
}
|
||||
import DefaultConnectorFormItems from "./DefaultConnectorFormItems"
|
||||
import {formItemLayoutWithOutLabel, providersConfig} from "../index"
|
||||
|
||||
export default function OvhCloudConnectorForm({form, onCreate}: {
|
||||
form: FormInstance,
|
||||
@@ -24,20 +17,16 @@ export default function OvhCloudConnectorForm({form, onCreate}: {
|
||||
|
||||
form.setFieldValue('provider', ConnectorProvider.OVHcloud)
|
||||
|
||||
const ovhFields = {
|
||||
appKey: t`Application key`,
|
||||
appSecret: t`Application secret`,
|
||||
consumerKey: t`Consumer key`
|
||||
}
|
||||
const ovhEndpointList = [
|
||||
{
|
||||
label: t`European Region`,
|
||||
value: 'ovh-eu'
|
||||
}
|
||||
{label: t`European Region`, value: 'ovh-eu'},
|
||||
{label: t`United States Region`, value: 'ovh-us'},
|
||||
{label: t`Canada Region`, value: 'ovh-ca'}
|
||||
]
|
||||
|
||||
const ovhSubsidiaryList = [...[
|
||||
'CZ', 'DE', 'ES', 'FI', 'FR', 'GB', 'IE', 'IT', 'LT', 'MA', 'NL', 'PL', 'PT', 'SN', 'TN'
|
||||
].map(c => ({value: c, label: regionNames.of(c) ?? c})), {value: 'EU', label: t`Europe`}]
|
||||
|
||||
const ovhPricingMode = [
|
||||
{value: 'create-default', label: t`The domain is free and at the standard price`},
|
||||
{
|
||||
@@ -55,16 +44,38 @@ export default function OvhCloudConnectorForm({form, onCreate}: {
|
||||
wrapperCol={{span: 14}}
|
||||
onFinish={onCreate}
|
||||
>
|
||||
{
|
||||
Object.keys(ovhFields).map(fieldName => <Form.Item
|
||||
key={ovhFields[fieldName as keyof typeof ovhFields]}
|
||||
label={ovhFields[fieldName as keyof typeof ovhFields]}
|
||||
name={['authData', fieldName]}
|
||||
rules={[{required: true, message: t`Required`}]}
|
||||
>
|
||||
<Input autoComplete='off'/>
|
||||
</Form.Item>)
|
||||
}
|
||||
<Form.Item
|
||||
label={t`Application key`}
|
||||
name={['authData', 'appKey']}
|
||||
rules={[{required: true, message: t`Required`}]}
|
||||
>
|
||||
<Input autoComplete='off'/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label={t`Application secret`}
|
||||
name={['authData', 'appSecret']}
|
||||
rules={[{required: true, message: t`Required`}]}
|
||||
>
|
||||
<Input autoComplete='off'/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label={t`Consumer key`}
|
||||
name={['authData', 'consumerKey']}
|
||||
rules={[{required: true, message: t`Required`}]}
|
||||
>
|
||||
<Input autoComplete='off'/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label={t`Application key`}
|
||||
name={['authData', 'appKey']}
|
||||
rules={[{required: true, message: t`Required`}]}
|
||||
>
|
||||
<Input autoComplete='off'/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label={t`OVH Endpoint`}
|
||||
name={['authData', 'apiEndpoint']}
|
||||
@@ -108,7 +119,7 @@ export default function OvhCloudConnectorForm({form, onCreate}: {
|
||||
/>
|
||||
</Popconfirm>
|
||||
</Form.Item>
|
||||
<DefaultConnectorFormItems tosLink={providersConfig()[ConnectorProvider.OVHcloud].tosLink}/>
|
||||
<DefaultConnectorFormItems tosLink={providersConfig[ConnectorProvider.OVHcloud].tosLink}/>
|
||||
</Form>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user