diff --git a/plugins/lime-plugin-mesh-wide/src/components/FeatureDetail/LinkDetail.tsx b/plugins/lime-plugin-mesh-wide/src/components/FeatureDetail/LinkDetail.tsx index 12dc4351..07104a69 100644 --- a/plugins/lime-plugin-mesh-wide/src/components/FeatureDetail/LinkDetail.tsx +++ b/plugins/lime-plugin-mesh-wide/src/components/FeatureDetail/LinkDetail.tsx @@ -15,7 +15,10 @@ import { } from "plugins/lime-plugin-mesh-wide/src/hooks/useLocatedLinks"; import { useNodes } from "plugins/lime-plugin-mesh-wide/src/hooks/useNodes"; import { MacToMacLink } from "plugins/lime-plugin-mesh-wide/src/lib/links/PointToPointLink"; -import { readableBytes } from "plugins/lime-plugin-mesh-wide/src/lib/utils"; +import { + dataTypeNameMapping, + readableBytes, +} from "plugins/lime-plugin-mesh-wide/src/lib/utils"; import { useSetLinkReferenceState } from "plugins/lime-plugin-mesh-wide/src/meshWideQueries"; import { BaseMacToMacLink, @@ -315,13 +318,13 @@ export const LinkReferenceStatus = ({ reference }: LinkMapFeature) => { let btnText = ( Set reference state for this -
{reference.type} link +
{dataTypeNameMapping(reference.type)}
); if (isDown) { btnText = ( - Delete this {reference.type} link + Delete this {dataTypeNameMapping(reference.type)}
from reference state
diff --git a/plugins/lime-plugin-mesh-wide/src/components/FeatureDetail/ShowErrorsDetail.tsx b/plugins/lime-plugin-mesh-wide/src/components/FeatureDetail/ShowErrorsDetail.tsx index da852ce5..6aa64d32 100644 --- a/plugins/lime-plugin-mesh-wide/src/components/FeatureDetail/ShowErrorsDetail.tsx +++ b/plugins/lime-plugin-mesh-wide/src/components/FeatureDetail/ShowErrorsDetail.tsx @@ -1,6 +1,9 @@ import { Trans } from "@lingui/macro"; +import { SharedStateDataTypeKeys } from "components/shared-state/SharedStateTypes"; + import { Row } from "plugins/lime-plugin-mesh-wide/src/components/FeatureDetail/index"; +import { dataTypeNameMapping } from "plugins/lime-plugin-mesh-wide/src/lib/utils"; import { ErrorsDetails } from "plugins/lime-plugin-mesh-wide/src/meshWideTypes"; export const ShowErrorsDetail = ({ errors }: { errors: ErrorsDetails }) => { @@ -45,7 +48,7 @@ export const ShowErrorsDetail = ({ errors }: { errors: ErrorsDetails }) => { return (
- {dataType} + {dataTypeNameMapping(dataType)}
{nodes && ( @@ -71,12 +74,19 @@ export const ShowErrorsDetail = ({ errors }: { errors: ErrorsDetails }) => { Are they installed or properly initialized? - {[...errors.meshWideDataErrors].map((data, k) => ( -
- {JSON.stringify(data.queryKey, null, 2)}:{" "} - {data?.error?.toString()} -
- ))} + {[...errors.meshWideDataErrors].map((data, k) => { + const queryKey = JSON.stringify( + data.queryKey, + null, + 2 + ) as SharedStateDataTypeKeys; + return ( +
+ {dataTypeNameMapping(queryKey)}:{" "} + {data?.error?.toString()} +
+ ); + })}
)} diff --git a/plugins/lime-plugin-mesh-wide/src/components/configPage/modals.tsx b/plugins/lime-plugin-mesh-wide/src/components/configPage/modals.tsx index a0405aad..a0c1beb1 100644 --- a/plugins/lime-plugin-mesh-wide/src/components/configPage/modals.tsx +++ b/plugins/lime-plugin-mesh-wide/src/components/configPage/modals.tsx @@ -6,6 +6,7 @@ import { useForm } from "react-hook-form"; import { ModalActions, useModal } from "components/Modal/Modal"; import InputField from "components/inputs/InputField"; +import { dataTypeNameMapping } from "plugins/lime-plugin-mesh-wide/src/lib/utils"; import { MeshWideMapDataTypeKeys } from "plugins/lime-plugin-mesh-wide/src/meshWideTypes"; const useActionModal = ( @@ -126,14 +127,19 @@ export const useSetLinkReferenceStateModal = () => { cb: () => Promise ) => { let title = ( - Set reference state for this {dataType} link? + + Set reference state for this {dataTypeNameMapping(dataType)}? + ); let content = ( This will set the reference state of this link: ); if (isDown) { title = ( - Remove this {dataType} from the reference state + + Remove this {dataTypeNameMapping(dataType)} from the + reference state + ); content = ( diff --git a/plugins/lime-plugin-mesh-wide/src/lib/utils.ts b/plugins/lime-plugin-mesh-wide/src/lib/utils.ts index b6d37988..030a6a2e 100644 --- a/plugins/lime-plugin-mesh-wide/src/lib/utils.ts +++ b/plugins/lime-plugin-mesh-wide/src/lib/utils.ts @@ -1,6 +1,8 @@ -import { INodes } from "plugins/lime-plugin-mesh-wide/src/meshWideTypes"; +import { t } from "@lingui/macro"; + +import { SharedStateDataTypeKeys } from "components/shared-state/SharedStateTypes"; -import { isEmpty } from "utils/utils"; +import { INodes } from "plugins/lime-plugin-mesh-wide/src/meshWideTypes"; export const readableBytes = (bytes: number) => { const sizes = ["B", "KB", "MB", "GB", "TB"]; @@ -65,3 +67,22 @@ export const splitNodesByLocated = (nodeList: INodes): ISplitNodesByLocated => { return { locatedNodes, nonLocatedNodes }; }; + +export const dataTypeNameMapping = (dataType: SharedStateDataTypeKeys) => { + switch (dataType) { + case "node_info": + return t`Node Info`; + case "node_info_ref": + return t`Node Info Reference`; + case "wifi_links_info": + return t`Wifi Links`; + case "wifi_links_info_ref": + return t`Wifi Links Reference`; + case "bat_links_info": + return t`Batman Links`; + case "bat_links_info_ref": + return t`Batman Links Reference`; + default: + return dataType; + } +};