Skip to content

Commit 08a8d63

Browse files
Remove column arg where it is always "alert-message"
1 parent bfae001 commit 08a8d63

1 file changed

Lines changed: 29 additions & 41 deletions

File tree

extensions/ql-vscode/src/view/results/alert-table-header.tsx

Lines changed: 29 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as React from "react";
22
import { useCallback } from "react";
33
import { vscode } from "../vscode-api";
44
import {
5-
InterpretedResultsSortColumn,
65
InterpretedResultsSortState,
76
SortDirection,
87
} from "../../common/interface-types";
@@ -13,47 +12,38 @@ export function AlertTableHeader({
1312
}: {
1413
sortState?: InterpretedResultsSortState;
1514
}) {
16-
const sortClass = useCallback(
17-
(column: InterpretedResultsSortColumn): string => {
18-
if (sortState !== undefined && sortState.sortBy === column) {
19-
return sortState.sortDirection === SortDirection.asc
20-
? "sort-asc"
21-
: "sort-desc";
22-
} else {
23-
return "sort-none";
24-
}
25-
},
26-
[sortState],
27-
);
15+
const sortClass = useCallback((): string => {
16+
if (sortState !== undefined && sortState.sortBy === "alert-message") {
17+
return sortState.sortDirection === SortDirection.asc
18+
? "sort-asc"
19+
: "sort-desc";
20+
} else {
21+
return "sort-none";
22+
}
23+
}, [sortState]);
2824

29-
const getNextSortState = useCallback(
30-
(
31-
column: InterpretedResultsSortColumn,
32-
): InterpretedResultsSortState | undefined => {
33-
const prevDirection =
34-
sortState && sortState.sortBy === column
35-
? sortState.sortDirection
36-
: undefined;
37-
const nextDirection = nextSortDirection(prevDirection, true);
38-
return nextDirection === undefined
39-
? undefined
40-
: { sortBy: column, sortDirection: nextDirection };
41-
},
42-
[sortState],
43-
);
25+
const getNextSortState = useCallback(():
26+
| InterpretedResultsSortState
27+
| undefined => {
28+
const prevDirection =
29+
sortState && sortState.sortBy === "alert-message"
30+
? sortState.sortDirection
31+
: undefined;
32+
const nextDirection = nextSortDirection(prevDirection, true);
33+
return nextDirection === undefined
34+
? undefined
35+
: { sortBy: "alert-message", sortDirection: nextDirection };
36+
}, [sortState]);
4437

45-
const toggleSortStateForColumn = useCallback(
46-
(column: InterpretedResultsSortColumn): void => {
47-
vscode.postMessage({
48-
t: "changeInterpretedSort",
49-
sortState: getNextSortState(column),
50-
});
51-
},
52-
[getNextSortState],
53-
);
38+
const toggleSortStateForColumn = useCallback((): void => {
39+
vscode.postMessage({
40+
t: "changeInterpretedSort",
41+
sortState: getNextSortState(),
42+
});
43+
}, [getNextSortState]);
5444

5545
const clickCallback = useCallback(
56-
() => toggleSortStateForColumn("alert-message"),
46+
() => toggleSortStateForColumn(),
5747
[toggleSortStateForColumn],
5848
);
5949

@@ -62,9 +52,7 @@ export function AlertTableHeader({
6252
<tr>
6353
<th colSpan={2}></th>
6454
<th
65-
className={`${sortClass(
66-
"alert-message",
67-
)} vscode-codeql__alert-message-cell`}
55+
className={`${sortClass()} vscode-codeql__alert-message-cell`}
6856
colSpan={3}
6957
onClick={clickCallback}
7058
>

0 commit comments

Comments
 (0)