11import { useMutation , useQuery , useQueryClient } from "@tanstack/react-query" ;
22import { VscodeButton , VscodeCheckbox } from "@vscode-elements/react-elements" ;
33import CustomTable from "./components/CustomTable" ;
4+ import { FileLink } from "./components/FileLink" ;
45import { IconButton } from "./components/IconButton" ;
56import { useWebviewStore } from "./store" ;
67import {
@@ -9,6 +10,8 @@ import {
910 vscodeClient ,
1011} from "./webviewVsCodeApi" ;
1112
13+ import React , { useState } from "react" ;
14+
1215const styles = {
1316 infoPanel : { padding : "10px" } ,
1417 header : { marginBottom : "10px" } ,
@@ -27,15 +30,43 @@ const styles = {
2730 } ,
2831 value : {
2932 fontSize : "14px" ,
30- wordBreak : "break-all " ,
33+ wordBreak : "break-word " ,
3134 color : "var(--vscode-foreground)" ,
3235 } ,
36+ toggleButton : {
37+ display : "flex" ,
38+ alignItems : "center" ,
39+ gap : "4px" ,
40+ color : "var(--vscode-textLink-foreground)" ,
41+ cursor : "pointer" ,
42+ background : "none" ,
43+ border : "none" ,
44+ padding : "4px 0" ,
45+ marginTop : "0px" ,
46+ } ,
47+ pathContainer : {
48+ display : "flex" ,
49+ flexDirection : "column" as const ,
50+ gap : "6px" ,
51+ } ,
52+ pathItem : {
53+ display : "flex" ,
54+ alignItems : "center" ,
55+ } ,
56+ pathInfo : {
57+ marginLeft : "8px" ,
58+ opacity : 0.8 ,
59+ } ,
3360} as const ;
3461
3562const ToolInfo = ( {
3663 onClose,
3764 selectedTool,
38- } : { selectedTool : MiseTool ; onClose : ( ) => void } ) => {
65+ } : {
66+ selectedTool : MiseTool ;
67+ onClose : ( ) => void ;
68+ } ) => {
69+ const [ showAll , setShowAll ] = useState ( false ) ;
3970 const trackedConfigQuery = useQuery ( trackedConfigsQueryOptions ) ;
4071 const configs = trackedConfigQuery . data || [ ] ;
4172
@@ -47,6 +78,11 @@ const ToolInfo = ({
4778 return Object . keys ( config . tools ) . includes ( selectedTool . name ) ;
4879 } ) ;
4980
81+ const displayedConfigs = showAll
82+ ? configsWithTool
83+ : configsWithTool . slice ( 0 , 3 ) ;
84+ const hasMore = configsWithTool . length > 3 ;
85+
5086 return (
5187 < div style = { styles . infoPanel } >
5288 < div
@@ -61,7 +97,7 @@ const ToolInfo = ({
6197 < i className = "codicon codicon-tools" />
6298 { selectedTool . name }
6399 </ div >
64- < IconButton iconName = { "close" } onClick = { onClose } />
100+ < IconButton iconName = "close" onClick = { onClose } />
65101 </ div >
66102
67103 < div >
@@ -112,14 +148,37 @@ const ToolInfo = ({
112148 { configsWithTool . length > 0 && (
113149 < div >
114150 < p style = { styles . label } > Used in</ p >
115- < div style = { styles . value } >
116- { configsWithTool
117- . map ( ( config ) => {
118- // @ts -ignore
119- const toolInfo = config . tools [ selectedTool . name ] ;
120- return `${ toDisplayPath ( config . path ) } (${ JSON . stringify ( toolInfo ) } )` ;
121- } )
122- . join ( ", " ) }
151+ < div style = { styles . pathContainer } >
152+ { displayedConfigs . map ( ( config ) => {
153+ // @ts -ignore
154+ const toolInfo = config . tools [ selectedTool . name ] ;
155+ return (
156+ < span
157+ key = { config . path + selectedTool . name }
158+ style = { styles . pathItem }
159+ >
160+ < FileLink filePath = { config . path } />
161+ < span style = { styles . pathInfo } >
162+ ({ JSON . stringify ( toolInfo ) } )
163+ </ span >
164+ </ span >
165+ ) ;
166+ } ) }
167+
168+ { hasMore && (
169+ < button
170+ type = { "button" }
171+ onClick = { ( ) => setShowAll ( ! showAll ) }
172+ style = { styles . toggleButton }
173+ >
174+ < i
175+ className = { `codicon codicon-chevron-${ showAll ? "up" : "down" } ` }
176+ />
177+ { showAll
178+ ? "Show less"
179+ : `Show ${ configsWithTool . length - 3 } more` }
180+ </ button >
181+ ) }
123182 </ div >
124183 </ div >
125184 ) }
@@ -246,10 +305,28 @@ export const Tools = () => {
246305 mutationFn : ( ) => vscodeClient . request ( { mutationKey : [ "pruneTools" ] } ) ,
247306 } ) ;
248307
308+ const trackedConfigQuery = useQuery ( trackedConfigsQueryOptions ) ;
309+ const configs = trackedConfigQuery . data || [ ] ;
310+
311+ if ( ! selectedTool ) {
312+ return null ;
313+ }
314+
315+ const configsWithTool = configs . filter ( ( config ) => {
316+ return Object . keys ( config . tools ) . includes ( selectedTool . name ) ;
317+ } ) ;
318+
249319 const outdatedToolsQuery = useQuery ( {
250320 queryKey : [ "outdatedTools" ] ,
251- queryFn : ( { queryKey } ) =>
252- vscodeClient . request ( { queryKey } ) as Promise < Array < MiseToolUpdate > > ,
321+ queryFn : ( { queryKey } ) => {
322+ if ( ! navigator . onLine ) {
323+ return [ ] ;
324+ }
325+
326+ return vscodeClient . request ( { queryKey } ) as Promise <
327+ Array < MiseToolUpdate >
328+ > ;
329+ } ,
253330 } ) ;
254331
255332 if ( toolsQuery . isError ) {
@@ -285,7 +362,11 @@ export const Tools = () => {
285362 />
286363 ) }
287364 < CustomTable
288- style = { { height : window . innerHeight - ( selectedTool ? 280 : 40 ) } }
365+ style = { {
366+ height :
367+ window . innerHeight -
368+ ( selectedTool ? ( configsWithTool ?. length > 3 ? 320 : 280 ) : 40 ) ,
369+ } }
289370 filterRowElement = {
290371 < div
291372 style = { {
0 commit comments