diff --git a/.changeset/auth-provider-icon-element-core-components.md b/.changeset/auth-provider-icon-element-core-components.md
new file mode 100644
index 0000000000..7bd7aa6d52
--- /dev/null
+++ b/.changeset/auth-provider-icon-element-core-components.md
@@ -0,0 +1,5 @@
+---
+'@backstage/core-components': patch
+---
+
+The login request dialog now handles auth provider icons passed as `IconElement` in addition to `IconComponent`.
diff --git a/.changeset/auth-provider-icon-element-user-settings.md b/.changeset/auth-provider-icon-element-user-settings.md
new file mode 100644
index 0000000000..16b9adb94f
--- /dev/null
+++ b/.changeset/auth-provider-icon-element-user-settings.md
@@ -0,0 +1,5 @@
+---
+'@backstage/plugin-user-settings': patch
+---
+
+The `ProviderSettingsItem` `icon` prop now accepts `IconElement` in addition to `IconComponent`.
diff --git a/.changeset/auth-provider-icon-element.md b/.changeset/auth-provider-icon-element.md
new file mode 100644
index 0000000000..def6666c2d
--- /dev/null
+++ b/.changeset/auth-provider-icon-element.md
@@ -0,0 +1,5 @@
+---
+'@backstage/frontend-plugin-api': patch
+---
+
+The `icon` field on `AuthProviderInfo` now accepts `IconElement` in addition to `IconComponent`, letting you pass `` instead of `MyIcon`.
diff --git a/packages/core-components/src/components/OAuthRequestDialog/LoginRequestListItem.tsx b/packages/core-components/src/components/OAuthRequestDialog/LoginRequestListItem.tsx
index 328ab50a34..a34ae21892 100644
--- a/packages/core-components/src/components/OAuthRequestDialog/LoginRequestListItem.tsx
+++ b/packages/core-components/src/components/OAuthRequestDialog/LoginRequestListItem.tsx
@@ -20,10 +20,11 @@ import ListItemAvatar from '@material-ui/core/ListItemAvatar';
import ListItemText from '@material-ui/core/ListItemText';
import Typography from '@material-ui/core/Typography';
import Button from '@material-ui/core/Button';
-import { useState } from 'react';
+import { createElement, isValidElement, useState } from 'react';
import { isError } from '@backstage/errors';
import {
configApiRef,
+ IconComponent,
PendingOAuthRequest,
useApi,
} from '@backstage/core-plugin-api';
@@ -68,7 +69,7 @@ const LoginRequestListItem = ({ request, busy, setBusy }: RowProps) => {
}
};
- const IconComponent = request.provider.icon;
+ const providerIcon = request.provider.icon;
const message =
request.provider.message ??
t('oauthRequestDialog.message', {
@@ -76,11 +77,14 @@ const LoginRequestListItem = ({ request, busy, setBusy }: RowProps) => {
provider: request.provider.title,
});
+ const iconElement =
+ providerIcon === null || isValidElement(providerIcon)
+ ? providerIcon
+ : createElement(providerIcon as IconComponent, { fontSize: 'large' });
+
return (
-
-
-
+ {iconElement ?? <>>}
`) or an `IconComponent`
+ * (e.g. `MyIcon`). Prefer passing `IconElement`.
*/
- icon: IconComponent;
+ icon: IconComponent | IconElement;
/**
* Optional user friendly messaage to display for the auth provider.
diff --git a/plugins/user-settings/report.api.md b/plugins/user-settings/report.api.md
index 77670bb357..2994f2c13c 100644
--- a/plugins/user-settings/report.api.md
+++ b/plugins/user-settings/report.api.md
@@ -11,6 +11,7 @@ import { ElementType } from 'react';
import { ErrorApi } from '@backstage/core-plugin-api';
import { FetchApi } from '@backstage/core-plugin-api';
import { IconComponent } from '@backstage/core-plugin-api';
+import { IconElement } from '@backstage/frontend-plugin-api';
import { IdentityApi } from '@backstage/core-plugin-api';
import { JsonValue } from '@backstage/types';
import { JSX as JSX_2 } from 'react/jsx-runtime';
@@ -35,7 +36,7 @@ export const DefaultProviderSettings: (props: {
export const ProviderSettingsItem: (props: {
title: string;
description: string;
- icon: IconComponent;
+ icon: IconComponent | IconElement;
apiRef: ApiRef;
}) => JSX_2.Element;
diff --git a/plugins/user-settings/src/components/AuthProviders/ProviderSettingsItem.tsx b/plugins/user-settings/src/components/AuthProviders/ProviderSettingsItem.tsx
index 32eaeb0cb9..534e1dc5ad 100644
--- a/plugins/user-settings/src/components/AuthProviders/ProviderSettingsItem.tsx
+++ b/plugins/user-settings/src/components/AuthProviders/ProviderSettingsItem.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import { useEffect, useState } from 'react';
+import { createElement, isValidElement, useEffect, useState } from 'react';
import Button from '@material-ui/core/Button';
import Grid from '@material-ui/core/Grid';
import ListItem from '@material-ui/core/ListItem';
@@ -33,6 +33,7 @@ import {
errorApiRef,
IconComponent,
} from '@backstage/core-plugin-api';
+import { IconElement } from '@backstage/frontend-plugin-api';
import { ProviderSettingsAvatar } from './ProviderSettingsAvatar';
import { useTranslationRef } from '@backstage/frontend-plugin-api';
import { userSettingsTranslationRef } from '../../translation';
@@ -43,10 +44,10 @@ const emptyProfile: ProfileInfo = {};
export const ProviderSettingsItem = (props: {
title: string;
description: string;
- icon: IconComponent;
+ icon: IconComponent | IconElement;
apiRef: ApiRef;
}) => {
- const { title, description, icon: Icon, apiRef } = props;
+ const { title, description, icon, apiRef } = props;
const api = useApi(apiRef);
const errorApi = useApi(errorApiRef);
@@ -86,11 +87,14 @@ export const ProviderSettingsItem = (props: {
};
}, [api]);
+ const iconElement =
+ icon === null || isValidElement(icon)
+ ? icon
+ : createElement(icon as IconComponent);
+
return (
-
-
-
+ {iconElement}