({
nodeModel,
viewModel,
preview,
connBtnRef,
changeConnModalAtom,
error,
}: BlockFrameProps & { changeConnModalAtom: jotai.PrimitiveAtom<boolean>; error?: Error })
| 208 | HeaderEndIcons.displayName = "HeaderEndIcons"; |
| 209 | |
| 210 | const BlockFrame_Header = ({ |
| 211 | nodeModel, |
| 212 | viewModel, |
| 213 | preview, |
| 214 | connBtnRef, |
| 215 | changeConnModalAtom, |
| 216 | error, |
| 217 | }: BlockFrameProps & { changeConnModalAtom: jotai.PrimitiveAtom<boolean>; error?: Error }) => { |
| 218 | const waveEnv = useWaveEnv<BlockEnv>(); |
| 219 | const metaView = jotai.useAtomValue(waveEnv.getBlockMetaKeyAtom(nodeModel.blockId, "view")); |
| 220 | const metaFrameTitle = jotai.useAtomValue(waveEnv.getBlockMetaKeyAtom(nodeModel.blockId, "frame:title")); |
| 221 | const metaFrameIcon = jotai.useAtomValue(waveEnv.getBlockMetaKeyAtom(nodeModel.blockId, "frame:icon")); |
| 222 | const metaConnection = jotai.useAtomValue(waveEnv.getBlockMetaKeyAtom(nodeModel.blockId, "connection")); |
| 223 | let viewName = util.useAtomValueSafe(viewModel?.viewName) ?? blockViewToName(metaView); |
| 224 | let viewIconUnion = util.useAtomValueSafe(viewModel?.viewIcon) ?? blockViewToIcon(metaView); |
| 225 | const preIconButton = util.useAtomValueSafe(viewModel?.preIconButton); |
| 226 | const useTermHeader = util.useAtomValueSafe(viewModel?.useTermHeader); |
| 227 | const termConfigedDurable = util.useAtomValueSafe(viewModel?.termConfigedDurable); |
| 228 | const hideViewName = util.useAtomValueSafe(viewModel?.hideViewName); |
| 229 | const badge = jotai.useAtomValue(getBlockBadgeAtom(useTermHeader ? nodeModel.blockId : null)); |
| 230 | const magnified = jotai.useAtomValue(nodeModel.isMagnified); |
| 231 | const prevMagifiedState = React.useRef(magnified); |
| 232 | const manageConnection = util.useAtomValueSafe(viewModel?.manageConnection); |
| 233 | const iconColor = jotai.useAtomValue(waveEnv.getBlockMetaKeyAtom(nodeModel.blockId, "icon:color")); |
| 234 | const dragHandleRef = preview ? null : nodeModel.dragHandleRef; |
| 235 | const isTerminalBlock = metaView === "term"; |
| 236 | viewName = metaFrameTitle ?? viewName; |
| 237 | viewIconUnion = metaFrameIcon ?? viewIconUnion; |
| 238 | |
| 239 | React.useEffect(() => { |
| 240 | if (magnified && !preview && !prevMagifiedState.current) { |
| 241 | waveEnv.rpc.ActivityCommand(TabRpcClient, { nummagnify: 1 }); |
| 242 | recordTEvent("action:magnify", { "block:view": viewName }); |
| 243 | } |
| 244 | prevMagifiedState.current = magnified; |
| 245 | }, [magnified]); |
| 246 | |
| 247 | const viewIconElem = getViewIconElem(viewIconUnion, iconColor); |
| 248 | |
| 249 | return ( |
| 250 | <div |
| 251 | className={cn("block-frame-default-header", useTermHeader && "!pl-[2px]")} |
| 252 | data-role="block-header" |
| 253 | ref={dragHandleRef} |
| 254 | onContextMenu={(e) => handleHeaderContextMenu(e, nodeModel.blockId, viewModel, nodeModel, waveEnv)} |
| 255 | > |
| 256 | {!useTermHeader && ( |
| 257 | <> |
| 258 | {preIconButton && <IconButton decl={preIconButton} className="block-frame-preicon-button" />} |
| 259 | <div className="block-frame-default-header-iconview"> |
| 260 | {viewIconElem} |
| 261 | {viewName && !hideViewName && <div className="block-frame-view-type">{viewName}</div>} |
| 262 | </div> |
| 263 | </> |
| 264 | )} |
| 265 | {manageConnection && ( |
| 266 | <ConnectionButton |
| 267 | ref={connBtnRef} |
nothing calls this directly
no test coverage detected