feat: Remove unused dataModelManager prop from ElementEditor and clean up imports

This commit is contained in:
2025-12-17 17:42:42 +05:30
parent debabea79b
commit 97ab47354c
2 changed files with 4 additions and 24 deletions

View File

@@ -625,7 +625,6 @@ const DashboardEditor: React.FC = () => {
}}
setSwapSource={setSwapSource}
setShowSwapUI={setShowSwapUI}
dataModelManager={dataModelManager}
/>
)}
</div>

View File

@@ -1,14 +1,11 @@
import { useCallback, useEffect, useMemo, useState, type RefObject } from "react";
import { useCallback, useMemo, useState, type RefObject } from "react";
import { ExtendedCSSProperties, UIElement } from "../../../../types/exportedTypes";
import { getCurrentElementStyleValue } from "../../functions/helpers/getCurrentElementStyleValue";
import type { DataModelManager } from "../../data/dataModel";
import { DeleteIcon } from "../../../icons/ContextMenuIcons";
import DataSourceSelector from "../../../ui/inputs/DataSourceSelector";
import InputWithDropDown from "../../../ui/inputs/InputWithDropDown";
import InputRange from "../../../ui/inputs/InputRange";
import RenameInput from "../../../ui/inputs/RenameInput";
import { AddIcon, AlignJustifyIcon, AlignLeftIcon, AlignRightIcon, DeviceIcon, FlexColumnIcon, FlexRowIcon, FlexRowReverseIcon, ParametersIcon } from "../../../icons/ExportCommonIcons";
import { getAlphaFromRgba, rgbaToHex, hexToRgba } from "../../functions/helpers/colorHandlers";
import { AddIcon, DeviceIcon, ParametersIcon } from "../../../icons/ExportCommonIcons";
import DataDetailedDropdown from "../../../ui/inputs/DataDetailedDropdown";
import { useSceneContext } from "../../../../modules/scene/sceneContext";
import ElementDesign from "./ElementDesign";
@@ -34,7 +31,6 @@ interface ElementEditorProps {
handleRemoveElement: (blockId: string, elementId: string) => void;
setSwapSource: (source: string | null) => void;
setShowSwapUI: (show: boolean) => void;
dataModelManager: DataModelManager;
}
const ElementEditor: React.FC<ElementEditorProps> = ({
@@ -58,7 +54,6 @@ const ElementEditor: React.FC<ElementEditorProps> = ({
handleRemoveElement,
setSwapSource,
setShowSwapUI,
dataModelManager,
}) => {
const { simulationDashBoardStore, productStore, analysisStore } = useSceneContext();
const { products, selectedProduct, getProductById, getEventByModelUuid } = productStore();
@@ -69,7 +64,6 @@ const ElementEditor: React.FC<ElementEditorProps> = ({
const [selectType, setSelectType] = useState("design");
const [selectDataMapping, setSelectDataMapping] = useState(element?.type === "graph" && element.dataType === "multiple-machine" ? "multipleMachine" : "singleMachine");
// Get asset dropdown items from product
const getAssetDropdownItems = useCallback(() => {
if (!product?.eventDatas) return [];
@@ -84,7 +78,6 @@ const ElementEditor: React.FC<ElementEditorProps> = ({
(assetId: string | undefined) => {
if (!product || !assetId) return [];
// Global system metrics (available for all assets)
const globalItems = [
{
title: "System Performance",
@@ -261,7 +254,6 @@ const ElementEditor: React.FC<ElementEditorProps> = ({
[product]
);
// Get common value dropdown items (available across all assets)
const getCommonValueDropdownItems = useCallback(() => {
const commonItems = [
{ id: "timeMetrics.uptime", label: "Uptime", icon: <ParametersIcon /> },
@@ -282,13 +274,10 @@ const ElementEditor: React.FC<ElementEditorProps> = ({
const singleValueFields = useMemo(() => {
if (element?.type === "graph" && element.dataType === "single-machine") {
// Get the dataValue array - ensure it's always an array
const dataValues = Array.isArray(element.dataValue) ? element.dataValue : [];
// Generate dropdown options based on the selected data source
const valueOptions = element.dataSource ? getLableValueDropdownItems(element.dataSource).flatMap((section) => section.items.map((item) => ({ id: item.id, label: item.label }))) : [];
// Create fields based on the number of data values in the element
return dataValues.map((value, index) => ({
id: `data-value-${index}`,
label: `Data Value ${index + 1}`,
@@ -297,7 +286,6 @@ const ElementEditor: React.FC<ElementEditorProps> = ({
}));
}
// Return default field if not a graph with single-machine data type
return [
{
id: "data-value",
@@ -336,30 +324,23 @@ const ElementEditor: React.FC<ElementEditorProps> = ({
setSelectDataMapping(newDataType);
// Convert the element data type when switching
if (newDataType === "singleMachine" && element.dataType === "multiple-machine") {
// Convert from multiple-machine to single-machine
updateDataType(selectedBlock, selectedElement, "single-machine");
} else if (newDataType === "multipleMachine" && element.dataType === "single-machine") {
// Convert from single-machine to multiple-machine
updateDataType(selectedBlock, selectedElement, "multiple-machine");
}
};
const addField = () => {
if (selectDataMapping === "singleMachine" && element?.type === "graph" && element.dataType === "single-machine") {
// For single machine, add new data value field
const currentDataValue = Array.isArray(element.dataValue) ? element.dataValue : [];
const newDataValue = [...currentDataValue, ""]; // Add empty string for new field
const newDataValue = [...currentDataValue, ""];
// Update the element's dataValue
updateDataValue(selectedBlock, selectedElement, newDataValue);
} else if (selectDataMapping === "multipleMachine" && element?.type === "graph" && element.dataType === "multiple-machine") {
// For multiple machine, add new data source field
const currentDataSource = Array.isArray(element.dataSource) ? element.dataSource : [];
const newDataSource = [...currentDataSource, ""]; // Add empty string for new field
const newDataSource = [...currentDataSource, ""];
// Update the element's dataSource
updateDataSource(selectedBlock, selectedElement, newDataSource);
}
};