-
Notifications
You must be signed in to change notification settings - Fork 226
Expand file tree
/
Copy pathRawResultCell.tsx
More file actions
46 lines (43 loc) · 1.31 KB
/
RawResultCell.tsx
File metadata and controls
46 lines (43 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import type { CellValue } from "../../common/raw-result-types";
import { sendTelemetry } from "../common/telemetry";
import { convertNonPrintableChars } from "../../common/text-utils";
import { tryGetRemoteLocation } from "../../common/bqrs-utils";
import { RawNumberValue } from "../common/RawNumberValue";
import { Link } from "../common/Link";
type CellProps = {
value: CellValue;
fileLinkPrefix: string;
sourceLocationPrefix: string;
};
const sendRawResultsLinkTelemetry = () => sendTelemetry("raw-results-link");
export const RawResultCell = ({
value,
fileLinkPrefix,
sourceLocationPrefix,
}: CellProps) => {
switch (value.type) {
case "boolean":
return <span>{value.value.toString()}</span>;
case "number":
return <RawNumberValue value={value.value} />;
case "string":
return <span>{convertNonPrintableChars(value.value.toString())}</span>;
case "entity": {
const url = tryGetRemoteLocation(
value.value.url,
fileLinkPrefix,
sourceLocationPrefix,
);
const safeLabel = convertNonPrintableChars(value.value.label);
if (url) {
return (
<Link onClick={sendRawResultsLinkTelemetry} href={url}>
{safeLabel}
</Link>
);
} else {
return <span>{safeLabel}</span>;
}
}
}
};