Extract on-click handlers to consts
This commit is contained in:
@@ -50,6 +50,8 @@ type CodeSnippetMessageProps = {
|
||||
children: React.ReactNode;
|
||||
};
|
||||
|
||||
const sendAlertMessageLinkTelemetry = () => sendTelemetry("alert-message-link");
|
||||
|
||||
export const CodeSnippetMessage = ({
|
||||
message,
|
||||
severity,
|
||||
@@ -66,7 +68,7 @@ export const CodeSnippetMessage = ({
|
||||
return (
|
||||
<LocationLink
|
||||
key={index}
|
||||
onClick={() => sendTelemetry("alert-message-link")}
|
||||
onClick={sendAlertMessageLinkTelemetry}
|
||||
href={createRemoteFileRef(
|
||||
token.location.fileLink,
|
||||
token.location.highlightedRegion?.startLine,
|
||||
|
||||
@@ -47,6 +47,9 @@ type Props = {
|
||||
messageChildren?: React.ReactNode;
|
||||
};
|
||||
|
||||
const sendCodeSnippetTitleLinkTelemetry = () =>
|
||||
sendTelemetry("file-code-snippet-title-link");
|
||||
|
||||
export const FileCodeSnippet = ({
|
||||
fileLink,
|
||||
codeSnippet,
|
||||
@@ -69,7 +72,7 @@ export const FileCodeSnippet = ({
|
||||
<Container>
|
||||
<TitleContainer>
|
||||
<VSCodeLink
|
||||
onClick={() => sendTelemetry("file-code-snippet-title-link")}
|
||||
onClick={sendCodeSnippetTitleLinkTelemetry}
|
||||
href={titleFileUri}
|
||||
>
|
||||
{fileLink.filePath}
|
||||
@@ -90,7 +93,7 @@ export const FileCodeSnippet = ({
|
||||
<Container>
|
||||
<TitleContainer>
|
||||
<VSCodeLink
|
||||
onClick={() => sendTelemetry("file-code-snippet-title-link")}
|
||||
onClick={sendCodeSnippetTitleLinkTelemetry}
|
||||
href={titleFileUri}
|
||||
>
|
||||
{fileLink.filePath}
|
||||
|
||||
@@ -45,6 +45,8 @@ type CellProps = {
|
||||
sourceLocationPrefix: string;
|
||||
};
|
||||
|
||||
const sendRawResultsLinkTelemetry = () => sendTelemetry("raw-results-link");
|
||||
|
||||
const Cell = ({ value, fileLinkPrefix, sourceLocationPrefix }: CellProps) => {
|
||||
switch (typeof value) {
|
||||
case "string":
|
||||
@@ -60,10 +62,7 @@ const Cell = ({ value, fileLinkPrefix, sourceLocationPrefix }: CellProps) => {
|
||||
const safeLabel = convertNonPrintableChars(value.label);
|
||||
if (url) {
|
||||
return (
|
||||
<VSCodeLink
|
||||
onClick={() => sendTelemetry("raw-results-link")}
|
||||
href={url}
|
||||
>
|
||||
<VSCodeLink onClick={sendRawResultsLinkTelemetry} href={url}>
|
||||
{safeLabel}
|
||||
</VSCodeLink>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user