Skip to content

Commit e961c90

Browse files
committed
Right align and format raw result numbers
This changes the formatting for both the local raw results table and the variant analysis raw results table to right align and format numbers.
1 parent 93251f8 commit e961c90

3 files changed

Lines changed: 44 additions & 19 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import * as React from "react";
2+
import { styled } from "styled-components";
3+
import { formatDecimal } from "../../common/number";
4+
5+
const RightAlignedSpan = styled.span`
6+
display: inline-block;
7+
text-align: right;
8+
width: 100%;
9+
`;
10+
11+
type Props = {
12+
value: number;
13+
};
14+
15+
export const RawNumberValue = ({ value }: Props) => {
16+
return <RightAlignedSpan>{formatDecimal(value)}</RightAlignedSpan>;
17+
};

extensions/ql-vscode/src/view/results/RawTableValue.tsx

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,34 @@ import * as React from "react";
22

33
import { Location } from "./locations/Location";
44
import { CellValue } from "../../common/bqrs-cli-types";
5+
import { RawNumberValue } from "../common/RawNumberValue";
56

67
interface Props {
78
value: CellValue;
89
databaseUri: string;
910
onSelected?: () => void;
1011
}
1112

12-
export default function RawTableValue(props: Props): JSX.Element {
13-
const rawValue = props.value;
14-
if (
15-
typeof rawValue === "string" ||
16-
typeof rawValue === "number" ||
17-
typeof rawValue === "boolean"
18-
) {
19-
return <Location label={rawValue.toString()} />;
13+
export default function RawTableValue({
14+
value,
15+
databaseUri,
16+
onSelected,
17+
}: Props): JSX.Element {
18+
switch (typeof value) {
19+
case "boolean":
20+
return <span>{value.toString()}</span>;
21+
case "number":
22+
return <RawNumberValue value={value} />;
23+
case "string":
24+
return <Location label={value.toString()} />;
25+
default:
26+
return (
27+
<Location
28+
loc={value.url}
29+
label={value.label}
30+
databaseUri={databaseUri}
31+
onClick={onSelected}
32+
/>
33+
);
2034
}
21-
22-
return (
23-
<Location
24-
loc={rawValue.url}
25-
label={rawValue.label}
26-
databaseUri={props.databaseUri}
27-
onClick={props.onSelected}
28-
/>
29-
);
3035
}

extensions/ql-vscode/src/view/variant-analysis/RawResultsTable.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { tryGetRemoteLocation } from "../../common/bqrs-utils";
1111
import TextButton from "../common/TextButton";
1212
import { convertNonPrintableChars } from "../../common/text-utils";
1313
import { sendTelemetry, useTelemetryOnChange } from "../common/telemetry";
14+
import { RawNumberValue } from "../common/RawNumberValue";
1415

1516
const numOfResultsInContractedMode = 5;
1617

@@ -50,9 +51,11 @@ const sendRawResultsLinkTelemetry = () => sendTelemetry("raw-results-link");
5051

5152
const Cell = ({ value, fileLinkPrefix, sourceLocationPrefix }: CellProps) => {
5253
switch (typeof value) {
53-
case "string":
54-
case "number":
5554
case "boolean":
55+
return <span>{value.toString()}</span>;
56+
case "number":
57+
return <RawNumberValue value={value} />;
58+
case "string":
5659
return <span>{convertNonPrintableChars(value.toString())}</span>;
5760
case "object": {
5861
const url = tryGetRemoteLocation(

0 commit comments

Comments
 (0)