PHP 8.2.30
Preview: base-action-component.js Size: 2.43 KB
//proc/thread-self/root/home/byroehnu/.trash/node_modules11/adminjs/lib/frontend/components/app/base-action-component.js

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 { useTranslation } from '../../hooks/index.js';
/**
 * Component which renders all the default and custom actions for both the Resource and the Record.
 *
 * It passes all props down to the actual Action component.
 *
 * Example of creating your own actions:
 * ```
 * // AdminJS options
 * const AdminJSOptions = {
 *   resources: [
 *      resource,
 *      options: {
 *        actions: {
 *           myNewAction: {
 *             label: 'amazing action',
 *             icon: 'Add',
 *             inVisible: (resource, record) => record.param('email') !== '',
 *             actionType: 'record',
 *             component: 'MyNewAction',
 *             handler: (request, response, data) => {
 *               return {
 *                  ...
 *               }
 *             }
 *           }
 *        }
 *      }
 *   ]
 * }
 * ```
 *
 * ```
 * // ./my-new-action.js
 * import { Box } from 'adminjs'
 *
 * const MyNewAction = (props) => {
 *   const { resource, action, record } = props
 *   // do something with the props and render action
 *   return (
 *     <Box>Some Action Content</Box>
 *   )
 * }
 * ```
 *
 * @component
 * @name BaseActionComponent
 * @subcategory Application
 */
export const BaseActionComponent = 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 /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement(Action, {
      action: action,
      resource: resource,
      record: record,
      records: records,
      setTag: setTag
    }));
  }
  return Action || /*#__PURE__*/React.createElement(MessageBox, {
    variant: "danger"
  }, translateMessage('noActionComponent'), /*#__PURE__*/React.createElement(Trans, {
    key: "messages.buttons.seeTheDocumentation"
  }, "See:", /*#__PURE__*/React.createElement(Link, {
    ml: "default",
    href: documentationLink
  }, "the documentation")));
};
export default BaseActionComponent;

Directory Contents

Dirs: 6 × Files: 17

Name Size Perms Modified Actions
- drwxr-xr-x 2026-02-28 00:31:42
Edit Download
- drwxr-xr-x 2026-02-28 00:31:50
Edit Download
- drwxr-xr-x 2026-02-28 00:31:44
Edit Download
- drwxr-xr-x 2026-02-28 00:31:48
Edit Download
sidebar DIR
- drwxr-xr-x 2026-02-28 00:31:50
Edit Download
utils DIR
- drwxr-xr-x 2026-02-28 00:31:48
Edit Download
335 B lrw-r--r-- 2026-02-28 00:29:12
Edit Download
303 B lrw-r--r-- 2026-02-28 00:31:14
Edit Download
481 B lrw-r--r-- 2026-02-28 00:31:14
Edit Download
2.43 KB lrw-r--r-- 2026-02-28 00:31:14
Edit Download
2.87 KB lrw-r--r-- 2026-02-28 00:31:22
Edit Download
6.16 KB lrw-r--r-- 2026-02-28 00:31:26
Edit Download
3.20 KB lrw-r--r-- 2026-02-28 00:31:28
Edit Download
1.02 KB lrw-r--r-- 2026-02-28 00:31:28
Edit Download
2.15 KB lrw-r--r-- 2026-02-28 00:31:28
Edit Download
3.87 KB lrw-r--r-- 2026-02-28 00:31:30
Edit Download
238 B lrw-r--r-- 2026-02-28 00:31:34
Edit Download
775 B lrw-r--r-- 2026-02-28 00:31:44
Edit Download
971 B lrw-r--r-- 2026-02-28 00:31:46
Edit Download
2.61 KB lrw-r--r-- 2026-02-28 00:31:48
Edit Download
1.40 KB lrw-r--r-- 2026-02-28 00:31:50
Edit Download
1.72 KB lrw-r--r-- 2026-02-28 00:31:50
Edit Download
1.13 KB lrw-r--r-- 2026-02-28 00:31:52
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).