Skip to content

Commit 578cfad

Browse files
committed
EIWFY23Q4-1 Sort validation by line by default
1 parent c98c0b6 commit 578cfad

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/LoadSchema.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class LoadSchemaWR extends React.PureComponent<LoadSchemaProps, LoadSchemaState>
7777
header="Schema load failed"
7878
description="Attempted to pull the JSON Schema down from the public internet."
7979
primaryAction={(
80-
<p>Error: ${result.schema.message}</p>
80+
<p>Error: {result.schema.message}</p>
8181
)}
8282
/>
8383
);
@@ -96,4 +96,4 @@ class LoadSchemaWR extends React.PureComponent<LoadSchemaProps, LoadSchemaState>
9696
}
9797
}
9898

99-
export const LoadSchema = withRouter<LoadSchemaProps, typeof LoadSchemaWR>(LoadSchemaWR);
99+
export const LoadSchema = withRouter<LoadSchemaProps, typeof LoadSchemaWR>(LoadSchemaWR);

src/SchemaValidator.tsx

+10-4
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,32 @@ const severityDefinitions = {
3737
};
3838

3939
export const SchemaValidator: FC<SchemaValidatorProps> = ({ results, onSelectRange }) => {
40+
const sortedByLineNumber = results.sort((a, b) => {
41+
if (a.startLineNumber !== b.startLineNumber) {
42+
return a.startLineNumber - b.startLineNumber;
43+
}
44+
return a.startColumn - b.startColumn;
45+
});
4046
return (
4147
<Table>
4248
<THead>
4349
<SortableColumn name="severity">Severity</SortableColumn>
4450
<SortableColumn name="message">Message</SortableColumn>
4551
<SortableColumn name="startLineNumber">Location</SortableColumn>
4652
</THead>
47-
<TBody rows={results}>
53+
<TBody rows={sortedByLineNumber}>
4854
{(row) => {
4955
const { label, icon: Icon, color } = severityDefinitions[row.severity];
5056
const {
51-
modelVersionId,
5257
message,
5358
startColumn,
5459
startLineNumber,
5560
endColumn,
5661
endLineNumber,
5762
} = row;
63+
const locationString = `${startLineNumber}:${startColumn}-${endLineNumber}:${endColumn}`
5864
return (
59-
<Row key={modelVersionId}>
65+
<Row key={`${locationString}-${message}`}>
6066
<Cell>
6167
<Flex>
6268
<Icon label={label} primaryColor={color} />
@@ -77,7 +83,7 @@ export const SchemaValidator: FC<SchemaValidatorProps> = ({ results, onSelectRan
7783
});
7884
}}
7985
>
80-
{startLineNumber}:{startColumn}-{endLineNumber}:{endColumn}
86+
{locationString}
8187
</a>
8288
</Cell>
8389
</Row>

0 commit comments

Comments
 (0)