From 83a437b349ad9e4fcb67ccb3251af33de00fc0ce Mon Sep 17 00:00:00 2001 From: Tim Hansen Date: Tue, 13 Apr 2021 07:59:31 -0600 Subject: [PATCH] SignInConfig -> SignInProviderConfig Signed-off-by: Tim Hansen --- docs/auth/index.md | 6 +++--- packages/core/src/layout/SignInPage/SignInPage.tsx | 4 ++-- packages/core/src/layout/SignInPage/commonProvider.tsx | 4 ++-- packages/core/src/layout/SignInPage/index.ts | 2 +- packages/core/src/layout/SignInPage/providers.tsx | 10 +++++++--- packages/core/src/layout/SignInPage/types.ts | 6 +++--- 6 files changed, 18 insertions(+), 14 deletions(-) diff --git a/docs/auth/index.md b/docs/auth/index.md index fc6ce33e2b..f3783c79f3 100644 --- a/docs/auth/index.md +++ b/docs/auth/index.md @@ -58,7 +58,7 @@ the local `auth.environment` setting will be selected. After configuring an authentication provider, the `app` frontend package needs a small update to show this provider as a login option. The `SignInPage` component handles this, and takes either a `provider` or `providers` (array) prop of -`SignInConfig` definitions. +`SignInProviderConfig` definitions. These reference the [ApiRef](../reference/utility-apis/README.md) exported by the provider. Again, an example using GitHub that can be adapted to any of the @@ -66,9 +66,9 @@ built-in providers: ```diff # packages/app/src/App.tsx -+ import { githubAuthApiRef, SignInConfig, SignInPage } from '@backstage/core'; ++ import { githubAuthApiRef, SignInProviderConfig, SignInPage } from '@backstage/core'; -+ const githubProvider: SignInConfig = { ++ const githubProvider: SignInProviderConfig = { + id: 'github-auth-provider', + title: 'GitHub', + message: 'Sign in using GitHub', diff --git a/packages/core/src/layout/SignInPage/SignInPage.tsx b/packages/core/src/layout/SignInPage/SignInPage.tsx index c3e5b75bb7..daefe40c73 100644 --- a/packages/core/src/layout/SignInPage/SignInPage.tsx +++ b/packages/core/src/layout/SignInPage/SignInPage.tsx @@ -22,7 +22,7 @@ import { ContentHeader } from '../ContentHeader/ContentHeader'; import { Grid, Button, Typography } from '@material-ui/core'; import { SignInPageProps, useApi, configApiRef } from '@backstage/core-api'; import { useSignInProviders, getSignInProviders } from './providers'; -import { IdentityProviders, SignInConfig } from './types'; +import { IdentityProviders, SignInProviderConfig } from './types'; import { Progress } from '../../components/Progress'; import { GridItem, useStyles } from './styles'; import { InfoCard } from '../InfoCard'; @@ -34,7 +34,7 @@ type MultiSignInPageProps = SignInPageProps & { }; type SingleSignInPageProps = SignInPageProps & { - provider: SignInConfig; + provider: SignInProviderConfig; auto?: boolean; }; diff --git a/packages/core/src/layout/SignInPage/commonProvider.tsx b/packages/core/src/layout/SignInPage/commonProvider.tsx index b7480afa49..591efe9ece 100644 --- a/packages/core/src/layout/SignInPage/commonProvider.tsx +++ b/packages/core/src/layout/SignInPage/commonProvider.tsx @@ -21,13 +21,13 @@ import { ProviderComponent, ProviderLoader, SignInProvider, - SignInConfig, + SignInProviderConfig, } from './types'; import { useApi, errorApiRef } from '@backstage/core-api'; import { GridItem } from './styles'; const Component: ProviderComponent = ({ config, onResult }) => { - const { apiRef, title, message } = config as SignInConfig; + const { apiRef, title, message } = config as SignInProviderConfig; const authApi = useApi(apiRef); const errorApi = useApi(errorApiRef); diff --git a/packages/core/src/layout/SignInPage/index.ts b/packages/core/src/layout/SignInPage/index.ts index 9ea0be9cbd..b10ea7ae33 100644 --- a/packages/core/src/layout/SignInPage/index.ts +++ b/packages/core/src/layout/SignInPage/index.ts @@ -14,5 +14,5 @@ * limitations under the License. */ -export type { SignInConfig } from './types'; +export type { SignInProviderConfig } from './types'; export { SignInPage } from './SignInPage'; diff --git a/packages/core/src/layout/SignInPage/providers.tsx b/packages/core/src/layout/SignInPage/providers.tsx index e2c17ab80d..1ea32220b0 100644 --- a/packages/core/src/layout/SignInPage/providers.tsx +++ b/packages/core/src/layout/SignInPage/providers.tsx @@ -22,7 +22,11 @@ import { useApiHolder, errorApiRef, } from '@backstage/core-api'; -import { SignInConfig, IdentityProviders, SignInProvider } from './types'; +import { + IdentityProviders, + SignInProvider, + SignInProviderConfig, +} from './types'; import { commonProvider } from './commonProvider'; import { guestProvider } from './guestProvider'; import { customProvider } from './customProvider'; @@ -33,7 +37,7 @@ export type SignInProviderType = { [key: string]: { components: SignInProvider; id: string; - config?: SignInConfig; + config?: SignInProviderConfig; }; }; @@ -62,7 +66,7 @@ export function getSignInProviders( return acc; } - const { id } = config as SignInConfig; + const { id } = config as SignInProviderConfig; validateIDs(id, acc); acc[id] = { components: signInProviders.common, id, config }; diff --git a/packages/core/src/layout/SignInPage/types.ts b/packages/core/src/layout/SignInPage/types.ts index 48945e6988..0c78549d0c 100644 --- a/packages/core/src/layout/SignInPage/types.ts +++ b/packages/core/src/layout/SignInPage/types.ts @@ -25,17 +25,17 @@ import { SessionApi, } from '@backstage/core-api'; -export type SignInConfig = { +export type SignInProviderConfig = { id: string; title: string; message: string; apiRef: ApiRef; }; -export type IdentityProviders = ('guest' | 'custom' | SignInConfig)[]; +export type IdentityProviders = ('guest' | 'custom' | SignInProviderConfig)[]; export type ProviderComponent = ComponentType< - SignInPageProps & { config: SignInConfig } + SignInPageProps & { config: SignInProviderConfig } >; export type ProviderLoader = (