@oussemasahbeni/keycloakify-login-shadcn 250004.0.3 → 250004.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/keycloak-theme/components/langauges.tsx +1 -1
- package/keycloak-theme/components/theme-toggle.tsx +0 -1
- package/keycloak-theme/components/ui/alert.tsx +1 -2
- package/keycloak-theme/components/ui/button.tsx +1 -2
- package/keycloak-theme/components/ui/card.tsx +0 -1
- package/keycloak-theme/components/ui/checkbox.tsx +0 -1
- package/keycloak-theme/components/ui/dropdown-menu.tsx +14 -4
- package/keycloak-theme/components/ui/field.tsx +0 -1
- package/keycloak-theme/components/ui/input-otp.tsx +0 -1
- package/keycloak-theme/components/ui/input.tsx +0 -1
- package/keycloak-theme/components/ui/label.tsx +1 -2
- package/keycloak-theme/components/ui/radio-group.tsx +0 -1
- package/keycloak-theme/components/ui/select.tsx +12 -4
- package/keycloak-theme/components/ui/separator.tsx +0 -1
- package/keycloak-theme/components/ui/tooltip.tsx +0 -1
- package/keycloak-theme/login/KcContext.ts +23 -23
- package/keycloak-theme/login/KcPage.tsx +45 -47
- package/keycloak-theme/login/assets/img/auth-logo.svg +100 -100
- package/keycloak-theme/login/assets/img/shape.svg +71 -71
- package/keycloak-theme/login/components/LogoutOtherSessions.tsx +24 -26
- package/keycloak-theme/login/components/PasswordWrapper.tsx +35 -35
- package/keycloak-theme/login/components/Template/Template.tsx +279 -227
- package/keycloak-theme/login/components/Template/index.ts +1 -1
- package/keycloak-theme/login/components/Template/useInitializeTemplate.ts +61 -61
- package/keycloak-theme/login/components/UserProfileFormFields/AddRemoveButtonsMultiValuedAttribute.tsx +65 -61
- package/keycloak-theme/login/components/UserProfileFormFields/DO_MAKE_USER_CONFIRM_PASSWORD.ts +2 -2
- package/keycloak-theme/login/components/UserProfileFormFields/FieldErrors.tsx +33 -29
- package/keycloak-theme/login/components/UserProfileFormFields/GroupLabel.tsx +90 -71
- package/keycloak-theme/login/components/UserProfileFormFields/InputFieldByType.tsx +66 -59
- package/keycloak-theme/login/components/UserProfileFormFields/InputLabel.tsx +0 -1
- package/keycloak-theme/login/components/UserProfileFormFields/InputTag.tsx +133 -116
- package/keycloak-theme/login/components/UserProfileFormFields/InputTagSelects.tsx +150 -136
- package/keycloak-theme/login/components/UserProfileFormFields/SelectTag.tsx +135 -114
- package/keycloak-theme/login/components/UserProfileFormFields/TextareaTag.tsx +55 -43
- package/keycloak-theme/login/components/UserProfileFormFields/UserProfileFormFields.tsx +133 -127
- package/keycloak-theme/login/components/UserProfileFormFields/index.ts +1 -1
- package/keycloak-theme/login/i18n.ts +47 -47
- package/keycloak-theme/login/mocks/KcPageStory.tsx +6 -2
- package/keycloak-theme/login/mocks/getKcContextMock.ts +22 -22
- package/keycloak-theme/login/pages/PageIndex.tsx +130 -134
- package/keycloak-theme/login/pages/code/Page.stories.tsx +57 -70
- package/keycloak-theme/login/pages/code/Page.tsx +89 -89
- package/keycloak-theme/login/pages/code/index.ts +3 -3
- package/keycloak-theme/login/pages/delete-account-confirm/Page.stories.tsx +37 -46
- package/keycloak-theme/login/pages/delete-account-confirm/Page.tsx +60 -63
- package/keycloak-theme/login/pages/delete-account-confirm/index.ts +3 -3
- package/keycloak-theme/login/pages/delete-credential/Page.stories.tsx +25 -30
- package/keycloak-theme/login/pages/delete-credential/Page.tsx +56 -51
- package/keycloak-theme/login/pages/delete-credential/index.ts +3 -3
- package/keycloak-theme/login/pages/error/Page.stories.tsx +46 -58
- package/keycloak-theme/login/pages/error/Page.tsx +43 -42
- package/keycloak-theme/login/pages/error/index.ts +3 -3
- package/keycloak-theme/login/pages/frontchannel-logout/Page.stories.tsx +25 -32
- package/keycloak-theme/login/pages/frontchannel-logout/Page.tsx +82 -84
- package/keycloak-theme/login/pages/frontchannel-logout/index.ts +3 -3
- package/keycloak-theme/login/pages/idp-review-user-profile/Page.stories.tsx +46 -59
- package/keycloak-theme/login/pages/idp-review-user-profile/Page.tsx +49 -52
- package/keycloak-theme/login/pages/idp-review-user-profile/index.ts +3 -3
- package/keycloak-theme/login/pages/info/Page.stories.tsx +50 -60
- package/keycloak-theme/login/pages/info/Page.tsx +94 -92
- package/keycloak-theme/login/pages/link-idp-action/Page.stories.tsx +32 -16
- package/keycloak-theme/login/pages/link-idp-action/Page.tsx +45 -43
- package/keycloak-theme/login/pages/link-idp-action/index.ts +3 -3
- package/keycloak-theme/login/pages/login/Form.tsx +242 -242
- package/keycloak-theme/login/pages/login/Info.tsx +29 -29
- package/keycloak-theme/login/pages/login/Page.stories.tsx +346 -365
- package/keycloak-theme/login/pages/login/Page.tsx +43 -44
- package/keycloak-theme/login/pages/login/SocialProviders.tsx +93 -107
- package/keycloak-theme/login/pages/login/index.ts +3 -3
- package/keycloak-theme/login/pages/login/providers/apple.svg +3 -3
- package/keycloak-theme/login/pages/login/providers/bitbucket.svg +11 -11
- package/keycloak-theme/login/pages/login/providers/discord.svg +4 -4
- package/keycloak-theme/login/pages/login/providers/facebook.svg +5 -5
- package/keycloak-theme/login/pages/login/providers/github.svg +3 -3
- package/keycloak-theme/login/pages/login/providers/gitlab.svg +7 -7
- package/keycloak-theme/login/pages/login/providers/google.svg +7 -7
- package/keycloak-theme/login/pages/login/providers/instagram.svg +31 -31
- package/keycloak-theme/login/pages/login/providers/linkedin.svg +3 -3
- package/keycloak-theme/login/pages/login/providers/microsoft.svg +6 -6
- package/keycloak-theme/login/pages/login/providers/oidc.svg +5 -5
- package/keycloak-theme/login/pages/login/providers/openshift.svg +7 -7
- package/keycloak-theme/login/pages/login/providers/paypal.svg +6 -6
- package/keycloak-theme/login/pages/login/providers/slack.svg +11 -11
- package/keycloak-theme/login/pages/login/providers/stackoverflow.svg +5 -5
- package/keycloak-theme/login/pages/login/providers/x.svg +3 -3
- package/keycloak-theme/login/pages/login/useProviderLogos.tsx +39 -39
- package/keycloak-theme/login/pages/login/useScript.tsx +62 -62
- package/keycloak-theme/login/pages/login-config-totp/Page.stories.tsx +45 -60
- package/keycloak-theme/login/pages/login-config-totp/Page.tsx +253 -240
- package/keycloak-theme/login/pages/login-config-totp/index.ts +3 -3
- package/keycloak-theme/login/pages/login-idp-link-confirm/Page.stories.tsx +30 -35
- package/keycloak-theme/login/pages/login-idp-link-confirm/Page.tsx +40 -43
- package/keycloak-theme/login/pages/login-idp-link-confirm/index.ts +3 -3
- package/keycloak-theme/login/pages/login-idp-link-confirm-override/Page.stories.tsx +16 -23
- package/keycloak-theme/login/pages/login-idp-link-confirm-override/Page.tsx +44 -47
- package/keycloak-theme/login/pages/login-idp-link-confirm-override/index.ts +3 -3
- package/keycloak-theme/login/pages/login-idp-link-email/Page.stories.tsx +54 -63
- package/keycloak-theme/login/pages/login-idp-link-email/Page.tsx +51 -54
- package/keycloak-theme/login/pages/login-idp-link-email/index.ts +3 -3
- package/keycloak-theme/login/pages/login-oauth-grant/Page.stories.tsx +39 -45
- package/keycloak-theme/login/pages/login-oauth-grant/Page.tsx +136 -126
- package/keycloak-theme/login/pages/login-oauth-grant/index.ts +3 -3
- package/keycloak-theme/login/pages/login-oauth2-device-verify-user-code/Page.stories.tsx +38 -48
- package/keycloak-theme/login/pages/login-oauth2-device-verify-user-code/Page.tsx +56 -58
- package/keycloak-theme/login/pages/login-oauth2-device-verify-user-code/index.ts +3 -3
- package/keycloak-theme/login/pages/login-otp/Page.stories.tsx +82 -97
- package/keycloak-theme/login/pages/login-otp/Page.tsx +117 -108
- package/keycloak-theme/login/pages/login-otp/index.ts +3 -3
- package/keycloak-theme/login/pages/login-page-expired/Page.stories.tsx +28 -37
- package/keycloak-theme/login/pages/login-page-expired/Page.tsx +45 -47
- package/keycloak-theme/login/pages/login-page-expired/index.ts +3 -3
- package/keycloak-theme/login/pages/login-passkeys-conditional-authenticate/Page.stories.tsx +20 -0
- package/keycloak-theme/login/pages/login-passkeys-conditional-authenticate/Page.tsx +290 -233
- package/keycloak-theme/login/pages/login-passkeys-conditional-authenticate/index.ts +3 -3
- package/keycloak-theme/login/pages/login-passkeys-conditional-authenticate/useScript.tsx +63 -63
- package/keycloak-theme/login/pages/login-password/Page.stories.tsx +55 -56
- package/keycloak-theme/login/pages/login-password/Page.tsx +148 -149
- package/keycloak-theme/login/pages/login-password/index.ts +3 -3
- package/keycloak-theme/login/pages/login-password/useScript.tsx +62 -63
- package/keycloak-theme/login/pages/login-recovery-authn-code-config/Page.stories.tsx +28 -36
- package/keycloak-theme/login/pages/login-recovery-authn-code-config/Page.tsx +178 -181
- package/keycloak-theme/login/pages/login-recovery-authn-code-config/index.ts +3 -3
- package/keycloak-theme/login/pages/login-recovery-authn-code-config/useScript.tsx +145 -145
- package/keycloak-theme/login/pages/login-recovery-authn-code-input/Page.stories.tsx +16 -22
- package/keycloak-theme/login/pages/login-recovery-authn-code-input/Page.tsx +69 -70
- package/keycloak-theme/login/pages/login-recovery-authn-code-input/index.ts +3 -3
- package/keycloak-theme/login/pages/login-reset-otp/Page.stories.tsx +62 -75
- package/keycloak-theme/login/pages/login-reset-otp/Page.tsx +85 -86
- package/keycloak-theme/login/pages/login-reset-otp/index.ts +3 -3
- package/keycloak-theme/login/pages/login-reset-password/Form.tsx +67 -68
- package/keycloak-theme/login/pages/login-reset-password/Page.stories.tsx +44 -55
- package/keycloak-theme/login/pages/login-reset-password/Page.tsx +27 -27
- package/keycloak-theme/login/pages/login-reset-password/index.ts +3 -3
- package/keycloak-theme/login/pages/login-update-password/Page.stories.tsx +40 -51
- package/keycloak-theme/login/pages/login-update-password/Page.tsx +109 -111
- package/keycloak-theme/login/pages/login-update-password/index.ts +3 -3
- package/keycloak-theme/login/pages/login-update-profile/Page.stories.tsx +28 -37
- package/keycloak-theme/login/pages/login-update-profile/Page.tsx +67 -68
- package/keycloak-theme/login/pages/login-update-profile/index.ts +3 -3
- package/keycloak-theme/login/pages/login-username/Page.stories.tsx +32 -43
- package/keycloak-theme/login/pages/login-username/Page.tsx +246 -246
- package/keycloak-theme/login/pages/login-username/index.ts +3 -3
- package/keycloak-theme/login/pages/login-username/useScript.tsx +62 -62
- package/keycloak-theme/login/pages/login-verify-email/Page.stories.tsx +68 -81
- package/keycloak-theme/login/pages/login-verify-email/Page.tsx +37 -38
- package/keycloak-theme/login/pages/login-verify-email/index.ts +3 -3
- package/keycloak-theme/login/pages/login-x509-info/Page.stories.tsx +29 -38
- package/keycloak-theme/login/pages/login-x509-info/Page.tsx +72 -75
- package/keycloak-theme/login/pages/login-x509-info/index.ts +3 -3
- package/keycloak-theme/login/pages/logout-confirm/Page.stories.tsx +34 -43
- package/keycloak-theme/login/pages/logout-confirm/Page.tsx +50 -53
- package/keycloak-theme/login/pages/logout-confirm/index.ts +3 -3
- package/keycloak-theme/login/pages/register/Form.tsx +107 -106
- package/keycloak-theme/login/pages/register/Page.stories.tsx +40 -14
- package/keycloak-theme/login/pages/register/Page.tsx +26 -26
- package/keycloak-theme/login/pages/register/TermsAcceptance.tsx +55 -56
- package/keycloak-theme/login/pages/register/index.ts +3 -3
- package/keycloak-theme/login/pages/saml-post-form/Page.stories.tsx +16 -23
- package/keycloak-theme/login/pages/saml-post-form/Page.tsx +64 -66
- package/keycloak-theme/login/pages/saml-post-form/index.ts +3 -3
- package/keycloak-theme/login/pages/select-authenticator/Page.stories.tsx +83 -96
- package/keycloak-theme/login/pages/select-authenticator/Page.tsx +97 -100
- package/keycloak-theme/login/pages/select-authenticator/index.ts +3 -3
- package/keycloak-theme/login/pages/select-organization/Page.stories.tsx +62 -49
- package/keycloak-theme/login/pages/select-organization/Page.tsx +123 -126
- package/keycloak-theme/login/pages/select-organization/index.ts +3 -3
- package/keycloak-theme/login/pages/terms/Page.stories.tsx +15 -0
- package/keycloak-theme/login/pages/terms/Page.tsx +49 -51
- package/keycloak-theme/login/pages/terms/index.ts +3 -3
- package/keycloak-theme/login/pages/update-email/Page.stories.tsx +27 -36
- package/keycloak-theme/login/pages/update-email/Page.tsx +61 -62
- package/keycloak-theme/login/pages/update-email/index.ts +3 -3
- package/keycloak-theme/login/pages/webauthn-authenticate/Page.stories.tsx +112 -127
- package/keycloak-theme/login/pages/webauthn-authenticate/Page.tsx +206 -202
- package/keycloak-theme/login/pages/webauthn-authenticate/index.ts +3 -3
- package/keycloak-theme/login/pages/webauthn-authenticate/useScript.tsx +55 -55
- package/keycloak-theme/login/pages/webauthn-error/Page.stories.tsx +52 -67
- package/keycloak-theme/login/pages/webauthn-error/Page.tsx +70 -73
- package/keycloak-theme/login/pages/webauthn-error/index.ts +3 -3
- package/keycloak-theme/login/pages/webauthn-register/Page.stories.tsx +39 -50
- package/keycloak-theme/login/pages/webauthn-register/Page.tsx +78 -78
- package/keycloak-theme/login/pages/webauthn-register/index.ts +3 -3
- package/keycloak-theme/login/pages/webauthn-register/useScript.tsx +62 -62
- package/keycloak-theme/login/shared/getColorScheme.ts +45 -45
- package/keycloak-theme/login/styleLevelCustomization.tsx +34 -36
- package/keycloak-theme/public/site.webmanifest +11 -1
- package/package.json +6 -2
|
@@ -1,100 +1,97 @@
|
|
|
1
|
-
import { Button } from "@/components/ui/button";
|
|
2
|
-
import { useI18n } from
|
|
3
|
-
import { useKcContext } from
|
|
4
|
-
import { ChevronRight, Fingerprint, Globe, KeyRound, Shield } from "lucide-react";
|
|
5
|
-
import { FaKey } from "react-icons/fa";
|
|
6
|
-
import { assert } from "tsafe/assert";
|
|
7
|
-
import { Template } from "../../components/Template";
|
|
8
|
-
|
|
9
|
-
const getAuthenticatorIcon = (authSelection: {
|
|
10
|
-
displayName: string;
|
|
11
|
-
iconCssClass?: string;
|
|
12
|
-
}) => {
|
|
13
|
-
const displayName = authSelection.displayName.toLowerCase();
|
|
14
|
-
const iconClass = authSelection.iconCssClass?.toLowerCase() || "";
|
|
15
|
-
|
|
16
|
-
if (
|
|
17
|
-
displayName.includes("webauthn") ||
|
|
18
|
-
displayName.includes("passwordless") ||
|
|
19
|
-
iconClass.includes("webauthn") ||
|
|
20
|
-
displayName.includes("passkey")
|
|
21
|
-
) {
|
|
22
|
-
return <Fingerprint className="w-5 h-5" />;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (
|
|
26
|
-
displayName.includes("otp") ||
|
|
27
|
-
displayName.includes("totp") ||
|
|
28
|
-
displayName.includes("authenticator")
|
|
29
|
-
) {
|
|
30
|
-
return <Shield className="w-5 h-5" />;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (
|
|
34
|
-
displayName.includes("identity-provider") ||
|
|
35
|
-
displayName.includes("idp") ||
|
|
36
|
-
displayName.includes("sso") ||
|
|
37
|
-
iconClass.includes("identityprovider")
|
|
38
|
-
) {
|
|
39
|
-
return <Globe className="w-5 h-5" />;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (
|
|
43
|
-
displayName.includes("password") ||
|
|
44
|
-
displayName.includes("username") ||
|
|
45
|
-
iconClass.includes("password")
|
|
46
|
-
) {
|
|
47
|
-
return <KeyRound className="w-5 h-5" />;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return <FaKey className="w-5 h-5" />;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export function Page() {
|
|
54
|
-
const { kcContext } = useKcContext();
|
|
55
|
-
assert(kcContext.pageId === "select-authenticator.ftl");
|
|
56
|
-
|
|
57
|
-
const { url, auth } = kcContext;
|
|
58
|
-
|
|
59
|
-
const { msg, advancedMsg } = useI18n();
|
|
60
|
-
return (
|
|
61
|
-
<Template
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
<div className="
|
|
86
|
-
{advancedMsg(authenticationSelection.
|
|
87
|
-
</div>
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
</Template>
|
|
99
|
-
);
|
|
100
|
-
}
|
|
1
|
+
import { Button } from "@/components/ui/button";
|
|
2
|
+
import { useI18n } from "@/login/i18n";
|
|
3
|
+
import { useKcContext } from "@/login/KcContext";
|
|
4
|
+
import { ChevronRight, Fingerprint, Globe, KeyRound, Shield } from "lucide-react";
|
|
5
|
+
import { FaKey } from "react-icons/fa";
|
|
6
|
+
import { assert } from "tsafe/assert";
|
|
7
|
+
import { Template } from "../../components/Template";
|
|
8
|
+
|
|
9
|
+
const getAuthenticatorIcon = (authSelection: {
|
|
10
|
+
displayName: string;
|
|
11
|
+
iconCssClass?: string;
|
|
12
|
+
}) => {
|
|
13
|
+
const displayName = authSelection.displayName.toLowerCase();
|
|
14
|
+
const iconClass = authSelection.iconCssClass?.toLowerCase() || "";
|
|
15
|
+
|
|
16
|
+
if (
|
|
17
|
+
displayName.includes("webauthn") ||
|
|
18
|
+
displayName.includes("passwordless") ||
|
|
19
|
+
iconClass.includes("webauthn") ||
|
|
20
|
+
displayName.includes("passkey")
|
|
21
|
+
) {
|
|
22
|
+
return <Fingerprint className="w-5 h-5" />;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (
|
|
26
|
+
displayName.includes("otp") ||
|
|
27
|
+
displayName.includes("totp") ||
|
|
28
|
+
displayName.includes("authenticator")
|
|
29
|
+
) {
|
|
30
|
+
return <Shield className="w-5 h-5" />;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (
|
|
34
|
+
displayName.includes("identity-provider") ||
|
|
35
|
+
displayName.includes("idp") ||
|
|
36
|
+
displayName.includes("sso") ||
|
|
37
|
+
iconClass.includes("identityprovider")
|
|
38
|
+
) {
|
|
39
|
+
return <Globe className="w-5 h-5" />;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (
|
|
43
|
+
displayName.includes("password") ||
|
|
44
|
+
displayName.includes("username") ||
|
|
45
|
+
iconClass.includes("password")
|
|
46
|
+
) {
|
|
47
|
+
return <KeyRound className="w-5 h-5" />;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return <FaKey className="w-5 h-5" />;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export function Page() {
|
|
54
|
+
const { kcContext } = useKcContext();
|
|
55
|
+
assert(kcContext.pageId === "select-authenticator.ftl");
|
|
56
|
+
|
|
57
|
+
const { url, auth } = kcContext;
|
|
58
|
+
|
|
59
|
+
const { msg, advancedMsg } = useI18n();
|
|
60
|
+
return (
|
|
61
|
+
<Template displayInfo={false} headerNode={msg("loginChooseAuthenticator")}>
|
|
62
|
+
<form
|
|
63
|
+
id="kc-select-credential-form"
|
|
64
|
+
className="space-y-3"
|
|
65
|
+
action={url.loginAction}
|
|
66
|
+
method="post"
|
|
67
|
+
>
|
|
68
|
+
<div className="space-y-2">
|
|
69
|
+
{auth.authenticationSelections.map((authenticationSelection, i) => (
|
|
70
|
+
<Button
|
|
71
|
+
key={i}
|
|
72
|
+
variant="outline"
|
|
73
|
+
className="w-full h-auto p-4 flex items-center justify-between text-left hover:bg-accent"
|
|
74
|
+
type="submit"
|
|
75
|
+
name="authenticationExecution"
|
|
76
|
+
value={authenticationSelection.authExecId}
|
|
77
|
+
>
|
|
78
|
+
<div className="flex items-center gap-3 flex-1">
|
|
79
|
+
{getAuthenticatorIcon(authenticationSelection)}
|
|
80
|
+
|
|
81
|
+
<div className="flex-1 min-w-0">
|
|
82
|
+
<div className="font-medium text-sm">
|
|
83
|
+
{advancedMsg(authenticationSelection.displayName)}
|
|
84
|
+
</div>
|
|
85
|
+
<div className="text-xs text-muted-foreground mt-1 whitespace-normal">
|
|
86
|
+
{advancedMsg(authenticationSelection.helpText)}
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
<ChevronRight className="w-4 h-4 text-muted-foreground shrink-0" />
|
|
91
|
+
</Button>
|
|
92
|
+
))}
|
|
93
|
+
</div>
|
|
94
|
+
</form>
|
|
95
|
+
</Template>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Page } from "./Page";
|
|
2
|
-
|
|
3
|
-
export default Page;
|
|
1
|
+
import { Page } from "./Page";
|
|
2
|
+
|
|
3
|
+
export default Page;
|
|
@@ -11,8 +11,27 @@ export default meta;
|
|
|
11
11
|
|
|
12
12
|
type Story = StoryObj<typeof meta>;
|
|
13
13
|
|
|
14
|
-
export const Default: Story = {
|
|
15
|
-
|
|
14
|
+
export const Default: Story = {};
|
|
15
|
+
|
|
16
|
+
export const Arabic: Story = {
|
|
17
|
+
args: {
|
|
18
|
+
kcContext: {
|
|
19
|
+
locale: {
|
|
20
|
+
currentLanguageTag: "ar",
|
|
21
|
+
rtl: true
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
export const French: Story = {
|
|
27
|
+
args: {
|
|
28
|
+
kcContext: {
|
|
29
|
+
locale: {
|
|
30
|
+
currentLanguageTag: "fr",
|
|
31
|
+
rtl: false
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
16
35
|
};
|
|
17
36
|
|
|
18
37
|
/**
|
|
@@ -22,25 +41,23 @@ export const Default: Story = {
|
|
|
22
41
|
* - Key Aspect: Ensures that when there are more than 3 organizations, they are displayed in a grid.
|
|
23
42
|
*/
|
|
24
43
|
export const WithManyOrganizations: Story = {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
/>
|
|
43
|
-
)
|
|
44
|
+
args: {
|
|
45
|
+
kcContext: {
|
|
46
|
+
url: {
|
|
47
|
+
loginAction: "/mock-login-action"
|
|
48
|
+
},
|
|
49
|
+
user: {
|
|
50
|
+
organizations: [
|
|
51
|
+
{ alias: "org1", name: "Organization 1" },
|
|
52
|
+
{ alias: "org2", name: "Organization 2" },
|
|
53
|
+
{ alias: "org3", name: "Organization 3" },
|
|
54
|
+
{ alias: "org4", name: "Organization 4" },
|
|
55
|
+
{ alias: "org5", name: "Organization 5" },
|
|
56
|
+
{ alias: "org6", name: "Organization 6" }
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
44
61
|
};
|
|
45
62
|
|
|
46
63
|
/**
|
|
@@ -50,22 +67,20 @@ export const WithManyOrganizations: Story = {
|
|
|
50
67
|
* - Key Aspect: Ensures that when there are 3 or fewer organizations, they are displayed in a list.
|
|
51
68
|
*/
|
|
52
69
|
export const WithFewOrganizations: Story = {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
/>
|
|
68
|
-
)
|
|
70
|
+
args: {
|
|
71
|
+
kcContext: {
|
|
72
|
+
url: {
|
|
73
|
+
loginAction: "/mock-login-action"
|
|
74
|
+
},
|
|
75
|
+
user: {
|
|
76
|
+
organizations: [
|
|
77
|
+
{ alias: "org1", name: "Organization 1" },
|
|
78
|
+
{ alias: "org2", name: "Organization 2" },
|
|
79
|
+
{ alias: "org3", name: "Organization 3" }
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
69
84
|
};
|
|
70
85
|
|
|
71
86
|
/**
|
|
@@ -75,16 +90,14 @@ export const WithFewOrganizations: Story = {
|
|
|
75
90
|
* - Key Aspect: Ensures that a single organization is displayed correctly.
|
|
76
91
|
*/
|
|
77
92
|
export const WithSingleOrganization: Story = {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
/>
|
|
89
|
-
)
|
|
93
|
+
args: {
|
|
94
|
+
kcContext: {
|
|
95
|
+
url: {
|
|
96
|
+
loginAction: "/mock-login-action"
|
|
97
|
+
},
|
|
98
|
+
user: {
|
|
99
|
+
organizations: [{ alias: "org1", name: "My Organization" }]
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
90
103
|
};
|
|
@@ -1,126 +1,123 @@
|
|
|
1
|
-
import { Button } from "@/components/ui/button";
|
|
2
|
-
import {
|
|
3
|
-
Select,
|
|
4
|
-
SelectContent,
|
|
5
|
-
SelectItem,
|
|
6
|
-
SelectTrigger,
|
|
7
|
-
SelectValue
|
|
8
|
-
} from "@/components/ui/select";
|
|
9
|
-
import { useI18n } from
|
|
10
|
-
import { useKcContext } from
|
|
11
|
-
import { Building2 } from "lucide-react";
|
|
12
|
-
import { MouseEvent, useRef, useState } from "react";
|
|
13
|
-
import { assert } from
|
|
14
|
-
import { Template } from "../../components/Template";
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const [
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
className="
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
</Template>
|
|
125
|
-
);
|
|
126
|
-
}
|
|
1
|
+
import { Button } from "@/components/ui/button";
|
|
2
|
+
import {
|
|
3
|
+
Select,
|
|
4
|
+
SelectContent,
|
|
5
|
+
SelectItem,
|
|
6
|
+
SelectTrigger,
|
|
7
|
+
SelectValue
|
|
8
|
+
} from "@/components/ui/select";
|
|
9
|
+
import { useI18n } from "@/login/i18n";
|
|
10
|
+
import { useKcContext } from "@/login/KcContext";
|
|
11
|
+
import { Building2 } from "lucide-react";
|
|
12
|
+
import { type MouseEvent, useRef, useState } from "react";
|
|
13
|
+
import { assert } from "tsafe/assert";
|
|
14
|
+
import { Template } from "../../components/Template";
|
|
15
|
+
|
|
16
|
+
export function Page() {
|
|
17
|
+
const { kcContext } = useKcContext();
|
|
18
|
+
assert(kcContext.pageId === "select-organization.ftl");
|
|
19
|
+
|
|
20
|
+
const { msg } = useI18n();
|
|
21
|
+
|
|
22
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
23
|
+
const [selectedOrg, setSelectedOrg] = useState<string>("");
|
|
24
|
+
const formRef = useRef<HTMLFormElement>(null);
|
|
25
|
+
const organizationInputRef = useRef<HTMLInputElement>(null);
|
|
26
|
+
|
|
27
|
+
const onOrganizationClick =
|
|
28
|
+
(organizationAlias: string) => (event: MouseEvent<HTMLButtonElement>) => {
|
|
29
|
+
event.preventDefault();
|
|
30
|
+
|
|
31
|
+
if (!organizationInputRef.current || !formRef.current) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
organizationInputRef.current.value = organizationAlias;
|
|
36
|
+
setIsSubmitting(true);
|
|
37
|
+
|
|
38
|
+
if (typeof formRef.current.requestSubmit === "function") {
|
|
39
|
+
formRef.current.requestSubmit();
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
formRef.current.submit();
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const onSelectChange = (value: string) => {
|
|
47
|
+
setSelectedOrg(value);
|
|
48
|
+
if (!organizationInputRef.current || !formRef.current) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
organizationInputRef.current.value = value;
|
|
53
|
+
setIsSubmitting(true);
|
|
54
|
+
|
|
55
|
+
if (typeof formRef.current.requestSubmit === "function") {
|
|
56
|
+
formRef.current.requestSubmit();
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
formRef.current.submit();
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const organizations = kcContext.user.organizations ?? [];
|
|
64
|
+
const useSelect = organizations.length > 3;
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<Template headerNode={msg("organization.selectTitle")}>
|
|
68
|
+
<form ref={formRef} action={kcContext.url.loginAction} method="post">
|
|
69
|
+
<div id="kc-user-organizations" className="space-y-2">
|
|
70
|
+
<h2 className="text-md font-semibold">
|
|
71
|
+
{msg("organization.select")}
|
|
72
|
+
</h2>
|
|
73
|
+
{useSelect ? (
|
|
74
|
+
<div className="space-y-2">
|
|
75
|
+
<Select
|
|
76
|
+
value={selectedOrg}
|
|
77
|
+
onValueChange={onSelectChange}
|
|
78
|
+
disabled={isSubmitting}
|
|
79
|
+
>
|
|
80
|
+
<SelectTrigger className="w-full">
|
|
81
|
+
<SelectValue
|
|
82
|
+
placeholder={msg("organization.pickPlaceholder")}
|
|
83
|
+
/>
|
|
84
|
+
</SelectTrigger>
|
|
85
|
+
<SelectContent>
|
|
86
|
+
{organizations.map(({ alias, name }) => (
|
|
87
|
+
<SelectItem key={alias} value={alias}>
|
|
88
|
+
<div className="flex items-center gap-2">
|
|
89
|
+
<Building2 className="w-4 h-4 text-muted-foreground" />
|
|
90
|
+
{name ?? alias}
|
|
91
|
+
</div>
|
|
92
|
+
</SelectItem>
|
|
93
|
+
))}
|
|
94
|
+
</SelectContent>
|
|
95
|
+
</Select>
|
|
96
|
+
</div>
|
|
97
|
+
) : (
|
|
98
|
+
<ul className="space-y-3">
|
|
99
|
+
{organizations.map(({ alias, name }) => (
|
|
100
|
+
<li key={alias}>
|
|
101
|
+
<Button
|
|
102
|
+
id={`organization-${alias}`}
|
|
103
|
+
type="button"
|
|
104
|
+
variant="outline"
|
|
105
|
+
onClick={onOrganizationClick(alias)}
|
|
106
|
+
disabled={isSubmitting}
|
|
107
|
+
className="w-full h-auto p-4 flex items-center gap-3 justify-start hover:bg-accent hover:border-primary transition-colors"
|
|
108
|
+
>
|
|
109
|
+
<Building2 className="w-5 h-5 text-muted-foreground shrink-0" />
|
|
110
|
+
<span className="font-medium text-sm">
|
|
111
|
+
{name ?? alias}
|
|
112
|
+
</span>
|
|
113
|
+
</Button>
|
|
114
|
+
</li>
|
|
115
|
+
))}
|
|
116
|
+
</ul>
|
|
117
|
+
)}
|
|
118
|
+
</div>
|
|
119
|
+
<input ref={organizationInputRef} type="hidden" name="kc.org" />
|
|
120
|
+
</form>
|
|
121
|
+
</Template>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Page } from "./Page";
|
|
2
|
-
|
|
3
|
-
export default Page;
|
|
1
|
+
import { Page } from "./Page";
|
|
2
|
+
|
|
3
|
+
export default Page;
|
|
@@ -23,6 +23,21 @@ export const Default: Story = {
|
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
+
export const Arabic: Story = {
|
|
27
|
+
args: {
|
|
28
|
+
kcContext: {
|
|
29
|
+
locale: {
|
|
30
|
+
currentLanguageTag: "ar",
|
|
31
|
+
rtl: true
|
|
32
|
+
},
|
|
33
|
+
"x-keycloakify": {
|
|
34
|
+
messages: {
|
|
35
|
+
termsText: "<p>شروطي باللغة <strong>العربية</strong></p>"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
26
41
|
export const French: Story = {
|
|
27
42
|
args: {
|
|
28
43
|
kcContext: {
|