Skip to content

Commit

Permalink
chore(rxPage): show no wired connections found error message
Browse files Browse the repository at this point in the history
  • Loading branch information
selankon committed Mar 25, 2024
1 parent 2675efc commit 3a54c5c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion plugins/lime-plugin-rx/src/rxApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ interface DeviceStatus {
address: string;
}

interface SwitchStatus {
export interface SwitchStatus {
device: string;
num: number;
role: string;
Expand Down
15 changes: 10 additions & 5 deletions plugins/lime-plugin-rx/src/sections/wired.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import {
SectionTitle,
} from "plugins/lime-plugin-rx/src/components/components";
import { PortsIcon } from "plugins/lime-plugin-rx/src/icons/portsIcon";
import { StatusResponse } from "plugins/lime-plugin-rx/src/rxApi";
import { SwitchStatus } from "plugins/lime-plugin-rx/src/rxApi";
import { useNodeStatus } from "plugins/lime-plugin-rx/src/rxQueries";

const Ports = ({ status }: { status: StatusResponse }) => {
const ports = status.switch_status.reduce((acc, obj) => {
const Ports = ({ switches }: { switches: SwitchStatus[] }) => {
const ports = switches.reduce((acc, obj) => {
const { role } = obj;
if (!acc[role]) {
acc[role] = [];
Expand All @@ -21,7 +21,6 @@ const Ports = ({ status }: { status: StatusResponse }) => {

return (
<div className={"flex flex-row px-10"} data-testid="ports-container">
{" "}
{Object.keys(ports).map((role) => {
if (
role.toLowerCase() === "wan" ||
Expand Down Expand Up @@ -58,6 +57,8 @@ const Ports = ({ status }: { status: StatusResponse }) => {
export const Wired = () => {
const { data: status, isLoading } = useNodeStatus();

const switches = status?.switch_status;

return (
<Section>
<SectionTitle icon={<PortsIcon className={IconsClassName} />}>
Expand All @@ -66,8 +67,12 @@ export const Wired = () => {
<div className={"mt-4"}>
{isLoading ? (
<span>Loading...</span>
) : switches.length ? (
<Ports switches={status.switch_status} />
) : (
<Ports status={status} />
<div className={"flex-1 flex justify-center"}>
No wired connections found
</div>
)}
</div>
</Section>
Expand Down

0 comments on commit 3a54c5c

Please sign in to comment.