MCPcopy Index your code
hub / github.com/coder/coder / VSCodeIconLink

Function VSCodeIconLink

site/src/pages/WorkspacesPage/WorkspacesTable.tsx:828–865  ·  view source on GitHub ↗
({
	variant,
	label,
	owner,
	workspace,
	agent,
	folder,
	children,
})

Source from the content-addressed store, hash-verified

826// key generation is a POST request that should only fire when
827// the user actually wants to open VS Code.
828const VSCodeIconLink: FC<VSCodeIconLinkProps> = ({
829 variant,
830 label,
831 owner,
832 workspace,
833 agent,
834 folder,
835 children,
836}) => {
837 const generateKeyMutation = useMutation({
838 mutationFn: () => API.getApiKey(),
839 onSuccess: ({ key }) => {
840 // We use a `location.href` here instead of a `navigate` because
841 // these are protocol-specific links.
842 location.href = getVSCodeHref(variant, {
843 owner,
844 workspace,
845 token: key,
846 agent,
847 folder,
848 });
849 },
850 });
851
852 return (
853 <BaseIconLink
854 label={label}
855 isLoading={generateKeyMutation.isPending}
856 onClick={() => {
857 if (!generateKeyMutation.isPending) {
858 generateKeyMutation.mutate();
859 }
860 }}
861 >
862 {children}
863 </BaseIconLink>
864 );
865};
866
867type BaseIconLinkCommonProps = PropsWithChildren<{
868 label: string;

Callers

nothing calls this directly

Calls 1

getVSCodeHrefFunction · 0.90

Tested by

no test coverage detected