diff --git a/cockpit/IPC/src/Components/IOList/ListItem.tsx b/cockpit/IPC/src/Components/IOList/ListItem.tsx index aa191e6539..5a99b1c9d8 100644 --- a/cockpit/IPC/src/Components/IOList/ListItem.tsx +++ b/cockpit/IPC/src/Components/IOList/ListItem.tsx @@ -111,7 +111,7 @@ const ListItem: React.FC = ({ */ function getSecondaryContent(interfaceData: any): ReactElement | null { const internals = (secData: any) => { - switch (secData.type) { + switch (secData.typeJson.type[0]) { case 'boolean': return handleBoolContent(data); @@ -153,7 +153,7 @@ const ListItem: React.FC = ({ */ function getTinkerInterface(interfaceData: any): React.ReactElement | null { const internals = (interfacedata: any) => { - switch (interfacedata.type) { + switch (interfacedata.typeJson.type[0]) { case 'boolean': return ; diff --git a/cockpit/IPC/src/Components/Tinker/NumberTinker.tsx b/cockpit/IPC/src/Components/Tinker/NumberTinker.tsx index c4d904776f..77602b23e0 100644 --- a/cockpit/IPC/src/Components/Tinker/NumberTinker.tsx +++ b/cockpit/IPC/src/Components/Tinker/NumberTinker.tsx @@ -1,5 +1,5 @@ /* eslint-disable react/function-component-definition */ -import React, { useCallback, useMemo, useState } from 'react'; +import React, { useCallback, useState } from 'react'; import { TFC_DBUS_DOMAIN, TFC_DBUS_ORGANIZATION } from 'src/variables'; import { AlertVariant, TextInput } from '@patternfly/react-core'; import { useAlertContext } from '../Alert/AlertContext'; @@ -12,26 +12,13 @@ interface NumberTinkerIface { const NumberTinker: React.FC = ({ interfaceData, isChecked }) => { const [error, setError] = useState(undefined); const { addAlert } = useAlertContext(); - const [typeJson, setTypeJson] = useState<{ type: string[], minimum: number | null, maximum: number | null }>(); - function getType(): void { - const proxy = window.cockpit.dbus(interfaceData.process) - .proxy(interfaceData.interfaceName, `/${TFC_DBUS_DOMAIN}/${TFC_DBUS_ORGANIZATION}/Slots`); - proxy.wait().then(() => { - try { - setTypeJson(JSON.parse(proxy.data.Type)); - } catch (e) { - setTypeJson({ type: ['integer'], minimum: null, maximum: null }); - } - }); - } + const { typeJson } = interfaceData; + const slotPath = `/${TFC_DBUS_DOMAIN}/${TFC_DBUS_ORGANIZATION}/Slots`; const signalPath = `/${TFC_DBUS_DOMAIN}/${TFC_DBUS_ORGANIZATION}/Signals`; - useMemo(() => { - getType(); - }, [interfaceData]); - const handleInputChange = (value: string) => { + console.log(typeJson); if (!typeJson) { return { value: undefined, error: 'Unknown type' }; } diff --git a/cockpit/IPC/src/views/IODebug.tsx b/cockpit/IPC/src/views/IODebug.tsx index 633f955c7d..11d5c7d4f4 100644 --- a/cockpit/IPC/src/views/IODebug.tsx +++ b/cockpit/IPC/src/views/IODebug.tsx @@ -161,7 +161,7 @@ const IODebug: React.FC = ({ isDark }) => { data: proxy.data.Value, process, interfaceName: interfaceData.name, - type: JSON.parse(proxy.Type).type[0] ?? interfaceData.valueType, + typeJson: JSON.parse(proxy.Type) ?? interfaceData.valueType, direction, hidden: false, listener: false,