Skip to content

Commit 99bfb2d

Browse files
committed
release(ui): cut @srl-labs/clab-ui v0.0.19
1 parent 11e6937 commit 99bfb2d

File tree

9 files changed

+299
-184
lines changed

9 files changed

+299
-184
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@srl-labs/clab-ui",
3-
"version": "0.0.18",
3+
"version": "0.0.19",
44
"private": false,
55
"description": "Shared UI package for containerlab webviews and topology editing.",
66
"license": "Apache-2.0",

src/components/panels/context-panel/views/LinkInfoView.tsx

Lines changed: 42 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -45,42 +45,55 @@ function toEndpointTab(id: string): EndpointTab {
4545
return id === "b" ? "b" : "a";
4646
}
4747

48+
function buildFallbackEndpoint(options: {
49+
node: string;
50+
endpoint?: string;
51+
mac?: string;
52+
mtu?: string | number;
53+
type?: string;
54+
stats?: InterfaceStatsPayload;
55+
}): EndpointData {
56+
return {
57+
node: options.node,
58+
interface: options.endpoint ?? "",
59+
mac: options.mac ?? "",
60+
mtu: options.mtu ?? "",
61+
type: options.type ?? "",
62+
stats: options.stats
63+
};
64+
}
65+
66+
function mergeEndpointData(fallback: EndpointData, override?: EndpointData): EndpointData {
67+
return {
68+
...fallback,
69+
...(override ?? {}),
70+
stats: override?.stats ?? fallback.stats
71+
};
72+
}
73+
4874
function getEndpoints(linkData: LinkInfoData): { a: EndpointData; b: EndpointData } {
4975
const extraData = linkData.extraData ?? {};
50-
const sourceMac = getString(extraData.clabSourceMacAddress) ?? "";
51-
const sourceType = getString(extraData.clabSourceType) ?? "";
52-
const targetMac = getString(extraData.clabTargetMacAddress) ?? "";
53-
const targetType = getString(extraData.clabTargetType) ?? "";
54-
55-
const fallbackA: EndpointData = {
76+
const fallbackA = buildFallbackEndpoint({
5677
node: linkData.source,
57-
interface: linkData.sourceEndpoint ?? "",
58-
mac: sourceMac,
59-
mtu: extraData.clabSourceMtu ?? "",
60-
type: sourceType,
78+
endpoint: linkData.sourceEndpoint,
79+
mac: getString(extraData.clabSourceMacAddress) ?? "",
80+
mtu: extraData.clabSourceMtu,
81+
type: getString(extraData.clabSourceType) ?? "",
6182
stats: extraData.clabSourceStats
62-
};
63-
const a: EndpointData = {
64-
...fallbackA,
65-
...(linkData.endpointA ?? {}),
66-
stats: linkData.endpointA?.stats ?? fallbackA.stats
67-
};
68-
69-
const fallbackB: EndpointData = {
83+
});
84+
const fallbackB = buildFallbackEndpoint({
7085
node: linkData.target,
71-
interface: linkData.targetEndpoint ?? "",
72-
mac: targetMac,
73-
mtu: extraData.clabTargetMtu ?? "",
74-
type: targetType,
86+
endpoint: linkData.targetEndpoint,
87+
mac: getString(extraData.clabTargetMacAddress) ?? "",
88+
mtu: extraData.clabTargetMtu,
89+
type: getString(extraData.clabTargetType) ?? "",
7590
stats: extraData.clabTargetStats
76-
};
77-
const b: EndpointData = {
78-
...fallbackB,
79-
...(linkData.endpointB ?? {}),
80-
stats: linkData.endpointB?.stats ?? fallbackB.stats
81-
};
91+
});
8292

83-
return { a, b };
93+
return {
94+
a: mergeEndpointData(fallbackA, linkData.endpointA),
95+
b: mergeEndpointData(fallbackB, linkData.endpointB)
96+
};
8497
}
8598

8699
export const LinkInfoView: React.FC<LinkInfoViewProps> = ({ linkData }) => {

src/hooks/app/useTopoViewerMessageSubscription.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,18 @@ function handlePanelAction(
6060
switch (action) {
6161
case "edit-node":
6262
if (nodeId !== undefined) editNode(nodeId);
63-
return;
63+
break;
6464
case "edit-link":
6565
if (edgeId !== undefined) editEdge(edgeId);
66-
return;
66+
break;
6767
case "node-info":
6868
if (nodeId !== undefined) selectNode(nodeId);
69-
return;
69+
break;
7070
case "link-info":
7171
if (edgeId !== undefined) selectEdge(edgeId);
72-
return;
72+
break;
73+
default:
74+
break;
7375
}
7476
}
7577

@@ -136,30 +138,30 @@ export function useTopoViewerMessageSubscription(): void {
136138
switch (event.type) {
137139
case "modeChanged":
138140
handleTopoModeChanged(event);
139-
return;
141+
break;
140142
case "panelAction":
141143
handlePanelAction(event);
142-
return;
144+
break;
143145
case "customNodesUpdated":
144146
handleCustomNodesUpdated(event);
145-
return;
147+
break;
146148
case "customNodeError":
147149
handleCustomNodeError(event);
148-
return;
150+
break;
149151
case "iconList":
150152
handleIconList(event);
151-
return;
153+
break;
152154
case "lifecycleLog":
153155
handleLifecycleLog(event);
154-
return;
156+
break;
155157
case "lifecycleStatus":
156158
handleLifecycleStatus(event);
157-
return;
159+
break;
158160
case "fitViewport":
159161
handleFitViewport();
160-
return;
162+
break;
161163
case "svgExportResult":
162-
return;
164+
break;
163165
}
164166
});
165167
}, [host]);

src/hooks/canvas/useAnnotations.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ import {
99
useGraphStore,
1010
useIsLocked
1111
} from "../../stores";
12-
import { collectNodeGroupMemberships } from "../../annotations/groupMembership";
13-
import { TRAFFIC_RATE_NODE_TYPE } from "../../annotations/annotationNodeConverters";
12+
import { collectNodeGroupMemberships, TRAFFIC_RATE_NODE_TYPE } from "../../annotations";
1413
import type { GroupStyleAnnotation } from "../../core/types/topology";
1514

1615
import type { AnnotationContextValue } from "./annotationTypes";

src/host/controllers.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,16 +281,16 @@ export function createExplorerController(options: ExplorerControllerOptions): Ex
281281
switch (message.command) {
282282
case "ready":
283283
this.connect();
284-
return;
284+
break;
285285
case "setFilter":
286286
await this.setFilter(message.value);
287-
return;
287+
break;
288288
case "invokeAction":
289289
await this.invokeAction(message.actionRef);
290-
return;
290+
break;
291291
case "persistUiState":
292292
await this.persistUiState(message.state);
293-
return;
293+
break;
294294
}
295295
},
296296

0 commit comments

Comments
 (0)