11import * as React from "react" ;
22import { useState } from "react" ;
33import { styled } from "styled-components" ;
4- import { VSCodeLink } from "@vscode/webview-ui-toolkit/react" ;
5- import {
6- CellValue ,
7- RawResultSet ,
8- ResultSetSchema ,
9- } from "../../common/bqrs-cli-types" ;
10- import { tryGetRemoteLocation } from "../../common/bqrs-utils" ;
4+ import { RawResultSet , ResultSetSchema } from "../../common/bqrs-cli-types" ;
115import TextButton from "../common/TextButton" ;
12- import { convertNonPrintableChars } from "../../ common/text-utils " ;
13- import { sendTelemetry , useTelemetryOnChange } from "../common/telemetry " ;
6+ import { useTelemetryOnChange } from "../common/telemetry " ;
7+ import { RawResultRow } from "./RawResultRow " ;
148
159const numOfResultsInContractedMode = 5 ;
1610
17- const StyledRow = styled . div `
18- border-color: var(--vscode-editor-snippetFinalTabstopHighlightBorder);
19- border-style: solid;
20- justify-content: center;
21- align-items: center;
22- padding: 0.4rem;
23- word-break: break-word;
24- ` ;
25-
2611type TableContainerProps = {
2712 columnCount : number ;
2813} ;
@@ -40,60 +25,6 @@ const TableContainer = styled.div<TableContainerProps>`
4025 padding: 0.4rem;
4126` ;
4227
43- type CellProps = {
44- value : CellValue ;
45- fileLinkPrefix : string ;
46- sourceLocationPrefix : string ;
47- } ;
48-
49- const sendRawResultsLinkTelemetry = ( ) => sendTelemetry ( "raw-results-link" ) ;
50-
51- const Cell = ( { value, fileLinkPrefix, sourceLocationPrefix } : CellProps ) => {
52- switch ( typeof value ) {
53- case "string" :
54- case "number" :
55- case "boolean" :
56- return < span > { convertNonPrintableChars ( value . toString ( ) ) } </ span > ;
57- case "object" : {
58- const url = tryGetRemoteLocation (
59- value . url ,
60- fileLinkPrefix ,
61- sourceLocationPrefix ,
62- ) ;
63- const safeLabel = convertNonPrintableChars ( value . label ) ;
64- if ( url ) {
65- return (
66- < VSCodeLink onClick = { sendRawResultsLinkTelemetry } href = { url } >
67- { safeLabel }
68- </ VSCodeLink >
69- ) ;
70- } else {
71- return < span > { safeLabel } </ span > ;
72- }
73- }
74- }
75- } ;
76-
77- type RowProps = {
78- row : CellValue [ ] ;
79- fileLinkPrefix : string ;
80- sourceLocationPrefix : string ;
81- } ;
82-
83- const Row = ( { row, fileLinkPrefix, sourceLocationPrefix } : RowProps ) => (
84- < >
85- { row . map ( ( cell , cellIndex ) => (
86- < StyledRow key = { cellIndex } >
87- < Cell
88- value = { cell }
89- fileLinkPrefix = { fileLinkPrefix }
90- sourceLocationPrefix = { sourceLocationPrefix }
91- />
92- </ StyledRow >
93- ) ) }
94- </ >
95- ) ;
96-
9728type RawResultsTableProps = {
9829 schema : ResultSetSchema ;
9930 results : RawResultSet ;
@@ -122,7 +53,7 @@ const RawResultsTable = ({
12253 < >
12354 < TableContainer columnCount = { schema . columns . length } >
12455 { results . rows . slice ( 0 , numOfResultsToShow ) . map ( ( row , rowIndex ) => (
125- < Row
56+ < RawResultRow
12657 key = { rowIndex }
12758 row = { row }
12859 fileLinkPrefix = { fileLinkPrefix }
0 commit comments