Skip to content

Commit 1cdedf3

Browse files
authored
Update translations (#2623)
* Update translations * Clean up the buttons
1 parent 00609aa commit 1cdedf3

File tree

25 files changed

+253
-252
lines changed

25 files changed

+253
-252
lines changed

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

Lines changed: 92 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
1-
import { VSCodeCheckbox, VSCodeButton } from "@vscode/webview-ui-toolkit/react"
2-
import { useCallback, useState } from "react"
3-
import { useExtensionState } from "../../context/ExtensionStateContext"
4-
import { useAppTranslation } from "../../i18n/TranslationContext"
1+
import { VSCodeCheckbox } from "@vscode/webview-ui-toolkit/react"
2+
import { useCallback, useMemo, useState } from "react"
53
import { Trans } from "react-i18next"
64
import { VSCodeLink } from "@vscode/webview-ui-toolkit/react"
5+
6+
import { Button } from "@/components/ui"
7+
78
import { vscode } from "../../utils/vscode"
9+
import { useExtensionState } from "../../context/ExtensionStateContext"
10+
import { useAppTranslation } from "../../i18n/TranslationContext"
11+
12+
const ICON_MAP: Record<string, string> = {
13+
readFiles: "eye",
14+
editFiles: "edit",
15+
executeCommands: "terminal",
16+
useBrowser: "globe",
17+
useMcp: "plug",
18+
switchModes: "sync",
19+
subtasks: "discard",
20+
retryRequests: "refresh",
21+
}
822

923
interface AutoApproveAction {
1024
id: string
@@ -42,56 +56,69 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => {
4256

4357
const { t } = useAppTranslation()
4458

45-
const actions: AutoApproveAction[] = [
46-
{
47-
id: "readFiles",
48-
label: t("chat:autoApprove.actions.readFiles.label"),
49-
enabled: alwaysAllowReadOnly ?? false,
50-
description: t("chat:autoApprove.actions.readFiles.description"),
51-
},
52-
{
53-
id: "editFiles",
54-
label: t("chat:autoApprove.actions.editFiles.label"),
55-
enabled: alwaysAllowWrite ?? false,
56-
description: t("chat:autoApprove.actions.editFiles.description"),
57-
},
58-
{
59-
id: "executeCommands",
60-
label: t("chat:autoApprove.actions.executeCommands.label"),
61-
enabled: alwaysAllowExecute ?? false,
62-
description: t("chat:autoApprove.actions.executeCommands.description"),
63-
},
64-
{
65-
id: "useBrowser",
66-
label: t("chat:autoApprove.actions.useBrowser.label"),
67-
enabled: alwaysAllowBrowser ?? false,
68-
description: t("chat:autoApprove.actions.useBrowser.description"),
69-
},
70-
{
71-
id: "useMcp",
72-
label: t("chat:autoApprove.actions.useMcp.label"),
73-
enabled: alwaysAllowMcp ?? false,
74-
description: t("chat:autoApprove.actions.useMcp.description"),
75-
},
76-
{
77-
id: "switchModes",
78-
label: t("chat:autoApprove.actions.switchModes.label"),
79-
enabled: alwaysAllowModeSwitch ?? false,
80-
description: t("chat:autoApprove.actions.switchModes.description"),
81-
},
82-
{
83-
id: "subtasks",
84-
label: t("chat:autoApprove.actions.subtasks.label"),
85-
enabled: alwaysAllowSubtasks ?? false,
86-
description: t("chat:autoApprove.actions.subtasks.description"),
87-
},
88-
{
89-
id: "retryRequests",
90-
label: t("chat:autoApprove.actions.retryRequests.label"),
91-
enabled: alwaysApproveResubmit ?? false,
92-
description: t("chat:autoApprove.actions.retryRequests.description"),
93-
},
94-
]
59+
const actions: AutoApproveAction[] = useMemo(
60+
() => [
61+
{
62+
id: "readFiles",
63+
label: t("chat:autoApprove.actions.readFiles.label"),
64+
enabled: alwaysAllowReadOnly ?? false,
65+
description: t("chat:autoApprove.actions.readFiles.description"),
66+
},
67+
{
68+
id: "editFiles",
69+
label: t("chat:autoApprove.actions.editFiles.label"),
70+
enabled: alwaysAllowWrite ?? false,
71+
description: t("chat:autoApprove.actions.editFiles.description"),
72+
},
73+
{
74+
id: "executeCommands",
75+
label: t("chat:autoApprove.actions.executeCommands.label"),
76+
enabled: alwaysAllowExecute ?? false,
77+
description: t("chat:autoApprove.actions.executeCommands.description"),
78+
},
79+
{
80+
id: "useBrowser",
81+
label: t("chat:autoApprove.actions.useBrowser.label"),
82+
enabled: alwaysAllowBrowser ?? false,
83+
description: t("chat:autoApprove.actions.useBrowser.description"),
84+
},
85+
{
86+
id: "useMcp",
87+
label: t("chat:autoApprove.actions.useMcp.label"),
88+
enabled: alwaysAllowMcp ?? false,
89+
description: t("chat:autoApprove.actions.useMcp.description"),
90+
},
91+
{
92+
id: "switchModes",
93+
label: t("chat:autoApprove.actions.switchModes.label"),
94+
enabled: alwaysAllowModeSwitch ?? false,
95+
description: t("chat:autoApprove.actions.switchModes.description"),
96+
},
97+
{
98+
id: "subtasks",
99+
label: t("chat:autoApprove.actions.subtasks.label"),
100+
enabled: alwaysAllowSubtasks ?? false,
101+
description: t("chat:autoApprove.actions.subtasks.description"),
102+
},
103+
{
104+
id: "retryRequests",
105+
label: t("chat:autoApprove.actions.retryRequests.label"),
106+
enabled: alwaysApproveResubmit ?? false,
107+
description: t("chat:autoApprove.actions.retryRequests.description"),
108+
},
109+
],
110+
[
111+
alwaysAllowReadOnly,
112+
alwaysAllowWrite,
113+
alwaysAllowExecute,
114+
alwaysAllowBrowser,
115+
alwaysAllowMcp,
116+
alwaysAllowModeSwitch,
117+
alwaysAllowSubtasks,
118+
alwaysApproveResubmit,
119+
t,
120+
],
121+
)
95122

96123
const toggleExpanded = useCallback(() => {
97124
setIsExpanded((prev) => !prev)
@@ -102,7 +129,7 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => {
102129
.map((action) => action.label)
103130
.join(", ")
104131

105-
// Individual checkbox handlers - each one only updates its own state
132+
// Individual checkbox handlers - each one only updates its own state.
106133
const handleReadOnlyChange = useCallback(() => {
107134
const newValue = !(alwaysAllowReadOnly ?? false)
108135
setAlwaysAllowReadOnly(newValue)
@@ -159,7 +186,7 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => {
159186
})
160187
}, [])
161188

162-
// Map action IDs to their specific handlers
189+
// Map action IDs to their specific handlers.
163190
const actionHandlers: Record<AutoApproveAction["id"], () => void> = {
164191
readFiles: handleReadOnlyChange,
165192
editFiles: handleWriteChange,
@@ -237,10 +264,9 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => {
237264
</div>
238265
</div>
239266
{isExpanded && (
240-
<div style={{ padding: "0" }}>
267+
<div className="flex flex-col gap-2">
241268
<div
242269
style={{
243-
marginBottom: "10px",
244270
color: "var(--vscode-descriptionForeground)",
245271
fontSize: "12px",
246272
}}>
@@ -251,43 +277,24 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => {
251277
}}
252278
/>
253279
</div>
254-
<div
255-
className="flex flex-row gap-2 [@media(min-width:400px)]:gap-4 flex-wrap justify-center"
256-
style={{ paddingBottom: "2rem" }}>
280+
<div className="grid grid-cols-2 [@media(min-width:320px)]:grid-cols-4 gap-2">
257281
{actions.map((action) => {
258-
const iconMap: Record<string, string> = {
259-
readFiles: "eye",
260-
editFiles: "edit",
261-
executeCommands: "terminal",
262-
useBrowser: "globe",
263-
useMcp: "plug",
264-
switchModes: "sync",
265-
subtasks: "discard",
266-
retryRequests: "refresh",
267-
}
268-
const codicon = iconMap[action.id] || "question"
282+
const codicon = ICON_MAP[action.id] || "question"
269283
return (
270-
<VSCodeButton
284+
<Button
271285
key={action.id}
272-
appearance={action.enabled ? "primary" : "secondary"}
286+
variant={action.enabled ? "default" : "ghost"}
273287
onClick={(e) => {
274288
e.stopPropagation()
275289
actionHandlers[action.id]()
276290
}}
277291
title={action.description}
278-
className="aspect-square min-h-[80px] min-w-[80px] max-h-[100px] max-w-[100px]"
279-
style={{ flexBasis: "20%" }}>
280-
<span className="flex flex-col items-center gap-1 h-full">
281-
<span
282-
className={`codicon codicon-${codicon} text-base `}
283-
style={{
284-
fontSize: "1.5rem",
285-
paddingTop: "0.5rem",
286-
}}
287-
/>
292+
className="h-12">
293+
<span className="flex flex-col items-center gap-1">
294+
<span className={`codicon codicon-${codicon}`} />
288295
<span className="text-sm text-center">{action.label}</span>
289296
</span>
290-
</VSCodeButton>
297+
</Button>
291298
)
292299
})}
293300
</div>

0 commit comments

Comments
 (0)