refactor(storybook): merge duplicate types
This commit is contained in:
parent
8cdc6b7730
commit
d2e22ab798
@ -1,28 +1,16 @@
|
|||||||
import { KcContextBase, getKcContext } from "keycloakify/lib/getKcContext";
|
import { KcContextBase, getKcContext } from "keycloakify/lib/getKcContext";
|
||||||
import type { DeepPartial } from "keycloakify/lib/tools/DeepPartial";
|
import type { DeepPartial } from "keycloakify/lib/tools/DeepPartial";
|
||||||
import type { ExtendsKcContextBase } from "keycloakify/lib/getKcContext/getKcContextFromWindow";
|
import type { ExtendsKcContextBase } from "keycloakify/lib/getKcContext/getKcContextFromWindow";
|
||||||
|
import type { KcContextExtension } from "keycloak-theme/kcContext";
|
||||||
|
|
||||||
type KcContextExt =
|
|
||||||
| { pageId: "my-extra-page-1.ftl"; }
|
|
||||||
| { pageId: "my-extra-page-2.ftl"; someCustomValue: string; }
|
|
||||||
// NOTE: register.ftl is deprecated in favor of register-user-profile.ftl
|
|
||||||
// but let's say we use it anyway and have this plugin enabled: https://github.com/micedre/keycloak-mail-whitelisting
|
|
||||||
// keycloak-mail-whitelisting define the non standard ftl global authorizedMailDomains, we declare it here.
|
|
||||||
| { pageId: "register.ftl"; authorizedMailDomains: string[]; }
|
|
||||||
|
|
||||||
export const useKcStoryData = (mockData: (
|
export const useKcStoryData = (mockData: (
|
||||||
{ pageId: KcContextBase['pageId'] | KcContextExt['pageId'] } & DeepPartial<ExtendsKcContextBase<KcContextExt>>
|
{ pageId: KcContextBase['pageId'] | KcContextExtension['pageId'] } & DeepPartial<ExtendsKcContextBase<KcContextExtension>>
|
||||||
)) => {
|
)) => {
|
||||||
|
const { kcContext } = getKcContext<KcContextExtension>({ mockPageId: mockData.pageId, mockData: [mockData] })
|
||||||
const { kcContext } = getKcContext<KcContextExt>({
|
return { kcContext: kcContext as NonNullable<typeof kcContext> }
|
||||||
mockPageId: mockData.pageId,
|
|
||||||
mockData: [mockData]
|
|
||||||
})
|
|
||||||
if (!kcContext) throw new Error("no kcContext")
|
|
||||||
return { kcContext }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const socialProviders = [
|
export const socialProviders = [
|
||||||
{ loginUrl: 'google', alias: 'google', providerId: 'google', displayName: 'Google' },
|
{ loginUrl: 'google', alias: 'google', providerId: 'google', displayName: 'Google' },
|
||||||
{ loginUrl: 'microsoft', alias: 'microsoft', providerId: 'microsoft', displayName: 'Microsoft' },
|
{ loginUrl: 'microsoft', alias: 'microsoft', providerId: 'microsoft', displayName: 'Microsoft' },
|
||||||
|
@ -1,11 +1,6 @@
|
|||||||
import { getKcContext } from "keycloakify/lib/getKcContext";
|
import { getKcContext } from "keycloakify/lib/getKcContext";
|
||||||
|
|
||||||
//NOTE: In most of the cases you do not need to overload the KcContext, you can
|
export type KcContextExtension =
|
||||||
// just call getKcContext(...) without type arguments.
|
|
||||||
// You want to overload the KcContext only if:
|
|
||||||
// - You have custom plugins that add some values to the context (like https://github.com/micedre/keycloak-mail-whitelisting that adds authorizedMailDomains)
|
|
||||||
// - You want to add support for extra pages that are not yey featured by default, see: https://docs.keycloakify.dev/contributing#adding-support-for-a-new-page
|
|
||||||
export const { kcContext } = getKcContext<
|
|
||||||
// NOTE: A 'keycloakify' field must be added
|
// NOTE: A 'keycloakify' field must be added
|
||||||
// in the package.json to generate theses extra pages
|
// in the package.json to generate theses extra pages
|
||||||
// https://docs.keycloakify.dev/build-options#keycloakify.extrapages
|
// https://docs.keycloakify.dev/build-options#keycloakify.extrapages
|
||||||
@ -14,8 +9,14 @@ export const { kcContext } = getKcContext<
|
|||||||
// NOTE: register.ftl is deprecated in favor of register-user-profile.ftl
|
// NOTE: register.ftl is deprecated in favor of register-user-profile.ftl
|
||||||
// but let's say we use it anyway and have this plugin enabled: https://github.com/micedre/keycloak-mail-whitelisting
|
// but let's say we use it anyway and have this plugin enabled: https://github.com/micedre/keycloak-mail-whitelisting
|
||||||
// keycloak-mail-whitelisting define the non standard ftl global authorizedMailDomains, we declare it here.
|
// keycloak-mail-whitelisting define the non standard ftl global authorizedMailDomains, we declare it here.
|
||||||
| { pageId: "register.ftl"; authorizedMailDomains: string[]; }
|
| { pageId: "register.ftl"; authorizedMailDomains: string[]; };
|
||||||
>({
|
|
||||||
|
//NOTE: In most of the cases you do not need to overload the KcContext, you can
|
||||||
|
// just call getKcContext(...) without type arguments.
|
||||||
|
// You want to overload the KcContext only if:
|
||||||
|
// - You have custom plugins that add some values to the context (like https://github.com/micedre/keycloak-mail-whitelisting that adds authorizedMailDomains)
|
||||||
|
// - You want to add support for extra pages that are not yey featured by default, see: https://docs.keycloakify.dev/contributing#adding-support-for-a-new-page
|
||||||
|
export const { kcContext } = getKcContext<KcContextExtension>({
|
||||||
// Uncomment to test the login page for development.
|
// Uncomment to test the login page for development.
|
||||||
//mockPageId: "login.ftl",
|
//mockPageId: "login.ftl",
|
||||||
mockData: [
|
mockData: [
|
||||||
|
Loading…
Reference in New Issue
Block a user