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