Skip to content

Commit 5b83ddc

Browse files
authored
refactor: Node Power Confirmation (#26)
* refactor: ConfirmationModal to allow div's * feat: add confirmation dialogs for power and reset actions on nodes * chore: i18n keys * chore: bump version to 3.3.6
1 parent 251c9bb commit 5b83ddc

File tree

10 files changed

+235
-54
lines changed

10 files changed

+235
-54
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bmc-ui",
3-
"version": "3.3.5",
3+
"version": "3.3.6",
44
"private": true,
55
"type": "module",
66
"scripts": {

src/components/ConfirmationModal.tsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ interface ConfirmationModalProps {
2626
onClose: () => void;
2727
onConfirm: () => void;
2828
title: string;
29-
message: string;
29+
message: string | React.ReactNode;
3030
}
3131

3232
export default function ConfirmationModal({
@@ -39,13 +39,22 @@ export default function ConfirmationModal({
3939
const { t } = useTranslation();
4040
const isDesktop = useMediaQuery("(min-width: 768px)");
4141

42+
const messageContent =
43+
typeof message === "string" ? (
44+
<DialogDescription>{message}</DialogDescription>
45+
) : (
46+
<div className="text-sm text-neutral-500 dark:text-neutral-400">
47+
{message}
48+
</div>
49+
);
50+
4251
if (isDesktop) {
4352
return (
4453
<Dialog open={isOpen} onOpenChange={(open) => !open && onClose()}>
4554
<DialogContent className={cn("modal-rounded", "p-6")}>
4655
<DialogHeader>
4756
<DialogTitle className="mb-4">{title}</DialogTitle>
48-
<DialogDescription>{message}</DialogDescription>
57+
{messageContent}
4958
</DialogHeader>
5059
<DialogFooter className="mt-2">
5160
<Button type="button" variant="bw" onClick={onClose}>
@@ -65,7 +74,13 @@ export default function ConfirmationModal({
6574
<DrawerContent>
6675
<DrawerHeader className="text-left">
6776
<DrawerTitle className="mb-4">{title}</DrawerTitle>
68-
<DrawerDescription>{message}</DrawerDescription>
77+
{typeof message === "string" ? (
78+
<DrawerDescription>{message}</DrawerDescription>
79+
) : (
80+
<div className="text-sm text-neutral-500 dark:text-neutral-400">
81+
{message}
82+
</div>
83+
)}
6984
</DrawerHeader>
7085
<DrawerFooter className="mt-2">
7186
<DrawerClose asChild>

src/locale/de.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,15 @@ const translations = {
6565
nodeRestarted: "Knoten {{nodeId}} wurde neu gestartet.",
6666
pmError: "Fehler beim Ändern des Knotenstatus.",
6767
persistSuccess: "Knoteninformationen gespeichert.",
68+
powerOffConfirmTitle: "Knoten {{nodeId}} ausschalten?",
69+
powerOnConfirmTitle: "Knoten {{nodeId}} einschalten?",
70+
resetConfirmTitle: "Knoten {{nodeId}} zurücksetzen?",
71+
powerOffConfirmDescription:
72+
"Dies wird Knoten {{nodeId}} herunterfahren. Alle laufenden Prozesse werden beendet.",
73+
powerOnConfirmDescription: "Dies wird Knoten {{nodeId}} starten.",
74+
resetConfirmDescription:
75+
"Dies wird Knoten {{nodeId}} zwangsweise neu starten. Nicht gespeicherte Daten gehen verloren.",
76+
dontAskAgain: "Bei Knotenstromoperationen nicht mehr nachfragen",
6877
},
6978
usb: {
7079
header: "USB-Route",

src/locale/en.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@ const translations = {
6262
nodeRestarted: "Node {{nodeId}} was restarted.",
6363
pmError: "Error changing node state.",
6464
persistSuccess: "Nodes information saved.",
65+
powerOffConfirmTitle: "Power off Node {{nodeId}}?",
66+
powerOnConfirmTitle: "Power on Node {{nodeId}}?",
67+
resetConfirmTitle: "Reset Node {{nodeId}}?",
68+
powerOffConfirmDescription:
69+
"This will shut down Node {{nodeId}}. Any running processes will be terminated.",
70+
powerOnConfirmDescription: "This will start up Node {{nodeId}}.",
71+
resetConfirmDescription:
72+
"This will forcefully restart Node {{nodeId}}. Any unsaved data will be lost.",
73+
dontAskAgain: "Don't ask again for node power operations",
6574
},
6675
usb: {
6776
header: "USB route",

src/locale/es.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@ const translations = {
6464
nodeRestarted: "El nodo {{nodeId}} se reinició.",
6565
pmError: "Error al cambiar el estado del nodo.",
6666
persistSuccess: "Información de nodos guardada.",
67+
powerOffConfirmTitle: "¿Apagar Nodo {{nodeId}}?",
68+
powerOnConfirmTitle: "¿Encender Nodo {{nodeId}}?",
69+
resetConfirmTitle: "¿Reiniciar Nodo {{nodeId}}?",
70+
powerOffConfirmDescription:
71+
"Esto apagará el Nodo {{nodeId}}. Todos los procesos en ejecución serán terminados.",
72+
powerOnConfirmDescription: "Esto iniciará el Nodo {{nodeId}}.",
73+
resetConfirmDescription:
74+
"Esto reiniciará forzosamente el Nodo {{nodeId}}. Cualquier dato no guardado se perderá.",
75+
dontAskAgain: "No volver a preguntar para operaciones de energía de nodos",
6776
},
6877
usb: {
6978
header: "Ruta USB",

src/locale/nl.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@ const translations = {
6464
nodeRestarted: "Node {{nodeId}} is opnieuw gestart.",
6565
pmError: "Fout bij het wijzigen van de nodestatus.",
6666
persistSuccess: "Node-informatie opgeslagen.",
67+
powerOffConfirmTitle: "Node {{nodeId}} uitschakelen?",
68+
powerOnConfirmTitle: "Node {{nodeId}} inschakelen?",
69+
resetConfirmTitle: "Node {{nodeId}} herstarten?",
70+
powerOffConfirmDescription:
71+
"Dit zal Node {{nodeId}} afsluiten. Alle lopende processen worden beëindigd.",
72+
powerOnConfirmDescription: "Dit zal Node {{nodeId}} opstarten.",
73+
resetConfirmDescription:
74+
"Dit zal Node {{nodeId}} geforceerd herstarten. Niet-opgeslagen gegevens gaan verloren.",
75+
dontAskAgain: "Niet meer vragen voor node-stroomacties",
6776
},
6877
usb: {
6978
header: "USB-route",

src/locale/pl.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,15 @@ const translations = {
6565
nodeRestarted: "Węzeł {{nodeId}} został ponownie uruchomiony.",
6666
pmError: "Błąd podczas zmiany stanu węzła.",
6767
persistSuccess: "Informacje o węzłach zostały zapisane.",
68+
powerOffConfirmTitle: "Wyłączyć Węzeł {{nodeId}}?",
69+
powerOnConfirmTitle: "Włączyć Węzeł {{nodeId}}?",
70+
resetConfirmTitle: "Zresetować Węzeł {{nodeId}}?",
71+
powerOffConfirmDescription:
72+
"To wyłączy Węzeł {{nodeId}}. Wszystkie uruchomione procesy zostaną zakończone.",
73+
powerOnConfirmDescription: "To uruchomi Węzeł {{nodeId}}.",
74+
resetConfirmDescription:
75+
"To wymusi restart Węzła {{nodeId}}. Wszystkie niezapisane dane zostaną utracone.",
76+
dontAskAgain: "Nie pytaj ponownie o operacje zasilania węzłów",
6877
},
6978
usb: {
7079
header: "Trasa USB",

src/locale/zh-Hans.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,15 @@ const translations = {
6363
nodeRestarted: "节点 {{nodeId}} 已重新启动。",
6464
pmError: "更改节点状态时出错。",
6565
persistSuccess: "节点信息已保存。",
66+
powerOffConfirmTitle: "关闭节点 {{nodeId}}?",
67+
powerOnConfirmTitle: "启动节点 {{nodeId}}?",
68+
resetConfirmTitle: "重置节点 {{nodeId}}?",
69+
powerOffConfirmDescription:
70+
"这将关闭节点 {{nodeId}}。所有正在运行的进程都将被终止。",
71+
powerOnConfirmDescription: "这将启动节点 {{nodeId}}。",
72+
resetConfirmDescription:
73+
"这将强制重启节点 {{nodeId}}。任何未保存的数据都将丢失。",
74+
dontAskAgain: "不再询问节点电源操作",
6675
},
6776
usb: {
6877
header: "USB 路由",

0 commit comments

Comments
 (0)