11import { useTranslation } from "next-i18next" ;
22import { toast } from "sonner" ;
3+ import { AlertBlock } from "@/components/shared/alert-block" ;
4+ import { DialogAction } from "@/components/shared/dialog-action" ;
35import { Button } from "@/components/ui/button" ;
46import {
57 DropdownMenu ,
@@ -85,7 +87,26 @@ export const ShowTraefikActions = ({ serverId }: Props) => {
8587 </ DropdownMenuItem >
8688 </ EditTraefikEnv >
8789
88- < DropdownMenuItem
90+ < DialogAction
91+ title = {
92+ haveTraefikDashboardPortEnabled
93+ ? "Disable Traefik Dashboard"
94+ : "Enable Traefik Dashboard"
95+ }
96+ description = {
97+ < div className = "space-y-4" >
98+ < AlertBlock type = "warning" >
99+ The Traefik container will be recreated from scratch. This
100+ means the container will be deleted and created again, which
101+ may cause downtime in your applications.
102+ </ AlertBlock >
103+ < p >
104+ Are you sure you want to{ " " }
105+ { haveTraefikDashboardPortEnabled ? "disable" : "enable" } the
106+ Traefik dashboard?
107+ </ p >
108+ </ div >
109+ }
89110 onClick = { async ( ) => {
90111 await toggleDashboard ( {
91112 enableDashboard : ! haveTraefikDashboardPortEnabled ,
@@ -97,14 +118,26 @@ export const ShowTraefikActions = ({ serverId }: Props) => {
97118 ) ;
98119 refetchDashboard ( ) ;
99120 } )
100- . catch ( ( ) => { } ) ;
121+ . catch ( ( error ) => {
122+ const errorMessage =
123+ error ?. message ||
124+ "Failed to toggle dashboard. Please check if port 8080 is available." ;
125+ toast . error ( errorMessage ) ;
126+ } ) ;
101127 } }
102- className = "w-full cursor-pointer space-x-3"
128+ disabled = { toggleDashboardIsLoading }
129+ type = "default"
103130 >
104- < span >
105- { haveTraefikDashboardPortEnabled ? "Disable" : "Enable" } Dashboard
106- </ span >
107- </ DropdownMenuItem >
131+ < DropdownMenuItem
132+ onSelect = { ( e ) => e . preventDefault ( ) }
133+ className = "w-full cursor-pointer space-x-3"
134+ >
135+ < span >
136+ { haveTraefikDashboardPortEnabled ? "Disable" : "Enable" } { " " }
137+ Dashboard
138+ </ span >
139+ </ DropdownMenuItem >
140+ </ DialogAction >
108141 < ManageTraefikPorts serverId = { serverId } >
109142 < DropdownMenuItem
110143 onSelect = { ( e ) => e . preventDefault ( ) }
0 commit comments