@planningcenter/topbar 12.8.1 → 12.8.2-rc.0

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/topbar.js CHANGED
@@ -1949,6 +1949,44 @@ const AppsMenu = ({
1949
1949
  }))))))));
1950
1950
  };
1951
1951
 
1952
+ // Every app that renders topbar runs its own Sentry, which reports what
1953
+ // reaches `window.reportError`, so topbar's errors land in that app's project.
1954
+ // Whether they should go to a topbar-owned project instead is still open
1955
+ // (CHAT-1808); only this function would change.
1956
+ function reportTopbarError(error) {
1957
+ window.reportError(error);
1958
+ }
1959
+
1960
+ class ErrorBoundary extends React.Component {
1961
+ constructor() {
1962
+ super(...arguments);
1963
+ this.state = {
1964
+ hasError: false
1965
+ };
1966
+ }
1967
+ static getDerivedStateFromError() {
1968
+ return {
1969
+ hasError: true
1970
+ };
1971
+ }
1972
+ componentDidCatch(error) {
1973
+ reportTopbarError(error);
1974
+ }
1975
+ render() {
1976
+ var _a;
1977
+ return this.state.hasError ? (_a = this.props.fallback) !== null && _a !== void 0 ? _a : null : this.props.children;
1978
+ }
1979
+ }
1980
+ function withErrorBoundary(Component, fallback) {
1981
+ return function Guarded(props) {
1982
+ return /*#__PURE__*/React.createElement(ErrorBoundary, {
1983
+ fallback: fallback
1984
+ }, /*#__PURE__*/React.createElement(Component, {
1985
+ ...props
1986
+ }));
1987
+ };
1988
+ }
1989
+
1952
1990
  const FEATURE_FLAGS = {
1953
1991
  CHURCH_CENTER_PRODUCT: "ROLLOUT_church_center_product",
1954
1992
  PRODUCT_SEARCH: "product_search"
@@ -6222,6 +6260,13 @@ function StyledRoot({
6222
6260
  }
6223
6261
  `), children);
6224
6262
  }
6263
+ function TopbarPlaceholder() {
6264
+ return /*#__PURE__*/React.createElement("div", {
6265
+ style: {
6266
+ height: "var(--topbar-height)"
6267
+ }
6268
+ });
6269
+ }
6225
6270
 
6226
6271
  var styles$b = {"route":"route--8BWe","is-active":"is-active-FsU9Y","apps-routes-separator":"apps-routes-separator-Nlm-N"};
6227
6272
 
@@ -6491,7 +6536,7 @@ const UserMenuTrigger = ({
6491
6536
  }, orgName)), /*#__PURE__*/React.createElement(DisclosureChevronIcon, null)));
6492
6537
  };
6493
6538
 
6494
- const NotSmallTopbar = ({
6539
+ const UnguardedNotSmallTopbar = ({
6495
6540
  notifications = () => null,
6496
6541
  search = () => null,
6497
6542
  showOrgName = true,
@@ -6588,6 +6633,7 @@ const NotSmallRoute = ({
6588
6633
  ...nativeProps
6589
6634
  });
6590
6635
  };
6636
+ const NotSmallTopbar = withErrorBoundary(UnguardedNotSmallTopbar, /*#__PURE__*/React.createElement(TopbarPlaceholder, null));
6591
6637
 
6592
6638
  var styles$8 = {"avatar":"avatar-tW-wn"};
6593
6639
 
@@ -6781,7 +6827,7 @@ const AppsSwitcher = ({
6781
6827
 
6782
6828
  var styles$6 = {"current-route":"current-route-wpJgz","actions":"actions-INQ7-","is-active":"is-active-wy8Bg","routes":"routes-Nmt1S","route":"route-kkknQ","profile-button":"profile-button-a2WO2"};
6783
6829
 
6784
- const SmallTopbar = ({
6830
+ const UnguardedSmallTopbar = ({
6785
6831
  currentRouteComponent = props => (/*#__PURE__*/React.createElement("span", {
6786
6832
  ...props
6787
6833
  })),
@@ -6870,6 +6916,7 @@ const SmallRoute = ({
6870
6916
  className: classnames(styles$6["route"], className, active && styles$6["is-active"]),
6871
6917
  ...props
6872
6918
  }));
6919
+ const SmallTopbar = withErrorBoundary(UnguardedSmallTopbar, /*#__PURE__*/React.createElement(TopbarPlaceholder, null));
6873
6920
 
6874
6921
  function getLoginProfilePath({
6875
6922
  env,
@@ -10136,7 +10183,7 @@ const toolsRouteMap = Object.fromEntries(Object.entries(TOOLS_MAP).map(([k, v])
10136
10183
  function toolIsRoutable(tool) {
10137
10184
  return tool.name.toLowerCase() in toolsRouteMap;
10138
10185
  }
10139
- function Toolbar({
10186
+ function UnguardedToolbar({
10140
10187
  appName,
10141
10188
  autoMountTool,
10142
10189
  env,
@@ -10580,6 +10627,9 @@ function getDataPendoAttribute(toolName) {
10580
10627
  return `toolbar-${toolName.toLowerCase()}`;
10581
10628
  }
10582
10629
  }
10630
+ const Toolbar = withErrorBoundary(UnguardedToolbar, /*#__PURE__*/React.createElement("div", {
10631
+ className: styles$2["toolbar"]
10632
+ }));
10583
10633
 
10584
10634
  exports.AccessibilityToolbar = AccessibilityToolbar;
10585
10635
  exports.AppsProvider = AppsProvider;