PHP 8.2.30
Preview: action-href.ts Size: 1.04 KB
//proc/thread-self/root/home/byroehnu/.trash/node_modules11/adminjs/src/frontend/interfaces/action/action-href.ts

import { RecordActionParams, ViewHelpers } from '../../../backend/utils/view-helpers/index.js'
import { DifferentActionParams } from '../../hooks/index.js'
import { ActionJSON } from './action-json.interface.js'

const h = new ViewHelpers()

export const actionHref = (
  action: ActionJSON,
  params: DifferentActionParams,
): string | null => {
  const actionName = action.name

  if (!action.component && !action.hasHandler) {
    return null
  }

  if (params.recordIds?.length) {
    params.recordIds = [...new Set(params.recordIds)]
  }

  const hrefMap = {
    record: (): string => h.recordActionUrl({
      ...params as RecordActionParams,
      actionName,
    }),
    resource: (): string => h.resourceActionUrl({
      resourceId: params.resourceId,
      actionName,
      search: params.search,
    }),
    bulk: (): string => h.bulkActionUrl({
      ...params,
      actionName,
    }),
  }
  if (hrefMap[action.actionType]) {
    return hrefMap[action.actionType]()
  }
  throw new Error('"actionType" should be either record, resource or bulk')
}

Directory Contents

Dirs: 0 × Files: 11

Name Size Perms Modified Actions
325 B lrw-r--r-- 2026-02-28 00:31:58
Edit Download
1.04 KB lrw-r--r-- 2026-02-28 00:31:58
Edit Download
1.97 KB lrw-r--r-- 2026-02-28 00:31:58
Edit Download
1.07 KB lrw-r--r-- 2026-02-28 00:32:02
Edit Download
2.96 KB lrw-r--r-- 2026-02-28 00:32:02
Edit Download
146 B lrw-r--r-- 2026-02-28 00:32:02
Edit Download
1.58 KB lrw-r--r-- 2026-02-28 00:32:02
Edit Download
410 B lrw-r--r-- 2026-02-28 00:32:28
Edit Download
391 B lrw-r--r-- 2026-02-28 00:32:28
Edit Download
404 B lrw-r--r-- 2026-02-28 00:32:28
Edit Download
407 B lrw-r--r-- 2026-02-28 00:32:28
Edit Download

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