Extract on-click handlers to consts
This commit is contained in:
@@ -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,
|
||||||
|
|||||||
@@ -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}
|
||||||
|
|||||||
@@ -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>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user