Skip to content

Commit

Permalink
Merge pull request #619 from kbss-cvut/fix/560-cant-delete-manual-fai…
Browse files Browse the repository at this point in the history
…lure-rate

Fix cant delete manual failure rate
  • Loading branch information
blcham authored Oct 8, 2024
2 parents e434734 + cf7c8c5 commit d5d1257
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
4 changes: 3 additions & 1 deletion src/components/editor/faultTree/canvas/EditorCanvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { JOINTJS_NODE_MODEL } from "@components/editor/faultTree/shapes/constant
import { FaultEventScenario } from "@models/faultEventScenario";
import { findNodeByIri } from "@utils/treeUtils";
import FaultEventScenariosTable from "../menu/FaultEventScenariosTable";
import { Box, TextField, Typography, IconButton, useTheme } from "@mui/material";
import { Box, TextField, Typography, IconButton, useTheme, Divider } from "@mui/material";
import { useTranslation } from "react-i18next";
import RestartAltIcon from "@mui/icons-material/RestartAlt";
import PlayArrow from "@mui/icons-material/PlayArrow";
Expand Down Expand Up @@ -370,6 +370,8 @@ const EditorCanvas = ({
</IconButton>
</Box>
</CurrentFaultTreeTableProvider>
<Divider className={classes.divider} />

{!showTable && (
<FaultEventMenu
selectedShapeToolData={sidebarSelectedEvent}
Expand Down
29 changes: 15 additions & 14 deletions src/components/editor/faultTree/menu/faultEvent/FaultEventMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ const FaultEventMenu = ({

if (selectedRadioButton === RadioButtonType.Manual) {
await updateEvent({
probability: manualFailureRates[shapeToolData.eventType] || manualFailureRates.default,
probability: manualFailureRates[shapeToolData.eventType],
selectedEstimate: undefined,
});
} else {
Expand All @@ -153,11 +153,12 @@ const FaultEventMenu = ({
const inputValue = event.target.value;
const regex = /^[0-9]*\.?[0-9]*$/;
if (regex.test(inputValue)) {
const inputNumber = inputValue === "" ? undefined : inputValue;
if (type === NodeTypeWithManualFailureRate.Sns) {
setBasicManuallyDefinedFailureRate(inputValue);
setBasicManuallyDefinedFailureRate(inputNumber);
}
if (type === NodeTypeWithManualFailureRate.External) {
setExternalManuallyDefinedFailureRate(inputValue);
setExternalManuallyDefinedFailureRate(inputNumber);
}
setIsModified(true);
}
Expand Down Expand Up @@ -419,11 +420,6 @@ const FaultEventMenu = ({
{/* ROOT NODE */}
{shapeToolData && shapeToolData.iri === rootIri && (
<>
{basedFailureRate && (
<Box className={classes.eventPropertyRow}>{fhaFailureRateComponent(basedFailureRate, null, null)}</Box>
)}
{getRequiredFailureRate() &&
requiredFailureRateComponent(getRequiredFailureRate(), requiredFailureRateStatusColor, violatesRequirement)}
{shapeToolData?.probability && (
<Box className={classes.eventPropertyRow}>
{calculatedFailureRateComponent(
Expand All @@ -433,18 +429,18 @@ const FaultEventMenu = ({
)}
</Box>
)}
{getRequiredFailureRate() &&
requiredFailureRateComponent(getRequiredFailureRate(), requiredFailureRateStatusColor, violatesRequirement)}
{basedFailureRate && (
<Box className={classes.eventPropertyRow}>{fhaFailureRateComponent(basedFailureRate, null, null)}</Box>
)}
<Divider className={classes.divider} />
</>
)}

{/* EXTERNAL NODE */}
{shapeToolData && shapeToolData.eventType === EventType.EXTERNAL && shapeToolData.isReference && (
<>
{basedFailureRate && (
<Box className={classes.eventPropertyRow}>{fhaFailureRateComponent(basedFailureRate, null, null)}</Box>
)}
{getRequiredFailureRate() &&
requiredFailureRateComponent(getRequiredFailureRate(), requiredFailureRateStatusColor, violatesRequirement)}
{shapeToolData?.probability && (
<Box className={classes.eventPropertyRow}>
{calculatedFailureRateComponent(
Expand All @@ -454,6 +450,11 @@ const FaultEventMenu = ({
)}
</Box>
)}
{getRequiredFailureRate() &&
requiredFailureRateComponent(getRequiredFailureRate(), requiredFailureRateStatusColor, violatesRequirement)}
{basedFailureRate && (
<Box className={classes.eventPropertyRow}>{fhaFailureRateComponent(basedFailureRate, null, null)}</Box>
)}
<Divider className={classes.divider} />
</>
)}
Expand All @@ -463,7 +464,7 @@ const FaultEventMenu = ({
<>
{shapeToolData?.probability && (
<Box className={classes.eventPropertyRow}>
{failureRateComponent(shapeToolData.probability, theme.main.black, [])}
{failureRateComponent(shapeToolData.probability, "eventDescription.manuallyDefinedFailureRate", [])}
</Box>
)}
</>
Expand Down

0 comments on commit d5d1257

Please sign in to comment.