keycloak_theme/stories/login/pages/LoginConfigTotp.stories.tsx

65 lines
1.6 KiB
TypeScript
Raw Normal View History

2023-04-20 05:41:34 +02:00
import React from "react";
2024-06-03 00:11:19 +02:00
import type { Meta, StoryObj } from "@storybook/react";
2024-06-09 11:53:25 +02:00
import { createKcPageStory } from "../KcPageStory";
2023-04-20 05:41:34 +02:00
2024-06-09 11:53:25 +02:00
const { KcPageStory } = createKcPageStory({ pageId: "login-config-totp.ftl" });
2023-04-20 05:41:34 +02:00
2024-06-03 00:11:19 +02:00
const meta = {
2024-06-06 07:28:34 +02:00
title: "login/login-config-totp.ftl",
2024-06-09 11:53:25 +02:00
component: KcPageStory
} satisfies Meta<typeof KcPageStory>;
2023-04-20 05:41:34 +02:00
export default meta;
2024-06-03 00:11:19 +02:00
type Story = StoryObj<typeof meta>;
export const Default: Story = {
2024-06-09 11:53:25 +02:00
render: () => <KcPageStory />
2024-06-03 00:11:19 +02:00
};
export const WithManualSetUp: Story = {
render: () => (
2024-06-09 11:53:25 +02:00
<KcPageStory
2024-06-03 00:11:19 +02:00
kcContext={{
mode: "manual"
}}
/>
)
};
export const WithError: Story = {
render: () => (
2024-06-09 11:53:25 +02:00
<KcPageStory
2024-06-03 00:11:19 +02:00
kcContext={{
messagesPerField: {
get: (fieldName: string) => (fieldName === "totp" ? "Invalid TOTP" : undefined),
exists: (fieldName: string) => fieldName === "totp",
existsError: (fieldName: string) => fieldName === "totp",
printIfExists: <T,>(fieldName: string, x: T) => (fieldName === "totp" ? x : undefined)
}
}}
/>
)
};
export const WithAppInitiatedAction: Story = {
render: () => (
<KcPageStory
kcContext={{
isAppInitiatedAction: true
}}
/>
)
};
export const WithPreFilledUserLabel: Story = {
render: () => (
<KcPageStory
kcContext={{
totp: {
otpCredentials: [{ userLabel: "MyDevice" }]
}
}}
/>
)
};