PHP 8.2.30
Preview: error-message.tsx Size: 2.25 KB
//proc/thread-self/root/home/byroehnu/.trash/node_modules11/adminjs/src/frontend/components/app/error-message.tsx

import React, { ReactNode } from 'react'
import { InfoBox, MessageBox, Text } from '@adminjs/design-system'

import { useTranslation } from '../../hooks/index.js'

/**
 * @memberof ErrorMessageBox
 * @alias ErrorMessageBoxProps
 */
export type ErrorMessageBoxProps = {
  title: string;
  children: ReactNode;
  testId?: string;
}

/**
 * @class
 * Prints error message
 *
 * @component
 * @private
 * @example
 * return (
 * <ErrorMessageBox title={'Some error'}>
 *   <p>Text below the title</p>
 * </ErrorMessageBox>
 * )
 */
const ErrorMessageBox: React.FC<ErrorMessageBoxProps> = (props) => {
  const { children, title, testId } = props
  return (
    <MessageBox data-testid={testId} message={title}>
      <Text>
        {children}
      </Text>
    </MessageBox>
  )
}

const NoResourceError: React.FC<{ resourceId: string }> = (props) => {
  const { resourceId } = props
  const { translateMessage } = useTranslation()
  return (
    <InfoBox
      title={translateMessage('pageNotFound_title', resourceId, { resourceId })}
      illustration="NotFound"
      testId="NoResourceError"
    >
      <Text>
        {translateMessage('error404Resource', resourceId, { resourceId })}
      </Text>
    </InfoBox>
  )
}

const NoActionError: React.FC<{ resourceId: string; actionName: string }> = (props) => {
  const { resourceId, actionName } = props
  const { translateMessage } = useTranslation()
  return (
    <InfoBox
      title={translateMessage('pageNotFound_title', resourceId, { resourceId })}
      illustration="NotFound"
      testId="NoActionError"
    >
      <Text>
        {translateMessage('error404Action', resourceId, { resourceId, actionName })}
      </Text>
    </InfoBox>
  )
}

const NoRecordError: React.FC<{
  resourceId: string;
  recordId: string;
}> = (props) => {
  const { resourceId, recordId } = props
  const { translateMessage } = useTranslation()
  return (
    <InfoBox
      title={translateMessage('pageNotFound_title', resourceId, { resourceId })}
      illustration="NotFound"
      testId="NoRecordError"
    >
      <Text>
        {translateMessage('error404Record', resourceId, { resourceId, recordId })}
      </Text>
    </InfoBox>
  )
}

export {
  NoResourceError,
  NoActionError,
  NoRecordError,
  ErrorMessageBox,
  ErrorMessageBox as default,
}

Directory Contents

Dirs: 6 × Files: 17

Name Size Perms Modified Actions
- drwxr-xr-x 2026-02-28 00:32:46
Edit Download
- drwxr-xr-x 2026-02-28 00:32:50
Edit Download
- drwxr-xr-x 2026-02-28 00:32:46
Edit Download
- drwxr-xr-x 2026-02-28 00:32:48
Edit Download
sidebar DIR
- drwxr-xr-x 2026-02-28 00:32:50
Edit Download
utils DIR
- drwxr-xr-x 2026-02-28 00:32:48
Edit Download
383 B lrw-r--r-- 2026-02-28 00:32:46
Edit Download
235 B lrw-r--r-- 2026-02-28 00:32:46
Edit Download
525 B lrw-r--r-- 2026-02-28 00:32:46
Edit Download
2.47 KB lrw-r--r-- 2026-02-28 00:32:46
Edit Download
3.21 KB lrw-r--r-- 2026-02-28 00:32:46
Edit Download
5.74 KB lrw-r--r-- 2026-02-28 00:32:46
Edit Download
3.51 KB lrw-r--r-- 2026-02-28 00:32:46
Edit Download
966 B lrw-r--r-- 2026-02-28 00:32:46
Edit Download
2.25 KB lrw-r--r-- 2026-02-28 00:32:46
Edit Download
4.08 KB lrw-r--r-- 2026-02-28 00:32:46
Edit Download
282 B lrw-r--r-- 2026-02-28 00:32:46
Edit Download
755 B lrw-r--r-- 2026-02-28 00:32:28
Edit Download
1.15 KB lrw-r--r-- 2026-02-28 00:32:48
Edit Download
3.27 KB lrw-r--r-- 2026-02-28 00:32:48
Edit Download
1.55 KB lrw-r--r-- 2026-02-28 00:32:50
Edit Download
1.71 KB lrw-r--r-- 2026-02-28 00:32:50
Edit Download
1.22 KB lrw-r--r-- 2026-02-28 00:32:50
Edit Download

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