From f8863959b54da89bc000c8368819906628a7f266 Mon Sep 17 00:00:00 2001 From: chenos Date: Wed, 16 Feb 2022 22:45:03 +0800 Subject: [PATCH] feat(client): add Action.Link schema component --- .../antd/action/Action.Link.tsx | 31 +++++++++++++++++++ .../schema-component/antd/action/Action.tsx | 2 ++ 2 files changed, 33 insertions(+) create mode 100644 packages/client/src/schema-component/antd/action/Action.Link.tsx diff --git a/packages/client/src/schema-component/antd/action/Action.Link.tsx b/packages/client/src/schema-component/antd/action/Action.Link.tsx new file mode 100644 index 0000000000..d28a154704 --- /dev/null +++ b/packages/client/src/schema-component/antd/action/Action.Link.tsx @@ -0,0 +1,31 @@ +import { observer, RecursionField, useField, useFieldSchema } from '@formily/react'; +import React, { useState } from 'react'; +import { Link } from 'react-router-dom'; +import { ActionContext } from './context'; +import { useA } from './hooks'; +import { ComposedAction } from './types'; + +export const ActionLink: ComposedAction = observer((props: any) => { + const { openMode, containerRefKey, useAction = useA, onClick, ...others } = props; + const [visible, setVisible] = useState(false); + const schema = useFieldSchema(); + const field = useField(); + const { run } = useAction(); + return ( + + { + onClick && onClick(e); + setVisible(true); + run(); + }} + > + {field.title} + + + + ); +}); + +export default ActionLink; diff --git a/packages/client/src/schema-component/antd/action/Action.tsx b/packages/client/src/schema-component/antd/action/Action.tsx index a461a6f8a0..d94027398c 100644 --- a/packages/client/src/schema-component/antd/action/Action.tsx +++ b/packages/client/src/schema-component/antd/action/Action.tsx @@ -3,6 +3,7 @@ import { Button } from 'antd'; import React, { useState } from 'react'; import ActionContainer from './Action.Container'; import { ActionDrawer } from './Action.Drawer'; +import { ActionLink } from './Action.Link'; import { ActionModal } from './Action.Modal'; import { ActionPage } from './Action.Page'; import { ActionContext } from './context'; @@ -32,6 +33,7 @@ export const Action: ComposedAction = observer((props: any) => { ); }); +Action.Link = ActionLink; Action.Drawer = ActionDrawer; Action.Modal = ActionModal; Action.Container = ActionContainer;