Extract on-click handlers to consts

This commit is contained in:
Robert
2023-01-12 11:01:10 +00:00
parent 0aa2cd6e90
commit 25a3ba76ed
3 changed files with 11 additions and 7 deletions

View File

@@ -50,6 +50,8 @@ type CodeSnippetMessageProps = {
children: React.ReactNode; children: React.ReactNode;
}; };
const sendAlertMessageLinkTelemetry = () => sendTelemetry("alert-message-link");
export const CodeSnippetMessage = ({ export const CodeSnippetMessage = ({
message, message,
severity, severity,
@@ -66,7 +68,7 @@ export const CodeSnippetMessage = ({
return ( return (
<LocationLink <LocationLink
key={index} key={index}
onClick={() => sendTelemetry("alert-message-link")} onClick={sendAlertMessageLinkTelemetry}
href={createRemoteFileRef( href={createRemoteFileRef(
token.location.fileLink, token.location.fileLink,
token.location.highlightedRegion?.startLine, token.location.highlightedRegion?.startLine,

View File

@@ -47,6 +47,9 @@ type Props = {
messageChildren?: React.ReactNode; messageChildren?: React.ReactNode;
}; };
const sendCodeSnippetTitleLinkTelemetry = () =>
sendTelemetry("file-code-snippet-title-link");
export const FileCodeSnippet = ({ export const FileCodeSnippet = ({
fileLink, fileLink,
codeSnippet, codeSnippet,
@@ -69,7 +72,7 @@ export const FileCodeSnippet = ({
<Container> <Container>
<TitleContainer> <TitleContainer>
<VSCodeLink <VSCodeLink
onClick={() => sendTelemetry("file-code-snippet-title-link")} onClick={sendCodeSnippetTitleLinkTelemetry}
href={titleFileUri} href={titleFileUri}
> >
{fileLink.filePath} {fileLink.filePath}
@@ -90,7 +93,7 @@ export const FileCodeSnippet = ({
<Container> <Container>
<TitleContainer> <TitleContainer>
<VSCodeLink <VSCodeLink
onClick={() => sendTelemetry("file-code-snippet-title-link")} onClick={sendCodeSnippetTitleLinkTelemetry}
href={titleFileUri} href={titleFileUri}
> >
{fileLink.filePath} {fileLink.filePath}

View File

@@ -45,6 +45,8 @@ type CellProps = {
sourceLocationPrefix: string; sourceLocationPrefix: string;
}; };
const sendRawResultsLinkTelemetry = () => sendTelemetry("raw-results-link");
const Cell = ({ value, fileLinkPrefix, sourceLocationPrefix }: CellProps) => { const Cell = ({ value, fileLinkPrefix, sourceLocationPrefix }: CellProps) => {
switch (typeof value) { switch (typeof value) {
case "string": case "string":
@@ -60,10 +62,7 @@ const Cell = ({ value, fileLinkPrefix, sourceLocationPrefix }: CellProps) => {
const safeLabel = convertNonPrintableChars(value.label); const safeLabel = convertNonPrintableChars(value.label);
if (url) { if (url) {
return ( return (
<VSCodeLink <VSCodeLink onClick={sendRawResultsLinkTelemetry} href={url}>
onClick={() => sendTelemetry("raw-results-link")}
href={url}
>
{safeLabel} {safeLabel}
</VSCodeLink> </VSCodeLink>
); );