1- import { Settings } from "lucide-react" ;
1+ import { ExternalLink , Settings } from "lucide-react" ;
22import { useState } from "react" ;
33import { AlertBlock } from "@/components/shared/alert-block" ;
44import { Button } from "@/components/ui/button" ;
@@ -10,6 +10,12 @@ import {
1010 DialogTitle ,
1111 DialogTrigger ,
1212} from "@/components/ui/dialog" ;
13+ import {
14+ Tooltip ,
15+ TooltipContent ,
16+ TooltipProvider ,
17+ TooltipTrigger ,
18+ } from "@/components/ui/tooltip" ;
1319import { cn } from "@/lib/utils" ;
1420import {
1521 EndpointSpecForm ,
@@ -27,45 +33,90 @@ type MenuItem = {
2733 id : string ;
2834 label : string ;
2935 description : string ;
36+ docUrl ?: string ;
37+ docDescription ?: string ;
3038} ;
3139
3240const menuItems : MenuItem [ ] = [
3341 {
3442 id : "health-check" ,
3543 label : "Health Check" ,
3644 description : "Configure health check settings" ,
45+ docUrl :
46+ "https://docs.docker.com/reference/cli/docker/service/create/#healthcheck" ,
47+ docDescription :
48+ "Configure HEALTHCHECK to test a container's health. Determines if a container is healthy by running a command inside the container." ,
3749 } ,
3850 {
3951 id : "restart-policy" ,
4052 label : "Restart Policy" ,
4153 description : "Configure restart policy" ,
54+ docUrl :
55+ "https://docs.docker.com/reference/cli/docker/service/create/#restart-policy" ,
56+ docDescription :
57+ "Configure the restart policy for containers in the service. Controls when and how containers should be restarted." ,
4258 } ,
4359 {
4460 id : "placement" ,
4561 label : "Placement" ,
4662 description : "Configure placement constraints" ,
63+ docUrl :
64+ "https://docs.docker.com/reference/cli/docker/service/create/#placement-pref" ,
65+ docDescription :
66+ "Control which nodes service tasks can be scheduled on. Use constraints, preferences, and platform specifications." ,
4767 } ,
4868 {
4969 id : "update-config" ,
5070 label : "Update Config" ,
5171 description : "Configure update strategy" ,
72+ docUrl :
73+ "https://docs.docker.com/reference/cli/docker/service/create/#update-config" ,
74+ docDescription :
75+ "Configure how the service should be updated. Controls parallelism, delay, failure action, and order of updates." ,
5276 } ,
5377 {
5478 id : "rollback-config" ,
5579 label : "Rollback Config" ,
5680 description : "Configure rollback strategy" ,
81+ docUrl :
82+ "https://docs.docker.com/reference/cli/docker/service/create/#rollback-config" ,
83+ docDescription :
84+ "Configure automated rollback on update failure. Similar to update config but applies to rollback operations." ,
85+ } ,
86+ {
87+ id : "mode" ,
88+ label : "Mode" ,
89+ description : "Configure service mode" ,
90+ docUrl : "https://docs.docker.com/reference/cli/docker/service/create/#mode" ,
91+ docDescription :
92+ "Set service mode to either 'replicated' (default) with a specified number of tasks, or 'global' (one task per node)." ,
93+ } ,
94+ {
95+ id : "labels" ,
96+ label : "Labels" ,
97+ description : "Configure service labels" ,
98+ docUrl :
99+ "https://docs.docker.com/reference/cli/docker/service/create/#label" ,
100+ docDescription :
101+ "Add metadata to services using labels. Labels are key-value pairs for organizing and filtering services." ,
57102 } ,
58- { id : "mode" , label : "Mode" , description : "Configure service mode" } ,
59- { id : "labels" , label : "Labels" , description : "Configure service labels" } ,
60103 {
61104 id : "stop-grace-period" ,
62105 label : "Stop Grace Period" ,
63106 description : "Configure stop grace period" ,
107+ docUrl :
108+ "https://docs.docker.com/reference/cli/docker/service/create/#stop-grace-period" ,
109+ docDescription :
110+ "Time to wait before forcefully killing a container. Given in nanoseconds. Default is 10 seconds." ,
64111 } ,
65112 {
66113 id : "endpoint-spec" ,
67114 label : "Endpoint Spec" ,
68115 description : "Configure endpoint specification" ,
116+ docUrl :
117+ "https://docs.docker.com/reference/cli/docker/service/create/#endpoint-mode" ,
118+ docDescription :
119+ "Configure endpoint mode for service discovery. Choose between 'vip' (virtual IP) or 'dnsrr' (DNS round-robin)." ,
69120 } ,
70121] ;
71122
@@ -110,22 +161,48 @@ export const AddSwarmSettings = ({ id, type }: Props) => {
110161 { /* Left Column - Menu */ }
111162 < div className = "w-64 flex-shrink-0 border-r pr-4 overflow-y-auto" >
112163 < nav className = "space-y-1" >
113- { menuItems . map ( ( item ) => (
114- < button
115- key = { item . id }
116- type = "button"
117- onClick = { ( ) => setActiveMenu ( item . id ) }
118- className = { cn (
119- "w-full text-left px-3 py-2 rounded-md text-sm transition-colors" ,
120- activeMenu === item . id
121- ? "bg-primary text-primary-foreground"
122- : "hover:bg-muted" ,
123- ) }
124- >
125- < div className = "font-medium" > { item . label } </ div >
126- < div className = "text-xs opacity-80" > { item . description } </ div >
127- </ button >
128- ) ) }
164+ < TooltipProvider >
165+ { menuItems . map ( ( item ) => (
166+ < div key = { item . id } className = "relative group" >
167+ < button
168+ type = "button"
169+ onClick = { ( ) => setActiveMenu ( item . id ) }
170+ className = { cn (
171+ "w-full text-left px-3 py-2 rounded-md text-sm transition-colors" ,
172+ activeMenu === item . id
173+ ? "bg-primary text-primary-foreground"
174+ : "hover:bg-muted" ,
175+ ) }
176+ >
177+ < div className = "flex items-center justify-between gap-2" >
178+ < div className = "flex-1" >
179+ < div className = "font-medium" > { item . label } </ div >
180+ < div className = "text-xs opacity-80" >
181+ { item . description }
182+ </ div >
183+ </ div >
184+ { item . docUrl && (
185+ < Tooltip >
186+ < TooltipTrigger asChild >
187+ < a
188+ href = { item . docUrl }
189+ target = "_blank"
190+ rel = "noopener noreferrer"
191+ onClick = { ( e ) => e . stopPropagation ( ) }
192+ >
193+ < ExternalLink className = "size-3.5" />
194+ </ a >
195+ </ TooltipTrigger >
196+ < TooltipContent side = "right" className = "max-w-xs" >
197+ < p className = "text-xs" > { item . docDescription } </ p >
198+ </ TooltipContent >
199+ </ Tooltip >
200+ ) }
201+ </ div >
202+ </ button >
203+ </ div >
204+ ) ) }
205+ </ TooltipProvider >
129206 </ nav >
130207 </ div >
131208
0 commit comments