@keycloakify/keycloak-account-ui 25.0.1-rc.8 → 25.0.2-rc.0
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/KcAccountUiLoader.js +19 -5
- package/KcAccountUiLoader.js.map +1 -1
- package/README.md +10 -10
- package/package.json +6 -6
- package/public/content.d.ts +1 -1
- package/public/content.js +1 -1
- package/public/content.js.map +1 -1
- package/root/PageNav.d.ts +2 -3
- package/root/PageNav.js +8 -5
- package/root/PageNav.js.map +1 -1
- package/src/KcAccountUiLoader.tsx +30 -14
- package/src/public/content.ts +1 -1
- package/src/root/PageNav.tsx +10 -7
package/KcAccountUiLoader.js
CHANGED
|
@@ -15,7 +15,7 @@ import { assert } from "tsafe/assert";
|
|
|
15
15
|
import { is } from "tsafe/is";
|
|
16
16
|
import { joinPath } from "./utils/joinPath";
|
|
17
17
|
import defaultContent from "./public/content";
|
|
18
|
-
import defaultLogoSvgUrl from "
|
|
18
|
+
import defaultLogoSvgUrl from "@keycloakify/keycloak-account-ui/public/logo.svg";
|
|
19
19
|
export function KcAccountUiLoader(props) {
|
|
20
20
|
const { KcAccountUi, loadingFallback } = props, paramsOfInit = __rest(props, ["KcAccountUi", "loadingFallback"]);
|
|
21
21
|
assert(is(KcAccountUi));
|
|
@@ -33,7 +33,7 @@ function init(params) {
|
|
|
33
33
|
var _a, _b;
|
|
34
34
|
exit_condition: {
|
|
35
35
|
const paramsFingerprint = JSON.stringify(params);
|
|
36
|
-
if (
|
|
36
|
+
if (previousRunParamsFingerprint === undefined) {
|
|
37
37
|
previousRunParamsFingerprint = paramsFingerprint;
|
|
38
38
|
break exit_condition;
|
|
39
39
|
}
|
|
@@ -43,21 +43,35 @@ function init(params) {
|
|
|
43
43
|
}
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
|
-
const { content = defaultContent, kcContext, logoUrl = defaultLogoSvgUrl, } = params;
|
|
47
46
|
{
|
|
48
47
|
const url = new URL(window.location.href);
|
|
49
48
|
url.searchParams.delete("referrer");
|
|
50
49
|
url.searchParams.delete("referrer_uri");
|
|
51
50
|
window.history.replaceState({}, "", url.toString());
|
|
52
51
|
}
|
|
52
|
+
const { content = defaultContent, kcContext } = params;
|
|
53
|
+
const logoUrl = (() => {
|
|
54
|
+
var _a;
|
|
55
|
+
const logoUrl_params = (_a = params.logoUrl) !== null && _a !== void 0 ? _a : defaultLogoSvgUrl;
|
|
56
|
+
const url = new URL(logoUrl_params.startsWith("http")
|
|
57
|
+
? logoUrl_params
|
|
58
|
+
: joinPath(window.location.origin, logoUrl_params));
|
|
59
|
+
return url.href.substring(url.origin.length);
|
|
60
|
+
})();
|
|
61
|
+
const resourceUrl = kcContext.resourceUrl;
|
|
62
|
+
if (!logoUrl.startsWith(resourceUrl)) {
|
|
63
|
+
const error = new Error(`ERROR: The logo url can't be an external url.`);
|
|
64
|
+
alert(error.message);
|
|
65
|
+
throw error;
|
|
66
|
+
}
|
|
53
67
|
const environment = {
|
|
54
68
|
serverBaseUrl: kcContext.serverBaseUrl,
|
|
55
69
|
authUrl: kcContext.authUrl,
|
|
56
70
|
authServerUrl: kcContext.authServerUrl,
|
|
57
71
|
realm: kcContext.realm.name,
|
|
58
72
|
clientId: kcContext.clientId,
|
|
59
|
-
resourceUrl
|
|
60
|
-
logo:
|
|
73
|
+
resourceUrl,
|
|
74
|
+
logo: logoUrl.substring(resourceUrl.length),
|
|
61
75
|
logoUrl: logoUrl,
|
|
62
76
|
baseUrl: `${kcContext.baseUrl.scheme}:${kcContext.baseUrl.rawSchemeSpecificPart}`,
|
|
63
77
|
locale: kcContext.locale,
|
package/KcAccountUiLoader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KcAccountUiLoader.js","sourceRoot":"","sources":["src/KcAccountUiLoader.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAA4B,MAAM,OAAO,CAAC;AACpE,OAAO,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gBAAgB;SAC7C;KACF,CAAC;IAEF,CAAC;QACC,MAAM,EAAyD,CAAC;QAEhE,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAChD,MAAM,CAAC,EAAE,GAAG,aAAa,CAAC;QAC1B,MAAM,CAAC,IAAI,GAAG,kBAAkB,CAAC;QACjC,MAAM,CAAC,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAE1D,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC;IAE/B,MAAM,CAAC,KAAK,GAAG,KAAK,UAAU,KAAK,CAAC,GAAG,IAAI;QACzC,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;QAEnB,IAAI,GAAG,KAAK,QAAQ,CAAC,WAAW,CAAC,WAAW,EAAE,eAAe,CAAC,EAAE,CAAC;YAC/D,OAAO;gBACL,IAAI,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC;aACzB,CAAC;QAChB,CAAC;QAED,OAAO,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC;IAC5B,CAAC,CAAC;AACJ,CAAC"}
|
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<a href="https://github.com/keycloakify/keycloak-account-ui/actions">
|
|
9
9
|
<img src="https://github.com/keycloakify/keycloak-account-ui/actions/workflows/ci.yaml/badge.svg?branch=main">
|
|
10
10
|
</a>
|
|
11
|
-
<a href="https://www.npmjs.com/package/@keycloakify/keycloak-account-ui/v/25.0.
|
|
11
|
+
<a href="https://www.npmjs.com/package/@keycloakify/keycloak-account-ui/v/25.0.2-rc.0">
|
|
12
12
|
<img src="https://img.shields.io/npm/dm/@keycloakify/keycloak-account-ui">
|
|
13
13
|
</a>
|
|
14
14
|
<p align="center">
|
|
@@ -26,19 +26,19 @@ All credits goes to the keycloak team for the original work. Mainly [@jonkoops
|
|
|
26
26
|
This re-packaged distribution exists to make it possible to take ownership of
|
|
27
27
|
some specific part of the Account UI to create your own custom version of it.
|
|
28
28
|
In straight forward therms it make the Account UI ejectable, you can copy
|
|
29
|
-
past [the source files](https://unpkg.com/browse/@keycloakify/keycloak-account-ui@25.0.
|
|
29
|
+
past [the source files](https://unpkg.com/browse/@keycloakify/keycloak-account-ui@25.0.2-rc.0/src/) that you want to modify into your codebase.
|
|
30
30
|
|
|
31
31
|
For more details on integrating this package into your project, refer to the [Keycloakify documentation](https://keycloakify.dev).
|
|
32
32
|
|
|
33
33
|
> **Note:** This package's GitHub repository does not contain any code as it is automatically generated at build time by [scripts/prepare.ts](/scripts/prepare.ts).
|
|
34
|
-
> You can browse the sources includes int the NPM package [here](https://unpkg.com/browse/@keycloakify/keycloak-account-ui@25.0.
|
|
34
|
+
> You can browse the sources includes int the NPM package [here](https://unpkg.com/browse/@keycloakify/keycloak-account-ui@25.0.2-rc.0/src/).
|
|
35
35
|
|
|
36
36
|
## Installation
|
|
37
37
|
|
|
38
38
|
> **Note:** This README file is automatically generated at build so the information above are guaranteed to be up to date.
|
|
39
|
-
> You are currently viewing the README of [`@keycloakify/keycloak-account-ui@25.0.
|
|
40
|
-
> mirrors [`@keycloak/keycloak-account-ui@25.0.
|
|
41
|
-
> It is the version of the Account UI that ships with [**Keycloak 25.0.
|
|
39
|
+
> You are currently viewing the README of [`@keycloakify/keycloak-account-ui@25.0.2-rc.0`](https://www.npmjs.com/package/@keycloakify/keycloak-account-ui/v/25.0.2-rc.0) that
|
|
40
|
+
> mirrors [`@keycloak/keycloak-account-ui@25.0.2`](https://www.npmjs.com/package/@keycloak/keycloak-account-ui/v/25.0.2).
|
|
41
|
+
> It is the version of the Account UI that ships with [**Keycloak 25.0.2**](https://github.com/keycloak/keycloak/tree/25.0.2/js/apps/account-ui).
|
|
42
42
|
|
|
43
43
|
Here are all the dependencies that are required to use the Account UI in your project.
|
|
44
44
|
It's important to respect the exact version range listed here to avoid any compatibility issues.
|
|
@@ -48,7 +48,7 @@ It's important to respect the exact version range listed here to avoid any compa
|
|
|
48
48
|
```json
|
|
49
49
|
{
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@keycloakify/keycloak-account-ui": "25.0.
|
|
51
|
+
"@keycloakify/keycloak-account-ui": "25.0.2-rc.0",
|
|
52
52
|
"@patternfly/patternfly": "^5.3.1",
|
|
53
53
|
"@patternfly/react-core": "^5.3.3",
|
|
54
54
|
"@patternfly/react-icons": "^5.3.2",
|
|
@@ -59,9 +59,9 @@ It's important to respect the exact version range listed here to avoid any compa
|
|
|
59
59
|
"react-hook-form": "7.51.5",
|
|
60
60
|
"react-i18next": "^14.1.2",
|
|
61
61
|
"react-router-dom": "^6.23.1",
|
|
62
|
-
"keycloak-js": "25.0.
|
|
62
|
+
"keycloak-js": "25.0.2",
|
|
63
63
|
"@patternfly/react-styles": "^5.3.1",
|
|
64
|
-
"@keycloak/keycloak-admin-client": "25.0.
|
|
64
|
+
"@keycloak/keycloak-admin-client": "25.0.2"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@types/lodash-es": "^4.17.12"
|
|
@@ -72,4 +72,4 @@ It's important to respect the exact version range listed here to avoid any compa
|
|
|
72
72
|
## Ejecting
|
|
73
73
|
|
|
74
74
|
You can take partial ownership of some parts of the Account UI by copy pasting the sources files you want to modify into your codebase.
|
|
75
|
-
You can browse the sources files **[here](https://unpkg.com/browse/@keycloakify/keycloak-account-ui@25.0.
|
|
75
|
+
You can browse the sources files **[here](https://unpkg.com/browse/@keycloakify/keycloak-account-ui@25.0.2-rc.0/src/)**.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keycloakify/keycloak-account-ui",
|
|
3
|
-
"version": "25.0.
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "25.0.2-rc.0",
|
|
4
|
+
"description": "Repackaged Keycloak Account UI",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git://github.com/keycloakify/keycloak-account-ui.git"
|
|
@@ -397,9 +397,9 @@
|
|
|
397
397
|
"react-hook-form": "7.51.5",
|
|
398
398
|
"react-i18next": "^14.1.2",
|
|
399
399
|
"react-router-dom": "^6.23.1",
|
|
400
|
-
"keycloak-js": "25.0.
|
|
400
|
+
"keycloak-js": "25.0.2",
|
|
401
401
|
"@patternfly/react-styles": "^5.3.1",
|
|
402
|
-
"@keycloak/keycloak-admin-client": "25.0.
|
|
402
|
+
"@keycloak/keycloak-admin-client": "25.0.2"
|
|
403
403
|
},
|
|
404
404
|
"devDependencies": {
|
|
405
405
|
"react": "^18.3.1",
|
|
@@ -431,9 +431,9 @@
|
|
|
431
431
|
"react-hook-form": "7.51.5",
|
|
432
432
|
"react-i18next": "^14.1.2",
|
|
433
433
|
"react-router-dom": "^6.23.1",
|
|
434
|
-
"keycloak-js": "25.0.
|
|
434
|
+
"keycloak-js": "25.0.2",
|
|
435
435
|
"@patternfly/react-styles": "^5.3.1",
|
|
436
|
-
"@keycloak/keycloak-admin-client": "25.0.
|
|
436
|
+
"@keycloak/keycloak-admin-client": "25.0.2"
|
|
437
437
|
},
|
|
438
438
|
"dependencies": {
|
|
439
439
|
"tsafe": "^1.7.2"
|
package/public/content.d.ts
CHANGED
package/public/content.js
CHANGED
package/public/content.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content.js","sourceRoot":"","sources":["../src/public/content.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;IACd;QACE,OAAO,EAAE,cAAc;QACvB,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"content.js","sourceRoot":"","sources":["../src/public/content.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;IACd;QACE,OAAO,EAAE,cAAc;QACvB,MAAM,EAAE,EAAE;KACX;IACD;QACE,OAAO,EAAE,iBAAiB;QAC1B,UAAU,EAAE;YACV;gBACE,OAAO,EAAE,WAAW;gBACpB,MAAM,EAAE,6BAA6B;aACtC;YACD;gBACE,OAAO,EAAE,gBAAgB;gBACzB,MAAM,EAAE,kCAAkC;aAC3C;YACD;gBACE,OAAO,EAAE,gBAAgB;gBACzB,MAAM,EAAE,kCAAkC;gBAC1C,WAAW,EAAE,yBAAyB;aACvC;SACF;KACF;IACD;QACE,OAAO,EAAE,cAAc;QACvB,MAAM,EAAE,cAAc;KACvB;IACD;QACE,OAAO,EAAE,QAAQ;QACjB,MAAM,EAAE,QAAQ;QAChB,WAAW,EAAE,qBAAqB;KACnC;IACD;QACE,OAAO,EAAE,WAAW;QACpB,MAAM,EAAE,WAAW;QACnB,WAAW,EAAE,sBAAsB;KACpC;IACD;QACE,OAAO,EAAE,SAAS;QAClB,MAAM,EAAE,SAAS;QACjB,WAAW,EAAE,kBAAkB;KAChC;CACO,CAAC;AACX,eAAe,OAAO,CAAC"}
|
package/root/PageNav.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { PropsWithChildren } from "react";
|
|
2
|
-
import { To } from "react-router-dom";
|
|
3
2
|
import { type Feature } from "../environment";
|
|
4
3
|
import { TFuncKey } from "../i18n";
|
|
5
4
|
type RootMenuItem = {
|
|
@@ -16,8 +15,8 @@ type MenuItemWithChildren = {
|
|
|
16
15
|
export type MenuItem = RootMenuItem | MenuItemWithChildren;
|
|
17
16
|
export declare const PageNav: () => import("react/jsx-runtime").JSX.Element;
|
|
18
17
|
type NavLinkProps = {
|
|
19
|
-
|
|
18
|
+
path: string;
|
|
20
19
|
isActive: boolean;
|
|
21
20
|
};
|
|
22
|
-
export declare const NavLink: ({
|
|
21
|
+
export declare const NavLink: ({ path, isActive, children, }: PropsWithChildren<NavLinkProps>) => import("react/jsx-runtime").JSX.Element;
|
|
23
22
|
export {};
|
package/root/PageNav.js
CHANGED
|
@@ -21,23 +21,26 @@ function NavMenuItem({ menuItem }) {
|
|
|
21
21
|
const { pathname } = useLocation();
|
|
22
22
|
const isActive = useMemo(() => matchMenuItem(pathname, menuItem), [pathname, menuItem]);
|
|
23
23
|
if ("path" in menuItem) {
|
|
24
|
-
return (_jsx(NavLink, {
|
|
24
|
+
return (_jsx(NavLink, { path: menuItem.path, isActive: isActive, children: t(menuItem.label) }));
|
|
25
25
|
}
|
|
26
26
|
return (_jsx(NavExpandable, { "data-testid": menuItem.label, title: t(menuItem.label), isActive: isActive, isExpanded: isActive, children: menuItem.children
|
|
27
27
|
.filter((menuItem) => menuItem.isVisible ? features[menuItem.isVisible] : true)
|
|
28
28
|
.map((child) => (_jsx(NavMenuItem, { menuItem: child }, child.label))) }));
|
|
29
29
|
}
|
|
30
|
+
function getFullUrl(path) {
|
|
31
|
+
return `${new URL(environment.baseUrl).pathname}${path}`;
|
|
32
|
+
}
|
|
30
33
|
function matchMenuItem(currentPath, menuItem) {
|
|
31
34
|
if ("path" in menuItem) {
|
|
32
|
-
return !!matchPath(menuItem.path, currentPath);
|
|
35
|
+
return !!matchPath(getFullUrl(menuItem.path), currentPath);
|
|
33
36
|
}
|
|
34
37
|
return menuItem.children.some((child) => matchMenuItem(currentPath, child));
|
|
35
38
|
}
|
|
36
|
-
export const NavLink = ({
|
|
37
|
-
const menuItemPath =
|
|
39
|
+
export const NavLink = ({ path, isActive, children, }) => {
|
|
40
|
+
const menuItemPath = getFullUrl(path);
|
|
38
41
|
const href = useHref(menuItemPath);
|
|
39
42
|
const handleClick = useLinkClickHandler(menuItemPath);
|
|
40
|
-
return (_jsx(NavItem, { "data-testid":
|
|
43
|
+
return (_jsx(NavItem, { "data-testid": path, to: href, isActive: isActive, onClick: (event) =>
|
|
41
44
|
// PatternFly does not have the correct type for this event, so we need to cast it.
|
|
42
45
|
handleClick(event), children: children }));
|
|
43
46
|
};
|
package/root/PageNav.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PageNav.js","sourceRoot":"","sources":["../src/root/PageNav.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAC5E,OAAO,EACL,GAAG,EACH,aAAa,EACb,OAAO,EACP,OAAO,EACP,WAAW,EACX,eAAe,EACf,OAAO,GACR,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAGL,QAAQ,EACR,OAAO,EACP,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,
|
|
1
|
+
{"version":3,"file":"PageNav.js","sourceRoot":"","sources":["../src/root/PageNav.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAC5E,OAAO,EACL,GAAG,EACH,aAAa,EACb,OAAO,EACP,OAAO,EACP,WAAW,EACX,eAAe,EACf,OAAO,GACR,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAGL,QAAQ,EACR,OAAO,EACP,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EACL,SAAS,EACT,OAAO,EACP,mBAAmB,EACnB,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAE1B,OAAO,gBAAgB,MAAM,uDAAuD,CAAC;AACrF,OAAO,EAAE,WAAW,EAAkC,MAAM,8CAA8C,CAAC;AAE3G,OAAO,EAAE,UAAU,EAAE,MAAM,mDAAmD,CAAC;AAiB/E,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,EAAE;IAC1B,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,EAAc,CAAC;IACzD,MAAM,OAAO,GAAG,cAAc,EAAe,CAAC;IAE9C,UAAU,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,YAAY,CAAC,CAAC;IAC5E,OAAO,C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EAAE,CAAC,KAAK,EAAE,EAAE;QACjB,mFAAmF;QACnF,WAAW,CAAC,KAAsD,CAAC,YAGpE,QAAQ,GACD,CACX,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Suspense, useMemo, type LazyExoticComponent } from "react";
|
|
2
2
|
import { assert } from "tsafe/assert";
|
|
3
3
|
import { is } from "tsafe/is";
|
|
4
|
-
import type { Environment } from "
|
|
5
|
-
import type { MenuItem } from "
|
|
6
|
-
import { joinPath } from "
|
|
7
|
-
import defaultContent from "
|
|
8
|
-
import defaultLogoSvgUrl from "
|
|
4
|
+
import type { Environment } from "@keycloakify/keycloak-account-ui/environment";
|
|
5
|
+
import type { MenuItem } from "@keycloakify/keycloak-account-ui/root/PageNav";
|
|
6
|
+
import { joinPath } from "@keycloakify/keycloak-account-ui/utils/joinPath";
|
|
7
|
+
import defaultContent from "@keycloakify/keycloak-account-ui/public/content";
|
|
8
|
+
import defaultLogoSvgUrl from "@keycloakify/keycloak-account-ui/public/logo.svg";
|
|
9
9
|
|
|
10
10
|
export type KcContextLike = {
|
|
11
11
|
serverBaseUrl: string;
|
|
@@ -78,7 +78,7 @@ function init(
|
|
|
78
78
|
exit_condition: {
|
|
79
79
|
const paramsFingerprint = JSON.stringify(params);
|
|
80
80
|
|
|
81
|
-
if (
|
|
81
|
+
if (previousRunParamsFingerprint === undefined) {
|
|
82
82
|
previousRunParamsFingerprint = paramsFingerprint;
|
|
83
83
|
break exit_condition;
|
|
84
84
|
}
|
|
@@ -91,12 +91,6 @@ function init(
|
|
|
91
91
|
return;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
const {
|
|
95
|
-
content = defaultContent,
|
|
96
|
-
kcContext,
|
|
97
|
-
logoUrl = defaultLogoSvgUrl,
|
|
98
|
-
} = params;
|
|
99
|
-
|
|
100
94
|
{
|
|
101
95
|
const url = new URL(window.location.href);
|
|
102
96
|
|
|
@@ -106,14 +100,36 @@ function init(
|
|
|
106
100
|
window.history.replaceState({}, "", url.toString());
|
|
107
101
|
}
|
|
108
102
|
|
|
103
|
+
const { content = defaultContent, kcContext } = params;
|
|
104
|
+
|
|
105
|
+
const logoUrl = (() => {
|
|
106
|
+
const logoUrl_params = params.logoUrl ?? defaultLogoSvgUrl;
|
|
107
|
+
|
|
108
|
+
const url = new URL(
|
|
109
|
+
logoUrl_params.startsWith("http")
|
|
110
|
+
? logoUrl_params
|
|
111
|
+
: joinPath(window.location.origin, logoUrl_params),
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
return url.href.substring(url.origin.length);
|
|
115
|
+
})();
|
|
116
|
+
|
|
117
|
+
const resourceUrl = kcContext.resourceUrl;
|
|
118
|
+
|
|
119
|
+
if (!logoUrl.startsWith(resourceUrl)) {
|
|
120
|
+
const error = new Error(`ERROR: The logo url can't be an external url.`);
|
|
121
|
+
alert(error.message);
|
|
122
|
+
throw error;
|
|
123
|
+
}
|
|
124
|
+
|
|
109
125
|
const environment = {
|
|
110
126
|
serverBaseUrl: kcContext.serverBaseUrl,
|
|
111
127
|
authUrl: kcContext.authUrl,
|
|
112
128
|
authServerUrl: kcContext.authServerUrl,
|
|
113
129
|
realm: kcContext.realm.name,
|
|
114
130
|
clientId: kcContext.clientId,
|
|
115
|
-
resourceUrl
|
|
116
|
-
logo:
|
|
131
|
+
resourceUrl,
|
|
132
|
+
logo: logoUrl.substring(resourceUrl.length),
|
|
117
133
|
logoUrl: logoUrl,
|
|
118
134
|
baseUrl: `${kcContext.baseUrl.scheme}:${kcContext.baseUrl.rawSchemeSpecificPart}`,
|
|
119
135
|
locale: kcContext.locale,
|
package/src/public/content.ts
CHANGED
package/src/root/PageNav.tsx
CHANGED
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
} from "react";
|
|
18
18
|
import { useTranslation } from "react-i18next";
|
|
19
19
|
import {
|
|
20
|
-
To,
|
|
21
20
|
matchPath,
|
|
22
21
|
useHref,
|
|
23
22
|
useLinkClickHandler,
|
|
@@ -92,7 +91,7 @@ function NavMenuItem({ menuItem }: NavMenuItemProps) {
|
|
|
92
91
|
|
|
93
92
|
if ("path" in menuItem) {
|
|
94
93
|
return (
|
|
95
|
-
<NavLink
|
|
94
|
+
<NavLink path={menuItem.path} isActive={isActive}>
|
|
96
95
|
{t(menuItem.label)}
|
|
97
96
|
</NavLink>
|
|
98
97
|
);
|
|
@@ -116,31 +115,35 @@ function NavMenuItem({ menuItem }: NavMenuItemProps) {
|
|
|
116
115
|
);
|
|
117
116
|
}
|
|
118
117
|
|
|
118
|
+
function getFullUrl(path: string) {
|
|
119
|
+
return `${new URL(environment.baseUrl).pathname}${path}`;
|
|
120
|
+
}
|
|
121
|
+
|
|
119
122
|
function matchMenuItem(currentPath: string, menuItem: MenuItem): boolean {
|
|
120
123
|
if ("path" in menuItem) {
|
|
121
|
-
return !!matchPath(menuItem.path, currentPath);
|
|
124
|
+
return !!matchPath(getFullUrl(menuItem.path), currentPath);
|
|
122
125
|
}
|
|
123
126
|
|
|
124
127
|
return menuItem.children.some((child) => matchMenuItem(currentPath, child));
|
|
125
128
|
}
|
|
126
129
|
|
|
127
130
|
type NavLinkProps = {
|
|
128
|
-
|
|
131
|
+
path: string;
|
|
129
132
|
isActive: boolean;
|
|
130
133
|
};
|
|
131
134
|
|
|
132
135
|
export const NavLink = ({
|
|
133
|
-
|
|
136
|
+
path,
|
|
134
137
|
isActive,
|
|
135
138
|
children,
|
|
136
139
|
}: PropsWithChildren<NavLinkProps>) => {
|
|
137
|
-
const menuItemPath =
|
|
140
|
+
const menuItemPath = getFullUrl(path);
|
|
138
141
|
const href = useHref(menuItemPath);
|
|
139
142
|
const handleClick = useLinkClickHandler(menuItemPath);
|
|
140
143
|
|
|
141
144
|
return (
|
|
142
145
|
<NavItem
|
|
143
|
-
data-testid={
|
|
146
|
+
data-testid={path}
|
|
144
147
|
to={href}
|
|
145
148
|
isActive={isActive}
|
|
146
149
|
onClick={(event) =>
|