Skip to content

Commit 5922bdf

Browse files
Merge pull request #2785 from github/robertbrignull/in-progress-dropdown
Adjust styling of disabled dropdowns when automodeling is in progress
2 parents 860507d + a2f1710 commit 5922bdf

File tree

3 files changed

+23
-18
lines changed

3 files changed

+23
-18
lines changed

extensions/ql-vscode/src/stories/model-editor/MethodRow.stories.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,10 @@ AlreadyModeled.args = {
101101
method: { ...method, supported: true },
102102
modeledMethod: undefined,
103103
};
104+
105+
export const ModelingInProgress = Template.bind({});
106+
ModelingInProgress.args = {
107+
method,
108+
modeledMethod,
109+
modelingInProgress: true,
110+
};

extensions/ql-vscode/src/view/common/Dropdown.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ type Props = {
1919
value: string | undefined;
2020
options: Array<{ value: string; label: string }>;
2121
disabled?: boolean;
22-
onChange: (event: ChangeEvent<HTMLSelectElement>) => void;
22+
disabledPlaceholder?: string;
23+
onChange?: (event: ChangeEvent<HTMLSelectElement>) => void;
2324
};
2425

2526
/**
@@ -32,16 +33,23 @@ type Props = {
3233
* See https://github.com/github/vscode-codeql/pull/2582#issuecomment-1622164429
3334
* for more info on the problem and other potential solutions.
3435
*/
35-
export function Dropdown({ value, options, disabled, onChange }: Props) {
36+
export function Dropdown({
37+
value,
38+
options,
39+
disabled,
40+
disabledPlaceholder,
41+
onChange,
42+
}: Props) {
43+
const disabledValue = disabledPlaceholder ?? DISABLED_VALUE;
3644
return (
3745
<StyledDropdown
38-
value={disabled ? DISABLED_VALUE : value}
46+
value={disabled ? disabledValue : value}
3947
disabled={disabled}
4048
onChange={onChange}
4149
>
4250
{disabled ? (
43-
<option key={DISABLED_VALUE} value={DISABLED_VALUE}>
44-
{DISABLED_VALUE}
51+
<option key={disabledValue} value={disabledValue}>
52+
{disabledValue}
4553
</option>
4654
) : (
4755
options.map((option) => (

extensions/ql-vscode/src/view/model-editor/InProgressDropdown.tsx

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,12 @@ import * as React from "react";
22
import { Dropdown } from "../common/Dropdown";
33

44
export const InProgressDropdown = () => {
5-
const options: Array<{ label: string; value: string }> = [
6-
{
7-
label: "Thinking...",
8-
value: "Thinking...",
9-
},
10-
];
11-
const noop = () => {
12-
// Do nothing
13-
};
14-
155
return (
166
<Dropdown
177
value="Thinking..."
18-
options={options}
19-
disabled={false}
20-
onChange={noop}
8+
options={[]}
9+
disabled={true}
10+
disabledPlaceholder="Thinking..."
2111
/>
2212
);
2313
};

0 commit comments

Comments
 (0)