Skip to content

Commit ffe1704

Browse files
authored
Replace code paths dropdown with VS Code UI Toolkit (#1429)
1 parent bd2dd04 commit ffe1704

File tree

1 file changed

+20
-23
lines changed

1 file changed

+20
-23
lines changed

extensions/ql-vscode/src/remote-queries/view/CodePaths.tsx

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { TriangleDownIcon, XCircleIcon } from '@primer/octicons-react';
2-
import { ActionList, ActionMenu, Button, Overlay } from '@primer/react';
3-
import { VSCodeLink, VSCodeTag } from '@vscode/webview-ui-toolkit/react';
1+
import { XCircleIcon } from '@primer/octicons-react';
2+
import { Overlay } from '@primer/react';
3+
import { VSCodeDropdown, VSCodeLink, VSCodeOption, VSCodeTag } from '@vscode/webview-ui-toolkit/react';
44
import * as React from 'react';
5-
import { useRef, useState } from 'react';
5+
import { ChangeEvent, useRef, useState } from 'react';
66
import styled from 'styled-components';
77
import { CodeFlow, AnalysisMessage, ResultSeverity } from '../shared/analysis-result';
88
import FileCodeSnippet from './FileCodeSnippet';
@@ -94,25 +94,22 @@ const Menu = ({
9494
codeFlows: CodeFlow[],
9595
setSelectedCodeFlow: (value: React.SetStateAction<CodeFlow>) => void
9696
}) => {
97-
return <ActionMenu>
98-
<ActionMenu.Anchor>
99-
<Button variant="invisible" sx={{ fontWeight: 'normal', color: 'var(--vscode-editor-foreground);', padding: 0 }} >
100-
{getCodeFlowName(codeFlows[0])}
101-
<TriangleDownIcon size={16} />
102-
</Button>
103-
</ActionMenu.Anchor>
104-
<ActionMenu.Overlay sx={{ backgroundColor: 'var(--vscode-editor-background)' }}>
105-
<ActionList>
106-
{codeFlows.map((codeFlow, index) =>
107-
<ActionList.Item
108-
key={`codeflow-${index}'`}
109-
onSelect={(e: React.MouseEvent) => { setSelectedCodeFlow(codeFlow); }}>
110-
{getCodeFlowName(codeFlow)}
111-
</ActionList.Item>
112-
)}
113-
</ActionList>
114-
</ActionMenu.Overlay>
115-
</ActionMenu>;
97+
return <VSCodeDropdown
98+
onChange={(event: ChangeEvent<HTMLSelectElement>) => {
99+
const selectedOption = event.target;
100+
const selectedIndex = selectedOption.value as unknown as number;
101+
setSelectedCodeFlow(codeFlows[selectedIndex]);
102+
}}
103+
>
104+
{codeFlows.map((codeFlow, index) =>
105+
<VSCodeOption
106+
key={`codeflow-${index}'`}
107+
value={index}
108+
>
109+
{getCodeFlowName(codeFlow)}
110+
</VSCodeOption>
111+
)}
112+
</VSCodeDropdown>;
116113
};
117114

118115
const CodePaths = ({

0 commit comments

Comments
 (0)