Skip to content

Commit 9f58988

Browse files
committed
Split alert table dropdown indicator cell
1 parent b7a4419 commit 9f58988

File tree

2 files changed

+31
-25
lines changed

2 files changed

+31
-25
lines changed

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

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from "react";
22
import * as Sarif from "sarif";
33
import * as Keys from "./result-keys";
4-
import { chevronDown, chevronRight, info, listUnordered } from "./octicons";
4+
import { info, listUnordered } from "./octicons";
55
import {
66
className,
77
ResultTableProps,
@@ -22,6 +22,7 @@ import { AlertTableHeader } from "./AlertTableHeader";
2222
import { SarifMessageWithLocations } from "./locations/SarifMessageWithLocations";
2323
import { SarifLocation } from "./locations/SarifLocation";
2424
import { EmptyQueryResultsMessage } from "./EmptyQueryResultsMessage";
25+
import { AlertTableDropdownIndicatorCell } from "./AlertTableDropdownIndicatorCell";
2526

2627
type AlertTableProps = ResultTableProps & {
2728
resultSet: InterpretedResultSet<SarifInterpretationData>;
@@ -137,7 +138,6 @@ export class AlertTable extends React.Component<
137138
const currentResultExpanded = this.state.expanded.has(
138139
Keys.keyToString(resultKey),
139140
);
140-
const indicator = currentResultExpanded ? chevronDown : chevronRight;
141141
const location = result.locations !== undefined &&
142142
result.locations.length > 0 && (
143143
<SarifLocation
@@ -184,16 +184,10 @@ export class AlertTable extends React.Component<
184184
{...selectableZebraStripe(resultRowIsSelected, resultIndex)}
185185
key={resultIndex}
186186
>
187-
{/*
188-
eslint-disable-next-line
189-
jsx-a11y/no-noninteractive-element-interactions
190-
*/}
191-
<td
192-
className="vscode-codeql__icon-cell vscode-codeql__dropdown-cell"
193-
onMouseDown={toggler(indices)}
194-
>
195-
{indicator}
196-
</td>
187+
<AlertTableDropdownIndicatorCell
188+
expanded={currentResultExpanded}
189+
onClick={toggler(indices)}
190+
/>
197191
<td className="vscode-codeql__icon-cell">{listUnordered}</td>
198192
<td colSpan={2}>{msg}</td>
199193
{locationCells}
@@ -206,9 +200,6 @@ export class AlertTable extends React.Component<
206200
Keys.keyToString(pathKey),
207201
);
208202
if (currentResultExpanded) {
209-
const indicator = currentPathExpanded
210-
? chevronDown
211-
: chevronRight;
212203
const isPathSpecificallySelected = Keys.equalsNotUndefined(
213204
pathKey,
214205
selectedItem,
@@ -225,16 +216,10 @@ export class AlertTable extends React.Component<
225216
<td className="vscode-codeql__icon-cell">
226217
<span className="vscode-codeql__vertical-rule"></span>
227218
</td>
228-
{/*
229-
eslint-disable-next-line
230-
jsx-a11y/no-noninteractive-element-interactions
231-
*/}
232-
<td
233-
className="vscode-codeql__icon-cell vscode-codeql__dropdown-cell"
234-
onMouseDown={toggler([pathKey])}
235-
>
236-
{indicator}
237-
</td>
219+
<AlertTableDropdownIndicatorCell
220+
expanded={currentPathExpanded}
221+
onClick={toggler([pathKey])}
222+
/>
238223
<td className="vscode-codeql__text-center" colSpan={3}>
239224
Path
240225
</td>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import * as React from "react";
2+
import { chevronDown, chevronRight } from "./octicons";
3+
4+
type Props = {
5+
expanded: boolean;
6+
onClick: (e: React.MouseEvent) => void;
7+
};
8+
9+
export function AlertTableDropdownIndicatorCell({ expanded, onClick }: Props) {
10+
const indicator = expanded ? chevronDown : chevronRight;
11+
12+
return (
13+
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
14+
<td
15+
className="vscode-codeql__icon-cell vscode-codeql__dropdown-cell"
16+
onMouseDown={onClick}
17+
>
18+
{indicator}
19+
</td>
20+
);
21+
}

0 commit comments

Comments
 (0)