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
Devicerecord (or socket payload containing one) passed in via dialog props -
The notification helpers from
@mdk/foundationwired 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
| Prop | Type | Default | Description |
|---|---|---|---|
open | boolean | required | Controls dialog visibility |
onClose | (currentDialogFlow: string, isDontReset?: boolean) => void | required | Called when the dialog closes; receives the active flow key so callers can decide whether to reset selection state |
selectedSocketToReplace | UnknownRecord | none | Socket payload for the destination socket in a position-change or replace flow |
selectedEditSocket | UnknownRecord | none | Socket payload for the miner being edited, replaced, or moved |
onChangePositionClicked | () => void | none | Fired when the user picks "Change position" in the default flow |
onPositionChangedSuccess | () => void | none | Fired after a successful confirm-change-position submission |
isContainerEmpty | boolean | false | Hint for the container-selection step that the destination container has no occupied sockets |
dialogFlow | string | '' | 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 key | Surface rendered |
|---|---|
confirmChange | ConfirmChangePositionDialogContent |
containerSelection | ContainerSelectionDialogContent |
replaceMiner, changeInfo | AddReplaceMinerDialogContent |
confirmRemove | RemoveMinerDialogContent |
maintenance | MaintenanceDialogContent |
| none | DefaultPositionChangeDialogContent 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
| Prop | Type | Default | Description |
|---|---|---|---|
open | boolean | required | Controls dialog visibility |
onClose | () => void | required | Called when the dialog closes |
selectedSocketToReplace | UnknownRecord | none | Socket payload for the empty socket receiving a new miner |
selectedEditSocket | UnknownRecord | none | Socket payload for an existing miner when running the change-info flow |
currentDialogFlow | string | none | Flow key from POSITION_CHANGE_DIALOG_FLOWS; typically replaceMiner or changeInfo |
isDirectToMaintenanceMode | boolean | false | Register the new miner straight into the maintenance container instead of the selected socket |
minersType | string | none | Restricts the form to a specific miner type (used to gate model-specific validation) |
isContainerEmpty | boolean | none | Forwarded to internal validation when registering into an empty container |
Validation
- MAC and serial are validated against pending submissions before dispatch
isDirectToMaintenanceModeskips 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
| Prop | Type | Default | Description |
|---|---|---|---|
open | boolean | required | Controls dialog visibility |
onClose | (value?: boolean) => void | required | Called when the dialog closes |
miner | Device | none | The miner being moved out of maintenance |
containers | Device[] | [] | Candidate destination containers shown in the picker |
isLoading | boolean | none | Shows 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
ContainerSelectionDialogContentwith a synthesisedselectedSocketToReplaceof{ 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
| Prop | Type | Default | Description |
|---|---|---|---|
selectedEditSocket | Partial<{ miner: Device, containerInfo: { container?: string } }> | none | Socket payload for the miner being moved to maintenance |
onCancel | () => void | none | Called 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
actionsSlicewith the maintenance container, an emptypos, and an emptysubnet, preserving the prior position inposHistory - 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
| Prop | Type | Default | Description |
|---|---|---|---|
headDevice | Device | {} | The miner being removed; the dialog reads info.pos for the confirmation copy |
isRemoveMinerFlow | boolean | required | Controls dialog visibility |
onCancel | () => void | required | Called when the user cancels or after a successful submission |
Behavior
- Wraps
RemoveMinerDialogContentinside aDialogwith the title "Are you sure to permanently remove miner?" - On confirm, dispatches the remove action into
actionsSlicefor the head device
Basic usage
<RemoveMinerDialog
headDevice={selectedMiner}
isRemoveMinerFlow={isRemoveOpen}
onCancel={() => setRemoveOpen(false)}
/>
