@@ -17,6 +17,7 @@ import {
1717 Checkmark16Regular ,
1818 Checkmark20Regular ,
1919 Copy16Regular ,
20+ Open16Regular ,
2021 Warning20Regular ,
2122} from "@fluentui/react-icons" ;
2223import { useCallback , useMemo , useState } from "react" ;
@@ -95,11 +96,19 @@ interface DabDeploymentCompleteProps {
9596 onFinish : ( ) => void ;
9697}
9798
99+ type ApiEndpointAction = "copy" | "addToVSCode" | "openUrl" ;
100+
101+ interface ApiEndpointOpenUrlConfig {
102+ url : string ;
103+ label : string ;
104+ }
105+
98106interface ApiEndpoint {
99107 type : Dab . ApiType ;
100108 label : string ;
101109 url : string ;
102- action : "copy" | "addToVSCode" ;
110+ actions : ApiEndpointAction [ ] ;
111+ openUrlConfig ?: ApiEndpointOpenUrlConfig ;
103112}
104113
105114export const DabDeploymentComplete = ( {
@@ -109,7 +118,7 @@ export const DabDeploymentComplete = ({
109118 onFinish,
110119} : DabDeploymentCompleteProps ) => {
111120 const classes = useStyles ( ) ;
112- const { dabConfig, copyToClipboard, addDabMcpServer } = useDabContext ( ) ;
121+ const { dabConfig, copyToClipboard, openUrl , addDabMcpServer } = useDabContext ( ) ;
113122 const isSuccess = ! error && apiUrl ;
114123 const [ mcpAdded , setMcpAdded ] = useState ( false ) ;
115124 const [ mcpError , setMcpError ] = useState < string | null > ( null ) ;
@@ -125,23 +134,31 @@ export const DabDeploymentComplete = ({
125134 type : Dab . ApiType . Rest ,
126135 label : locConstants . schemaDesigner . restApi ,
127136 url : `${ apiUrl } /api` ,
128- action : "copy" ,
137+ actions : [ "openUrl" , "copy" ] ,
138+ openUrlConfig : {
139+ url : `${ apiUrl } /swagger/index.html` ,
140+ label : locConstants . schemaDesigner . viewSwagger ,
141+ } ,
129142 } ) ;
130143 }
131144 if ( enabledTypes . includes ( Dab . ApiType . GraphQL ) ) {
132145 result . push ( {
133146 type : Dab . ApiType . GraphQL ,
134147 label : locConstants . schemaDesigner . graphql ,
135148 url : `${ apiUrl } /graphql` ,
136- action : "copy" ,
149+ actions : [ "openUrl" , "copy" ] ,
150+ openUrlConfig : {
151+ url : `${ apiUrl } /graphql` ,
152+ label : locConstants . schemaDesigner . openNitro ,
153+ } ,
137154 } ) ;
138155 }
139156 if ( enabledTypes . includes ( Dab . ApiType . Mcp ) ) {
140157 result . push ( {
141158 type : Dab . ApiType . Mcp ,
142159 label : locConstants . schemaDesigner . mcp ,
143160 url : `${ apiUrl } /mcp` ,
144- action : "addToVSCode" ,
161+ actions : [ "addToVSCode" ] ,
145162 } ) ;
146163 }
147164 return result ;
@@ -160,41 +177,59 @@ export const DabDeploymentComplete = ({
160177 [ addDabMcpServer ] ,
161178 ) ;
162179
163- const renderEndpointAction = useCallback (
164- ( ep : ApiEndpoint ) => {
165- if ( ep . action === "copy" ) {
166- return (
167- < Button
168- appearance = "subtle"
169- icon = { < Copy16Regular /> }
170- size = "small"
171- className = { classes . actionButton }
172- onClick = { ( ) => copyToClipboard ( ep . url , Dab . CopyTextType . Url ) }
173- aria-label = { locConstants . schemaDesigner . copyUrl ( ep . label ) }
174- title = { locConstants . schemaDesigner . copyUrl ( ep . label ) }
175- />
176- ) ;
177- }
178- if ( ep . action === "addToVSCode" ) {
179- return (
180- < Button
181- appearance = "subtle"
182- icon = { mcpAdded ? < Checkmark16Regular /> : < Add16Regular /> }
183- size = "small"
184- className = { classes . actionButton }
185- disabled = { mcpAdded }
186- onClick = { ( ) => void handleAddMcpServer ( ep . url ) }
187- aria-label = { locConstants . schemaDesigner . addMcpServerToWorkspace }
188- title = { locConstants . schemaDesigner . addMcpServerToWorkspace } >
189- { mcpAdded
190- ? locConstants . schemaDesigner . mcpServerAdded
191- : locConstants . schemaDesigner . addToVSCode }
192- </ Button >
193- ) ;
180+ const renderAction = useCallback (
181+ ( ep : ApiEndpoint , action : ApiEndpointAction ) => {
182+ switch ( action ) {
183+ case "copy" :
184+ return (
185+ < Button
186+ key = { action }
187+ appearance = "subtle"
188+ icon = { < Copy16Regular /> }
189+ size = "small"
190+ className = { classes . actionButton }
191+ onClick = { ( ) => copyToClipboard ( ep . url , Dab . CopyTextType . Url ) }
192+ aria-label = { locConstants . schemaDesigner . copyUrl ( ep . label ) }
193+ title = { locConstants . schemaDesigner . copyUrl ( ep . label ) }
194+ />
195+ ) ;
196+ case "openUrl" :
197+ if ( ! ep . openUrlConfig ) {
198+ return null ;
199+ }
200+ return (
201+ < Button
202+ key = { action }
203+ appearance = "subtle"
204+ icon = { < Open16Regular /> }
205+ size = "small"
206+ className = { classes . actionButton }
207+ onClick = { ( ) => openUrl ( ep . openUrlConfig ! . url ) }
208+ aria-label = { ep . openUrlConfig . label }
209+ title = { ep . openUrlConfig . label } >
210+ { ep . openUrlConfig . label }
211+ </ Button >
212+ ) ;
213+ case "addToVSCode" :
214+ return (
215+ < Button
216+ key = { action }
217+ appearance = "subtle"
218+ icon = { mcpAdded ? < Checkmark16Regular /> : < Add16Regular /> }
219+ size = "small"
220+ className = { classes . actionButton }
221+ disabled = { mcpAdded }
222+ onClick = { ( ) => void handleAddMcpServer ( ep . url ) }
223+ aria-label = { locConstants . schemaDesigner . addMcpServerToWorkspace }
224+ title = { locConstants . schemaDesigner . addMcpServerToWorkspace } >
225+ { mcpAdded
226+ ? locConstants . schemaDesigner . mcpServerAdded
227+ : locConstants . schemaDesigner . addToVSCode }
228+ </ Button >
229+ ) ;
194230 }
195- return null ;
196231 } ,
197- [ classes . actionButton , copyToClipboard , mcpAdded , handleAddMcpServer ] ,
232+ [ classes . actionButton , copyToClipboard , openUrl , mcpAdded , handleAddMcpServer ] ,
198233 ) ;
199234
200235 return (
@@ -222,7 +257,7 @@ export const DabDeploymentComplete = ({
222257 < div key = { ep . type } className = { classes . apiUrlRow } >
223258 < Text className = { classes . apiLabel } > { ep . label } </ Text >
224259 < Text className = { classes . apiUrl } > { ep . url } </ Text >
225- { renderEndpointAction ( ep ) }
260+ { ep . actions . map ( ( action ) => renderAction ( ep , action ) ) }
226261 </ div >
227262 ) ) }
228263 </ div >
0 commit comments