PHP 8.2.30
Preview: get-navigation.ts Size: 1.62 KB
//home/byroehnu/easepay.easetack.com/node_modules/adminjs/src/backend/decorators/resource/utils/get-navigation.ts

import { ResourceJSON } from '../../../../frontend/interfaces/index.js'
import { ResourceOptions } from '../resource-options.interface.js'
import { BaseResource, SupportedDatabasesType } from '../../../adapters/index.js'

export type DatabaseData = {
  databaseName: BaseResource['databaseName'];
  databaseType: BaseResource['databaseType'];
}

export const DEFAULT_ICON = 'Archive'

type IconMapType = {[key in SupportedDatabasesType]: string}

export const getIcon = (icon?: SupportedDatabasesType | string): string => {
  const IconMap: IconMapType = {
    MariaDB: 'Sql',
    MySQL: 'Sql',
    Postgres: 'Sql',
    CockroachDB: 'Sql',
    SQLite: 'Sql',
    MicrosoftSQLServer: 'Sql',
    Oracle: 'Sql',
    SAPHana: 'CloudApp',
    MongoDB: 'Archive',
    other: 'Archive',
  }
  return (icon && IconMap[icon]) ? IconMap[icon] : DEFAULT_ICON
}

export const getNavigation = (
  options: ResourceOptions,
  database: DatabaseData,
): ResourceJSON['navigation'] => {
  const navigationOption = typeof options.navigation !== 'undefined'
    ? options.navigation
    : options.parent

  if (navigationOption === null || navigationOption === true) {
    return null
  }

  if (navigationOption === false) {
    return {
      name: null,
      icon: '',
      show: false,
    }
  }

  if (navigationOption === undefined || typeof navigationOption === 'string') {
    return {
      name: navigationOption || database.databaseName(),
      icon: getIcon(database.databaseType()),
      show: true,
    }
  }
  const { name, icon } = navigationOption
  return {
    name: name || null,
    icon: icon || getIcon(database.databaseType()),
    show: true,
  }
}

Directory Contents

Dirs: 0 × Files: 10

Name Size Perms Modified Actions
127 B lr--r--r-- 2026-03-14 01:49:20
Edit Download
1.65 KB lrw-r--r-- 2026-02-28 00:32:04
Edit Download
7.02 KB lrw-r--r-- 2026-02-28 00:32:04
Edit Download
3.68 KB lrw-r--r-- 2026-02-28 00:32:06
Edit Download
1.15 KB lrw-r--r-- 2026-02-28 00:32:14
Edit Download
813 B lrw-r--r-- 2026-02-28 00:32:14
Edit Download
2.04 KB lrw-r--r-- 2026-02-28 00:32:20
Edit Download
1.62 KB lrw-r--r-- 2026-02-28 00:32:20
Edit Download
1.02 KB lrw-r--r-- 2026-02-28 00:32:20
Edit Download
236 B lrw-r--r-- 2026-02-28 00:32:28
Edit Download

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