mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 11:56:29 +00:00
feat(client): add Action.Link schema component
This commit is contained in:
parent
022c173f7e
commit
f8863959b5
@ -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 (
|
||||
<ActionContext.Provider value={{ visible, setVisible, openMode, containerRefKey }}>
|
||||
<Link
|
||||
{...others}
|
||||
onClick={(e) => {
|
||||
onClick && onClick(e);
|
||||
setVisible(true);
|
||||
run();
|
||||
}}
|
||||
>
|
||||
{field.title}
|
||||
</Link>
|
||||
<RecursionField basePath={field.address} schema={schema} onlyRenderProperties />
|
||||
</ActionContext.Provider>
|
||||
);
|
||||
});
|
||||
|
||||
export default ActionLink;
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user