Skip to content

Commit

Permalink
Merge pull request #445 from akaene/fix/correct-f-rate-value-and-glob…
Browse files Browse the repository at this point in the history
…al-system-disable-fix

Fix/correct f rate value and global system disable fix
  • Loading branch information
blcham authored Jun 20, 2024
2 parents fe84ec5 + 518cff1 commit 3c5e593
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/components/appBar/AppBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ interface Props {
showBackButton?: boolean;
}

const shouldDropdownBeDisabled = (url: string) => {
const shouldSystemSwitchBeDisabled = (url: string) => {
const pathParts = url.split("/");
const routes = [ROUTES.FTA.substring(1), ROUTES.SYSTEMS.substring(1)];

Expand All @@ -52,7 +52,7 @@ const AppBar = ({ title, showBackButton = false, topPanelHeight }: Props) => {
const { i18n, t } = useTranslation();
const { appBarTitle, systemsList } = useAppBar();
const location = useLocation();
const dropdownDisabled = shouldDropdownBeDisabled(location.pathname);
const isGlobalSystemSwitchDisabled = shouldSystemSwitchBeDisabled(location.pathname);

const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
const [selectedSystem, setSelectedSystem] = useSelectedSystemSummaries();
Expand Down Expand Up @@ -158,7 +158,7 @@ const AppBar = ({ title, showBackButton = false, topPanelHeight }: Props) => {
: ""
}
onChange={handleSystemChange}
disabled={dropdownDisabled}
disabled={isGlobalSystemSwitchDisabled}
>
{systemsList.map((s, i) => {
return (
Expand All @@ -169,7 +169,7 @@ const AppBar = ({ title, showBackButton = false, topPanelHeight }: Props) => {
})}
</TextField>
<Box className={classes.tooltipContainer}>
{selectedSystem && (
{selectedSystem && !isGlobalSystemSwitchDisabled && (
<Tooltip title={t("common.delete")} className={classes.tooltip} onClick={handleSystemDelete}>
<CancelIcon />
</Tooltip>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,12 @@ const FaultEventMenu = ({ shapeToolData, onEventUpdated, refreshTree, rootIri }:
}
};

const handleManualFailureRateUpdate = () => {
onEventUpdated({ ...shapeToolData, probability: snsManuallyDefinedFailureRate });
const handleManualFailureRateUpdate = (eventType: EventType) => {
if (eventType === EventType.EXTERNAL) {
onEventUpdated({ ...shapeToolData, probability: externalManuallyDefinedFailureRate });
} else {
onEventUpdated({ ...shapeToolData, probability: snsManuallyDefinedFailureRate });
}
};

const handleFailureModeClicked = (failureMode: FailureMode) => {
Expand Down Expand Up @@ -346,7 +350,7 @@ const FaultEventMenu = ({ shapeToolData, onEventUpdated, refreshTree, rootIri }:
}
inputProps={{ inputMode: "decimal" }}
disabled={selectedRadioButton !== RadioButtonType.Manual}
onBlur={handleManualFailureRateUpdate}
onBlur={() => handleManualFailureRateUpdate(EventType.BASIC)}
/>
</Box>
</RadioGroup>
Expand All @@ -366,7 +370,7 @@ const FaultEventMenu = ({ shapeToolData, onEventUpdated, refreshTree, rootIri }:
value={externalManuallyDefinedFailureRate || ""}
onChange={(event) => handleManuallyDefinedFailureRateChange(event, NodeTypeWithManualFailureRate.External)}
inputProps={{ inputMode: "decimal" }}
onBlur={handleManualFailureRateUpdate}
onBlur={() => handleManualFailureRateUpdate(EventType.EXTERNAL)}
/>
<Divider className={classes.divider} />
</Box>
Expand Down

0 comments on commit 3c5e593

Please sign in to comment.