11import { styled } from "styled-components" ;
22import type { ModelAlerts } from "../../model-editor/model-alerts/model-alerts" ;
33import { Codicon } from "../common" ;
4- import { useState } from "react" ;
5- import { VSCodeBadge } from "@vscode/webview-ui-toolkit/react" ;
4+ import { useCallback , useState } from "react" ;
5+ import { VSCodeBadge , VSCodeLink } from "@vscode/webview-ui-toolkit/react" ;
66import { formatDecimal } from "../../common/number" ;
77import AnalysisAlertResult from "../variant-analysis/AnalysisAlertResult" ;
88import { MethodName } from "../model-editor/MethodName" ;
99import { ModelDetails } from "./ModelDetails" ;
10+ import { vscode } from "../vscode-api" ;
1011
1112// This will ensure that these icons have a className which we can use in the TitleContainer
1213const ExpandCollapseCodicon = styled ( Codicon ) `` ;
@@ -36,6 +37,11 @@ const ModelTypeText = styled.span`
3637 color: var(--vscode-descriptionForeground);
3738` ;
3839
40+ const ViewLink = styled ( VSCodeLink ) `
41+ white-space: nowrap;
42+ padding: 0 0 0.25em 1em;
43+ ` ;
44+
3945const ModelDetailsContainer = styled . div `
4046 padding-top: 10px;
4147` ;
@@ -59,6 +65,14 @@ export const ModelAlertsResults = ({
5965 modelAlerts,
6066} : Props ) : React . JSX . Element => {
6167 const [ isExpanded , setExpanded ] = useState ( true ) ;
68+ const viewInModelEditor = useCallback (
69+ ( ) =>
70+ vscode . postMessage ( {
71+ t : "revealInModelEditor" ,
72+ method : modelAlerts . model ,
73+ } ) ,
74+ [ modelAlerts . model ] ,
75+ ) ;
6276 return (
6377 < div >
6478 < TitleContainer onClick = { ( ) => setExpanded ( ! isExpanded ) } >
@@ -71,6 +85,7 @@ export const ModelAlertsResults = ({
7185 < VSCodeBadge > { formatDecimal ( modelAlerts . alerts . length ) } </ VSCodeBadge >
7286 < MethodName { ...modelAlerts . model } > </ MethodName >
7387 < ModelTypeText > { modelAlerts . model . type } </ ModelTypeText >
88+ < ViewLink onClick = { viewInModelEditor } > View</ ViewLink >
7489 </ TitleContainer >
7590 { isExpanded && (
7691 < >
0 commit comments