Skip to content

Commit 6ec0f51

Browse files
committed
Remove showMultipleModels from view states
1 parent 5a29d35 commit 6ec0f51

File tree

13 files changed

+42
-188
lines changed

13 files changed

+42
-188
lines changed

extensions/ql-vscode/src/model-editor/method-modeling/method-modeling-view-provider.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ export class MethodModelingViewProvider extends AbstractWebviewViewProvider<
4848
t: "setMethodModelingPanelViewState",
4949
viewState: {
5050
language: this.language,
51-
showMultipleModels: true,
5251
},
5352
});
5453
}

extensions/ql-vscode/src/model-editor/model-editor-view.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,6 @@ export class ModelEditorView extends AbstractWebview<
385385
language: this.language,
386386
showGenerateButton,
387387
showLlmButton,
388-
showMultipleModels: true,
389388
mode: this.modelingStore.getMode(this.databaseItem),
390389
showModeSwitchButton,
391390
sourceArchiveAvailable,

extensions/ql-vscode/src/model-editor/shared/view-state.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@ export interface ModelEditorViewState {
77
language: QueryLanguage;
88
showGenerateButton: boolean;
99
showLlmButton: boolean;
10-
showMultipleModels: boolean;
1110
mode: Mode;
1211
showModeSwitchButton: boolean;
1312
sourceArchiveAvailable: boolean;
1413
}
1514

1615
export interface MethodModelingPanelViewState {
1716
language: QueryLanguage | undefined;
18-
showMultipleModels: boolean;
1917
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ LibraryRow.args = {
216216
viewState: createMockModelEditorViewState({
217217
showGenerateButton: true,
218218
showLlmButton: true,
219-
showMultipleModels: true,
220219
}),
221220
hideModeledMethods: false,
222221
};

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

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ import { Meta, StoryFn } from "@storybook/react";
66
import { MethodRow as MethodRowComponent } from "../../view/model-editor/MethodRow";
77
import { CallClassification, Method } from "../../model-editor/method";
88
import { ModeledMethod } from "../../model-editor/modeled-method";
9-
import {
10-
MULTIPLE_MODELS_GRID_TEMPLATE_COLUMNS,
11-
SINGLE_MODEL_GRID_TEMPLATE_COLUMNS,
12-
} from "../../view/model-editor/ModeledMethodDataGrid";
9+
import { MULTIPLE_MODELS_GRID_TEMPLATE_COLUMNS } from "../../view/model-editor/ModeledMethodDataGrid";
1310
import { DataGrid } from "../../view/common/DataGrid";
1411
import { createMockModelEditorViewState } from "../../../test/factories/model-editor/view-state";
1512

@@ -35,12 +32,8 @@ const Template: StoryFn<typeof MethodRowComponent> = (args) => {
3532
[args],
3633
);
3734

38-
const gridTemplateColumns = args.viewState?.showMultipleModels
39-
? MULTIPLE_MODELS_GRID_TEMPLATE_COLUMNS
40-
: SINGLE_MODEL_GRID_TEMPLATE_COLUMNS;
41-
4235
return (
43-
<DataGrid gridTemplateColumns={gridTemplateColumns}>
36+
<DataGrid gridTemplateColumns={MULTIPLE_MODELS_GRID_TEMPLATE_COLUMNS}>
4437
<MethodRowComponent
4538
{...args}
4639
modeledMethods={modeledMethods}
@@ -100,7 +93,6 @@ const modeledMethod: ModeledMethod = {
10093
const viewState = createMockModelEditorViewState({
10194
showGenerateButton: true,
10295
showLlmButton: true,
103-
showMultipleModels: true,
10496
});
10597

10698
export const Unmodeled = Template.bind({});

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ ModelEditor.args = {
3030
},
3131
showGenerateButton: true,
3232
showLlmButton: true,
33-
showMultipleModels: true,
3433
}),
3534
initialMethods: [
3635
{

extensions/ql-vscode/src/view/method-modeling/MethodModelingView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export function MethodModelingView({ initialViewState }: Props): JSX.Element {
110110
method={method}
111111
modeledMethods={modeledMethods}
112112
isModelingInProgress={isModelingInProgress}
113-
showMultipleModels={viewState?.showMultipleModels}
113+
showMultipleModels={true}
114114
onChange={onChange}
115115
/>
116116
);

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as React from "react";
22
import { styled } from "styled-components";
33
import { pluralize } from "../../common/word";
44
import { DataGridCell, DataGridRow } from "../common/DataGrid";
5-
import { ModelEditorViewState } from "../../model-editor/shared/view-state";
65

76
const HiddenMethodsCell = styled(DataGridCell)`
87
text-align: center;
@@ -11,23 +10,19 @@ const HiddenMethodsCell = styled(DataGridCell)`
1110
interface Props {
1211
numHiddenMethods: number;
1312
someMethodsAreVisible: boolean;
14-
viewState: ModelEditorViewState;
1513
}
1614

1715
export function HiddenMethodsRow({
1816
numHiddenMethods,
1917
someMethodsAreVisible,
20-
viewState,
2118
}: Props) {
2219
if (numHiddenMethods === 0) {
2320
return null;
2421
}
2522

26-
const gridColumn = viewState.showMultipleModels ? "span 6" : "span 5";
27-
2823
return (
2924
<DataGridRow>
30-
<HiddenMethodsCell gridColumn={gridColumn}>
25+
<HiddenMethodsCell gridColumn="span 6">
3126
{someMethodsAreVisible && "And "}
3227
{pluralize(numHiddenMethods, "method", "methods")} modeled in other
3328
CodeQL packs

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

Lines changed: 29 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ const ModelableMethodRow = forwardRef<HTMLElement | undefined, MethodRowProps>(
136136
}, [focusedIndex]);
137137

138138
const modeledMethods = useMemo(
139-
() => modeledMethodsToDisplay(modeledMethodsProp, method, viewState),
140-
[modeledMethodsProp, method, viewState],
139+
() => modeledMethodsToDisplay(modeledMethodsProp, method),
140+
[modeledMethodsProp, method],
141141
);
142142

143143
const validationErrors = useMemo(
@@ -219,13 +219,11 @@ const ModelableMethodRow = forwardRef<HTMLElement | undefined, MethodRowProps>(
219219
<DataGridCell>
220220
<InProgressDropdown />
221221
</DataGridCell>
222-
{viewState.showMultipleModels && (
223-
<DataGridCell>
224-
<CodiconRow appearance="icon" disabled={true}>
225-
<Codicon name="add" label="Add new model" />
226-
</CodiconRow>
227-
</DataGridCell>
228-
)}
222+
<DataGridCell>
223+
<CodiconRow appearance="icon" disabled={true}>
224+
<Codicon name="add" label="Add new model" />
225+
</CodiconRow>
226+
</DataGridCell>
229227
</>
230228
)}
231229
{!props.modelingInProgress && (
@@ -267,28 +265,26 @@ const ModelableMethodRow = forwardRef<HTMLElement | undefined, MethodRowProps>(
267265
onChange={modeledMethodChangedHandlers[index]}
268266
/>
269267
</DataGridCell>
270-
{viewState.showMultipleModels && (
271-
<DataGridCell>
272-
{index === 0 ? (
273-
<CodiconRow
274-
appearance="icon"
275-
aria-label="Add new model"
276-
onClick={handleAddModelClick}
277-
disabled={addModelButtonDisabled}
278-
>
279-
<Codicon name="add" />
280-
</CodiconRow>
281-
) : (
282-
<CodiconRow
283-
appearance="icon"
284-
aria-label="Remove model"
285-
onClick={removeModelClickedHandlers[index]}
286-
>
287-
<Codicon name="trash" />
288-
</CodiconRow>
289-
)}
290-
</DataGridCell>
291-
)}
268+
<DataGridCell>
269+
{index === 0 ? (
270+
<CodiconRow
271+
appearance="icon"
272+
aria-label="Add new model"
273+
onClick={handleAddModelClick}
274+
disabled={addModelButtonDisabled}
275+
>
276+
<Codicon name="add" />
277+
</CodiconRow>
278+
) : (
279+
<CodiconRow
280+
appearance="icon"
281+
aria-label="Remove model"
282+
onClick={removeModelClickedHandlers[index]}
283+
>
284+
<Codicon name="trash" />
285+
</CodiconRow>
286+
)}
287+
</DataGridCell>
292288
</DataGridRow>
293289
))}
294290
{validationErrors.map((error, index) => (
@@ -336,9 +332,7 @@ const UnmodelableMethodRow = forwardRef<
336332
<ViewLink onClick={jumpToMethod}>View</ViewLink>
337333
</ApiOrMethodRow>
338334
</DataGridCell>
339-
<DataGridCell gridColumn={`span ${viewState.showMultipleModels ? 5 : 4}`}>
340-
Method already modeled
341-
</DataGridCell>
335+
<DataGridCell gridColumn="span 5">Method already modeled</DataGridCell>
342336
</DataGridRow>
343337
);
344338
});
@@ -354,15 +348,10 @@ function sendJumpToMethodMessage(method: Method) {
354348
function modeledMethodsToDisplay(
355349
modeledMethods: ModeledMethod[],
356350
method: Method,
357-
viewState: ModelEditorViewState,
358351
): ModeledMethod[] {
359352
if (modeledMethods.length === 0) {
360353
return [createEmptyModeledMethod("none", method)];
361354
}
362355

363-
if (viewState.showMultipleModels) {
364-
return modeledMethods;
365-
} else {
366-
return modeledMethods.slice(0, 1);
367-
}
356+
return modeledMethods;
368357
}

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

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import { ModelEditorViewState } from "../../model-editor/shared/view-state";
99
import { ScreenReaderOnly } from "../common/ScreenReaderOnly";
1010
import { DataGrid, DataGridCell } from "../common/DataGrid";
1111

12-
export const SINGLE_MODEL_GRID_TEMPLATE_COLUMNS =
13-
"0.5fr 0.125fr 0.125fr 0.125fr 0.125fr";
1412
export const MULTIPLE_MODELS_GRID_TEMPLATE_COLUMNS =
1513
"0.5fr 0.125fr 0.125fr 0.125fr 0.125fr max-content";
1614

@@ -61,24 +59,18 @@ export const ModeledMethodDataGrid = ({
6159

6260
const someMethodsAreVisible = methodsWithModelability.length > 0;
6361

64-
const gridTemplateColumns = viewState.showMultipleModels
65-
? MULTIPLE_MODELS_GRID_TEMPLATE_COLUMNS
66-
: SINGLE_MODEL_GRID_TEMPLATE_COLUMNS;
67-
6862
return (
69-
<DataGrid gridTemplateColumns={gridTemplateColumns}>
63+
<DataGrid gridTemplateColumns={MULTIPLE_MODELS_GRID_TEMPLATE_COLUMNS}>
7064
{someMethodsAreVisible && (
7165
<>
7266
<DataGridCell rowType="header">API or method</DataGridCell>
7367
<DataGridCell rowType="header">Model type</DataGridCell>
7468
<DataGridCell rowType="header">Input</DataGridCell>
7569
<DataGridCell rowType="header">Output</DataGridCell>
7670
<DataGridCell rowType="header">Kind</DataGridCell>
77-
{viewState.showMultipleModels && (
78-
<DataGridCell rowType="header">
79-
<ScreenReaderOnly>Add or remove models</ScreenReaderOnly>
80-
</DataGridCell>
81-
)}
71+
<DataGridCell rowType="header">
72+
<ScreenReaderOnly>Add or remove models</ScreenReaderOnly>
73+
</DataGridCell>
8274
{methodsWithModelability.map(({ method, methodCanBeModeled }) => {
8375
const modeledMethods = modeledMethodsMap[method.signature] ?? [];
8476
return (
@@ -100,7 +92,6 @@ export const ModeledMethodDataGrid = ({
10092
<HiddenMethodsRow
10193
numHiddenMethods={numHiddenMethods}
10294
someMethodsAreVisible={someMethodsAreVisible}
103-
viewState={viewState}
10495
/>
10596
</DataGrid>
10697
);

0 commit comments

Comments
 (0)