@backstage/core-components 0.12.5 → 0.12.6-next.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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @backstage/core-components
2
2
 
3
+ ## 0.12.6-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 7908d72e033: Introduce a new global config parameter, `auth.enableExperimentalRedirectFlow`. When enabled, auth will happen with an in-window redirect flow rather than through a popup window.
8
+ - 8e00acb28db: Small tweaks to remove warnings in the console during development (mainly focusing on techdocs)
9
+ - 7245e744ab1: Fixed the font color on `BackstageHeaderLabel` to respect the active page theme.
10
+ - Updated dependencies
11
+ - @backstage/core-plugin-api@1.5.0
12
+ - @backstage/config@1.0.7
13
+ - @backstage/errors@1.1.5
14
+ - @backstage/theme@0.2.18
15
+ - @backstage/version-bridge@1.0.3
16
+
3
17
  ## 0.12.5
4
18
 
5
19
  ### Patch Changes
package/dist/index.esm.js CHANGED
@@ -7,7 +7,7 @@ import { Alert } from '@material-ui/lab';
7
7
  import pluralize from 'pluralize';
8
8
  import React, { useState, useEffect, useRef, useCallback, useLayoutEffect, lazy, Suspense, useMemo, Component as Component$3, Children, isValidElement, useContext, Fragment, createContext, forwardRef } from 'react';
9
9
  import MaterialAvatar from '@material-ui/core/Avatar';
10
- import { makeStyles, useTheme, darken, lighten, withStyles, createStyles, styled, ThemeProvider } from '@material-ui/core/styles';
10
+ import { makeStyles, useTheme, darken, lighten, withStyles, createStyles, styled, alpha, ThemeProvider } from '@material-ui/core/styles';
11
11
  import Button$1 from '@material-ui/core/Button';
12
12
  import MaterialLink from '@material-ui/core/Link';
13
13
  import classNames from 'classnames';
@@ -2059,9 +2059,12 @@ const useStyles$A = makeStyles(
2059
2059
  { name: "OAuthRequestDialog" }
2060
2060
  );
2061
2061
  function OAuthRequestDialog(_props) {
2062
+ var _a;
2062
2063
  const classes = useStyles$A();
2063
2064
  const [busy, setBusy] = useState(false);
2064
2065
  const oauthRequestApi = useApi(oauthRequestApiRef);
2066
+ const configApi = useApi(configApiRef);
2067
+ const authRedirect = (_a = configApi.getOptionalBoolean("enableExperimentalRedirectFlow")) != null ? _a : false;
2065
2068
  const requests = useObservable(
2066
2069
  useMemo(() => oauthRequestApi.authRequest$(), [oauthRequestApi]),
2067
2070
  []
@@ -2084,7 +2087,8 @@ function OAuthRequestDialog(_props) {
2084
2087
  classes: { root: classes.title },
2085
2088
  id: "oauth-req-dialog-title"
2086
2089
  },
2087
- /* @__PURE__ */ React.createElement(Typography, { className: classes.titleHeading, variant: "h1" }, "Login Required")
2090
+ /* @__PURE__ */ React.createElement(Typography, { className: classes.titleHeading, variant: "h1" }, "Login Required"),
2091
+ authRedirect ? /* @__PURE__ */ React.createElement(Typography, null, "This will trigger a http redirect to OAuth Login.") : null
2088
2092
  ), /* @__PURE__ */ React.createElement(DialogContent, { dividers: true, classes: { root: classes.contentList } }, /* @__PURE__ */ React.createElement(List, null, requests.map((request) => /* @__PURE__ */ React.createElement(
2089
2093
  LoginRequestListItem,
2090
2094
  {
@@ -6032,7 +6036,7 @@ const useStyles$4 = makeStyles(
6032
6036
  textAlign: "left"
6033
6037
  },
6034
6038
  label: {
6035
- color: theme.palette.common.white,
6039
+ color: theme.page.fontColor,
6036
6040
  fontWeight: theme.typography.fontWeightBold,
6037
6041
  letterSpacing: 0,
6038
6042
  fontSize: theme.typography.fontSize,
@@ -6040,14 +6044,23 @@ const useStyles$4 = makeStyles(
6040
6044
  lineHeight: 1
6041
6045
  },
6042
6046
  value: {
6043
- color: "rgba(255, 255, 255, 0.8)",
6047
+ color: alpha(theme.page.fontColor, 0.8),
6044
6048
  fontSize: theme.typography.fontSize,
6045
6049
  lineHeight: 1
6046
6050
  }
6047
6051
  }),
6048
6052
  { name: "BackstageHeaderLabel" }
6049
6053
  );
6050
- const HeaderLabelContent = ({ value, className }) => /* @__PURE__ */ React.createElement(Typography, { className }, value);
6054
+ const HeaderLabelContent = ({ value, className }) => {
6055
+ return /* @__PURE__ */ React.createElement(
6056
+ Typography,
6057
+ {
6058
+ component: typeof value === "string" ? "p" : "span",
6059
+ className
6060
+ },
6061
+ value
6062
+ );
6063
+ };
6051
6064
  function HeaderLabel(props) {
6052
6065
  const { label, value, url } = props;
6053
6066
  const classes = useStyles$4();
@@ -6495,16 +6508,23 @@ const GridItem = ({ children }) => {
6495
6508
  return /* @__PURE__ */ React.createElement(Grid, { component: "li", item: true, classes }, children);
6496
6509
  };
6497
6510
 
6498
- const Component$2 = ({ config, onSignInSuccess }) => {
6511
+ const Component$2 = ({
6512
+ config,
6513
+ onSignInStarted,
6514
+ onSignInSuccess,
6515
+ onSignInFailure
6516
+ }) => {
6499
6517
  const { apiRef, title, message } = config;
6500
6518
  const authApi = useApi(apiRef);
6501
6519
  const errorApi = useApi(errorApiRef);
6502
6520
  const handleLogin = async () => {
6503
6521
  try {
6522
+ onSignInStarted();
6504
6523
  const identityResponse = await authApi.getBackstageIdentity({
6505
6524
  instantPopup: true
6506
6525
  });
6507
6526
  if (!identityResponse) {
6527
+ onSignInFailure();
6508
6528
  throw new Error(
6509
6529
  `The ${title} provider is not configured to support sign-in`
6510
6530
  );
@@ -6518,6 +6538,7 @@ const Component$2 = ({ config, onSignInSuccess }) => {
6518
6538
  })
6519
6539
  );
6520
6540
  } catch (error) {
6541
+ onSignInFailure();
6521
6542
  errorApi.post(new ForwardedError("Login failed", error));
6522
6543
  }
6523
6544
  };
@@ -6548,7 +6569,7 @@ const loader$2 = async (apis, apiRef) => {
6548
6569
  };
6549
6570
  const commonProvider = { Component: Component$2, loader: loader$2 };
6550
6571
 
6551
- const Component$1 = ({ onSignInSuccess }) => /* @__PURE__ */ React.createElement(GridItem, null, /* @__PURE__ */ React.createElement(
6572
+ const Component$1 = ({ onSignInStarted, onSignInSuccess }) => /* @__PURE__ */ React.createElement(GridItem, null, /* @__PURE__ */ React.createElement(
6552
6573
  InfoCard,
6553
6574
  {
6554
6575
  title: "Guest",
@@ -6558,7 +6579,10 @@ const Component$1 = ({ onSignInSuccess }) => /* @__PURE__ */ React.createElement
6558
6579
  {
6559
6580
  color: "primary",
6560
6581
  variant: "outlined",
6561
- onClick: () => onSignInSuccess(new GuestUserIdentity())
6582
+ onClick: () => {
6583
+ onSignInStarted();
6584
+ onSignInSuccess(new GuestUserIdentity());
6585
+ }
6562
6586
  },
6563
6587
  "Enter"
6564
6588
  )
@@ -6591,13 +6615,14 @@ const asInputRef = (renderResult) => {
6591
6615
  ...rest
6592
6616
  };
6593
6617
  };
6594
- const Component = ({ onSignInSuccess }) => {
6618
+ const Component = ({ onSignInStarted, onSignInSuccess }) => {
6595
6619
  const classes = useFormStyles();
6596
6620
  const { register, handleSubmit, formState } = useForm({
6597
6621
  mode: "onChange"
6598
6622
  });
6599
6623
  const { errors } = formState;
6600
6624
  const handleResult = ({ userId, idToken }) => {
6625
+ onSignInStarted();
6601
6626
  onSignInSuccess(
6602
6627
  UserIdentity.fromLegacy({
6603
6628
  userId,
@@ -6752,6 +6777,7 @@ const useSignInProviders = (providers, onSignInSuccess) => {
6752
6777
  let didCancel = false;
6753
6778
  provider.components.loader(apiHolder, (_a = provider.config) == null ? void 0 : _a.apiRef).then((result) => {
6754
6779
  if (didCancel) {
6780
+ localStorage.removeItem(PROVIDER_STORAGE_KEY);
6755
6781
  return;
6756
6782
  }
6757
6783
  if (result) {
@@ -6760,10 +6786,10 @@ const useSignInProviders = (providers, onSignInSuccess) => {
6760
6786
  setLoading(false);
6761
6787
  }
6762
6788
  }).catch((error) => {
6789
+ localStorage.removeItem(PROVIDER_STORAGE_KEY);
6763
6790
  if (didCancel) {
6764
6791
  return;
6765
6792
  }
6766
- localStorage.removeItem(PROVIDER_STORAGE_KEY);
6767
6793
  errorApi.post(error);
6768
6794
  setLoading(false);
6769
6795
  });
@@ -6783,15 +6809,22 @@ const useSignInProviders = (providers, onSignInSuccess) => {
6783
6809
  const provider = providers[key];
6784
6810
  const { Component } = provider.components;
6785
6811
  const handleSignInSuccess = (result) => {
6786
- localStorage.setItem(PROVIDER_STORAGE_KEY, provider.id);
6787
6812
  handleWrappedResult(result);
6788
6813
  };
6814
+ const handleSignInStarted = () => {
6815
+ localStorage.setItem(PROVIDER_STORAGE_KEY, provider.config.id);
6816
+ };
6817
+ const handleSignInFailure = () => {
6818
+ localStorage.removeItem(PROVIDER_STORAGE_KEY);
6819
+ };
6789
6820
  return /* @__PURE__ */ React.createElement(
6790
6821
  Component,
6791
6822
  {
6792
6823
  key: provider.id,
6793
6824
  config: provider.config,
6794
- onSignInSuccess: handleSignInSuccess
6825
+ onSignInStarted: handleSignInStarted,
6826
+ onSignInSuccess: handleSignInSuccess,
6827
+ onSignInFailure: handleSignInFailure
6795
6828
  }
6796
6829
  );
6797
6830
  }),