MDK Logo

Constants

Shared constants for settings, permissions, and roles

The @mdk/foundation package provides domain-specific constants for mining applications.

Import

import {
  // Header controls
  HEADER_ITEMS,
  DEFAULT_HEADER_PREFERENCES,
  // Permissions
  AUTH_PERMISSIONS,
  AUTH_LEVELS,
  USER_ROLE,
  // Settings
  USER_ROLES,
  PERM_LEVEL_LABELS,
  // Role styling
  getRoleBadgeColors,
} from '@mdk/foundation'

Header controls

HEADER_ITEMS

Array of header metric options for the HeaderControlsSettings component.

import { HEADER_ITEMS } from '@mdk/foundation'
KeyLabel
poolMinersPool Miners
mosMinersMOS Miners
poolHashratePool Hashrate
mosHashrateMOS Hashrate
consumptionConsumption
efficiencyEfficiency

DEFAULT_HEADER_PREFERENCES

Default visibility state for all header items (all true).

import { DEFAULT_HEADER_PREFERENCES } from '@mdk/foundation'

// All items visible by default
DEFAULT_HEADER_PREFERENCES.poolMiners    // true
DEFAULT_HEADER_PREFERENCES.consumption   // true

HeaderPreferences type

import type { HeaderPreferences } from '@mdk/foundation'

type HeaderPreferences = {
  poolMiners: boolean
  mosMiners: boolean
  poolHashrate: boolean
  mosHashrate: boolean
  consumption: boolean
  efficiency: boolean
}

Permissions

AUTH_PERMISSIONS

Permission resource identifiers.

import { AUTH_PERMISSIONS } from '@mdk/foundation'

AUTH_PERMISSIONS.USERS      // 'users'
AUTH_PERMISSIONS.SETTINGS   // 'settings'
AUTH_PERMISSIONS.MINER      // 'miner'
ConstantValueDescription
USERSusersUser management
SETTINGSsettingsApplication settings
MINERminerMiner operations
ALERTSalertsAlert management
ACTIONSactionsAction execution
EXPLORERexplorerDevice explorer
INVENTORYinventoryInventory management
CONTAINERcontainerContainer management
PRODUCTIONproductionProduction data
REPORTINGreportingReports

AUTH_LEVELS

Permission access levels.

import { AUTH_LEVELS } from '@mdk/foundation'

AUTH_LEVELS.READ   // 'r'
AUTH_LEVELS.WRITE  // 'w'

USER_ROLE

User role identifiers.

import { USER_ROLE } from '@mdk/foundation'

USER_ROLE.ADMIN           // 'admin'
USER_ROLE.SITE_MANAGER    // 'site_manager'
USER_ROLE.READ_ONLY       // 'read_only_user'
ConstantValue
ADMINadmin
SITE_MANAGERsite_manager
SITE_OPERATORsite_operator
FIELD_OPERATORfield_operator
REPAIR_TECHNICIANrepair_technician
REPORTING_TOOL_MANAGERreporting_tool_manager
READ_ONLYread_only_user

Settings

USER_ROLES

Array of role options for select dropdowns.

import { USER_ROLES } from '@mdk/foundation'

// [{ label: 'Admin', value: 'admin' }, ...]

PERM_LEVEL_LABELS

Human-readable labels for permission levels.

import { PERM_LEVEL_LABELS } from '@mdk/foundation'

PERM_LEVEL_LABELS.rw    // 'Read & Write'
PERM_LEVEL_LABELS.r     // 'Read Only'
PERM_LEVEL_LABELS.none  // 'No Access'

SETTINGS_ERROR_CODES

Error code to message mapping.

import { SETTINGS_ERROR_CODES } from '@mdk/foundation'

SETTINGS_ERROR_CODES.ERR_USER_EXISTS  // 'User already exists'
SETTINGS_ERROR_CODES.DEFAULT          // 'An error occurred'

Role styling

getRoleBadgeColors

Get badge colors for a role.

import { getRoleBadgeColors } from '@mdk/foundation'

const { color, bgColor } = getRoleBadgeColors('admin')
// { color: '#e8833a', bgColor: 'rgba(232, 131, 58, 0.1)' }
RoleColorBackground
admin#e8833aOrange tint
site_manager#52c41aGreen tint
site_operator#faad14Yellow tint
read_only_user#8c8c8cGray tint

On this page