@localstack/appinspector-ui 1.0.25 → 1.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -2573,14 +2573,15 @@ var PillCell = ({
2573
2573
  // src/components/cells/service-cell.tsx
2574
2574
  var import_jsx_runtime125 = require("react/jsx-runtime");
2575
2575
  var ServiceCell = ({
2576
- borderColor,
2577
- borderWidth,
2578
2576
  height = "24px",
2579
2577
  resource,
2578
+ selected,
2580
2579
  service,
2581
2580
  showIcon = true,
2582
2581
  width = "32px"
2583
2582
  }) => {
2583
+ const borderColor = selected ? "text.primary" : "background.dark";
2584
+ const borderWidth = selected ? "2px" : void 0;
2584
2585
  return /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(import_material4.Box, { sx: { width: "100%" }, children: /* @__PURE__ */ (0, import_jsx_runtime125.jsxs)(PillCell, { borderColor, borderWidth, height, children: [
2585
2586
  showIcon ? /* @__PURE__ */ (0, import_jsx_runtime125.jsxs)(import_jsx_runtime125.Fragment, { children: [
2586
2587
  /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
@@ -4440,7 +4441,7 @@ var EventDetails = ({ onClose, selectedEvent }) => {
4440
4441
  /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(import_material16.Divider, {}),
4441
4442
  /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(ToggleSection, { headline: "Attributes", children: /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(import_material16.Stack, { spacing: 1, children: attributes.map(([key, value]) => /* @__PURE__ */ (0, import_jsx_runtime138.jsxs)(import_material16.Box, { children: [
4442
4443
  /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(import_material16.Typography, { sx: { fontWeight: 600 }, variant: "caption", children: key }),
4443
- /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(import_material16.Typography, { variant: "body2", children: renderKeyValue(key, value) })
4444
+ renderKeyValue(key, value)
4444
4445
  ] }, key)) }) })
4445
4446
  ] })
4446
4447
  ] }) })
@@ -4526,25 +4527,12 @@ var handleStyle = {
4526
4527
  borderColor: "lightgray",
4527
4528
  opacity: 0
4528
4529
  };
4529
- var ServiceNode = (0, import_react16.memo)(function ServiceNode2({ data, selected }) {
4530
- const handleClick = (0, import_react16.useCallback)(() => {
4531
- data.onEventSelect(data.event);
4532
- }, [data]);
4533
- const handleKeyPress = (0, import_react16.useCallback)(
4534
- (event) => {
4535
- if (event.key === "Enter" || event.key === " ") {
4536
- handleClick();
4537
- }
4538
- },
4539
- [handleClick]
4540
- );
4530
+ var ServiceNode = (0, import_react16.memo)(({ data, selected }) => {
4541
4531
  const hasErrors = (data.event.errors && data.event.errors.length > 0) ?? false;
4542
4532
  return /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)(import_material18.Box, { sx: { maxWidth: 200 }, children: [
4543
4533
  /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)(
4544
4534
  import_material18.Box,
4545
4535
  {
4546
- onClick: handleClick,
4547
- onKeyDown: handleKeyPress,
4548
4536
  role: "button",
4549
4537
  sx: {
4550
4538
  "&:hover": {
@@ -4568,10 +4556,9 @@ var ServiceNode = (0, import_react16.memo)(function ServiceNode2({ data, selecte
4568
4556
  /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
4569
4557
  ServiceCell,
4570
4558
  {
4571
- borderColor: selected ? "text.primary" : void 0,
4572
- borderWidth: selected ? "1.5px" : void 0,
4573
4559
  height: "32px",
4574
4560
  resource: data.event.resource_name,
4561
+ selected,
4575
4562
  service: data.event.service_name,
4576
4563
  width: "32px"
4577
4564
  }
@@ -4626,7 +4613,7 @@ var ServiceNode = (0, import_react16.memo)(function ServiceNode2({ data, selecte
4626
4613
  // src/components/trace-graph/utils.ts
4627
4614
  var import_dagre = __toESM(require("@dagrejs/dagre"), 1);
4628
4615
  var import_react17 = require("@xyflow/react");
4629
- var generateNodesAndEdges = (event, onEventSelect, parentId) => {
4616
+ var generateNodesAndEdges = (event, parentId) => {
4630
4617
  const nodes = [];
4631
4618
  const edges = [];
4632
4619
  nodes.push({
@@ -4635,7 +4622,6 @@ var generateNodesAndEdges = (event, onEventSelect, parentId) => {
4635
4622
  event,
4636
4623
  height: 28,
4637
4624
  id: event.span_id,
4638
- onEventSelect,
4639
4625
  position: { x: 0, y: 0 },
4640
4626
  width: 28
4641
4627
  },
@@ -4666,7 +4652,10 @@ var generateNodesAndEdges = (event, onEventSelect, parentId) => {
4666
4652
  }
4667
4653
  if (event.children && event.children.length > 0) {
4668
4654
  for (const child of event.children) {
4669
- const { edges: childEdges, nodes: childNodes } = generateNodesAndEdges(child, onEventSelect, event.span_id);
4655
+ const { edges: childEdges, nodes: childNodes } = generateNodesAndEdges(
4656
+ child,
4657
+ event.span_id
4658
+ );
4670
4659
  nodes.push(...childNodes);
4671
4660
  edges.push(...childEdges);
4672
4661
  }
@@ -4688,14 +4677,14 @@ var getLayoutedNodesAndEdges = (inputNodes, inputEdges) => {
4688
4677
  import_dagre.default.layout(dagreGraph);
4689
4678
  const layoutedNodes = inputNodes.map((node) => {
4690
4679
  const nodeWithPosition = dagreGraph.node(node.id);
4691
- const newNode = {
4680
+ return {
4692
4681
  ...node,
4693
4682
  position: {
4694
4683
  x: nodeWithPosition.x - nodeWidth / 2,
4695
4684
  y: nodeWithPosition.y - nodeHeight / 2
4696
- }
4685
+ },
4686
+ selectable: true
4697
4687
  };
4698
- return newNode;
4699
4688
  });
4700
4689
  return { edges: inputEdges, nodes: layoutedNodes };
4701
4690
  };
@@ -4842,19 +4831,12 @@ var TraceGraph = ({
4842
4831
  const [edges, setEdges] = (0, import_react21.useState)([]);
4843
4832
  const [initialViewSet, setInitialViewSet] = (0, import_react21.useState)(false);
4844
4833
  const { fitView, setCenter } = (0, import_react20.useReactFlow)();
4845
- const store = (0, import_react20.useStoreApi)();
4846
- const updateSelectedNode = (0, import_react21.useCallback)(
4847
- (nodeId) => {
4848
- const { addSelectedNodes } = store.getState();
4849
- if (nodeId) {
4850
- const targetNode = nodes.find((node) => node.id === nodeId);
4851
- if (targetNode) {
4852
- addSelectedNodes([targetNode.id]);
4853
- }
4854
- }
4855
- },
4856
- [nodes, store]
4857
- );
4834
+ const updateSelectedNode = (0, import_react21.useCallback)((nodeId) => {
4835
+ const toSelect = new Set(nodeId ? [nodeId] : []);
4836
+ setNodes((previousNodes) => {
4837
+ return previousNodes.map((node) => ({ ...node, selected: toSelect.has(node.id) }));
4838
+ });
4839
+ }, []);
4858
4840
  (0, import_react21.useEffect)(() => {
4859
4841
  const spansMap = /* @__PURE__ */ new Map();
4860
4842
  const rootSpans = [];
@@ -4877,16 +4859,19 @@ var TraceGraph = ({
4877
4859
  let allNodes = [];
4878
4860
  let allEdges = [];
4879
4861
  for (const rootSpan of rootSpans) {
4880
- const { edges: newEdges, nodes: newNodes } = generateNodesAndEdges(rootSpan, (event) => {
4881
- onEventSelect(event);
4882
- });
4862
+ const { edges: newEdges, nodes: newNodes } = generateNodesAndEdges(rootSpan);
4883
4863
  allNodes = [...allNodes, ...newNodes];
4884
4864
  allEdges = [...allEdges, ...newEdges];
4885
4865
  }
4886
4866
  const { edges: layoutedEdges, nodes: layoutedNodes } = getLayoutedNodesAndEdges(allNodes, allEdges);
4867
+ for (const node of layoutedNodes) {
4868
+ if (node.id === initialFocusEventId) {
4869
+ node.selected = true;
4870
+ }
4871
+ }
4887
4872
  setNodes(layoutedNodes);
4888
4873
  setEdges(layoutedEdges);
4889
- }, [onEventSelect, spans.data]);
4874
+ }, [spans.data, initialFocusEventId]);
4890
4875
  (0, import_react21.useEffect)(() => {
4891
4876
  const shouldSetInitialView = !spans.loading && nodes.length > 0 && !initialViewSet;
4892
4877
  if (shouldSetInitialView) {