mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-08 06:59:26 +08:00
* refactor(plugin-fm): change api and allow to select storage * fix(plugin-fm): fix lint errors and demo actions * refactor(plugin-fm): refactor action codes * fix(plugin-fm): fix api in test * fix(plugin-fm): fix build * fix(plugin-fm): fix locale * refactor(plugin-fm): hide storage from api and use sourceField param * fix(plugin-fm): fix storage select load * fix: improve code * fix(plugin-fm): change to attachmentField * refactor(plugin-fm): change middleware name * fix(plugin-fm): fix params in test cases --------- Co-authored-by: chenos <chenlinxh@gmail.com>
138 lines
3.8 KiB
TypeScript
138 lines
3.8 KiB
TypeScript
import { FormLayout } from '@formily/antd';
|
|
import { Field } from '@formily/core';
|
|
import { observer, RecursionField, Schema, useField, useForm } from '@formily/react';
|
|
import React, { useEffect, useState } from 'react';
|
|
import { NAMESPACE } from './locale';
|
|
|
|
const schema = {
|
|
local: {
|
|
properties: {
|
|
documentRoot: {
|
|
title: `{{t("Destination", { ns: "${NAMESPACE}" })}}`,
|
|
type: 'string',
|
|
'x-decorator': 'FormItem',
|
|
'x-component': 'Input',
|
|
default: 'uploads',
|
|
},
|
|
serve: {
|
|
type: 'string',
|
|
'x-decorator': 'FormItem',
|
|
'x-component': 'Checkbox',
|
|
'x-content': `{{t("Use the built-in static file server", { ns: "${NAMESPACE}" })}}`,
|
|
default: true,
|
|
},
|
|
},
|
|
},
|
|
'ali-oss': {
|
|
properties: {
|
|
region: {
|
|
title: `{{t("Region", { ns: "${NAMESPACE}" })}}`,
|
|
type: 'string',
|
|
'x-decorator': 'FormItem',
|
|
'x-component': 'Input',
|
|
required: true,
|
|
},
|
|
accessKeyId: {
|
|
title: `{{t("AccessKey ID", { ns: "${NAMESPACE}" })}}`,
|
|
type: 'string',
|
|
'x-decorator': 'FormItem',
|
|
'x-component': 'Input',
|
|
required: true,
|
|
},
|
|
accessKeySecret: {
|
|
title: `{{t("AccessKey Secret", { ns: "${NAMESPACE}" })}}`,
|
|
type: 'string',
|
|
'x-decorator': 'FormItem',
|
|
'x-component': 'Password',
|
|
required: true,
|
|
},
|
|
bucket: {
|
|
title: `{{t("Bucket", { ns: "${NAMESPACE}" })}}`,
|
|
type: 'string',
|
|
'x-decorator': 'FormItem',
|
|
'x-component': 'Input',
|
|
required: true,
|
|
},
|
|
},
|
|
},
|
|
'tx-cos': {
|
|
properties: {
|
|
Region: {
|
|
title: `{{t("Region", { ns: "${NAMESPACE}" })}}`,
|
|
type: 'string',
|
|
'x-decorator': 'FormItem',
|
|
'x-component': 'Input',
|
|
required: true,
|
|
},
|
|
SecretId: {
|
|
title: `{{t("SecretId", { ns: "${NAMESPACE}" })}}`,
|
|
type: 'string',
|
|
'x-decorator': 'FormItem',
|
|
'x-component': 'Input',
|
|
required: true,
|
|
},
|
|
SecretKey: {
|
|
title: `{{t("SecretKey", { ns: "${NAMESPACE}" })}}`,
|
|
type: 'string',
|
|
'x-decorator': 'FormItem',
|
|
'x-component': 'Password',
|
|
required: true,
|
|
},
|
|
Bucket: {
|
|
title: `{{t("Bucket", { ns: "${NAMESPACE}" })}}`,
|
|
type: 'string',
|
|
'x-decorator': 'FormItem',
|
|
'x-component': 'Input',
|
|
required: true,
|
|
},
|
|
},
|
|
},
|
|
s3: {
|
|
properties: {
|
|
region: {
|
|
title: `{{t("Region", { ns: "${NAMESPACE}" })}}`,
|
|
type: 'string',
|
|
'x-decorator': 'FormItem',
|
|
'x-component': 'Input',
|
|
required: true,
|
|
},
|
|
accessKeyId: {
|
|
title: `{{t("AccessKey ID", { ns: "${NAMESPACE}" })}}`,
|
|
type: 'string',
|
|
'x-decorator': 'FormItem',
|
|
'x-component': 'Input',
|
|
required: true,
|
|
},
|
|
secretAccessKey: {
|
|
title: `{{t("AccessKey Secret", { ns: "${NAMESPACE}" })}}`,
|
|
type: 'string',
|
|
'x-decorator': 'FormItem',
|
|
'x-component': 'Password',
|
|
required: true,
|
|
},
|
|
bucket: {
|
|
title: `{{t("Bucket", { ns: "${NAMESPACE}" })}}`,
|
|
type: 'string',
|
|
'x-decorator': 'FormItem',
|
|
'x-component': 'Input',
|
|
required: true,
|
|
},
|
|
},
|
|
},
|
|
};
|
|
|
|
export const StorageOptions = observer((props) => {
|
|
const form = useForm();
|
|
const field = useField<Field>();
|
|
const [s, setSchema] = useState(new Schema({}));
|
|
useEffect(() => {
|
|
// form.clearFormGraph('options.*');
|
|
setSchema(new Schema(schema[form.values.type] || {}));
|
|
}, [form.values.type]);
|
|
return (
|
|
<FormLayout layout={'vertical'}>
|
|
<RecursionField key={form.values.type || 'local'} basePath={field.address} onlyRenderProperties schema={s} />
|
|
</FormLayout>
|
|
);
|
|
});
|