@localstack/appinspector-ui 1.0.25 → 1.0.26

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.js CHANGED
@@ -2536,14 +2536,15 @@ var PillCell = ({
2536
2536
  // src/components/cells/service-cell.tsx
2537
2537
  import { Fragment as Fragment2, jsx as jsx125, jsxs as jsxs119 } from "react/jsx-runtime";
2538
2538
  var ServiceCell = ({
2539
- borderColor,
2540
- borderWidth,
2541
2539
  height = "24px",
2542
2540
  resource,
2541
+ selected,
2543
2542
  service,
2544
2543
  showIcon = true,
2545
2544
  width = "32px"
2546
2545
  }) => {
2546
+ const borderColor = selected ? "text.primary" : "background.dark";
2547
+ const borderWidth = selected ? "2px" : void 0;
2547
2548
  return /* @__PURE__ */ jsx125(Box3, { sx: { width: "100%" }, children: /* @__PURE__ */ jsxs119(PillCell, { borderColor, borderWidth, height, children: [
2548
2549
  showIcon ? /* @__PURE__ */ jsxs119(Fragment2, { children: [
2549
2550
  /* @__PURE__ */ jsx125(
@@ -3606,7 +3607,7 @@ import { ArrowBack } from "@mui/icons-material";
3606
3607
  import { Box as Box19, Button as Button5, Drawer, Paper as Paper2 } from "@mui/material";
3607
3608
  import { styled } from "@mui/material/styles";
3608
3609
  import { ReactFlowProvider } from "@xyflow/react";
3609
- import { useCallback as useCallback8, useEffect as useEffect7, useState as useState10 } from "react";
3610
+ import { useCallback as useCallback7, useEffect as useEffect7, useState as useState10 } from "react";
3610
3611
  import { useNavigate as useNavigate2, useParams, useSearchParams } from "react-router-dom";
3611
3612
 
3612
3613
  // src/components/event-details/event-details.tsx
@@ -4422,14 +4423,14 @@ function renderKeyValue(key, value) {
4422
4423
  // src/components/trace-graph/trace-graph.tsx
4423
4424
  import "@xyflow/react/dist/base.css";
4424
4425
  import { Alert as Alert3, Button as Button4 } from "@mui/material";
4425
- import { Background, ReactFlow, useReactFlow as useReactFlow2, useStoreApi } from "@xyflow/react";
4426
- import { useCallback as useCallback7, useEffect as useEffect6, useState as useState9 } from "react";
4426
+ import { Background, ReactFlow, useReactFlow as useReactFlow2 } from "@xyflow/react";
4427
+ import { useCallback as useCallback6, useEffect as useEffect6, useState as useState9 } from "react";
4427
4428
 
4428
4429
  // src/components/trace-graph/service-node.tsx
4429
4430
  import { Box as Box17, Stack as Stack3, Typography as Typography10 } from "@mui/material";
4430
4431
  import "@xyflow/react/dist/style.css";
4431
4432
  import { Handle, Position } from "@xyflow/react";
4432
- import { memo as memo2, useCallback as useCallback6 } from "react";
4433
+ import { memo as memo2 } from "react";
4433
4434
 
4434
4435
  // src/components/trace-graph/problem-indicator.tsx
4435
4436
  import { Error as ErrorIcon2, Info as Info2, Warning as Warning2 } from "@mui/icons-material";
@@ -4489,25 +4490,12 @@ var handleStyle = {
4489
4490
  borderColor: "lightgray",
4490
4491
  opacity: 0
4491
4492
  };
4492
- var ServiceNode = memo2(function ServiceNode2({ data, selected }) {
4493
- const handleClick = useCallback6(() => {
4494
- data.onEventSelect(data.event);
4495
- }, [data]);
4496
- const handleKeyPress = useCallback6(
4497
- (event) => {
4498
- if (event.key === "Enter" || event.key === " ") {
4499
- handleClick();
4500
- }
4501
- },
4502
- [handleClick]
4503
- );
4493
+ var ServiceNode = memo2(({ data, selected }) => {
4504
4494
  const hasErrors = (data.event.errors && data.event.errors.length > 0) ?? false;
4505
4495
  return /* @__PURE__ */ jsxs130(Box17, { sx: { maxWidth: 200 }, children: [
4506
4496
  /* @__PURE__ */ jsxs130(
4507
4497
  Box17,
4508
4498
  {
4509
- onClick: handleClick,
4510
- onKeyDown: handleKeyPress,
4511
4499
  role: "button",
4512
4500
  sx: {
4513
4501
  "&:hover": {
@@ -4531,10 +4519,9 @@ var ServiceNode = memo2(function ServiceNode2({ data, selected }) {
4531
4519
  /* @__PURE__ */ jsx140(
4532
4520
  ServiceCell,
4533
4521
  {
4534
- borderColor: selected ? "text.primary" : void 0,
4535
- borderWidth: selected ? "1.5px" : void 0,
4536
4522
  height: "32px",
4537
4523
  resource: data.event.resource_name,
4524
+ selected,
4538
4525
  service: data.event.service_name,
4539
4526
  width: "32px"
4540
4527
  }
@@ -4589,7 +4576,7 @@ var ServiceNode = memo2(function ServiceNode2({ data, selected }) {
4589
4576
  // src/components/trace-graph/utils.ts
4590
4577
  import dagre from "@dagrejs/dagre";
4591
4578
  import { MarkerType, Position as Position2 } from "@xyflow/react";
4592
- var generateNodesAndEdges = (event, onEventSelect, parentId) => {
4579
+ var generateNodesAndEdges = (event, parentId) => {
4593
4580
  const nodes = [];
4594
4581
  const edges = [];
4595
4582
  nodes.push({
@@ -4598,7 +4585,6 @@ var generateNodesAndEdges = (event, onEventSelect, parentId) => {
4598
4585
  event,
4599
4586
  height: 28,
4600
4587
  id: event.span_id,
4601
- onEventSelect,
4602
4588
  position: { x: 0, y: 0 },
4603
4589
  width: 28
4604
4590
  },
@@ -4629,7 +4615,10 @@ var generateNodesAndEdges = (event, onEventSelect, parentId) => {
4629
4615
  }
4630
4616
  if (event.children && event.children.length > 0) {
4631
4617
  for (const child of event.children) {
4632
- const { edges: childEdges, nodes: childNodes } = generateNodesAndEdges(child, onEventSelect, event.span_id);
4618
+ const { edges: childEdges, nodes: childNodes } = generateNodesAndEdges(
4619
+ child,
4620
+ event.span_id
4621
+ );
4633
4622
  nodes.push(...childNodes);
4634
4623
  edges.push(...childEdges);
4635
4624
  }
@@ -4651,14 +4640,14 @@ var getLayoutedNodesAndEdges = (inputNodes, inputEdges) => {
4651
4640
  dagre.layout(dagreGraph);
4652
4641
  const layoutedNodes = inputNodes.map((node) => {
4653
4642
  const nodeWithPosition = dagreGraph.node(node.id);
4654
- const newNode = {
4643
+ return {
4655
4644
  ...node,
4656
4645
  position: {
4657
4646
  x: nodeWithPosition.x - nodeWidth / 2,
4658
4647
  y: nodeWithPosition.y - nodeHeight / 2
4659
- }
4648
+ },
4649
+ selectable: true
4660
4650
  };
4661
- return newNode;
4662
4651
  });
4663
4652
  return { edges: inputEdges, nodes: layoutedNodes };
4664
4653
  };
@@ -4805,19 +4794,12 @@ var TraceGraph = ({
4805
4794
  const [edges, setEdges] = useState9([]);
4806
4795
  const [initialViewSet, setInitialViewSet] = useState9(false);
4807
4796
  const { fitView, setCenter } = useReactFlow2();
4808
- const store = useStoreApi();
4809
- const updateSelectedNode = useCallback7(
4810
- (nodeId) => {
4811
- const { addSelectedNodes } = store.getState();
4812
- if (nodeId) {
4813
- const targetNode = nodes.find((node) => node.id === nodeId);
4814
- if (targetNode) {
4815
- addSelectedNodes([targetNode.id]);
4816
- }
4817
- }
4818
- },
4819
- [nodes, store]
4820
- );
4797
+ const updateSelectedNode = useCallback6((nodeId) => {
4798
+ const toSelect = new Set(nodeId ? [nodeId] : []);
4799
+ setNodes((previousNodes) => {
4800
+ return previousNodes.map((node) => ({ ...node, selected: toSelect.has(node.id) }));
4801
+ });
4802
+ }, []);
4821
4803
  useEffect6(() => {
4822
4804
  const spansMap = /* @__PURE__ */ new Map();
4823
4805
  const rootSpans = [];
@@ -4840,16 +4822,19 @@ var TraceGraph = ({
4840
4822
  let allNodes = [];
4841
4823
  let allEdges = [];
4842
4824
  for (const rootSpan of rootSpans) {
4843
- const { edges: newEdges, nodes: newNodes } = generateNodesAndEdges(rootSpan, (event) => {
4844
- onEventSelect(event);
4845
- });
4825
+ const { edges: newEdges, nodes: newNodes } = generateNodesAndEdges(rootSpan);
4846
4826
  allNodes = [...allNodes, ...newNodes];
4847
4827
  allEdges = [...allEdges, ...newEdges];
4848
4828
  }
4849
4829
  const { edges: layoutedEdges, nodes: layoutedNodes } = getLayoutedNodesAndEdges(allNodes, allEdges);
4830
+ for (const node of layoutedNodes) {
4831
+ if (node.id === initialFocusEventId) {
4832
+ node.selected = true;
4833
+ }
4834
+ }
4850
4835
  setNodes(layoutedNodes);
4851
4836
  setEdges(layoutedEdges);
4852
- }, [onEventSelect, spans.data]);
4837
+ }, [spans.data, initialFocusEventId]);
4853
4838
  useEffect6(() => {
4854
4839
  const shouldSetInitialView = !spans.loading && nodes.length > 0 && !initialViewSet;
4855
4840
  if (shouldSetInitialView) {
@@ -4875,7 +4860,7 @@ var TraceGraph = ({
4875
4860
  updateSelectedNode(initialFocusEventId);
4876
4861
  }
4877
4862
  }, [initialFocusEventId, updateSelectedNode]);
4878
- const onNodeClick = useCallback7((_event, node) => {
4863
+ const onNodeClick = useCallback6((_event, node) => {
4879
4864
  onEventSelect(node.data.event);
4880
4865
  updateSelectedNode(node.id);
4881
4866
  }, [onEventSelect, updateSelectedNode]);
@@ -5044,7 +5029,7 @@ var TraceGraphPage = () => {
5044
5029
  const [spans, setSpans] = useState10();
5045
5030
  const [loading, setLoading] = useState10(false);
5046
5031
  const [fetchError, setFetchError] = useState10();
5047
- const fetchSpans = useCallback8(async () => {
5032
+ const fetchSpans = useCallback7(async () => {
5048
5033
  setLoading(true);
5049
5034
  try {
5050
5035
  const response = await api.getSpans({
@@ -5066,7 +5051,7 @@ var TraceGraphPage = () => {
5066
5051
  const [selectedEvent, setSelectedEvent] = useState10();
5067
5052
  const [viewPortPixelWidth, setViewPortPixelWidth] = useState10(0);
5068
5053
  const { checkStatus, error: statusError, status } = useStatus();
5069
- const calculateDrawerWidth = useCallback8(() => {
5054
+ const calculateDrawerWidth = useCallback7(() => {
5070
5055
  const percentageMatch = /(\d+)%/.exec(DRAWER_WIDTH);
5071
5056
  if (percentageMatch && open) {
5072
5057
  const percentage = Number.parseInt(percentageMatch[1], 10);
@@ -5088,16 +5073,16 @@ var TraceGraphPage = () => {
5088
5073
  clearTimeout(timeoutId);
5089
5074
  };
5090
5075
  }, [open, calculateDrawerWidth]);
5091
- const handleEventSelect = useCallback8((event) => {
5076
+ const handleEventSelect = useCallback7((event) => {
5092
5077
  setSelectedEvent(event);
5093
5078
  setOpen(true);
5094
5079
  }, []);
5095
- const handleRetry = useCallback8(() => {
5080
+ const handleRetry = useCallback7(() => {
5096
5081
  void checkStatus();
5097
5082
  }, [checkStatus]);
5098
5083
  const navigate = useNavigate2();
5099
5084
  const { resolveLink } = useAppInspector();
5100
- const navigateToSpansList = useCallback8(() => {
5085
+ const navigateToSpansList = useCallback7(() => {
5101
5086
  const url = resolveLink({ to: "spans-list" });
5102
5087
  navigate(url);
5103
5088
  }, [navigate, resolveLink]);