Extract RawResultRow to separate file

This commit is contained in:
Koen Vlaswinkel
2023-09-26 14:46:08 +02:00
parent 1afee02e78
commit 452329b07a
2 changed files with 41 additions and 36 deletions

View File

@@ -0,0 +1,38 @@
import * as React from "react";
import { styled } from "styled-components";
import { CellValue } from "../../common/bqrs-cli-types";
import { RawResultCell } from "./RawResultCell";
const StyledRow = styled.div`
border-color: var(--vscode-editor-snippetFinalTabstopHighlightBorder);
border-style: solid;
justify-content: center;
align-items: center;
padding: 0.4rem;
word-break: break-word;
`;
type RowProps = {
row: CellValue[];
fileLinkPrefix: string;
sourceLocationPrefix: string;
};
export const RawResultRow = ({
row,
fileLinkPrefix,
sourceLocationPrefix,
}: RowProps) => (
<>
{row.map((cell, cellIndex) => (
<StyledRow key={cellIndex}>
<RawResultCell
value={cell}
fileLinkPrefix={fileLinkPrefix}
sourceLocationPrefix={sourceLocationPrefix}
/>
</StyledRow>
))}
</>
);

View File

@@ -1,26 +1,13 @@
import * as React from "react";
import { useState } from "react";
import { styled } from "styled-components";
import {
CellValue,
RawResultSet,
ResultSetSchema,
} from "../../common/bqrs-cli-types";
import { RawResultSet, ResultSetSchema } from "../../common/bqrs-cli-types";
import TextButton from "../common/TextButton";
import { useTelemetryOnChange } from "../common/telemetry";
import { RawResultCell } from "./RawResultCell";
import { RawResultRow } from "./RawResultRow";
const numOfResultsInContractedMode = 5;
const StyledRow = styled.div`
border-color: var(--vscode-editor-snippetFinalTabstopHighlightBorder);
border-style: solid;
justify-content: center;
align-items: center;
padding: 0.4rem;
word-break: break-word;
`;
type TableContainerProps = {
columnCount: number;
};
@@ -38,26 +25,6 @@ const TableContainer = styled.div<TableContainerProps>`
padding: 0.4rem;
`;
type RowProps = {
row: CellValue[];
fileLinkPrefix: string;
sourceLocationPrefix: string;
};
const Row = ({ row, fileLinkPrefix, sourceLocationPrefix }: RowProps) => (
<>
{row.map((cell, cellIndex) => (
<StyledRow key={cellIndex}>
<RawResultCell
value={cell}
fileLinkPrefix={fileLinkPrefix}
sourceLocationPrefix={sourceLocationPrefix}
/>
</StyledRow>
))}
</>
);
type RawResultsTableProps = {
schema: ResultSetSchema;
results: RawResultSet;
@@ -86,7 +53,7 @@ const RawResultsTable = ({
<>
<TableContainer columnCount={schema.columns.length}>
{results.rows.slice(0, numOfResultsToShow).map((row, rowIndex) => (
<Row
<RawResultRow
key={rowIndex}
row={row}
fileLinkPrefix={fileLinkPrefix}