Merge pull request #3379 from github/koesie10/italic-model-pending
Show auto-model negative predictions in italics
This commit is contained in:
Коммит
3d2d86bf6e
|
@ -111,19 +111,27 @@ export function modeledMethodSupportsProvenance(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isModelAccepted(
|
export function isModelPending(
|
||||||
modeledMethod: ModeledMethod | undefined,
|
modeledMethod: ModeledMethod | undefined,
|
||||||
modelingStatus: ModelingStatus,
|
modelingStatus: ModelingStatus,
|
||||||
|
processedByAutoModel?: boolean,
|
||||||
): boolean {
|
): boolean {
|
||||||
if (!modeledMethod) {
|
if (
|
||||||
|
(!modeledMethod || modeledMethod.type === "none") &&
|
||||||
|
processedByAutoModel
|
||||||
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!modeledMethod) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
modelingStatus !== "unsaved" ||
|
modelingStatus === "unsaved" &&
|
||||||
modeledMethod.type === "none" ||
|
modeledMethod.type !== "none" &&
|
||||||
!modeledMethodSupportsProvenance(modeledMethod) ||
|
modeledMethodSupportsProvenance(modeledMethod) &&
|
||||||
modeledMethod.provenance !== "ai-generated"
|
modeledMethod.provenance === "ai-generated"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,5 +66,5 @@ export const ModelingNotAccepted = Template.bind({});
|
||||||
ModelingNotAccepted.args = {
|
ModelingNotAccepted.args = {
|
||||||
method,
|
method,
|
||||||
modeledMethod: generatedModeledMethod,
|
modeledMethod: generatedModeledMethod,
|
||||||
modelingStatus: "unsaved",
|
modelPending: true,
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,7 +7,6 @@ import { ModelOutputDropdown } from "../model-editor/ModelOutputDropdown";
|
||||||
import { ModelKindDropdown } from "../model-editor/ModelKindDropdown";
|
import { ModelKindDropdown } from "../model-editor/ModelKindDropdown";
|
||||||
import { InProgressDropdown } from "../model-editor/InProgressDropdown";
|
import { InProgressDropdown } from "../model-editor/InProgressDropdown";
|
||||||
import type { QueryLanguage } from "../../common/query-language";
|
import type { QueryLanguage } from "../../common/query-language";
|
||||||
import type { ModelingStatus } from "../../model-editor/shared/modeling-status";
|
|
||||||
|
|
||||||
const Container = styled.div`
|
const Container = styled.div`
|
||||||
padding-top: 0.5rem;
|
padding-top: 0.5rem;
|
||||||
|
@ -27,7 +26,7 @@ export type MethodModelingInputsProps = {
|
||||||
language: QueryLanguage;
|
language: QueryLanguage;
|
||||||
method: Method;
|
method: Method;
|
||||||
modeledMethod: ModeledMethod | undefined;
|
modeledMethod: ModeledMethod | undefined;
|
||||||
modelingStatus: ModelingStatus;
|
modelPending: boolean;
|
||||||
isModelingInProgress: boolean;
|
isModelingInProgress: boolean;
|
||||||
onChange: (modeledMethod: ModeledMethod) => void;
|
onChange: (modeledMethod: ModeledMethod) => void;
|
||||||
};
|
};
|
||||||
|
@ -36,7 +35,7 @@ export const MethodModelingInputs = ({
|
||||||
language,
|
language,
|
||||||
method,
|
method,
|
||||||
modeledMethod,
|
modeledMethod,
|
||||||
modelingStatus,
|
modelPending,
|
||||||
isModelingInProgress,
|
isModelingInProgress,
|
||||||
onChange,
|
onChange,
|
||||||
}: MethodModelingInputsProps): React.JSX.Element => {
|
}: MethodModelingInputsProps): React.JSX.Element => {
|
||||||
|
@ -44,7 +43,7 @@ export const MethodModelingInputs = ({
|
||||||
language,
|
language,
|
||||||
method,
|
method,
|
||||||
modeledMethod,
|
modeledMethod,
|
||||||
modelingStatus,
|
modelPending,
|
||||||
onChange,
|
onChange,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||||
import type { Method } from "../../model-editor/method";
|
import type { Method } from "../../model-editor/method";
|
||||||
import type { ModeledMethod } from "../../model-editor/modeled-method";
|
import type { ModeledMethod } from "../../model-editor/modeled-method";
|
||||||
|
import { isModelPending } from "../../model-editor/modeled-method";
|
||||||
import {
|
import {
|
||||||
canAddNewModeledMethod,
|
canAddNewModeledMethod,
|
||||||
canRemoveModeledMethod,
|
canRemoveModeledMethod,
|
||||||
|
@ -156,7 +157,10 @@ export const MultipleModeledMethodsPanel = ({
|
||||||
language={language}
|
language={language}
|
||||||
method={method}
|
method={method}
|
||||||
modeledMethod={modeledMethods[selectedIndex]}
|
modeledMethod={modeledMethods[selectedIndex]}
|
||||||
modelingStatus={modelingStatus}
|
modelPending={isModelPending(
|
||||||
|
modeledMethods[selectedIndex],
|
||||||
|
modelingStatus,
|
||||||
|
)}
|
||||||
isModelingInProgress={isModelingInProgress}
|
isModelingInProgress={isModelingInProgress}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
/>
|
/>
|
||||||
|
@ -165,7 +169,7 @@ export const MultipleModeledMethodsPanel = ({
|
||||||
language={language}
|
language={language}
|
||||||
method={method}
|
method={method}
|
||||||
modeledMethod={undefined}
|
modeledMethod={undefined}
|
||||||
modelingStatus={modelingStatus}
|
modelPending={false}
|
||||||
isModelingInProgress={isModelingInProgress}
|
isModelingInProgress={isModelingInProgress}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -17,7 +17,7 @@ describe(MethodModelingInputs.name, () => {
|
||||||
const language = QueryLanguage.Java;
|
const language = QueryLanguage.Java;
|
||||||
const method = createMethod();
|
const method = createMethod();
|
||||||
const modeledMethod = createSinkModeledMethod();
|
const modeledMethod = createSinkModeledMethod();
|
||||||
const modelingStatus = "unmodeled";
|
const modelPending = false;
|
||||||
const isModelingInProgress = false;
|
const isModelingInProgress = false;
|
||||||
const onChange = jest.fn();
|
const onChange = jest.fn();
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ describe(MethodModelingInputs.name, () => {
|
||||||
language,
|
language,
|
||||||
method,
|
method,
|
||||||
modeledMethod,
|
modeledMethod,
|
||||||
modelingStatus,
|
modelPending,
|
||||||
isModelingInProgress,
|
isModelingInProgress,
|
||||||
onChange,
|
onChange,
|
||||||
});
|
});
|
||||||
|
@ -53,7 +53,7 @@ describe(MethodModelingInputs.name, () => {
|
||||||
language,
|
language,
|
||||||
method,
|
method,
|
||||||
modeledMethod,
|
modeledMethod,
|
||||||
modelingStatus,
|
modelPending,
|
||||||
isModelingInProgress,
|
isModelingInProgress,
|
||||||
onChange,
|
onChange,
|
||||||
});
|
});
|
||||||
|
@ -76,7 +76,7 @@ describe(MethodModelingInputs.name, () => {
|
||||||
language,
|
language,
|
||||||
method,
|
method,
|
||||||
modeledMethod,
|
modeledMethod,
|
||||||
modelingStatus,
|
modelPending,
|
||||||
isModelingInProgress,
|
isModelingInProgress,
|
||||||
onChange,
|
onChange,
|
||||||
});
|
});
|
||||||
|
@ -91,7 +91,7 @@ describe(MethodModelingInputs.name, () => {
|
||||||
language={language}
|
language={language}
|
||||||
method={method}
|
method={method}
|
||||||
modeledMethod={updatedModeledMethod}
|
modeledMethod={updatedModeledMethod}
|
||||||
modelingStatus={modelingStatus}
|
modelPending={modelPending}
|
||||||
isModelingInProgress={isModelingInProgress}
|
isModelingInProgress={isModelingInProgress}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
/>,
|
/>,
|
||||||
|
@ -121,7 +121,7 @@ describe(MethodModelingInputs.name, () => {
|
||||||
language,
|
language,
|
||||||
method,
|
method,
|
||||||
modeledMethod,
|
modeledMethod,
|
||||||
modelingStatus,
|
modelPending,
|
||||||
isModelingInProgress: true,
|
isModelingInProgress: true,
|
||||||
onChange,
|
onChange,
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { styled } from "styled-components";
|
import { styled } from "styled-components";
|
||||||
import { Dropdown } from "../common/Dropdown";
|
import { Dropdown } from "../common/Dropdown";
|
||||||
|
|
||||||
export const InputDropdown = styled(Dropdown)<{ $accepted: boolean }>`
|
export const InputDropdown = styled(Dropdown)<{ $pending: boolean }>`
|
||||||
font-style: ${(props) => (props.$accepted ? "normal" : "italic")};
|
font-style: ${(props) => (props.$pending ? "italic" : "normal")};
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -16,6 +16,7 @@ import { vscode } from "../vscode-api";
|
||||||
|
|
||||||
import type { Method } from "../../model-editor/method";
|
import type { Method } from "../../model-editor/method";
|
||||||
import type { ModeledMethod } from "../../model-editor/modeled-method";
|
import type { ModeledMethod } from "../../model-editor/modeled-method";
|
||||||
|
import { isModelPending } from "../../model-editor/modeled-method";
|
||||||
import { ModelKindDropdown } from "./ModelKindDropdown";
|
import { ModelKindDropdown } from "./ModelKindDropdown";
|
||||||
import { Mode } from "../../model-editor/shared/mode";
|
import { Mode } from "../../model-editor/shared/mode";
|
||||||
import { MethodClassifications } from "./MethodClassifications";
|
import { MethodClassifications } from "./MethodClassifications";
|
||||||
|
@ -112,6 +113,7 @@ const ModelableMethodRow = forwardRef<HTMLElement | undefined, MethodRowProps>(
|
||||||
modeledMethods: modeledMethodsProp,
|
modeledMethods: modeledMethodsProp,
|
||||||
methodIsUnsaved,
|
methodIsUnsaved,
|
||||||
methodIsSelected,
|
methodIsSelected,
|
||||||
|
processedByAutoModel,
|
||||||
viewState,
|
viewState,
|
||||||
revealedMethodSignature,
|
revealedMethodSignature,
|
||||||
inputAccessPathSuggestions,
|
inputAccessPathSuggestions,
|
||||||
|
@ -255,88 +257,96 @@ const ModelableMethodRow = forwardRef<HTMLElement | undefined, MethodRowProps>(
|
||||||
)}
|
)}
|
||||||
{!props.modelingInProgress && (
|
{!props.modelingInProgress && (
|
||||||
<>
|
<>
|
||||||
{modeledMethods.map((modeledMethod, index) => (
|
{modeledMethods.map((modeledMethod, index) => {
|
||||||
<DataGridRow key={index} focused={focusedIndex === index}>
|
const modelPending = isModelPending(
|
||||||
<DataGridCell>
|
modeledMethod,
|
||||||
<ModelTypeDropdown
|
modelingStatus,
|
||||||
language={viewState.language}
|
processedByAutoModel,
|
||||||
method={method}
|
);
|
||||||
modeledMethod={modeledMethod}
|
|
||||||
modelingStatus={modelingStatus}
|
return (
|
||||||
onChange={modeledMethodChangedHandlers[index]}
|
<DataGridRow key={index} focused={focusedIndex === index}>
|
||||||
/>
|
<DataGridCell>
|
||||||
</DataGridCell>
|
<ModelTypeDropdown
|
||||||
<DataGridCell>
|
|
||||||
{inputAccessPathSuggestions === undefined ? (
|
|
||||||
<ModelInputDropdown
|
|
||||||
language={viewState.language}
|
language={viewState.language}
|
||||||
method={method}
|
method={method}
|
||||||
modeledMethod={modeledMethod}
|
modeledMethod={modeledMethod}
|
||||||
modelingStatus={modelingStatus}
|
modelPending={modelPending}
|
||||||
onChange={modeledMethodChangedHandlers[index]}
|
onChange={modeledMethodChangedHandlers[index]}
|
||||||
/>
|
/>
|
||||||
) : (
|
</DataGridCell>
|
||||||
<ModelInputSuggestBox
|
<DataGridCell>
|
||||||
modeledMethod={modeledMethod}
|
{inputAccessPathSuggestions === undefined ? (
|
||||||
suggestions={inputAccessPathSuggestions}
|
<ModelInputDropdown
|
||||||
typePathSuggestions={outputAccessPathSuggestions ?? []}
|
language={viewState.language}
|
||||||
onChange={modeledMethodChangedHandlers[index]}
|
method={method}
|
||||||
/>
|
modeledMethod={modeledMethod}
|
||||||
)}
|
modelPending={modelPending}
|
||||||
</DataGridCell>
|
onChange={modeledMethodChangedHandlers[index]}
|
||||||
<DataGridCell>
|
/>
|
||||||
{outputAccessPathSuggestions === undefined ? (
|
) : (
|
||||||
<ModelOutputDropdown
|
<ModelInputSuggestBox
|
||||||
|
modeledMethod={modeledMethod}
|
||||||
|
suggestions={inputAccessPathSuggestions}
|
||||||
|
typePathSuggestions={outputAccessPathSuggestions ?? []}
|
||||||
|
onChange={modeledMethodChangedHandlers[index]}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</DataGridCell>
|
||||||
|
<DataGridCell>
|
||||||
|
{outputAccessPathSuggestions === undefined ? (
|
||||||
|
<ModelOutputDropdown
|
||||||
|
language={viewState.language}
|
||||||
|
method={method}
|
||||||
|
modeledMethod={modeledMethod}
|
||||||
|
modelPending={modelPending}
|
||||||
|
onChange={modeledMethodChangedHandlers[index]}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<ModelOutputSuggestBox
|
||||||
|
modeledMethod={modeledMethod}
|
||||||
|
suggestions={outputAccessPathSuggestions}
|
||||||
|
onChange={modeledMethodChangedHandlers[index]}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</DataGridCell>
|
||||||
|
<DataGridCell>
|
||||||
|
<ModelKindDropdown
|
||||||
language={viewState.language}
|
language={viewState.language}
|
||||||
method={method}
|
|
||||||
modeledMethod={modeledMethod}
|
modeledMethod={modeledMethod}
|
||||||
modelingStatus={modelingStatus}
|
modelPending={modelPending}
|
||||||
onChange={modeledMethodChangedHandlers[index]}
|
onChange={modeledMethodChangedHandlers[index]}
|
||||||
/>
|
/>
|
||||||
) : (
|
</DataGridCell>
|
||||||
<ModelOutputSuggestBox
|
<DataGridCell>
|
||||||
modeledMethod={modeledMethod}
|
{index === 0 ? (
|
||||||
suggestions={outputAccessPathSuggestions}
|
<CodiconRow
|
||||||
onChange={modeledMethodChangedHandlers[index]}
|
appearance="icon"
|
||||||
/>
|
aria-label="Add new model"
|
||||||
)}
|
onClick={(event: React.MouseEvent) => {
|
||||||
</DataGridCell>
|
event.stopPropagation();
|
||||||
<DataGridCell>
|
handleAddModelClick();
|
||||||
<ModelKindDropdown
|
}}
|
||||||
language={viewState.language}
|
disabled={addModelButtonDisabled}
|
||||||
modeledMethod={modeledMethod}
|
>
|
||||||
modelingStatus={modelingStatus}
|
<Codicon name="add" />
|
||||||
onChange={modeledMethodChangedHandlers[index]}
|
</CodiconRow>
|
||||||
/>
|
) : (
|
||||||
</DataGridCell>
|
<CodiconRow
|
||||||
<DataGridCell>
|
appearance="icon"
|
||||||
{index === 0 ? (
|
aria-label="Remove model"
|
||||||
<CodiconRow
|
onClick={(event: React.MouseEvent) => {
|
||||||
appearance="icon"
|
event.stopPropagation();
|
||||||
aria-label="Add new model"
|
removeModelClickedHandlers[index]();
|
||||||
onClick={(event: React.MouseEvent) => {
|
}}
|
||||||
event.stopPropagation();
|
>
|
||||||
handleAddModelClick();
|
<Codicon name="trash" />
|
||||||
}}
|
</CodiconRow>
|
||||||
disabled={addModelButtonDisabled}
|
)}
|
||||||
>
|
</DataGridCell>
|
||||||
<Codicon name="add" />
|
</DataGridRow>
|
||||||
</CodiconRow>
|
);
|
||||||
) : (
|
})}
|
||||||
<CodiconRow
|
|
||||||
appearance="icon"
|
|
||||||
aria-label="Remove model"
|
|
||||||
onClick={(event: React.MouseEvent) => {
|
|
||||||
event.stopPropagation();
|
|
||||||
removeModelClickedHandlers[index]();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Codicon name="trash" />
|
|
||||||
</CodiconRow>
|
|
||||||
)}
|
|
||||||
</DataGridCell>
|
|
||||||
</DataGridRow>
|
|
||||||
))}
|
|
||||||
{validationErrors.map((error, index) => (
|
{validationErrors.map((error, index) => (
|
||||||
<DataGridCell gridColumn="span 5" key={index}>
|
<DataGridCell gridColumn="span 5" key={index}>
|
||||||
<ModeledMethodAlert
|
<ModeledMethodAlert
|
||||||
|
|
|
@ -3,13 +3,11 @@ import { useCallback, useMemo } from "react";
|
||||||
import type { ModeledMethod } from "../../model-editor/modeled-method";
|
import type { ModeledMethod } from "../../model-editor/modeled-method";
|
||||||
import {
|
import {
|
||||||
calculateNewProvenance,
|
calculateNewProvenance,
|
||||||
isModelAccepted,
|
|
||||||
modeledMethodSupportsInput,
|
modeledMethodSupportsInput,
|
||||||
} from "../../model-editor/modeled-method";
|
} from "../../model-editor/modeled-method";
|
||||||
import type { Method } from "../../model-editor/method";
|
import type { Method } from "../../model-editor/method";
|
||||||
import type { QueryLanguage } from "../../common/query-language";
|
import type { QueryLanguage } from "../../common/query-language";
|
||||||
import { getModelsAsDataLanguage } from "../../model-editor/languages";
|
import { getModelsAsDataLanguage } from "../../model-editor/languages";
|
||||||
import type { ModelingStatus } from "../../model-editor/shared/modeling-status";
|
|
||||||
import { InputDropdown } from "./InputDropdown";
|
import { InputDropdown } from "./InputDropdown";
|
||||||
import { ModelTypeTextbox } from "./ModelTypeTextbox";
|
import { ModelTypeTextbox } from "./ModelTypeTextbox";
|
||||||
|
|
||||||
|
@ -17,7 +15,7 @@ type Props = {
|
||||||
language: QueryLanguage;
|
language: QueryLanguage;
|
||||||
method: Method;
|
method: Method;
|
||||||
modeledMethod: ModeledMethod | undefined;
|
modeledMethod: ModeledMethod | undefined;
|
||||||
modelingStatus: ModelingStatus;
|
modelPending: boolean;
|
||||||
onChange: (modeledMethod: ModeledMethod) => void;
|
onChange: (modeledMethod: ModeledMethod) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -25,7 +23,7 @@ export const ModelInputDropdown = ({
|
||||||
language,
|
language,
|
||||||
method,
|
method,
|
||||||
modeledMethod,
|
modeledMethod,
|
||||||
modelingStatus,
|
modelPending,
|
||||||
onChange,
|
onChange,
|
||||||
}: Props): React.JSX.Element => {
|
}: Props): React.JSX.Element => {
|
||||||
const options = useMemo(() => {
|
const options = useMemo(() => {
|
||||||
|
@ -77,14 +75,12 @@ export const ModelInputDropdown = ({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const modelAccepted = isModelAccepted(modeledMethod, modelingStatus);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<InputDropdown
|
<InputDropdown
|
||||||
value={value}
|
value={value}
|
||||||
options={options}
|
options={options}
|
||||||
disabled={!enabled}
|
disabled={!enabled}
|
||||||
$accepted={modelAccepted}
|
$pending={modelPending}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
aria-label="Input"
|
aria-label="Input"
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -6,25 +6,23 @@ import type {
|
||||||
} from "../../model-editor/modeled-method";
|
} from "../../model-editor/modeled-method";
|
||||||
import {
|
import {
|
||||||
modeledMethodSupportsKind,
|
modeledMethodSupportsKind,
|
||||||
isModelAccepted,
|
|
||||||
calculateNewProvenance,
|
calculateNewProvenance,
|
||||||
} from "../../model-editor/modeled-method";
|
} from "../../model-editor/modeled-method";
|
||||||
import { getModelsAsDataLanguage } from "../../model-editor/languages";
|
import { getModelsAsDataLanguage } from "../../model-editor/languages";
|
||||||
import type { QueryLanguage } from "../../common/query-language";
|
import type { QueryLanguage } from "../../common/query-language";
|
||||||
import type { ModelingStatus } from "../../model-editor/shared/modeling-status";
|
|
||||||
import { InputDropdown } from "./InputDropdown";
|
import { InputDropdown } from "./InputDropdown";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
language: QueryLanguage;
|
language: QueryLanguage;
|
||||||
modeledMethod: ModeledMethod | undefined;
|
modeledMethod: ModeledMethod | undefined;
|
||||||
modelingStatus: ModelingStatus;
|
modelPending: boolean;
|
||||||
onChange: (modeledMethod: ModeledMethod) => void;
|
onChange: (modeledMethod: ModeledMethod) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ModelKindDropdown = ({
|
export const ModelKindDropdown = ({
|
||||||
language,
|
language,
|
||||||
modeledMethod,
|
modeledMethod,
|
||||||
modelingStatus,
|
modelPending,
|
||||||
onChange,
|
onChange,
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
const predicate = useMemo(() => {
|
const predicate = useMemo(() => {
|
||||||
|
@ -89,14 +87,12 @@ export const ModelKindDropdown = ({
|
||||||
}
|
}
|
||||||
}, [modeledMethod, value, kinds, onChangeKind]);
|
}, [modeledMethod, value, kinds, onChangeKind]);
|
||||||
|
|
||||||
const modelAccepted = isModelAccepted(modeledMethod, modelingStatus);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<InputDropdown
|
<InputDropdown
|
||||||
value={value}
|
value={value}
|
||||||
options={options}
|
options={options}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
$accepted={modelAccepted}
|
$pending={modelPending}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
aria-label="Kind"
|
aria-label="Kind"
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -3,13 +3,11 @@ import { useCallback, useMemo } from "react";
|
||||||
import type { ModeledMethod } from "../../model-editor/modeled-method";
|
import type { ModeledMethod } from "../../model-editor/modeled-method";
|
||||||
import {
|
import {
|
||||||
calculateNewProvenance,
|
calculateNewProvenance,
|
||||||
isModelAccepted,
|
|
||||||
modeledMethodSupportsOutput,
|
modeledMethodSupportsOutput,
|
||||||
} from "../../model-editor/modeled-method";
|
} from "../../model-editor/modeled-method";
|
||||||
import type { Method } from "../../model-editor/method";
|
import type { Method } from "../../model-editor/method";
|
||||||
import { getModelsAsDataLanguage } from "../../model-editor/languages";
|
import { getModelsAsDataLanguage } from "../../model-editor/languages";
|
||||||
import type { QueryLanguage } from "../../common/query-language";
|
import type { QueryLanguage } from "../../common/query-language";
|
||||||
import type { ModelingStatus } from "../../model-editor/shared/modeling-status";
|
|
||||||
import { InputDropdown } from "./InputDropdown";
|
import { InputDropdown } from "./InputDropdown";
|
||||||
import { ModelTypeTextbox } from "./ModelTypeTextbox";
|
import { ModelTypeTextbox } from "./ModelTypeTextbox";
|
||||||
|
|
||||||
|
@ -17,7 +15,7 @@ type Props = {
|
||||||
language: QueryLanguage;
|
language: QueryLanguage;
|
||||||
method: Method;
|
method: Method;
|
||||||
modeledMethod: ModeledMethod | undefined;
|
modeledMethod: ModeledMethod | undefined;
|
||||||
modelingStatus: ModelingStatus;
|
modelPending: boolean;
|
||||||
onChange: (modeledMethod: ModeledMethod) => void;
|
onChange: (modeledMethod: ModeledMethod) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -25,7 +23,7 @@ export const ModelOutputDropdown = ({
|
||||||
language,
|
language,
|
||||||
method,
|
method,
|
||||||
modeledMethod,
|
modeledMethod,
|
||||||
modelingStatus,
|
modelPending,
|
||||||
onChange,
|
onChange,
|
||||||
}: Props): React.JSX.Element => {
|
}: Props): React.JSX.Element => {
|
||||||
const options = useMemo(() => {
|
const options = useMemo(() => {
|
||||||
|
@ -78,14 +76,12 @@ export const ModelOutputDropdown = ({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const modelAccepted = isModelAccepted(modeledMethod, modelingStatus);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<InputDropdown
|
<InputDropdown
|
||||||
value={value}
|
value={value}
|
||||||
options={options}
|
options={options}
|
||||||
disabled={!enabled}
|
disabled={!enabled}
|
||||||
$accepted={modelAccepted}
|
$pending={modelPending}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
aria-label="Output"
|
aria-label="Output"
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -4,10 +4,7 @@ import type {
|
||||||
ModeledMethod,
|
ModeledMethod,
|
||||||
ModeledMethodType,
|
ModeledMethodType,
|
||||||
} from "../../model-editor/modeled-method";
|
} from "../../model-editor/modeled-method";
|
||||||
import {
|
import { calculateNewProvenance } from "../../model-editor/modeled-method";
|
||||||
calculateNewProvenance,
|
|
||||||
isModelAccepted,
|
|
||||||
} from "../../model-editor/modeled-method";
|
|
||||||
import type { Method } from "../../model-editor/method";
|
import type { Method } from "../../model-editor/method";
|
||||||
import { createEmptyModeledMethod } from "../../model-editor/modeled-method-empty";
|
import { createEmptyModeledMethod } from "../../model-editor/modeled-method-empty";
|
||||||
import type { Mutable } from "../../common/mutable";
|
import type { Mutable } from "../../common/mutable";
|
||||||
|
@ -15,14 +12,13 @@ import { ReadonlyDropdown } from "../common/ReadonlyDropdown";
|
||||||
import type { QueryLanguage } from "../../common/query-language";
|
import type { QueryLanguage } from "../../common/query-language";
|
||||||
import type { ModelsAsDataLanguagePredicates } from "../../model-editor/languages";
|
import type { ModelsAsDataLanguagePredicates } from "../../model-editor/languages";
|
||||||
import { getModelsAsDataLanguage } from "../../model-editor/languages";
|
import { getModelsAsDataLanguage } from "../../model-editor/languages";
|
||||||
import type { ModelingStatus } from "../../model-editor/shared/modeling-status";
|
|
||||||
import { InputDropdown } from "./InputDropdown";
|
import { InputDropdown } from "./InputDropdown";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
language: QueryLanguage;
|
language: QueryLanguage;
|
||||||
method: Method;
|
method: Method;
|
||||||
modeledMethod: ModeledMethod | undefined;
|
modeledMethod: ModeledMethod | undefined;
|
||||||
modelingStatus: ModelingStatus;
|
modelPending: boolean;
|
||||||
onChange: (modeledMethod: ModeledMethod) => void;
|
onChange: (modeledMethod: ModeledMethod) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -40,7 +36,7 @@ export const ModelTypeDropdown = ({
|
||||||
language,
|
language,
|
||||||
method,
|
method,
|
||||||
modeledMethod,
|
modeledMethod,
|
||||||
modelingStatus,
|
modelPending,
|
||||||
onChange,
|
onChange,
|
||||||
}: Props): React.JSX.Element => {
|
}: Props): React.JSX.Element => {
|
||||||
const options = useMemo(() => {
|
const options = useMemo(() => {
|
||||||
|
@ -114,13 +110,11 @@ export const ModelTypeDropdown = ({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const modelAccepted = isModelAccepted(modeledMethod, modelingStatus);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<InputDropdown
|
<InputDropdown
|
||||||
value={modeledMethod?.type ?? "none"}
|
value={modeledMethod?.type ?? "none"}
|
||||||
options={options}
|
options={options}
|
||||||
$accepted={modelAccepted}
|
$pending={modelPending}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
aria-label="Model type"
|
aria-label="Model type"
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -24,7 +24,7 @@ describe(ModelKindDropdown.name, () => {
|
||||||
<ModelKindDropdown
|
<ModelKindDropdown
|
||||||
language={QueryLanguage.Java}
|
language={QueryLanguage.Java}
|
||||||
modeledMethod={modeledMethod}
|
modeledMethod={modeledMethod}
|
||||||
modelingStatus="unsaved"
|
modelPending={false}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
/>,
|
/>,
|
||||||
);
|
);
|
||||||
|
@ -47,7 +47,7 @@ describe(ModelKindDropdown.name, () => {
|
||||||
<ModelKindDropdown
|
<ModelKindDropdown
|
||||||
language={QueryLanguage.Java}
|
language={QueryLanguage.Java}
|
||||||
modeledMethod={modeledMethod}
|
modeledMethod={modeledMethod}
|
||||||
modelingStatus="unsaved"
|
modelPending={false}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
/>,
|
/>,
|
||||||
);
|
);
|
||||||
|
@ -64,7 +64,7 @@ describe(ModelKindDropdown.name, () => {
|
||||||
<ModelKindDropdown
|
<ModelKindDropdown
|
||||||
language={QueryLanguage.Java}
|
language={QueryLanguage.Java}
|
||||||
modeledMethod={updatedModeledMethod}
|
modeledMethod={updatedModeledMethod}
|
||||||
modelingStatus="unsaved"
|
modelPending={false}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
/>,
|
/>,
|
||||||
);
|
);
|
||||||
|
@ -82,7 +82,7 @@ describe(ModelKindDropdown.name, () => {
|
||||||
<ModelKindDropdown
|
<ModelKindDropdown
|
||||||
language={QueryLanguage.Java}
|
language={QueryLanguage.Java}
|
||||||
modeledMethod={modeledMethod}
|
modeledMethod={modeledMethod}
|
||||||
modelingStatus="unsaved"
|
modelPending={false}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
/>,
|
/>,
|
||||||
);
|
);
|
||||||
|
@ -102,7 +102,7 @@ describe(ModelKindDropdown.name, () => {
|
||||||
<ModelKindDropdown
|
<ModelKindDropdown
|
||||||
language={QueryLanguage.Java}
|
language={QueryLanguage.Java}
|
||||||
modeledMethod={modeledMethod}
|
modeledMethod={modeledMethod}
|
||||||
modelingStatus="unsaved"
|
modelPending={false}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
/>,
|
/>,
|
||||||
);
|
);
|
||||||
|
|
|
@ -20,7 +20,7 @@ describe(ModelTypeDropdown.name, () => {
|
||||||
<ModelTypeDropdown
|
<ModelTypeDropdown
|
||||||
language={QueryLanguage.Java}
|
language={QueryLanguage.Java}
|
||||||
modeledMethod={modeledMethod}
|
modeledMethod={modeledMethod}
|
||||||
modelingStatus="unsaved"
|
modelPending={false}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
method={method}
|
method={method}
|
||||||
/>,
|
/>,
|
||||||
|
@ -42,7 +42,7 @@ describe(ModelTypeDropdown.name, () => {
|
||||||
<ModelTypeDropdown
|
<ModelTypeDropdown
|
||||||
language={QueryLanguage.Ruby}
|
language={QueryLanguage.Ruby}
|
||||||
modeledMethod={modeledMethod}
|
modeledMethod={modeledMethod}
|
||||||
modelingStatus="unsaved"
|
modelPending={false}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
method={method}
|
method={method}
|
||||||
/>,
|
/>,
|
||||||
|
@ -64,7 +64,7 @@ describe(ModelTypeDropdown.name, () => {
|
||||||
<ModelTypeDropdown
|
<ModelTypeDropdown
|
||||||
language={QueryLanguage.Java}
|
language={QueryLanguage.Java}
|
||||||
modeledMethod={modeledMethod}
|
modeledMethod={modeledMethod}
|
||||||
modelingStatus="unsaved"
|
modelPending={false}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
method={method}
|
method={method}
|
||||||
/>,
|
/>,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче