Use createEmptyModeledMethod in more places
This commit is contained in:
@@ -33,6 +33,7 @@ import { canAddNewModeledMethod } from "../../model-editor/shared/multiple-model
|
|||||||
import { DataGridCell, DataGridRow } from "../common/DataGrid";
|
import { DataGridCell, DataGridRow } from "../common/DataGrid";
|
||||||
import { validateModeledMethods } from "../../model-editor/shared/validation";
|
import { validateModeledMethods } from "../../model-editor/shared/validation";
|
||||||
import { ModeledMethodAlert } from "../method-modeling/ModeledMethodAlert";
|
import { ModeledMethodAlert } from "../method-modeling/ModeledMethodAlert";
|
||||||
|
import { createEmptyModeledMethod } from "../../model-editor/modeled-method-empty";
|
||||||
|
|
||||||
const ApiOrMethodRow = styled.div`
|
const ApiOrMethodRow = styled.div`
|
||||||
min-height: calc(var(--input-height) * 1px);
|
min-height: calc(var(--input-height) * 1px);
|
||||||
@@ -165,15 +166,10 @@ const ModelableMethodRow = forwardRef<HTMLElement | undefined, MethodRowProps>(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const handleAddModelClick = useCallback(() => {
|
const handleAddModelClick = useCallback(() => {
|
||||||
const newModeledMethod: ModeledMethod = {
|
const newModeledMethod: ModeledMethod = createEmptyModeledMethod(
|
||||||
type: "none",
|
"none",
|
||||||
provenance: "manual",
|
method,
|
||||||
signature: method.signature,
|
);
|
||||||
packageName: method.packageName,
|
|
||||||
typeName: method.typeName,
|
|
||||||
methodName: method.methodName,
|
|
||||||
methodParameters: method.methodParameters,
|
|
||||||
};
|
|
||||||
const newModeledMethods = [...modeledMethods, newModeledMethod];
|
const newModeledMethods = [...modeledMethods, newModeledMethod];
|
||||||
onChange(method.signature, newModeledMethods);
|
onChange(method.signature, newModeledMethods);
|
||||||
}, [method, modeledMethods, onChange]);
|
}, [method, modeledMethods, onChange]);
|
||||||
@@ -356,17 +352,7 @@ function modeledMethodsToDisplay(
|
|||||||
viewState: ModelEditorViewState,
|
viewState: ModelEditorViewState,
|
||||||
): ModeledMethod[] {
|
): ModeledMethod[] {
|
||||||
if (modeledMethods.length === 0) {
|
if (modeledMethods.length === 0) {
|
||||||
return [
|
return [createEmptyModeledMethod("none", method)];
|
||||||
{
|
|
||||||
type: "none",
|
|
||||||
provenance: "manual",
|
|
||||||
signature: method.signature,
|
|
||||||
packageName: method.packageName,
|
|
||||||
typeName: method.typeName,
|
|
||||||
methodName: method.methodName,
|
|
||||||
methodParameters: method.methodParameters,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (viewState.showMultipleModels) {
|
if (viewState.showMultipleModels) {
|
||||||
|
|||||||
Reference in New Issue
Block a user