-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: show track configuration files
- Loading branch information
Showing
13 changed files
with
342 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export function uniqBy<T>(array: T[], iteratee: (value: T) => string): T[] { | ||
if (!Array.isArray(array)) { | ||
throw new TypeError("Expected an array as first argument"); | ||
} | ||
|
||
const seen = new Map<string, T>(); | ||
|
||
for (const item of array) { | ||
const key = iteratee(item); | ||
if (!seen.has(key)) { | ||
seen.set(key, item); | ||
} | ||
} | ||
|
||
return Array.from(seen.values()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { useMutation, useQuery } from "@tanstack/react-query"; | ||
import CustomTable from "./components/CustomTable"; | ||
import { vscodeClient } from "./webviewVsCodeApi"; | ||
|
||
export const TrackedConfigs = () => { | ||
const settingsQuery = useQuery({ | ||
queryKey: ["trackedConfigs"], | ||
queryFn: ({ queryKey }) => | ||
vscodeClient.request({ queryKey }) as Promise< | ||
Array<{ path: string; tools: object }> | ||
>, | ||
}); | ||
|
||
const openFileMutation = useMutation({ | ||
mutationKey: ["openFile"], | ||
mutationFn: (path: string) => | ||
vscodeClient.request({ mutationKey: ["openFile"], variables: { path } }), | ||
}); | ||
|
||
if (settingsQuery.isError) { | ||
return <div>Error: {settingsQuery.error.message}</div>; | ||
} | ||
|
||
return ( | ||
<div> | ||
<CustomTable | ||
filterRowElement={"Showing tracked config files"} | ||
isLoading={settingsQuery.isLoading} | ||
data={settingsQuery.data || []} | ||
columns={[ | ||
{ | ||
id: "path", | ||
header: "File", | ||
accessorKey: "path", | ||
cell: ({ row }) => { | ||
return ( | ||
<a | ||
href={`#${row.original.path}`} | ||
onClick={(e) => { | ||
e.preventDefault(); | ||
openFileMutation.mutate(row.original.path); | ||
}} | ||
title={row.original.path} | ||
> | ||
{row.original.path} | ||
</a> | ||
); | ||
}, | ||
}, | ||
{ | ||
id: "tools", | ||
header: "Tools", | ||
accessorKey: "tools", | ||
cell: ({ row }) => { | ||
return Object.entries(row.original.tools).map( | ||
([toolName, toolVersion]) => ( | ||
<div key={toolName}> | ||
{toolName} = {JSON.stringify(toolVersion)} | ||
</div> | ||
), | ||
); | ||
}, | ||
}, | ||
]} | ||
/> | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.