Merge pull request #2422 from github/aeisenberg/compare-view-quick-eval
Allow compare view to work with quick-eval
This commit is contained in:
@@ -175,21 +175,40 @@ export class CompareView extends AbstractWebview<
|
|||||||
const commonResultSetNames = fromSchemaNames.filter((name) =>
|
const commonResultSetNames = fromSchemaNames.filter((name) =>
|
||||||
toSchemaNames.includes(name),
|
toSchemaNames.includes(name),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Fall back on the default result set names if there are no common ones.
|
||||||
|
const defaultFromResultSetName = fromSchemaNames.find((name) =>
|
||||||
|
name.startsWith("#"),
|
||||||
|
);
|
||||||
|
const defaultToResultSetName = toSchemaNames.find((name) =>
|
||||||
|
name.startsWith("#"),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (
|
||||||
|
commonResultSetNames.length === 0 &&
|
||||||
|
!(defaultFromResultSetName || defaultToResultSetName)
|
||||||
|
) {
|
||||||
|
throw new Error(
|
||||||
|
"No common result sets found between the two queries. Please check that the queries are compatible.",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const currentResultSetName =
|
const currentResultSetName =
|
||||||
selectedResultSetName || commonResultSetNames[0];
|
selectedResultSetName || commonResultSetNames[0];
|
||||||
const fromResultSet = await this.getResultSet(
|
const fromResultSet = await this.getResultSet(
|
||||||
fromSchemas,
|
fromSchemas,
|
||||||
currentResultSetName,
|
currentResultSetName || defaultFromResultSetName!,
|
||||||
from.completedQuery.query.resultsPaths.resultsPath,
|
from.completedQuery.query.resultsPaths.resultsPath,
|
||||||
);
|
);
|
||||||
const toResultSet = await this.getResultSet(
|
const toResultSet = await this.getResultSet(
|
||||||
toSchemas,
|
toSchemas,
|
||||||
currentResultSetName,
|
currentResultSetName || defaultToResultSetName!,
|
||||||
to.completedQuery.query.resultsPaths.resultsPath,
|
to.completedQuery.query.resultsPaths.resultsPath,
|
||||||
);
|
);
|
||||||
return [
|
return [
|
||||||
commonResultSetNames,
|
commonResultSetNames,
|
||||||
currentResultSetName,
|
currentResultSetName ||
|
||||||
|
`${defaultFromResultSetName} <-> ${defaultToResultSetName}`,
|
||||||
fromResultSet,
|
fromResultSet,
|
||||||
toResultSet,
|
toResultSet,
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -59,9 +59,7 @@ export function Compare(_: Record<string, never>): JSX.Element {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="vscode-codeql__compare-header">
|
<div className="vscode-codeql__compare-header">
|
||||||
<div className="vscode-codeql__compare-header-item">
|
<div className="vscode-codeql__compare-header-item">Comparing:</div>
|
||||||
Table to compare:
|
|
||||||
</div>
|
|
||||||
<CompareSelector
|
<CompareSelector
|
||||||
availableResultSets={comparison.commonResultSetNames}
|
availableResultSets={comparison.commonResultSetNames}
|
||||||
currentResultSetName={comparison.currentResultSetName}
|
currentResultSetName={comparison.currentResultSetName}
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function CompareSelector(props: Props) {
|
export default function CompareSelector(props: Props) {
|
||||||
return (
|
return props.availableResultSets.length ? (
|
||||||
|
// Handle case where there are shared result sets
|
||||||
<select
|
<select
|
||||||
value={props.currentResultSetName}
|
value={props.currentResultSetName}
|
||||||
onChange={(e) => props.updateResultSet(e.target.value)}
|
onChange={(e) => props.updateResultSet(e.target.value)}
|
||||||
@@ -18,5 +19,8 @@ export default function CompareSelector(props: Props) {
|
|||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
|
) : (
|
||||||
|
// Handle case where there are no shared result sets
|
||||||
|
<div>{props.currentResultSetName}</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user