File tree Expand file tree Collapse file tree 5 files changed +47
-7
lines changed
Expand file tree Collapse file tree 5 files changed +47
-7
lines changed Original file line number Diff line number Diff line change 11import { ResolvableLocationValue } from "../common/bqrs-cli-types" ;
2- import { ModeledMethodType } from "./modeled-method" ;
2+ import { ModeledMethod , ModeledMethodType } from "./modeled-method" ;
33
44export type Call = {
55 label : string ;
@@ -65,3 +65,15 @@ export function getArgumentsList(methodParameters: string): string[] {
6565
6666 return methodParameters . substring ( 1 , methodParameters . length - 1 ) . split ( "," ) ;
6767}
68+
69+ export function canMethodBeModeled (
70+ method : Method ,
71+ modeledMethod : ModeledMethod | undefined ,
72+ methodIsUnsaved : boolean ,
73+ ) : boolean {
74+ return (
75+ ! method . supported ||
76+ ( modeledMethod && modeledMethod ?. type !== "none" ) ||
77+ methodIsUnsaved
78+ ) ;
79+ }
Original file line number Diff line number Diff line change 1+ import * as React from "react" ;
2+
3+ import { Meta , StoryFn } from "@storybook/react" ;
4+
5+ import { MethodAlreadyModeled as MethodAlreadyModeledComponent } from "../../view/method-modeling/MethodAlreadyModeled" ;
6+
7+ export default {
8+ title : "Method Modeling/Method Already Modeled" ,
9+ component : MethodAlreadyModeledComponent ,
10+ } as Meta < typeof MethodAlreadyModeledComponent > ;
11+
12+ const Template : StoryFn < typeof MethodAlreadyModeledComponent > = ( ) => (
13+ < MethodAlreadyModeledComponent />
14+ ) ;
15+
16+ export const MethodAlreadyModeled = Template . bind ( { } ) ;
Original file line number Diff line number Diff line change 1+ import * as React from "react" ;
2+ import { ResponsiveContainer } from "../common/ResponsiveContainer" ;
3+
4+ export const MethodAlreadyModeled = ( ) => {
5+ return < ResponsiveContainer > Method already modeled</ ResponsiveContainer > ;
6+ } ;
Original file line number Diff line number Diff line change @@ -2,14 +2,15 @@ import * as React from "react";
22import { useEffect , useMemo , useState } from "react" ;
33import { MethodModeling } from "./MethodModeling" ;
44import { getModelingStatus } from "../../model-editor/shared/modeling-status" ;
5- import { Method } from "../../model-editor/method" ;
5+ import { Method , canMethodBeModeled } from "../../model-editor/method" ;
66import { ToMethodModelingMessage } from "../../common/interface-types" ;
77import { assertNever } from "../../common/helpers-pure" ;
88import { ModeledMethod } from "../../model-editor/modeled-method" ;
99import { vscode } from "../vscode-api" ;
1010import { NotInModelingMode } from "./NotInModelingMode" ;
1111import { NoMethodSelected } from "./NoMethodSelected" ;
1212import { MethodModelingPanelViewState } from "../../model-editor/shared/view-state" ;
13+ import { MethodAlreadyModeled } from "./MethodAlreadyModeled" ;
1314
1415type Props = {
1516 initialViewState ?: MethodModelingPanelViewState ;
@@ -84,6 +85,10 @@ export function MethodModelingView({ initialViewState }: Props): JSX.Element {
8485 return < NoMethodSelected /> ;
8586 }
8687
88+ if ( ! canMethodBeModeled ( method , modeledMethod , isMethodModified ) ) {
89+ return < MethodAlreadyModeled /> ;
90+ }
91+
8792 const onChange = ( modeledMethod : ModeledMethod ) => {
8893 vscode . postMessage ( {
8994 t : "setModeledMethod" ,
Original file line number Diff line number Diff line change 55 VSCodeDataGridRow ,
66} from "@vscode/webview-ui-toolkit/react" ;
77import { MethodRow } from "./MethodRow" ;
8- import { Method } from "../../model-editor/method" ;
8+ import { Method , canMethodBeModeled } from "../../model-editor/method" ;
99import { ModeledMethod } from "../../model-editor/modeled-method" ;
1010import { useMemo } from "react" ;
1111import { sortMethods } from "../../model-editor/shared/sorting" ;
@@ -47,10 +47,11 @@ export const ModeledMethodDataGrid = ({
4747 for ( const method of sortMethods ( methods ) ) {
4848 const modeledMethod = modeledMethods [ method . signature ] ;
4949 const methodIsUnsaved = modifiedSignatures . has ( method . signature ) ;
50- const methodCanBeModeled =
51- ! method . supported ||
52- ( modeledMethod && modeledMethod ?. type !== "none" ) ||
53- methodIsUnsaved ;
50+ const methodCanBeModeled = canMethodBeModeled (
51+ method ,
52+ modeledMethod ,
53+ methodIsUnsaved ,
54+ ) ;
5455
5556 if ( methodCanBeModeled || ! hideModeledMethods ) {
5657 methodsWithModelability . push ( { method, methodCanBeModeled } ) ;
You can’t perform that action at this time.
0 commit comments