tachybase_todo/packages/plugins/file-manager/src/client/initializers/UploadActionInitializer.tsx
Junyi 36d16bc015
refactor(plugin-fm): change api and allow to select storage (#1250)
* 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>
2023-06-06 19:30:42 +08:00

43 lines
1.1 KiB
TypeScript

import { ActionInitializer, useCollection } from '@nocobase/client';
import React from 'react';
export const UploadActionInitializer = (props) => {
const collection = useCollection();
const schema = {
type: 'void',
'x-action': 'create',
title: "{{t('Upload')}}",
'x-designer': 'Action.Designer',
'x-component': 'Action',
'x-decorator': 'ACLActionProvider',
'x-component-props': {
openMode: 'drawer',
type: 'primary',
icon: 'UploadOutlined',
},
properties: {
drawer: {
type: 'void',
title: '{{ t("Upload files") }}',
'x-component': 'Action.Container',
properties: {
upload: {
type: 'void',
title: '{{ t("Upload files") }}',
'x-component': 'Upload.DraggerV2',
'x-component-props': {
height: '50vh',
action: `${collection.name}:create`,
useProps: '{{useUploadFiles}}',
multiple: true,
listType: 'picture',
},
},
},
},
},
};
return <ActionInitializer {...props} schema={schema} />;
};