| import React from 'react' |
| import { Trans } from 'react-i18next' |
| import { MessageBox, Link } from '@adminjs/design-system' |
|
|
| import ErrorBoundary from './error-boundary.js' |
| import { actions } from '../actions/index.js' |
| import { DOCS } from '../../../constants.js' |
| import { ActionProps } from '../actions/action.props.js' |
| import { useTranslation } from '../../hooks/index.js' |
|
|
| declare const AdminJS: { |
| UserComponents: Array<string>; |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| export const BaseActionComponent: React.FC<ActionProps> = (props) => { |
| const { resource, action, record, records, setTag } = props |
| const documentationLink = [DOCS, 'BaseAction.html'].join('/') |
|
|
| const { translateMessage } = useTranslation() |
|
|
| let Action = actions[action.name] |
|
|
| if (action.component) { |
| Action = AdminJS.UserComponents[action.component] |
| } |
|
|
| if (Action) { |
| return ( |
| <ErrorBoundary> |
| <Action |
| action={action} |
| resource={resource} |
| record={record} |
| records={records} |
| setTag={setTag} |
| /> |
| </ErrorBoundary> |
| ) |
| } |
| return Action || ( |
| <MessageBox variant="danger"> |
| {translateMessage('noActionComponent')} |
| <Trans key="messages.buttons.seeTheDocumentation"> |
| See: |
| <Link ml="default" href={documentationLink}>the documentation</Link> |
| </Trans> |
| </MessageBox> |
| ) |
| } |
|
|
| export default BaseActionComponent |
|
|