({
variant,
label,
owner,
workspace,
agent,
folder,
children,
})
| 826 | // key generation is a POST request that should only fire when |
| 827 | // the user actually wants to open VS Code. |
| 828 | const 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 | |
| 867 | type BaseIconLinkCommonProps = PropsWithChildren<{ |
| 868 | label: string; |
nothing calls this directly
no test coverage detected