From 4d69283d5d179d58894325caeed43195ba4c5b32 Mon Sep 17 00:00:00 2001 From: Bogdan Kostov Date: Tue, 16 Jan 2024 15:27:18 +0100 Subject: [PATCH 1/6] [Fix #147] Add if clause to return empty array if input["@graph"] is empty in compactAndResolveReferencesAsArray - revert ad-hoc fix introduced in #125 --- .../dashboard/content/list/DashboardFailureModesTableList.tsx | 2 +- .../dashboard/content/list/DashboardFaultTreeList.tsx | 2 +- src/components/dashboard/content/list/DashboardSystemList.tsx | 2 +- src/utils/JsonLdUtils.tsx | 2 ++ 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/dashboard/content/list/DashboardFailureModesTableList.tsx b/src/components/dashboard/content/list/DashboardFailureModesTableList.tsx index f8b4b71a..cc496d15 100644 --- a/src/components/dashboard/content/list/DashboardFailureModesTableList.tsx +++ b/src/components/dashboard/content/list/DashboardFailureModesTableList.tsx @@ -56,7 +56,7 @@ const DashboardFailureModesTableList = () => { return ( - {tables.filter(m => !!m && !!m.iri).map((mode) => { + {tables.map((mode) => { const routePath = ROUTES.FMEA + extractFragment(mode.iri); return ( diff --git a/src/components/dashboard/content/list/DashboardFaultTreeList.tsx b/src/components/dashboard/content/list/DashboardFaultTreeList.tsx index 840d1a23..536e4744 100644 --- a/src/components/dashboard/content/list/DashboardFaultTreeList.tsx +++ b/src/components/dashboard/content/list/DashboardFaultTreeList.tsx @@ -52,7 +52,7 @@ const DashboardFaultTreeList = () => { return ( - {faultTrees.filter(f => !!f && !!f.iri).map((tree) => { + {faultTrees.map((tree) => { const routePath = ROUTES.FTA + extractFragment(tree.iri); return ( diff --git a/src/components/dashboard/content/list/DashboardSystemList.tsx b/src/components/dashboard/content/list/DashboardSystemList.tsx index caac6f29..05d86d39 100644 --- a/src/components/dashboard/content/list/DashboardSystemList.tsx +++ b/src/components/dashboard/content/list/DashboardSystemList.tsx @@ -52,7 +52,7 @@ const DashboardSystemList = () => { return ( - {systems.filter(s => !!s && !!s.iri).map((system) => { + {systems.map((system) => { const routePath = ROUTES.SYSTEM + extractFragment(system.iri); return ( diff --git a/src/utils/JsonLdUtils.tsx b/src/utils/JsonLdUtils.tsx index ff46e302..80f96b54 100644 --- a/src/utils/JsonLdUtils.tsx +++ b/src/utils/JsonLdUtils.tsx @@ -39,6 +39,8 @@ export default class JsonLdUtils { ): Promise { if (Array.isArray(input) && input.length === 0) { return Promise.resolve([]); + } else if (Array.isArray(input["@graph"]) && input["@graph"].length === 0) { + return Promise.resolve([]); } return compact(input, context) .then((res) => JsonLdUtils.loadArrayFromCompactedGraph(res)) From 262bde82653206ab1aa3ccaab61558632341d0b7 Mon Sep 17 00:00:00 2001 From: Bogdan Kostov Date: Tue, 16 Jan 2024 15:33:54 +0100 Subject: [PATCH 2/6] [Fix #148] Set focus in component form to top field. --- .../system/menu/failureMode/ComponentFailureModesList.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/editor/system/menu/failureMode/ComponentFailureModesList.tsx b/src/components/editor/system/menu/failureMode/ComponentFailureModesList.tsx index b996929d..cfadd69c 100644 --- a/src/components/editor/system/menu/failureMode/ComponentFailureModesList.tsx +++ b/src/components/editor/system/menu/failureMode/ComponentFailureModesList.tsx @@ -169,8 +169,7 @@ const ComponentFailureModesList = ({ component }) => { - Date: Tue, 16 Jan 2024 15:57:41 +0100 Subject: [PATCH 3/6] [Fix #149] Highlight and show new fault event in the fault event form. --- src/components/dialog/faultEvent/FaultEventDialog.tsx | 8 ++++---- src/components/editor/faultTree/Editor.tsx | 7 ++++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/components/dialog/faultEvent/FaultEventDialog.tsx b/src/components/dialog/faultEvent/FaultEventDialog.tsx index bdccae0e..99bca8f6 100644 --- a/src/components/dialog/faultEvent/FaultEventDialog.tsx +++ b/src/components/dialog/faultEvent/FaultEventDialog.tsx @@ -12,13 +12,13 @@ import {schema} from "./FaultEventCreation.schema"; import {yupResolver} from "@hookform/resolvers/yup"; import {eventFromHookFormValues} from "@services/faultEventService"; import {FaultEventsReuseProvider} from "@hooks/useReusableFaultEvents"; -import {useEffect} from "react"; +import {FaultEvent} from "@models/eventModel"; interface Props { open: boolean, eventIri: string, treeUri: string, - onCreated: () => void, + onCreated: (element: FaultEvent) => void, onClose: () => void, } @@ -34,8 +34,8 @@ const FaultEventDialog = ({open, eventIri, treeUri, onCreated, onClose}: Props) faultEventService.addEvent(eventIri, requestEvent) .then(value => { - onClose() - onCreated() + onClose(); + onCreated(value); }) .catch(reason => showSnackbar(reason, SnackbarType.ERROR)) } diff --git a/src/components/editor/faultTree/Editor.tsx b/src/components/editor/faultTree/Editor.tsx index 30094df9..1488153a 100644 --- a/src/components/editor/faultTree/Editor.tsx +++ b/src/components/editor/faultTree/Editor.tsx @@ -119,6 +119,11 @@ const Editor = ({setAppBarName}: DashboardTitleProps) => { const [eventDialogOpen, setEventDialogOpen] = useState(false); + const handleEventCreate = (newEvent: FaultEvent) => { + setSidebarSelectedEvent(newEvent); + refreshTree(); + } + const handleEventUpdate = (eventToUpdate: FaultEvent) => { faultEventService.update(eventToUpdate) .then(value => refreshTree()) @@ -176,7 +181,7 @@ const Editor = ({setAppBarName}: DashboardTitleProps) => { handleEventCreate(newEvent)} onClose={() => setEventDialogOpen(false)}/> Date: Tue, 23 Jan 2024 11:57:53 +0100 Subject: [PATCH 4/6] [Fix] Fix form issues in fault event editor - fix style of labels of comboboxes event and gate type - rename name field to "fault-event-name" to remove missing autocomplete browser warning. --- .../faultEvent/FaultEventCreation.schema.tsx | 2 +- .../dialog/faultEvent/FaultEventCreation.tsx | 28 +++++++++---------- .../faultEvent/FaultEventShapeToolPane.tsx | 4 +-- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/components/dialog/faultEvent/FaultEventCreation.schema.tsx b/src/components/dialog/faultEvent/FaultEventCreation.schema.tsx index 533026ff..70604dcd 100644 --- a/src/components/dialog/faultEvent/FaultEventCreation.schema.tsx +++ b/src/components/dialog/faultEvent/FaultEventCreation.schema.tsx @@ -3,7 +3,7 @@ import {yupOptionalNumber} from "@utils/validationUtils"; import {EventType, GateType} from "@models/eventModel"; export const schema = Yup.object().shape({ - name: Yup.string() + "fault-event-name": Yup.string() .min(1, 'Must be at least 1 character long') .required('Event is mandatory'), description: Yup.string().default(''), diff --git a/src/components/dialog/faultEvent/FaultEventCreation.tsx b/src/components/dialog/faultEvent/FaultEventCreation.tsx index 73582d25..a1dd3dc6 100644 --- a/src/components/dialog/faultEvent/FaultEventCreation.tsx +++ b/src/components/dialog/faultEvent/FaultEventCreation.tsx @@ -28,7 +28,7 @@ const FaultEventCreation = ({useFormMethods, eventReusing}: Props) => { useEffect(() => { if (selectedEvent) { - setValue('name', selectedEvent.name) + setValue('fault-event-name', selectedEvent.name) setValue('description', selectedEvent.description) setValue('probability', selectedEvent.probability) setValue('eventType', selectedEvent.eventType) @@ -43,7 +43,7 @@ const FaultEventCreation = ({useFormMethods, eventReusing}: Props) => {
Event: {eventReusing && - + <> { defaultValue={null} /> Create new Event: - } + } - + Type - { Object.values(EventType).map(value => - {value}) + {value}) } } @@ -76,10 +76,11 @@ const FaultEventCreation = ({useFormMethods, eventReusing}: Props) => { {/*TODO: sort out default value UI bug*/} {/*TODO: sort out default value UI bug*/} @@ -106,14 +107,13 @@ const FaultEventCreation = ({useFormMethods, eventReusing}: Props) => { Gate Type { - //@ts-ignore - return { gateTypeValues().map(value => { const [enabled, optionValue] = value - return {value} + return {optionValue} }) } diff --git a/src/components/editor/faultTree/menu/faultEvent/FaultEventShapeToolPane.tsx b/src/components/editor/faultTree/menu/faultEvent/FaultEventShapeToolPane.tsx index c492d818..0586c32b 100644 --- a/src/components/editor/faultTree/menu/faultEvent/FaultEventShapeToolPane.tsx +++ b/src/components/editor/faultTree/menu/faultEvent/FaultEventShapeToolPane.tsx @@ -31,10 +31,9 @@ const FaultEventShapeToolPane = ({data, onEventUpdated, refreshTree}: Props) => let defaultValues; if (data) { - console.log(data); defaultValues = { eventType: data.eventType, - name: data.name, + "fault-event-name": data.name, description: data.description, probability: data.probability + "", gateType: data.gateType, @@ -46,7 +45,6 @@ const FaultEventShapeToolPane = ({data, onEventUpdated, refreshTree}: Props) => }); updateFunction = async (values: any) => { - console.log(values); let dataClone = cloneDeep(data) const updatedFaultEvent = deepOmit(faultEventService.eventFromHookFormValues(values), '@type') From d820fedb9717161814488b17a33465d3d645da70 Mon Sep 17 00:00:00 2001 From: Bogdan Kostov Date: Tue, 23 Jan 2024 11:59:03 +0100 Subject: [PATCH 5/6] [Fix] Remove usage of deprecated mui api --- .../faultEvent/reorder/FaultEventChildrenReorderList.tsx | 2 -- src/styles/App.styles.declarations.tsx | 8 +++----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/components/editor/faultTree/menu/faultEvent/reorder/FaultEventChildrenReorderList.tsx b/src/components/editor/faultTree/menu/faultEvent/reorder/FaultEventChildrenReorderList.tsx index 3ce73ef0..7387eed5 100644 --- a/src/components/editor/faultTree/menu/faultEvent/reorder/FaultEventChildrenReorderList.tsx +++ b/src/components/editor/faultTree/menu/faultEvent/reorder/FaultEventChildrenReorderList.tsx @@ -37,8 +37,6 @@ const FaultEventChildrenReorderList = ({eventChildren, handleReorder}: Props) => const oldIndex = result.source.index; const newIndex = result.destination.index; - console.log(result); - setItems(items => { const newItems = arrayMoveImmutable(items, oldIndex, newIndex) handleChildrenReordered(newItems); diff --git a/src/styles/App.styles.declarations.tsx b/src/styles/App.styles.declarations.tsx index caa51382..5170b5d2 100644 --- a/src/styles/App.styles.declarations.tsx +++ b/src/styles/App.styles.declarations.tsx @@ -1,6 +1,4 @@ import * as React from "react"; -import { adaptV4Theme } from '@mui/material/styles'; -import {createMuiTheme, DeprecatedThemeOptions} from "@mui/material"; import {createTheme} from "@mui/material/styles"; declare module '@mui/material/styles' { @@ -33,10 +31,10 @@ declare module '@mui/material/styles' { } } -const createCustomMuiTheme = (options: DeprecatedThemeOptions) => { - return createTheme(adaptV4Theme({ +const createCustomMuiTheme = (options) => { + return createTheme({ ...options, - })); + }); } export default createCustomMuiTheme; \ No newline at end of file From 5cfd5a23cb8c1d6054e0be7e9e0ec41796274d52 Mon Sep 17 00:00:00 2001 From: Bogdan Kostov Date: Tue, 23 Jan 2024 11:59:53 +0100 Subject: [PATCH 6/6] [Bump] Bump MUI dependencies --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index ee7ad635..897ea5f5 100644 --- a/package.json +++ b/package.json @@ -7,10 +7,10 @@ "@emotion/react": "^11.11.1", "@emotion/styled": "^11.11.0", "@hookform/resolvers": "^3.1.1", - "@mui/icons-material": "^5.14.3", - "@mui/lab": "^5.0.0-alpha.138", - "@mui/material": "^5.14.3", - "@mui/x-data-grid": "^6.10.2", + "@mui/icons-material": "^5.15.4", + "@mui/lab": "^5.0.0-alpha.160", + "@mui/material": "^5.15.4", + "@mui/x-data-grid": "^6.18.7", "@types/react-beautiful-dnd": "^13.1.4", "array-move": "^4.0.0", "axios": "^1.4.0",