feat: Remove unused dataModelManager prop from ElementEditor and clean up imports
This commit is contained in:
@@ -625,7 +625,6 @@ const DashboardEditor: React.FC = () => {
|
|||||||
}}
|
}}
|
||||||
setSwapSource={setSwapSource}
|
setSwapSource={setSwapSource}
|
||||||
setShowSwapUI={setShowSwapUI}
|
setShowSwapUI={setShowSwapUI}
|
||||||
dataModelManager={dataModelManager}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -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 { ExtendedCSSProperties, UIElement } from "../../../../types/exportedTypes";
|
||||||
import { getCurrentElementStyleValue } from "../../functions/helpers/getCurrentElementStyleValue";
|
|
||||||
import type { DataModelManager } from "../../data/dataModel";
|
|
||||||
import { DeleteIcon } from "../../../icons/ContextMenuIcons";
|
import { DeleteIcon } from "../../../icons/ContextMenuIcons";
|
||||||
import DataSourceSelector from "../../../ui/inputs/DataSourceSelector";
|
import DataSourceSelector from "../../../ui/inputs/DataSourceSelector";
|
||||||
import InputWithDropDown from "../../../ui/inputs/InputWithDropDown";
|
import InputWithDropDown from "../../../ui/inputs/InputWithDropDown";
|
||||||
import InputRange from "../../../ui/inputs/InputRange";
|
import InputRange from "../../../ui/inputs/InputRange";
|
||||||
import RenameInput from "../../../ui/inputs/RenameInput";
|
import RenameInput from "../../../ui/inputs/RenameInput";
|
||||||
import { AddIcon, AlignJustifyIcon, AlignLeftIcon, AlignRightIcon, DeviceIcon, FlexColumnIcon, FlexRowIcon, FlexRowReverseIcon, ParametersIcon } from "../../../icons/ExportCommonIcons";
|
import { AddIcon, DeviceIcon, ParametersIcon } from "../../../icons/ExportCommonIcons";
|
||||||
import { getAlphaFromRgba, rgbaToHex, hexToRgba } from "../../functions/helpers/colorHandlers";
|
|
||||||
import DataDetailedDropdown from "../../../ui/inputs/DataDetailedDropdown";
|
import DataDetailedDropdown from "../../../ui/inputs/DataDetailedDropdown";
|
||||||
import { useSceneContext } from "../../../../modules/scene/sceneContext";
|
import { useSceneContext } from "../../../../modules/scene/sceneContext";
|
||||||
import ElementDesign from "./ElementDesign";
|
import ElementDesign from "./ElementDesign";
|
||||||
@@ -34,7 +31,6 @@ interface ElementEditorProps {
|
|||||||
handleRemoveElement: (blockId: string, elementId: string) => void;
|
handleRemoveElement: (blockId: string, elementId: string) => void;
|
||||||
setSwapSource: (source: string | null) => void;
|
setSwapSource: (source: string | null) => void;
|
||||||
setShowSwapUI: (show: boolean) => void;
|
setShowSwapUI: (show: boolean) => void;
|
||||||
dataModelManager: DataModelManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const ElementEditor: React.FC<ElementEditorProps> = ({
|
const ElementEditor: React.FC<ElementEditorProps> = ({
|
||||||
@@ -58,7 +54,6 @@ const ElementEditor: React.FC<ElementEditorProps> = ({
|
|||||||
handleRemoveElement,
|
handleRemoveElement,
|
||||||
setSwapSource,
|
setSwapSource,
|
||||||
setShowSwapUI,
|
setShowSwapUI,
|
||||||
dataModelManager,
|
|
||||||
}) => {
|
}) => {
|
||||||
const { simulationDashBoardStore, productStore, analysisStore } = useSceneContext();
|
const { simulationDashBoardStore, productStore, analysisStore } = useSceneContext();
|
||||||
const { products, selectedProduct, getProductById, getEventByModelUuid } = productStore();
|
const { products, selectedProduct, getProductById, getEventByModelUuid } = productStore();
|
||||||
@@ -69,7 +64,6 @@ const ElementEditor: React.FC<ElementEditorProps> = ({
|
|||||||
const [selectType, setSelectType] = useState("design");
|
const [selectType, setSelectType] = useState("design");
|
||||||
const [selectDataMapping, setSelectDataMapping] = useState(element?.type === "graph" && element.dataType === "multiple-machine" ? "multipleMachine" : "singleMachine");
|
const [selectDataMapping, setSelectDataMapping] = useState(element?.type === "graph" && element.dataType === "multiple-machine" ? "multipleMachine" : "singleMachine");
|
||||||
|
|
||||||
// Get asset dropdown items from product
|
|
||||||
const getAssetDropdownItems = useCallback(() => {
|
const getAssetDropdownItems = useCallback(() => {
|
||||||
if (!product?.eventDatas) return [];
|
if (!product?.eventDatas) return [];
|
||||||
|
|
||||||
@@ -84,7 +78,6 @@ const ElementEditor: React.FC<ElementEditorProps> = ({
|
|||||||
(assetId: string | undefined) => {
|
(assetId: string | undefined) => {
|
||||||
if (!product || !assetId) return [];
|
if (!product || !assetId) return [];
|
||||||
|
|
||||||
// Global system metrics (available for all assets)
|
|
||||||
const globalItems = [
|
const globalItems = [
|
||||||
{
|
{
|
||||||
title: "System Performance",
|
title: "System Performance",
|
||||||
@@ -261,7 +254,6 @@ const ElementEditor: React.FC<ElementEditorProps> = ({
|
|||||||
[product]
|
[product]
|
||||||
);
|
);
|
||||||
|
|
||||||
// Get common value dropdown items (available across all assets)
|
|
||||||
const getCommonValueDropdownItems = useCallback(() => {
|
const getCommonValueDropdownItems = useCallback(() => {
|
||||||
const commonItems = [
|
const commonItems = [
|
||||||
{ id: "timeMetrics.uptime", label: "Uptime", icon: <ParametersIcon /> },
|
{ id: "timeMetrics.uptime", label: "Uptime", icon: <ParametersIcon /> },
|
||||||
@@ -282,13 +274,10 @@ const ElementEditor: React.FC<ElementEditorProps> = ({
|
|||||||
|
|
||||||
const singleValueFields = useMemo(() => {
|
const singleValueFields = useMemo(() => {
|
||||||
if (element?.type === "graph" && element.dataType === "single-machine") {
|
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 : [];
|
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 }))) : [];
|
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) => ({
|
return dataValues.map((value, index) => ({
|
||||||
id: `data-value-${index}`,
|
id: `data-value-${index}`,
|
||||||
label: `Data Value ${index + 1}`,
|
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 [
|
return [
|
||||||
{
|
{
|
||||||
id: "data-value",
|
id: "data-value",
|
||||||
@@ -336,30 +324,23 @@ const ElementEditor: React.FC<ElementEditorProps> = ({
|
|||||||
|
|
||||||
setSelectDataMapping(newDataType);
|
setSelectDataMapping(newDataType);
|
||||||
|
|
||||||
// Convert the element data type when switching
|
|
||||||
if (newDataType === "singleMachine" && element.dataType === "multiple-machine") {
|
if (newDataType === "singleMachine" && element.dataType === "multiple-machine") {
|
||||||
// Convert from multiple-machine to single-machine
|
|
||||||
updateDataType(selectedBlock, selectedElement, "single-machine");
|
updateDataType(selectedBlock, selectedElement, "single-machine");
|
||||||
} else if (newDataType === "multipleMachine" && element.dataType === "single-machine") {
|
} else if (newDataType === "multipleMachine" && element.dataType === "single-machine") {
|
||||||
// Convert from single-machine to multiple-machine
|
|
||||||
updateDataType(selectedBlock, selectedElement, "multiple-machine");
|
updateDataType(selectedBlock, selectedElement, "multiple-machine");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const addField = () => {
|
const addField = () => {
|
||||||
if (selectDataMapping === "singleMachine" && element?.type === "graph" && element.dataType === "single-machine") {
|
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 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);
|
updateDataValue(selectedBlock, selectedElement, newDataValue);
|
||||||
} else if (selectDataMapping === "multipleMachine" && element?.type === "graph" && element.dataType === "multiple-machine") {
|
} 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 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);
|
updateDataSource(selectedBlock, selectedElement, newDataSource);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user