Split alert table dropdown indicator cell

This commit is contained in:
Koen Vlaswinkel
2023-08-18 12:24:55 +02:00
parent b7a4419420
commit 9f589880df
2 changed files with 31 additions and 25 deletions

View File

@@ -1,7 +1,7 @@
import * as React from "react"; import * as React from "react";
import * as Sarif from "sarif"; import * as Sarif from "sarif";
import * as Keys from "./result-keys"; import * as Keys from "./result-keys";
import { chevronDown, chevronRight, info, listUnordered } from "./octicons"; import { info, listUnordered } from "./octicons";
import { import {
className, className,
ResultTableProps, ResultTableProps,
@@ -22,6 +22,7 @@ import { AlertTableHeader } from "./AlertTableHeader";
import { SarifMessageWithLocations } from "./locations/SarifMessageWithLocations"; import { SarifMessageWithLocations } from "./locations/SarifMessageWithLocations";
import { SarifLocation } from "./locations/SarifLocation"; import { SarifLocation } from "./locations/SarifLocation";
import { EmptyQueryResultsMessage } from "./EmptyQueryResultsMessage"; import { EmptyQueryResultsMessage } from "./EmptyQueryResultsMessage";
import { AlertTableDropdownIndicatorCell } from "./AlertTableDropdownIndicatorCell";
type AlertTableProps = ResultTableProps & { type AlertTableProps = ResultTableProps & {
resultSet: InterpretedResultSet<SarifInterpretationData>; resultSet: InterpretedResultSet<SarifInterpretationData>;
@@ -137,7 +138,6 @@ export class AlertTable extends React.Component<
const currentResultExpanded = this.state.expanded.has( const currentResultExpanded = this.state.expanded.has(
Keys.keyToString(resultKey), Keys.keyToString(resultKey),
); );
const indicator = currentResultExpanded ? chevronDown : chevronRight;
const location = result.locations !== undefined && const location = result.locations !== undefined &&
result.locations.length > 0 && ( result.locations.length > 0 && (
<SarifLocation <SarifLocation
@@ -184,16 +184,10 @@ export class AlertTable extends React.Component<
{...selectableZebraStripe(resultRowIsSelected, resultIndex)} {...selectableZebraStripe(resultRowIsSelected, resultIndex)}
key={resultIndex} key={resultIndex}
> >
{/* <AlertTableDropdownIndicatorCell
eslint-disable-next-line expanded={currentResultExpanded}
jsx-a11y/no-noninteractive-element-interactions onClick={toggler(indices)}
*/} />
<td
className="vscode-codeql__icon-cell vscode-codeql__dropdown-cell"
onMouseDown={toggler(indices)}
>
{indicator}
</td>
<td className="vscode-codeql__icon-cell">{listUnordered}</td> <td className="vscode-codeql__icon-cell">{listUnordered}</td>
<td colSpan={2}>{msg}</td> <td colSpan={2}>{msg}</td>
{locationCells} {locationCells}
@@ -206,9 +200,6 @@ export class AlertTable extends React.Component<
Keys.keyToString(pathKey), Keys.keyToString(pathKey),
); );
if (currentResultExpanded) { if (currentResultExpanded) {
const indicator = currentPathExpanded
? chevronDown
: chevronRight;
const isPathSpecificallySelected = Keys.equalsNotUndefined( const isPathSpecificallySelected = Keys.equalsNotUndefined(
pathKey, pathKey,
selectedItem, selectedItem,
@@ -225,16 +216,10 @@ export class AlertTable extends React.Component<
<td className="vscode-codeql__icon-cell"> <td className="vscode-codeql__icon-cell">
<span className="vscode-codeql__vertical-rule"></span> <span className="vscode-codeql__vertical-rule"></span>
</td> </td>
{/* <AlertTableDropdownIndicatorCell
eslint-disable-next-line expanded={currentPathExpanded}
jsx-a11y/no-noninteractive-element-interactions onClick={toggler([pathKey])}
*/} />
<td
className="vscode-codeql__icon-cell vscode-codeql__dropdown-cell"
onMouseDown={toggler([pathKey])}
>
{indicator}
</td>
<td className="vscode-codeql__text-center" colSpan={3}> <td className="vscode-codeql__text-center" colSpan={3}>
Path Path
</td> </td>

View File

@@ -0,0 +1,21 @@
import * as React from "react";
import { chevronDown, chevronRight } from "./octicons";
type Props = {
expanded: boolean;
onClick: (e: React.MouseEvent) => void;
};
export function AlertTableDropdownIndicatorCell({ expanded, onClick }: Props) {
const indicator = expanded ? chevronDown : chevronRight;
return (
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
<td
className="vscode-codeql__icon-cell vscode-codeql__dropdown-cell"
onMouseDown={onClick}
>
{indicator}
</td>
);
}