@localstack/appinspector-ui 1.0.61 → 1.0.63

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
@@ -64,7 +64,7 @@ import { useCallback as useCallback9, useState as useState13 } from "react";
64
64
  import { Alert, Box as Box4, Button as Button2 } from "@mui/material";
65
65
 
66
66
  // src/components/spans-list/spans-data-grid.tsx
67
- import { DeleteForeverOutlined, SwapVertOutlined } from "@mui/icons-material";
67
+ import { DeleteForeverOutlined, PauseOutlined, PlayArrowOutlined, SwapVertOutlined } from "@mui/icons-material";
68
68
  import {
69
69
  Box as Box3,
70
70
  Button,
@@ -12142,8 +12142,8 @@ ServiceCell.displayName = "ServiceCell";
12142
12142
  import { Fragment as Fragment3, jsx as jsx124, jsxs as jsxs120 } from "react/jsx-runtime";
12143
12143
  var columnHelper = createColumnHelper();
12144
12144
  var newSpanBackgroundColor = {
12145
- dark: "#887b02",
12146
- light: "#ffde7b"
12145
+ dark: { from: "rgba(136, 123, 2, 1)", to: "rgba(136, 123, 2, 0)" },
12146
+ light: { from: "rgba(255, 222, 123, 1)", to: "rgba(255, 222, 123, 0)" }
12147
12147
  };
12148
12148
  var LABEL_BEGINNING_OF_STREAM = "This is the beginning of the stream";
12149
12149
  var LABEL_END_OF_STREAM = "This is the end of the stream";
@@ -12162,11 +12162,11 @@ var SpansDataGridRow = memo8(
12162
12162
  TableRow,
12163
12163
  {
12164
12164
  animate: {
12165
- backgroundColor: "transparent"
12165
+ backgroundColor: theme.palette.mode === "light" ? newSpanBackgroundColor.light.to : newSpanBackgroundColor.dark.to
12166
12166
  },
12167
12167
  component: motion.tr,
12168
12168
  initial: {
12169
- backgroundColor: theme.palette.mode === "light" ? newSpanBackgroundColor.light : newSpanBackgroundColor.dark
12169
+ backgroundColor: theme.palette.mode === "light" ? newSpanBackgroundColor.light.from : newSpanBackgroundColor.dark.from
12170
12170
  },
12171
12171
  sx: {
12172
12172
  transition: "background-color 1200ms ease-in"
@@ -12218,8 +12218,10 @@ var SpansDataGrid = ({
12218
12218
  onFetchForward,
12219
12219
  onOrderChange,
12220
12220
  onSpanClick,
12221
+ onToggleStream,
12221
12222
  order: order2,
12222
- spans
12223
+ spans,
12224
+ streamPaused
12223
12225
  }) => {
12224
12226
  const columns = useMemo5(() => [
12225
12227
  columnHelper.accessor("trace_id", {
@@ -12308,6 +12310,21 @@ var SpansDataGrid = ({
12308
12310
  return /* @__PURE__ */ jsxs120(Fragment3, { children: [
12309
12311
  /* @__PURE__ */ jsx124(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsxs120(Box3, { sx: { alignItems: "center", display: "flex", gap: "0.5rem" }, children: [
12310
12312
  /* @__PURE__ */ jsx124(Box3, { sx: { flexGrow: 1 } }),
12313
+ /* @__PURE__ */ jsx124(
12314
+ FormControlLabel,
12315
+ {
12316
+ control: /* @__PURE__ */ jsx124(
12317
+ Button,
12318
+ {
12319
+ onClick: onToggleStream,
12320
+ startIcon: streamPaused ? /* @__PURE__ */ jsx124(PlayArrowOutlined, {}) : /* @__PURE__ */ jsx124(PauseOutlined, {}),
12321
+ variant: "text",
12322
+ children: streamPaused ? "Resume Stream" : "Pause Stream"
12323
+ }
12324
+ ),
12325
+ label: ""
12326
+ }
12327
+ ),
12311
12328
  /* @__PURE__ */ jsx124(
12312
12329
  FormControlLabel,
12313
12330
  {
@@ -12444,9 +12461,10 @@ var SpansList = (props) => {
12444
12461
  onFetchForward: props.onFetchForward,
12445
12462
  onOrderChange: props.onOrderChange,
12446
12463
  onSpanClick: props.onSpanClick,
12464
+ onToggleStream: props.onToggleStream,
12447
12465
  order: props.order,
12448
- refetching: props.refetching,
12449
- spans: props.spans
12466
+ spans: props.spans,
12467
+ streamPaused: props.streamPaused
12450
12468
  }
12451
12469
  )
12452
12470
  ] });
@@ -12896,7 +12914,6 @@ var createPaginationBuffer = (options) => {
12896
12914
  let hasMoreBackward = void 0;
12897
12915
  let fetchingForward = false;
12898
12916
  let fetchingBackward = false;
12899
- const refetching = false;
12900
12917
  const reportDataChange = () => {
12901
12918
  options.onDataChange({
12902
12919
  hasMoreBackward: hasMoreBackward ?? false,
@@ -12907,8 +12924,7 @@ var createPaginationBuffer = (options) => {
12907
12924
  const reportStatusChange = () => {
12908
12925
  options.onStatusChange?.({
12909
12926
  fetchingBackward,
12910
- fetchingForward,
12911
- refetching
12927
+ fetchingForward
12912
12928
  });
12913
12929
  };
12914
12930
  const reportError = (error) => {
@@ -12916,6 +12932,25 @@ var createPaginationBuffer = (options) => {
12916
12932
  };
12917
12933
  let fetchForwardLater = false;
12918
12934
  let fetchBackwardLater = false;
12935
+ let fetchForwardSilentlyLater = false;
12936
+ const checkIfThereAreMoreItemsForward = async () => {
12937
+ if (hasMoreForward === true) {
12938
+ return;
12939
+ }
12940
+ fetchingForward = true;
12941
+ reportStatusChange();
12942
+ try {
12943
+ const newPage = await fetchPage(nextForwardToken);
12944
+ hasMoreForward = newPage.items.length > 0;
12945
+ reportDataChange();
12946
+ } catch (error) {
12947
+ reportError(error instanceof Error ? error : new Error("Failed to fetch forward page", { cause: error }));
12948
+ } finally {
12949
+ fetchingForward = false;
12950
+ reportStatusChange();
12951
+ }
12952
+ runPostFetchActions();
12953
+ };
12919
12954
  const fetchForward = async () => {
12920
12955
  fetchingForward = true;
12921
12956
  reportStatusChange();
@@ -12979,8 +13014,19 @@ var createPaginationBuffer = (options) => {
12979
13014
  fetchForwardLater = false;
12980
13015
  void fetchForward();
12981
13016
  }
13017
+ if (fetchForwardSilentlyLater) {
13018
+ fetchForwardSilentlyLater = false;
13019
+ void checkIfThereAreMoreItemsForward();
13020
+ }
12982
13021
  };
12983
13022
  return {
13023
+ checkIfThereAreMoreItemsForward: () => {
13024
+ if (fetchingForward || fetchingBackward) {
13025
+ fetchForwardSilentlyLater = true;
13026
+ return;
13027
+ }
13028
+ void checkIfThereAreMoreItemsForward();
13029
+ },
12984
13030
  clear: () => {
12985
13031
  if (items !== void 0) {
12986
13032
  items.length = 0;
@@ -13296,7 +13342,6 @@ var useSpans = () => {
13296
13342
  const [fetchError, setFetchError] = useState7();
13297
13343
  const [fetchingForward, setFetchingForward] = useState7(false);
13298
13344
  const [fetchingBackward, setFetchingBackward] = useState7(false);
13299
- const [refetching, setRefetching] = useState7(false);
13300
13345
  const paginationBuffer = useRef10(createPaginationBuffer({
13301
13346
  async fetchPage(token) {
13302
13347
  const response = await api.getSpans({
@@ -13323,7 +13368,6 @@ var useSpans = () => {
13323
13368
  onStatusChange(status2) {
13324
13369
  setFetchingBackward(status2.fetchingBackward);
13325
13370
  setFetchingForward(status2.fetchingForward);
13326
- setRefetching(status2.refetching);
13327
13371
  },
13328
13372
  // The spans endpoint is sorted by span ingestion time, which might differ from
13329
13373
  // the span timestamp. In order to accomodate for this, we will sort the spans
@@ -13357,9 +13401,19 @@ var useSpans = () => {
13357
13401
  setClearingSpans(false);
13358
13402
  }
13359
13403
  }, [paginationBuffer, api]);
13404
+ const [streamPaused, setStreamPaused] = useState7(false);
13405
+ const toggleStream = useCallback7(() => {
13406
+ setStreamPaused((previous) => !previous);
13407
+ }, []);
13360
13408
  useSpansWebSocket({
13361
13409
  onMessage: () => {
13362
- paginationBuffer.current.fetchForward();
13410
+ if (!hasMoreForward) {
13411
+ if (streamPaused) {
13412
+ paginationBuffer.current.checkIfThereAreMoreItemsForward();
13413
+ } else {
13414
+ paginationBuffer.current.fetchForward();
13415
+ }
13416
+ }
13363
13417
  }
13364
13418
  });
13365
13419
  return {
@@ -13373,10 +13427,11 @@ var useSpans = () => {
13373
13427
  fetchingForward,
13374
13428
  hasMoreBackward,
13375
13429
  hasMoreForward,
13376
- refetching,
13377
13430
  spans,
13378
13431
  status,
13379
- statusError
13432
+ statusError,
13433
+ streamPaused,
13434
+ toggleStream
13380
13435
  };
13381
13436
  };
13382
13437
 
@@ -14898,10 +14953,11 @@ var SpansListPage = () => {
14898
14953
  fetchingForward,
14899
14954
  hasMoreBackward,
14900
14955
  hasMoreForward,
14901
- refetching,
14902
14956
  spans,
14903
14957
  status,
14904
- statusError
14958
+ statusError,
14959
+ streamPaused,
14960
+ toggleStream
14905
14961
  } = useSpans();
14906
14962
  const clearSpansSync = useCallback9(() => {
14907
14963
  void clearSpans();
@@ -14954,9 +15010,10 @@ var SpansListPage = () => {
14954
15010
  onFetchForward: fetchForward,
14955
15011
  onOrderChange: setOrder,
14956
15012
  onSpanClick: navigateToSpan,
15013
+ onToggleStream: toggleStream,
14957
15014
  order: order2,
14958
- refetching,
14959
- spans
15015
+ spans,
15016
+ streamPaused
14960
15017
  }
14961
15018
  )
14962
15019
  }