Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | import { VSCodeCheckbox } from "@vscode/webview-ui-toolkit/react" import React from "react" import styled from "styled-components" import HeroTooltip from "@/components/common/HeroTooltip" import { ActionMetadata } from "./types" interface AutoApproveMenuItemProps { action: ActionMetadata isChecked: (action: ActionMetadata) => boolean isFavorited?: (action: ActionMetadata) => boolean onToggle: (action: ActionMetadata, checked: boolean) => Promise<void> onToggleFavorite?: (actionId: string) => Promise<void> condensed?: boolean showIcon?: boolean } const CheckboxContainer = styled.div.withConfig({ shouldForwardProp: (prop) => !["isFavorited"].includes(prop), })<{ isFavorited?: boolean; onClick?: (e: MouseEvent) => void; onMouseDown?: (e: React.MouseEvent) => void }>` display: flex; align-items: center; justify-content: space-between; /* Push content to edges */ padding-left: 4px; padding-right: 1px; border-radius: 4px; cursor: pointer; transition: all 0.2s ease; &:hover { background-color: var(--vscode-textBlockQuote-background); } .left-content { display: flex; align-items: center; gap: 8px; } .icon { color: var(--vscode-foreground); font-size: 14px; } .label { color: var(--vscode-foreground); font-size: 12px; font-weight: 500; } .star { color: ${(props) => (props.isFavorited ? "var(--vscode-terminal-ansiYellow)" : "var(--vscode-descriptionForeground)")}; opacity: ${(props) => (props.isFavorited ? 1 : 0.6)}; font-size: 14px; } ` const SubOptionAnimateIn = styled.div<{ show: boolean }>` position: relative; transform: ${(props) => (props.show ? "scaleY(1)" : "scaleY(0)")}; transform-origin: top; padding-left: 24px; opacity: ${(props) => (props.show ? "1" : "0")}; height: ${(props) => (props.show ? "auto" : "0")}; /* Manage height for layout */ overflow: visible; /* Allow tooltips to escape */ transition: transform 0.2s ease-in-out; ` const ActionButtonContainer = styled.div` padding: 2px; ` const AutoApproveMenuItem = ({ action, isChecked, isFavorited, onToggle, onToggleFavorite, condensed = false, showIcon = true, }: AutoApproveMenuItemProps) => { const checked = isChecked(action) const favorited = isFavorited?.(action) const onChange = async (e: Event) => { e.stopPropagation() await onToggle(action, !checked) } const content = ( <> <ActionButtonContainer> <HeroTooltip content={action.description} delay={500}> <CheckboxContainer isFavorited={favorited} onClick={onChange}> <div className="left-content"> {onToggleFavorite && !condensed && ( <HeroTooltip content={favorited ? "Remove from quick-access menu" : "Add to quick-access menu"} delay={500}> <span className={`p-0.5 codicon codicon-${favorited ? "star-full" : "star-empty"} star`} onClick={async (e) => { e.stopPropagation() if (action.id === "enableAll") { return } await onToggleFavorite?.(action.id) }} style={{ cursor: "pointer", }} /> </HeroTooltip> )} <VSCodeCheckbox checked={checked} /> {showIcon && <span className={`codicon ${action.icon} icon`}></span>} <span className="label">{condensed ? action.shortName : action.label}</span> </div> </CheckboxContainer> </HeroTooltip> </ActionButtonContainer> {action.subAction && !condensed && ( <SubOptionAnimateIn show={checked}> <AutoApproveMenuItem action={action.subAction} isChecked={isChecked} isFavorited={isFavorited} onToggle={onToggle} onToggleFavorite={onToggleFavorite} /> </SubOptionAnimateIn> )} </> ) return content } export default AutoApproveMenuItem |