Skip to content

Commit 38fb80f

Browse files
committed
refactor: improve tooltip implementation to follow codebase standards
- Replace native title attributes with StandardTooltip component - Add info icon with tooltip next to 'Manage Command Permissions' header - Remove redundant instruction text (now in tooltip) - Follow established pattern from settings components
1 parent 9a01e80 commit 38fb80f

File tree

1 file changed

+45
-35
lines changed

1 file changed

+45
-35
lines changed

webview-ui/src/components/chat/CommandPatternSelector.tsx

Lines changed: 45 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { useState } from "react"
22
import { ChevronDown, Check, X } from "lucide-react"
33
import { useAppTranslation } from "@src/i18n/TranslationContext"
44
import { cn } from "@src/lib/utils"
5+
import { StandardTooltip } from "@src/components/ui/standard-tooltip"
56

67
interface CommandPattern {
78
pattern: string
@@ -60,12 +61,17 @@ export const CommandPatternSelector = ({
6061
})}
6162
/>
6263
<span className="font-medium">{t("chat:commandExecution.manageCommands")}</span>
64+
{isExpanded && (
65+
<StandardTooltip content={t("chat:commandExecution.commandManagementDescription")}>
66+
<i
67+
className="codicon codicon-info text-vscode-descriptionForeground ml-1"
68+
style={{ fontSize: "12px" }}
69+
/>
70+
</StandardTooltip>
71+
)}
6372
</button>
6473
{isExpanded && (
6574
<div className="px-3 pb-3 space-y-2">
66-
<div className="text-xs text-vscode-descriptionForeground mb-2 ml-5">
67-
{t("chat:commandExecution.commandManagementDescription")}
68-
</div>
6975
{patterns.map((item, index) => {
7076
const status = getPatternStatus(item.pattern)
7177
return (
@@ -79,38 +85,42 @@ export const CommandPatternSelector = ({
7985
)}
8086
</div>
8187
<div className="flex items-center gap-1">
82-
<button
83-
onClick={() => handleAllowClick(item.pattern)}
84-
className={cn(
85-
"p-1 rounded transition-all",
86-
status === "allowed"
87-
? "bg-green-500/20 text-green-500 hover:bg-green-500/30"
88-
: "text-vscode-descriptionForeground hover:text-green-500 hover:bg-green-500/10",
89-
)}
90-
aria-label={
91-
status === "allowed"
92-
? `Remove ${item.pattern} from allowed list`
93-
: `Add ${item.pattern} to allowed list`
94-
}
95-
title={status === "allowed" ? "Remove from allowed" : "Add to allowed"}>
96-
<Check className="size-3.5" />
97-
</button>
98-
<button
99-
onClick={() => handleDenyClick(item.pattern)}
100-
className={cn(
101-
"p-1 rounded transition-all",
102-
status === "denied"
103-
? "bg-red-500/20 text-red-500 hover:bg-red-500/30"
104-
: "text-vscode-descriptionForeground hover:text-red-500 hover:bg-red-500/10",
105-
)}
106-
aria-label={
107-
status === "denied"
108-
? `Remove ${item.pattern} from denied list`
109-
: `Add ${item.pattern} to denied list`
110-
}
111-
title={status === "denied" ? "Remove from denied" : "Add to denied"}>
112-
<X className="size-3.5" />
113-
</button>
88+
<StandardTooltip
89+
content={status === "allowed" ? "Remove from allowed" : "Add to allowed"}>
90+
<button
91+
onClick={() => handleAllowClick(item.pattern)}
92+
className={cn(
93+
"p-1 rounded transition-all",
94+
status === "allowed"
95+
? "bg-green-500/20 text-green-500 hover:bg-green-500/30"
96+
: "text-vscode-descriptionForeground hover:text-green-500 hover:bg-green-500/10",
97+
)}
98+
aria-label={
99+
status === "allowed"
100+
? `Remove ${item.pattern} from allowed list`
101+
: `Add ${item.pattern} to allowed list`
102+
}>
103+
<Check className="size-3.5" />
104+
</button>
105+
</StandardTooltip>
106+
<StandardTooltip
107+
content={status === "denied" ? "Remove from denied" : "Add to denied"}>
108+
<button
109+
onClick={() => handleDenyClick(item.pattern)}
110+
className={cn(
111+
"p-1 rounded transition-all",
112+
status === "denied"
113+
? "bg-red-500/20 text-red-500 hover:bg-red-500/30"
114+
: "text-vscode-descriptionForeground hover:text-red-500 hover:bg-red-500/10",
115+
)}
116+
aria-label={
117+
status === "denied"
118+
? `Remove ${item.pattern} from denied list`
119+
: `Add ${item.pattern} to denied list`
120+
}>
121+
<X className="size-3.5" />
122+
</button>
123+
</StandardTooltip>
114124
</div>
115125
</div>
116126
)

0 commit comments

Comments
 (0)