11import { IconButton , TableToolbar , TableToolbarContent } from "@carbon/react"
22import { MachineLearning , Xml } from "@carbon/react/icons"
33import { useState } from "react"
4+ import { KEIP_ASSISTANT_DOCS_URL } from "../../singletons/externalEndpoints"
45import AssistantChatPanel from "./assistant/AssistantChatPanel"
56import { useLlmServerStatus } from "./assistant/llmStatusHook"
67import XmlPanel from "./xml/XmlPanel"
@@ -12,6 +13,7 @@ interface PanelButtonProps {
1213 disabled : boolean
1314 selected : boolean
1415 handleClick : ( ) => void
16+ helpLink ?: string
1517}
1618
1719type PanelKeys = "keipAssistant" | "xml"
@@ -20,6 +22,7 @@ interface PanelRef {
2022 icon : React . ReactNode
2123 panel : React . ReactNode
2224 enabled ?: boolean
25+ helpLink ?: string
2326}
2427
2528type Panels = {
@@ -31,6 +34,7 @@ const panels: Panels = {
3134 icon : < MachineLearning /> ,
3235 panel : < AssistantChatPanel /> ,
3336 enabled : false ,
37+ helpLink : KEIP_ASSISTANT_DOCS_URL ,
3438 } ,
3539 xml : {
3640 icon : < Xml /> ,
@@ -45,21 +49,39 @@ const PanelButton = ({
4549 disabled,
4650 selected,
4751 handleClick,
48- } : PanelButtonProps ) => (
49- < IconButton
50- className = {
51- selected ? "toolbar-button toolbar-button-selected" : "toolbar-button"
52- }
53- label = { name }
54- align = "left"
55- kind = "secondary"
56- size = "lg"
57- onClick = { handleClick }
58- disabled = { disabled }
59- >
60- { icon }
61- </ IconButton >
62- )
52+ helpLink,
53+ } : PanelButtonProps ) => {
54+ const button = (
55+ < IconButton
56+ className = {
57+ selected ? "toolbar-button toolbar-button-selected" : "toolbar-button"
58+ }
59+ label = { name }
60+ align = "left"
61+ kind = "secondary"
62+ size = "lg"
63+ onClick = { handleClick }
64+ disabled = { disabled }
65+ >
66+ { icon }
67+ </ IconButton >
68+ )
69+
70+ if ( helpLink && disabled ) {
71+ return (
72+ < a
73+ className = "help-link"
74+ href = { KEIP_ASSISTANT_DOCS_URL }
75+ target = "_blank"
76+ rel = "noopener noreferrer"
77+ >
78+ { button }
79+ </ a >
80+ )
81+ }
82+
83+ return button
84+ }
6385
6486const ToolbarMenu = ( ) => {
6587 const [ openPanel , setOpenPanel ] = useState < "" | PanelKeys > ( "" )
@@ -88,6 +110,7 @@ const ToolbarMenu = () => {
88110 disabled = { ! val . enabled }
89111 selected = { panelName === openPanel }
90112 handleClick = { handlePanelButtonClick ( panelName as PanelKeys ) }
113+ helpLink = { val . helpLink }
91114 />
92115 ) ) }
93116 </ TableToolbarContent >
0 commit comments