MDK Logo

Fleet management

Dialogs for adding, replacing, moving, and removing miners across containers

Dialogs that orchestrate the miner lifecycle in the device explorer: registering a new miner in an empty socket, replacing an existing miner, moving a miner to or from maintenance, changing position between sockets, and permanently removing a miner.

Prerequisites

  • Complete the @mdk/foundation installation and add the dependency

  • A connected Redux store

  • A miner Device record (or socket payload containing one) passed in via dialog props

  • The notification helpers from @mdk/foundation wired up; submit actions fire info or success notifications

PositionChangeDialog

Top-level dialog that orchestrates the miner position-change flows: change info, move to maintenance, replace miner, confirm position change, and container selection. Dispatches into actionsSlice to queue position updates and routes internally between the step-specific dialog surfaces.

Import

import { PositionChangeDialog } from '@mdk/foundation'

Props

PropTypeDefaultDescription
openbooleanrequiredControls dialog visibility
onClose(currentDialogFlow: string, isDontReset?: boolean) => voidrequiredCalled when the dialog closes; receives the active flow key so callers can decide whether to reset selection state
selectedSocketToReplaceUnknownRecordnoneSocket payload for the destination socket in a position-change or replace flow
selectedEditSocketUnknownRecordnoneSocket payload for the miner being edited, replaced, or moved
onChangePositionClicked() => voidnoneFired when the user picks "Change position" in the default flow
onPositionChangedSuccess() => voidnoneFired after a successful confirm-change-position submission
isContainerEmptybooleanfalseHint for the container-selection step that the destination container has no occupied sockets
dialogFlowstring''Initial flow key from POSITION_CHANGE_DIALOG_FLOWS; when omitted the default chooser is shown

Internal flows

The dialog routes between step-specific surfaces based on the active dialogFlow value:

Flow keySurface rendered
confirmChangeConfirmChangePositionDialogContent
containerSelectionContainerSelectionDialogContent
replaceMiner, changeInfoAddReplaceMinerDialogContent
confirmRemoveRemoveMinerDialogContent
maintenanceMaintenanceDialogContent
noneDefaultPositionChangeDialogContent chooser

When both selectedSocketToReplace and selectedEditSocket are set, the dialog auto-advances to the confirmChange flow.

Basic usage

const [open, setOpen] = useState(false)

<PositionChangeDialog
  open={open}
  onClose={() => setOpen(false)}
  selectedEditSocket={selectedEditSocket}
  dialogFlow={POSITION_CHANGE_DIALOG_FLOWS.CHANGE_INFO}
  onPositionChangedSuccess={() => refetchInventory()}
/>

Move-to-maintenance flow

<PositionChangeDialog
  open={open}
  onClose={handleClose}
  selectedEditSocket={selectedEditSocket}
  dialogFlow={POSITION_CHANGE_DIALOG_FLOWS.MAINTENANCE}
/>

Styling

  • .mdk-position-change-dialog: Root dialog element

AddReplaceMinerDialog

Dialog for registering a new miner in an empty socket or replacing an existing miner. Supports direct-to-maintenance registration, change-info mode for existing miners, and MAC/serial validation against pending submissions.

Import

import { AddReplaceMinerDialog } from '@mdk/foundation'

Props

PropTypeDefaultDescription
openbooleanrequiredControls dialog visibility
onClose() => voidrequiredCalled when the dialog closes
selectedSocketToReplaceUnknownRecordnoneSocket payload for the empty socket receiving a new miner
selectedEditSocketUnknownRecordnoneSocket payload for an existing miner when running the change-info flow
currentDialogFlowstringnoneFlow key from POSITION_CHANGE_DIALOG_FLOWS; typically replaceMiner or changeInfo
isDirectToMaintenanceModebooleanfalseRegister the new miner straight into the maintenance container instead of the selected socket
minersTypestringnoneRestricts the form to a specific miner type (used to gate model-specific validation)
isContainerEmptybooleannoneForwarded to internal validation when registering into an empty container

Validation

  • MAC and serial are validated against pending submissions before dispatch
  • isDirectToMaintenanceMode skips the position picker and uses the maintenance container as the target

Basic usage

<AddReplaceMinerDialog
  open={open}
  onClose={() => setOpen(false)}
  selectedSocketToReplace={emptySocket}
  currentDialogFlow={POSITION_CHANGE_DIALOG_FLOWS.REPLACE_MINER}
/>

Direct-to-maintenance registration

<AddReplaceMinerDialog
  open={open}
  onClose={() => setOpen(false)}
  selectedSocketToReplace={emptySocket}
  isDirectToMaintenanceMode
/>

ContainerSelectionDialog

Dialog for selecting a destination container and socket when bringing a miner back from the maintenance container. Wraps ContainerSelectionDialogContent with the maintenance container preset as the source.

Import

import { ContainerSelectionDialog } from '@mdk/foundation'

Props

PropTypeDefaultDescription
openbooleanrequiredControls dialog visibility
onClose(value?: boolean) => voidrequiredCalled when the dialog closes
minerDevicenoneThe miner being moved out of maintenance
containersDevice[][]Candidate destination containers shown in the picker
isLoadingbooleannoneShows a loading state while containers is being fetched

Behavior

  • Presets the source as the maintenance container and lets the user pick a destination container and socket
  • Internally renders ContainerSelectionDialogContent with a synthesised selectedSocketToReplace of { miner, containerInfo: { container: 'maintenance' }, pos: '', socket: '' }

Basic usage

<ContainerSelectionDialog
  open={open}
  onClose={() => setOpen(false)}
  miner={minerUnderMaintenance}
  containers={availableContainers}
  isLoading={isContainersLoading}
/>

MaintenanceDialogContent

Confirmation body rendered inside PositionChangeDialog when the flow is 'move to maintenance'. Dispatches the update action to actionsSlice with the maintenance container and an empty position, and fires a success notification on submit.

This is a content body intended to be rendered inside PositionChangeDialog (or any host Dialog); it does not render its own dialog chrome.

Import

import { MaintenanceDialogContent } from '@mdk/foundation'

Props

PropTypeDefaultDescription
selectedEditSocketPartial<{ miner: Device, containerInfo: { container?: string } }>noneSocket payload for the miner being moved to maintenance
onCancel() => voidnoneCalled when the user cancels or after a successful submission

Behavior

  • Confirms the action with the miner short-code and its current container and position
  • On submit, dispatches an update action into actionsSlice with the maintenance container, an empty pos, and an empty subnet, preserving the prior position in posHistory
  • Fires an info notification ("Action added") and calls onCancel

Basic usage

<MaintenanceDialogContent
  selectedEditSocket={selectedEditSocket}
  onCancel={() => setOpen(false)}
/>

Styling

  • .mdk-maintenance-confirm: Root container
  • .mdk-maintenance-confirm__warning: Confirmation copy
  • .mdk-maintenance-confirm__highlight: Inline miner short-code
  • .mdk-maintenance-confirm__footer: Cancel and confirm action row

RemoveMinerDialog

Confirmation dialog wrapping RemoveMinerDialogContent. Accepts the head device and a remove-flow flag; dispatches the remove action into actionsSlice when confirmed.

Import

import { RemoveMinerDialog } from '@mdk/foundation'

Props

PropTypeDefaultDescription
headDeviceDevice{}The miner being removed; the dialog reads info.pos for the confirmation copy
isRemoveMinerFlowbooleanrequiredControls dialog visibility
onCancel() => voidrequiredCalled when the user cancels or after a successful submission

Behavior

  • Wraps RemoveMinerDialogContent inside a Dialog with the title "Are you sure to permanently remove miner?"
  • On confirm, dispatches the remove action into actionsSlice for the head device

Basic usage

<RemoveMinerDialog
  headDevice={selectedMiner}
  isRemoveMinerFlow={isRemoveOpen}
  onCancel={() => setRemoveOpen(false)}
/>

On this page