When is storybook, don't print mock related warning in console
This commit is contained in:
parent
4d67f16e94
commit
05e5e4efec
@ -1,5 +1,6 @@
|
|||||||
import type { DeepPartial } from "keycloakify/tools/DeepPartial";
|
import type { DeepPartial } from "keycloakify/tools/DeepPartial";
|
||||||
import { deepAssign } from "keycloakify/tools/deepAssign";
|
import { deepAssign } from "keycloakify/tools/deepAssign";
|
||||||
|
import { isStorybook } from "keycloakify/lib/isStorybook";
|
||||||
import type { ExtendKcContext } from "./getKcContextFromWindow";
|
import type { ExtendKcContext } from "./getKcContextFromWindow";
|
||||||
import { getKcContextFromWindow } from "./getKcContextFromWindow";
|
import { getKcContextFromWindow } from "./getKcContextFromWindow";
|
||||||
import { symToStr } from "tsafe/symToStr";
|
import { symToStr } from "tsafe/symToStr";
|
||||||
@ -25,7 +26,13 @@ export function createGetKcContext<KcContextExtension extends { pageId: string }
|
|||||||
if (mockPageId !== undefined && realKcContext === undefined) {
|
if (mockPageId !== undefined && realKcContext === undefined) {
|
||||||
//TODO maybe trow if no mock fo custom page
|
//TODO maybe trow if no mock fo custom page
|
||||||
|
|
||||||
console.log(`%cKeycloakify: ${symToStr({ mockPageId })} set to ${mockPageId}.`, "background: red; color: yellow; font-size: medium");
|
warn_that_mock_is_enbaled: {
|
||||||
|
if (isStorybook) {
|
||||||
|
break warn_that_mock_is_enbaled;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`%cKeycloakify: ${symToStr({ mockPageId })} set to ${mockPageId}.`, "background: red; color: yellow; font-size: medium");
|
||||||
|
}
|
||||||
|
|
||||||
const kcContextDefaultMock = kcContextMocks.find(({ pageId }) => pageId === mockPageId);
|
const kcContextDefaultMock = kcContextMocks.find(({ pageId }) => pageId === mockPageId);
|
||||||
|
|
||||||
|
3
src/lib/isStorybook.ts
Normal file
3
src/lib/isStorybook.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
import { BASE_URL } from "./BASE_URL";
|
||||||
|
|
||||||
|
export const isStorybook = BASE_URL.startsWith(".");
|
@ -2,6 +2,7 @@ import type { KcContext, Attribute } from "./KcContext";
|
|||||||
import { kcContextMocks, kcContextCommonMock } from "./kcContextMocks";
|
import { kcContextMocks, kcContextCommonMock } from "./kcContextMocks";
|
||||||
import type { DeepPartial } from "keycloakify/tools/DeepPartial";
|
import type { DeepPartial } from "keycloakify/tools/DeepPartial";
|
||||||
import { deepAssign } from "keycloakify/tools/deepAssign";
|
import { deepAssign } from "keycloakify/tools/deepAssign";
|
||||||
|
import { isStorybook } from "keycloakify/lib/isStorybook";
|
||||||
import { id } from "tsafe/id";
|
import { id } from "tsafe/id";
|
||||||
import { exclude } from "tsafe/exclude";
|
import { exclude } from "tsafe/exclude";
|
||||||
import { assert } from "tsafe/assert";
|
import { assert } from "tsafe/assert";
|
||||||
@ -29,7 +30,13 @@ export function createGetKcContext<KcContextExtension extends { pageId: string }
|
|||||||
if (mockPageId !== undefined && realKcContext === undefined) {
|
if (mockPageId !== undefined && realKcContext === undefined) {
|
||||||
//TODO maybe trow if no mock fo custom page
|
//TODO maybe trow if no mock fo custom page
|
||||||
|
|
||||||
console.log(`%cKeycloakify: ${symToStr({ mockPageId })} set to ${mockPageId}.`, "background: red; color: yellow; font-size: medium");
|
warn_that_mock_is_enbaled: {
|
||||||
|
if (isStorybook) {
|
||||||
|
break warn_that_mock_is_enbaled;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`%cKeycloakify: ${symToStr({ mockPageId })} set to ${mockPageId}.`, "background: red; color: yellow; font-size: medium");
|
||||||
|
}
|
||||||
|
|
||||||
const kcContextDefaultMock = kcContextMocks.find(({ pageId }) => pageId === mockPageId);
|
const kcContextDefaultMock = kcContextMocks.find(({ pageId }) => pageId === mockPageId);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user