Merge branch 'main' into robertbrignull/legacy-conversion
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { ResolvableLocationValue } from "../common/bqrs-cli-types";
|
||||
import { ModeledMethodType } from "./modeled-method";
|
||||
import { ModeledMethod, ModeledMethodType } from "./modeled-method";
|
||||
|
||||
export type Call = {
|
||||
label: string;
|
||||
@@ -65,3 +65,15 @@ export function getArgumentsList(methodParameters: string): string[] {
|
||||
|
||||
return methodParameters.substring(1, methodParameters.length - 1).split(",");
|
||||
}
|
||||
|
||||
export function canMethodBeModeled(
|
||||
method: Method,
|
||||
modeledMethod: ModeledMethod | undefined,
|
||||
methodIsUnsaved: boolean,
|
||||
): boolean {
|
||||
return (
|
||||
!method.supported ||
|
||||
(modeledMethod && modeledMethod?.type !== "none") ||
|
||||
methodIsUnsaved
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import * as React from "react";
|
||||
|
||||
import { Meta, StoryFn } from "@storybook/react";
|
||||
|
||||
import { MethodAlreadyModeled as MethodAlreadyModeledComponent } from "../../view/method-modeling/MethodAlreadyModeled";
|
||||
|
||||
export default {
|
||||
title: "Method Modeling/Method Already Modeled",
|
||||
component: MethodAlreadyModeledComponent,
|
||||
} as Meta<typeof MethodAlreadyModeledComponent>;
|
||||
|
||||
const Template: StoryFn<typeof MethodAlreadyModeledComponent> = () => (
|
||||
<MethodAlreadyModeledComponent />
|
||||
);
|
||||
|
||||
export const MethodAlreadyModeled = Template.bind({});
|
||||
@@ -0,0 +1,6 @@
|
||||
import * as React from "react";
|
||||
import { ResponsiveContainer } from "../common/ResponsiveContainer";
|
||||
|
||||
export const MethodAlreadyModeled = () => {
|
||||
return <ResponsiveContainer>Method already modeled</ResponsiveContainer>;
|
||||
};
|
||||
@@ -2,7 +2,7 @@ import * as React from "react";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { MethodModeling } from "./MethodModeling";
|
||||
import { getModelingStatus } from "../../model-editor/shared/modeling-status";
|
||||
import { Method } from "../../model-editor/method";
|
||||
import { Method, canMethodBeModeled } from "../../model-editor/method";
|
||||
import { ToMethodModelingMessage } from "../../common/interface-types";
|
||||
import { assertNever } from "../../common/helpers-pure";
|
||||
import { ModeledMethod } from "../../model-editor/modeled-method";
|
||||
@@ -11,6 +11,7 @@ import { NotInModelingMode } from "./NotInModelingMode";
|
||||
import { NoMethodSelected } from "./NoMethodSelected";
|
||||
import { MethodModelingPanelViewState } from "../../model-editor/shared/view-state";
|
||||
import { convertFromLegacyModeledMethod } from "../../model-editor/shared/modeled-methods-legacy";
|
||||
import { MethodAlreadyModeled } from "./MethodAlreadyModeled";
|
||||
|
||||
type Props = {
|
||||
initialViewState?: MethodModelingPanelViewState;
|
||||
@@ -88,6 +89,10 @@ export function MethodModelingView({ initialViewState }: Props): JSX.Element {
|
||||
return <NoMethodSelected />;
|
||||
}
|
||||
|
||||
if (!canMethodBeModeled(method, modeledMethod, isMethodModified)) {
|
||||
return <MethodAlreadyModeled />;
|
||||
}
|
||||
|
||||
const onChange = (modeledMethod: ModeledMethod) => {
|
||||
vscode.postMessage({
|
||||
t: "setModeledMethod",
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
VSCodeDataGridRow,
|
||||
} from "@vscode/webview-ui-toolkit/react";
|
||||
import { MethodRow } from "./MethodRow";
|
||||
import { Method } from "../../model-editor/method";
|
||||
import { Method, canMethodBeModeled } from "../../model-editor/method";
|
||||
import { ModeledMethod } from "../../model-editor/modeled-method";
|
||||
import { useMemo } from "react";
|
||||
import { sortMethods } from "../../model-editor/shared/sorting";
|
||||
@@ -47,10 +47,11 @@ export const ModeledMethodDataGrid = ({
|
||||
for (const method of sortMethods(methods)) {
|
||||
const modeledMethod = modeledMethods[method.signature];
|
||||
const methodIsUnsaved = modifiedSignatures.has(method.signature);
|
||||
const methodCanBeModeled =
|
||||
!method.supported ||
|
||||
(modeledMethod && modeledMethod?.type !== "none") ||
|
||||
methodIsUnsaved;
|
||||
const methodCanBeModeled = canMethodBeModeled(
|
||||
method,
|
||||
modeledMethod,
|
||||
methodIsUnsaved,
|
||||
);
|
||||
|
||||
if (methodCanBeModeled || !hideModeledMethods) {
|
||||
methodsWithModelability.push({ method, methodCanBeModeled });
|
||||
|
||||
Reference in New Issue
Block a user