Skip to content

Commit

Permalink
Merge pull request #613 from kbss-cvut/fix/603-remove-and-disable-app…
Browse files Browse the repository at this point in the history
…-parts

Remove and disable app parts
  • Loading branch information
blcham authored Oct 3, 2024
2 parents de3e56c + 968c098 commit 77454fd
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 54 deletions.
29 changes: 17 additions & 12 deletions src/components/dashboard/content/DashboardContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import NatureIcon from "@mui/icons-material/Nature";
import SystemDialog from "@components/dialog/system/SystemDialog";
import TableChartIcon from "@mui/icons-material/TableChart";
import FailureModesTableAggregateDialog from "@components/dialog/failureModesTable/aggregate/FailureModesTableAggregateDialog";
import { ENVVariable } from "../../../utils/constants";

const DashboardContent = () => {
const { classes } = useStyles();
Expand Down Expand Up @@ -43,14 +44,16 @@ const DashboardContent = () => {
onOpen={() => setSpeedDialOpen(true)}
open={speedDialOpen}
>
<SpeedDialAction
key="speed-dial-action-new-table-aggregate"
icon={<TableChartIcon />}
tooltipOpen
tooltipTitle={"Aggregated FMEA"}
title={"Aggregated FMEA"}
onClick={handleNewFmeaAggregate}
/>
{!ENVVariable.DISABLE_FMEA && (
<SpeedDialAction
key="speed-dial-action-new-table-aggregate"
icon={<TableChartIcon />}
tooltipOpen
tooltipTitle={"Aggregated FMEA"}
title={"Aggregated FMEA"}
onClick={handleNewFmeaAggregate}
/>
)}
<SpeedDialAction
key="speed-dial-action-new-tree"
icon={<NatureIcon />}
Expand All @@ -71,10 +74,12 @@ const DashboardContent = () => {

<FaultTreeDialog open={createFaultTreeDialogOpen} handleCloseDialog={() => setCreateFaultTreeDialogOpen(false)} />
<SystemDialog open={createSystemDialogOpen} handleCloseDialog={() => setCreateSystemDialogOpen(false)} />
<FailureModesTableAggregateDialog
open={createFmeaAggregateDialogOpen}
onClose={() => setCreateFmeaAggregateDialogOpen(false)}
/>
{!ENVVariable.DISABLE_FMEA && (
<FailureModesTableAggregateDialog
open={createFmeaAggregateDialogOpen}
onClose={() => setCreateFmeaAggregateDialogOpen(false)}
/>
)}
</React.Fragment>
);
};
Expand Down
16 changes: 9 additions & 7 deletions src/components/editor/faultTree/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import FaultEventDialog from "../../dialog/faultEvent/FaultEventDialog";
import { FaultEvent } from "@models/eventModel";
import { contextMenuDefaultAnchor, ElementContextMenuAnchor } from "@utils/contextMenu";
import FailureModesTableDialog from "@components/dialog/failureModesTable/FailureModesTableDialog";
import { ROUTES } from "@utils/constants";
import { ENVVariable, ROUTES } from "@utils/constants";
import { extractFragment } from "@services/utils/uriIdentifierUtils";
import { FTABoundary } from "@components/editor/faultTree/shapes/shapesDefinitions";
import * as joint from "jointjs";
Expand Down Expand Up @@ -274,12 +274,14 @@ const Editor = () => {
onClose={() => setEventDialogOpen(false)}
/>

<FailureModesTableDialog
open={failureModesTableOpen}
faultTreeIri={faultTree?.iri}
onCreated={handleFailureModesTableCreated}
onClose={() => setFailureModesTableOpen(false)}
/>
{!ENVVariable.DISABLE_FMEA && (
<FailureModesTableDialog
open={failureModesTableOpen}
faultTreeIri={faultTree?.iri}
onCreated={handleFailureModesTableCreated}
onClose={() => setFailureModesTableOpen(false)}
/>
)}
</div>
);
};
Expand Down
3 changes: 2 additions & 1 deletion src/components/editor/menu/DiagramOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Tooltip from "@mui/material/Tooltip";
import * as React from "react";
import { useTranslation } from "react-i18next";
import CircularProgress from "@mui/material/CircularProgress";
import { ENVVariable } from "@utils/constants";

export interface Props {
onApplyAutomaticLayout: () => void;
Expand Down Expand Up @@ -39,7 +40,7 @@ const DiagramOptions = ({
<IconButton color="primary" onClick={onExportDiagram} aria-label="save" size="large">
<SaveAltIcon />
</IconButton>
{tableConversionAllowed && (
{!ENVVariable && tableConversionAllowed && (
<IconButton color="primary" onClick={onConvertToTable} aria-label="convert" size="large">
<TableChartIcon />
</IconButton>
Expand Down
54 changes: 28 additions & 26 deletions src/components/navigation/SidePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import AccountTreeIcon from "@mui/icons-material/AccountTree";
import ArticleIcon from "@mui/icons-material/Article";
import BackupTableIcon from "@mui/icons-material/BackupTable";
import { useLocation, useNavigate } from "react-router-dom";
import { ROUTES } from "@utils/constants";
import { ENVVariable, ROUTES } from "@utils/constants";
import useStyles from "./SidePanel.styles";
import MenuOpenIcon from "@mui/icons-material/MenuOpen";
import MenuIcon from "@mui/icons-material/Menu";
Expand Down Expand Up @@ -55,7 +55,7 @@ const SidePanel: FC<SidePanelProps> = ({
icon: <AccountTreeIcon />,
route: ROUTES.FTA,
},
{
!ENVVariable.DISABLE_FMEA && {
title: `${t("categories.worksheets")}`,
icon: <ArticleIcon />,
route: ROUTES.FMEA,
Expand All @@ -74,31 +74,33 @@ const SidePanel: FC<SidePanelProps> = ({
style={{ transition: showAnimation ? "width 0.3s" : "none" }}
>
<Box style={{ marginTop: topPanelHeight }}>
{menuItems.map((item, index) => {
const isHighLighted = index === hoveredItemIndex || location.pathname.includes(item.route);
const bgColor = isHighLighted ? theme.sidePanel.colors.hover : "transparent";
const iconColor = isHighLighted ? theme.sidePanel.colors.iconActive : theme.sidePanel.colors.icon;
const titleColor = isHighLighted ? theme.sidePanel.colors.textActive : theme.sidePanel.colors.text;
return (
<Box
key={`${item.title}-${index}`}
className={classes.menuItem}
onMouseEnter={() => setHoveredItemIndex(index)}
onMouseLeave={() => setHoveredItemIndex(undefined)}
onClick={() => handleMenuItemClick(item.route)}
style={{ backgroundColor: bgColor }}
>
<Box className={classes.iconContainer} style={{ color: iconColor }}>
{item.icon}
</Box>
<Box className={classes.titleContainer}>
<Typography className={classes.title} style={{ color: titleColor }}>
{item.title}
</Typography>
{menuItems
.filter((item) => !!item)
.map((item, index) => {
const isHighLighted = index === hoveredItemIndex || location.pathname.includes(item.route);
const bgColor = isHighLighted ? theme.sidePanel.colors.hover : "transparent";
const iconColor = isHighLighted ? theme.sidePanel.colors.iconActive : theme.sidePanel.colors.icon;
const titleColor = isHighLighted ? theme.sidePanel.colors.textActive : theme.sidePanel.colors.text;
return (
<Box
key={`${item.title}-${index}`}
className={classes.menuItem}
onMouseEnter={() => setHoveredItemIndex(index)}
onMouseLeave={() => setHoveredItemIndex(undefined)}
onClick={() => handleMenuItemClick(item.route)}
style={{ backgroundColor: bgColor }}
>
<Box className={classes.iconContainer} style={{ color: iconColor }}>
{item.icon}
</Box>
<Box className={classes.titleContainer}>
<Typography className={classes.title} style={{ color: titleColor }}>
{item.title}
</Typography>
</Box>
</Box>
</Box>
);
})}
);
})}
<Box className={classes.toggleContainer} onClick={toggleSidePanel}>
<Box className={classes.toggleIconBox}>{isCollapsed ? <MenuIcon /> : <MenuOpenIcon />}</Box>
</Box>
Expand Down
5 changes: 3 additions & 2 deletions src/components/routes/AppRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,12 @@ const AppRoutes = () => {
path: ROUTES.FTA + ROUTE_PARAMS.FTA_FRAGMENT,
element: <FaultTreeDashboard />,
},
{

!ENVVariable.DISABLE_FMEA && {
path: ROUTES.FMEA,
element: <FmeaOverview />,
},
{
!ENVVariable.DISABLE_FMEA && {
path: ROUTES.FMEA + ROUTE_PARAMS.FMEA_FRAGMENT,
element: <FailureModesTableDashboard />,
},
Expand Down
4 changes: 2 additions & 2 deletions src/contexts/AppBarContext.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ROUTES } from "@utils/constants";
import { ENVVariable, ROUTES } from "@utils/constants";
import React, { createContext, ReactNode, useContext, useEffect, useState } from "react";
import { useLocation } from "react-router-dom";
import { useTranslation } from "react-i18next";
Expand All @@ -21,9 +21,9 @@ interface AppBarTitleProviderProps {
const categoryTitles = {
[ROUTES.SYSTEMS]: "categories.systems",
[ROUTES.FTA]: "categories.trees",
[ROUTES.FMEA]: "categories.worksheets",
[ROUTES.FHA]: "categories.tables",
};
if (!ENVVariable.DISABLE_FMEA) categoryTitles[ROUTES.FMEA] = "categories.worksheets";

const AppBarMainContext = createContext<AppBarTitleContextType>({
appBarTitle: "",
Expand Down
13 changes: 9 additions & 4 deletions src/models/eventModel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ export const CONTEXT = Object.assign({}, ctx, ABSTRACT_CONTEXT, FAILURE_MODE_CON
export enum EventType {
BASIC = "BASIC",
EXTERNAL = "EXTERNAL",
UNDEVELOPED = "UNDEVELOPED",
CONDITIONING = "CONDITIONING",
// UNDEVELOPED = "UNDEVELOPED", // TODO to enable requires to allow setting manual failure rate
// CONDITIONING = "CONDITIONING",
INTERMEDIATE = "INTERMEDIATE",
}

Expand Down Expand Up @@ -153,8 +153,13 @@ export enum GateType {
// returns true as first argument of array if option should be enabled in select
export const gateTypeValues = (): [boolean, GateType][] =>
Object.values(GateType).map((value) => {
if (value === GateType.UNUSED) {
return [false, GateType.UNUSED];
if (
value === GateType.UNUSED ||
value === GateType.PRIORITY_AND ||
value === GateType.INHIBIT ||
value === GateType.XOR
) {
return [false, value];
} else {
return [true, value];
}
Expand Down
1 change: 1 addition & 0 deletions src/utils/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const ENVVariable = {
AUTHENTICATION: getEnv("FTA_FMEA_AUTHENTICATION", "internal"),
AUTH_SERVER_URL: getEnv("FTA_FMEA_AUTH_SERVER_URL", ""),
AUTH_CLIENT_ID: getEnv("FTA_FMEA_AUTH_CLIENT_ID", ""),
DISABLE_FMEA: getEnv("FTA_FMEA_DISABLE_FMEA", ""),
};

export const JSONLD = "application/ld+json";
Expand Down

0 comments on commit 77454fd

Please sign in to comment.