Skip to content

Commit 64e53c9

Browse files
committed
feat(ui): add link to Keip Assistant docs on toolbar button
1 parent 1161002 commit 64e53c9

File tree

5 files changed

+48
-16
lines changed

5 files changed

+48
-16
lines changed

ui/.env

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
VITE_FLOW_TRANSLATOR_BASE_URL=http://localhost:8080
1+
VITE_FLOW_TRANSLATOR_BASE_URL=http://localhost:8080
2+
VITE_KEIP_ASSISTANT_DOCS_URL=https://github.com/OctoConsulting/keip-canvas/blob/main/docs/KEIP-ASSISTANT.md

ui/src/components/toolbar/ToolbarMenu.tsx

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { IconButton, TableToolbar, TableToolbarContent } from "@carbon/react"
22
import { MachineLearning, Xml } from "@carbon/react/icons"
33
import { useState } from "react"
4+
import { KEIP_ASSISTANT_DOCS_URL } from "../../singletons/externalEndpoints"
45
import AssistantChatPanel from "./assistant/AssistantChatPanel"
56
import { useLlmServerStatus } from "./assistant/llmStatusHook"
67
import XmlPanel from "./xml/XmlPanel"
@@ -12,6 +13,7 @@ interface PanelButtonProps {
1213
disabled: boolean
1314
selected: boolean
1415
handleClick: () => void
16+
helpLink?: string
1517
}
1618

1719
type 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

2528
type 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

6486
const 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>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
export const FLOW_TRANSLATOR_BASE_URL = import.meta.env
22
.VITE_FLOW_TRANSLATOR_BASE_URL
3+
4+
export const KEIP_ASSISTANT_DOCS_URL = import.meta.env
5+
.VITE_KEIP_ASSISTANT_DOCS_URL

ui/src/styles.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@
7575
border-bottom: 4px solid themes.$interactive;
7676
}
7777

78+
.help-link .cds--tooltip-trigger__wrapper {
79+
cursor: help;
80+
}
81+
7882
// Begin AI Chat Panel //
7983
.chat-history {
8084
flex: 2;

ui/src/vite-env.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
interface ImportMetaEnv {
44
readonly VITE_FLOW_TRANSLATOR_BASE_URL: string
5+
readonly VITE_KEIP_ASSISTANT_DOCS_URL: string
56
}
67

78
interface ImportMeta {

0 commit comments

Comments
 (0)