Skip to content

Commit bd5d361

Browse files
Pass around toggle instead of toggler
1 parent e3596db commit bd5d361

3 files changed

Lines changed: 10 additions & 16 deletions

File tree

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,6 @@ export class AlertTable extends React.Component<
8484
};
8585
};
8686

87-
const toggler: (keys: Keys.ResultKey[]) => (e: React.MouseEvent) => void = (
88-
indices,
89-
) => {
90-
return (e) => this.toggle(e, indices);
91-
};
92-
9387
if (!resultSet.interpretation.data.runs?.[0]?.results?.length) {
9488
return <AlertTableNoResults {...this.props} />;
9589
}
@@ -109,7 +103,7 @@ export class AlertTable extends React.Component<
109103
databaseUri={databaseUri}
110104
sourceLocationPrefix={sourceLocationPrefix}
111105
updateSelectionCallback={updateSelectionCallback}
112-
toggler={toggler}
106+
toggleExpanded={this.toggle.bind(this)}
113107
scroller={this.scroller}
114108
/>
115109
),

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ interface Props {
1818
updateSelectionCallback: (
1919
resultKey: Keys.PathNode | Keys.Result | undefined,
2020
) => () => void;
21-
toggler: (keys: Keys.ResultKey[]) => (e: React.MouseEvent) => void;
21+
toggleExpanded: (e: React.MouseEvent, keys: Keys.ResultKey[]) => void;
2222
scroller: ScrollIntoViewHelper;
2323
}
2424

@@ -32,7 +32,7 @@ export function AlertTablePathRow(props: Props) {
3232
databaseUri,
3333
sourceLocationPrefix,
3434
updateSelectionCallback,
35-
toggler,
35+
toggleExpanded,
3636
scroller,
3737
} = props;
3838

@@ -41,8 +41,8 @@ export function AlertTablePathRow(props: Props) {
4141
[pathIndex, resultIndex],
4242
);
4343
const handleDropdownClick = useMemo(
44-
() => toggler([pathKey]),
45-
[pathKey, toggler],
44+
() => (e: React.MouseEvent) => toggleExpanded(e, [pathKey]),
45+
[pathKey, toggleExpanded],
4646
);
4747

4848
const isPathSpecificallySelected = Keys.equalsNotUndefined(

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ interface Props {
2020
updateSelectionCallback: (
2121
resultKey: Keys.PathNode | Keys.Result | undefined,
2222
) => () => void;
23-
toggler: (keys: Keys.ResultKey[]) => (e: React.MouseEvent) => void;
23+
toggleExpanded: (e: React.MouseEvent, keys: Keys.ResultKey[]) => void;
2424
scroller: ScrollIntoViewHelper;
2525
}
2626

@@ -33,7 +33,7 @@ export function AlertTableResultRow(props: Props) {
3333
databaseUri,
3434
sourceLocationPrefix,
3535
updateSelectionCallback,
36-
toggler,
36+
toggleExpanded,
3737
scroller,
3838
} = props;
3939

@@ -53,8 +53,8 @@ export function AlertTableResultRow(props: Props) {
5353
: /* if there's exactly one path, auto-expand
5454
* the path when expanding the result */
5555
[resultKey];
56-
return toggler(indices);
57-
}, [result, resultKey, toggler]);
56+
return (e: React.MouseEvent) => toggleExpanded(e, indices);
57+
}, [result, resultKey, toggleExpanded]);
5858

5959
const resultRowIsSelected =
6060
selectedItem?.resultIndex === resultIndex &&
@@ -122,7 +122,7 @@ export function AlertTableResultRow(props: Props) {
122122
databaseUri={databaseUri}
123123
sourceLocationPrefix={sourceLocationPrefix}
124124
updateSelectionCallback={updateSelectionCallback}
125-
toggler={toggler}
125+
toggleExpanded={toggleExpanded}
126126
scroller={scroller}
127127
/>
128128
))}

0 commit comments

Comments
 (0)