@localstack/appinspector-ui 1.0.112 → 1.0.114

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
@@ -2421,6 +2421,13 @@ var import_material23 = require("@mui/material");
2421
2421
  var import_react69 = require("react");
2422
2422
 
2423
2423
  // src/api/errors.ts
2424
+ var AppInspectorDisabledError = class extends Error {
2425
+ constructor(message, cause) {
2426
+ super(message);
2427
+ this.name = "AppInspectorDisabledError";
2428
+ this.cause = cause;
2429
+ }
2430
+ };
2424
2431
  var AppInspectorNotFoundError = class extends Error {
2425
2432
  localstackVersion;
2426
2433
  constructor(message, cause, localstackVersion) {
@@ -15012,7 +15019,7 @@ var LoadSpansRow = ({ colSpan, fetching, label, onFetch }) => /* @__PURE__ */ (0
15012
15019
  fetching && /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(import_material6.CircularProgress, { size: 24, sx: { m: 2 } })
15013
15020
  ] }) });
15014
15021
  var SpansDataGridRow = (0, import_react42.memo)(
15015
- ({ row }) => {
15022
+ ({ onSpanClick, row }) => {
15016
15023
  const theme = (0, import_material6.useTheme)();
15017
15024
  return /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(
15018
15025
  import_material6.TableRow,
@@ -15025,7 +15032,11 @@ var SpansDataGridRow = (0, import_react42.memo)(
15025
15032
  initial: {
15026
15033
  backgroundColor: theme.palette.mode === "light" ? newSpanBackgroundColor.light.from : newSpanBackgroundColor.dark.from
15027
15034
  },
15035
+ onClick: () => {
15036
+ onSpanClick(row.original);
15037
+ },
15028
15038
  sx: {
15039
+ cursor: "pointer",
15029
15040
  transition: "background-color 1200ms ease-in"
15030
15041
  },
15031
15042
  children: row.getVisibleCells().map((cell) => {
@@ -15142,7 +15153,8 @@ var SpansDataGrid = ({
15142
15153
  import_material6.Button,
15143
15154
  {
15144
15155
  "data-testid": VIEW_SPAN_DETAILS_TEST_ID,
15145
- onClick: () => {
15156
+ onClick: (event) => {
15157
+ event.stopPropagation();
15146
15158
  onSpanClick(props.row.original);
15147
15159
  },
15148
15160
  size: "small",
@@ -15303,7 +15315,7 @@ var SpansDataGrid = ({
15303
15315
  for (let index = rows.length - 1; index >= 0; index--) {
15304
15316
  const row = rows.at(index);
15305
15317
  reversed.push(
15306
- /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(SpansDataGridRow, { row }, row.original.span_id)
15318
+ /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(SpansDataGridRow, { onSpanClick, row }, row.original.span_id)
15307
15319
  );
15308
15320
  }
15309
15321
  return reversed;
@@ -15314,7 +15326,7 @@ var SpansDataGrid = ({
15314
15326
  !clearingSpans && order2 === "oldest_first" && /* @__PURE__ */ (0, import_jsx_runtime127.jsxs)(import_jsx_runtime127.Fragment, { children: [
15315
15327
  hasRows && !hasMoreBackward && /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(StreamBoundaryRow, { colSpan: columnCount, label: LABEL_BEGINNING_OF_STREAM }),
15316
15328
  hasRows && hasMoreBackward && /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(LoadSpansRow, { colSpan: columnCount, fetching: fetchingBackward, label: LABEL_LOAD_OLDER, onFetch: onFetchBackward }),
15317
- hasRows && /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(AnimatePresence, { initial: false, children: rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(SpansDataGridRow, { row }, row.original.span_id)) }),
15329
+ hasRows && /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(AnimatePresence, { initial: false, children: rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(SpansDataGridRow, { onSpanClick, row }, row.original.span_id)) }),
15318
15330
  hasRows && hasMoreForward && /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(LoadSpansRow, { colSpan: columnCount, fetching: fetchingForward, label: LABEL_LOAD_NEWER, onFetch: onFetchForward }),
15319
15331
  hasRows && !hasMoreForward && /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(StreamBoundaryRow, { colSpan: columnCount, label: LABEL_END_OF_STREAM })
15320
15332
  ] })
@@ -15510,7 +15522,7 @@ var StatusMessage = ({
15510
15522
  }
15511
15523
  );
15512
15524
  }
15513
- if (status?.status === "DISABLED") {
15525
+ if (error instanceof AppInspectorDisabledError || status?.status === "DISABLED") {
15514
15526
  return /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
15515
15527
  import_material8.Box,
15516
15528
  {
@@ -15666,9 +15678,12 @@ var import_jsx_runtime130 = require("react/jsx-runtime");
15666
15678
  var AppInspectorStatusContext = (0, import_react45.createContext)(void 0);
15667
15679
  var StatusProvider = ({ children }) => {
15668
15680
  const { checking, checkStatus, error, status } = useStatus();
15681
+ const reportDisabled = (0, import_react45.useCallback)(() => {
15682
+ void checkStatus();
15683
+ }, [checkStatus]);
15669
15684
  const value = (0, import_react45.useMemo)(
15670
- () => ({ checking, checkStatus, status, statusError: error }),
15671
- [checking, checkStatus, status, error]
15685
+ () => ({ checking, checkStatus, reportDisabled, status, statusError: error }),
15686
+ [checking, checkStatus, reportDisabled, status, error]
15672
15687
  );
15673
15688
  return /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(AppInspectorStatusContext.Provider, { value, children });
15674
15689
  };
@@ -16026,17 +16041,19 @@ var makeRequest = async (options) => {
16026
16041
  new Error(`404 from ${url}: ${response.statusText}`)
16027
16042
  );
16028
16043
  }
16044
+ if (response.status === 503) {
16045
+ throw new AppInspectorDisabledError(
16046
+ ERROR_MESSAGES.APP_INSPECTOR_DISABLED,
16047
+ new Error(`503 from ${url}: ${response.statusText}`)
16048
+ );
16049
+ }
16029
16050
  throw new Error(`API request failed: ${response.status.toString()} ${response.statusText}`);
16030
16051
  }
16031
16052
  options.captureHeaders?.(response.headers);
16032
16053
  return await response.json();
16033
16054
  } catch (error) {
16034
16055
  if (error instanceof TypeError) {
16035
- const message = error.message.toLowerCase();
16036
- const isNetworkError = message.includes("fetch") || message.includes("network") || message.includes("failed to fetch");
16037
- if (isNetworkError) {
16038
- throw new ConnectionError(ERROR_MESSAGES.CONNECTION_FAILED, error);
16039
- }
16056
+ throw new ConnectionError(ERROR_MESSAGES.CONNECTION_FAILED, error);
16040
16057
  }
16041
16058
  if (error instanceof Error) {
16042
16059
  throw error;
@@ -18283,6 +18300,7 @@ function useThrottledItems(items, getId, catchUpIncrement = 10) {
18283
18300
  var PAGE_SIZE = 30;
18284
18301
  var useSpans = () => {
18285
18302
  const api = useAppInspectorApi();
18303
+ const { reportDisabled } = useAppInspectorStatus();
18286
18304
  const [spans, setSpans] = (0, import_react52.useState)();
18287
18305
  const throttledSpans = useThrottledItems(spans, (span) => span.span_id);
18288
18306
  const [fetchError, setFetchError] = (0, import_react52.useState)();
@@ -18387,6 +18405,11 @@ var useSpans = () => {
18387
18405
  const clearFetchError = (0, import_react52.useCallback)(() => {
18388
18406
  setFetchError(void 0);
18389
18407
  }, []);
18408
+ (0, import_react52.useEffect)(() => {
18409
+ if (fetchError instanceof AppInspectorDisabledError || fetchError instanceof ConnectionError) {
18410
+ reportDisabled();
18411
+ }
18412
+ }, [fetchError, reportDisabled]);
18390
18413
  return {
18391
18414
  clearFetchError,
18392
18415
  clearingSpans,
@@ -31362,7 +31385,12 @@ var TraceGraphPage = ({ onClose, spanId, traceId }) => {
31362
31385
  spansReference.current = spans;
31363
31386
  }
31364
31387
  }, [spans, setSelectedEvent, spanId]);
31365
- const { checkStatus, status, statusError } = useAppInspectorStatus();
31388
+ const { checkStatus, reportDisabled, status, statusError } = useAppInspectorStatus();
31389
+ (0, import_react68.useEffect)(() => {
31390
+ if (fetchError instanceof AppInspectorDisabledError || fetchError instanceof ConnectionError) {
31391
+ reportDisabled();
31392
+ }
31393
+ }, [fetchError, reportDisabled]);
31366
31394
  const handleEnable = (0, import_react68.useCallback)(async () => {
31367
31395
  await api.setStatus({ status: "ENABLED" });
31368
31396
  void checkStatus();