Fix syncronization with non react pages

This commit is contained in:
Joseph Garrone 2021-03-05 19:50:08 +01:00
parent a69bee8726
commit 06ab2ab82e
7 changed files with 47 additions and 51 deletions

View File

@ -56,7 +56,7 @@
"cheerio": "^1.0.0-rc.5", "cheerio": "^1.0.0-rc.5",
"evt": "2.0.0-beta.15", "evt": "2.0.0-beta.15",
"minimal-polyfills": "^2.1.6", "minimal-polyfills": "^2.1.6",
"powerhooks": "^0.0.14", "powerhooks": "^0.0.17",
"tss-react": "^0.0.9" "tss-react": "^0.0.9"
} }
} }

View File

@ -90,11 +90,6 @@ export function generateKeycloakThemeResources(
"destDirPath": tmpDirPath "destDirPath": tmpDirPath
}); });
transformCodebase({
"srcDirPath": pathJoin(tmpDirPath, "keycloak", "common"),
"destDirPath": pathJoin(tmpDirPath, "..", "common")
});
transformCodebase({ transformCodebase({
"srcDirPath": pathJoin(tmpDirPath, "keycloak", "login", "resources"), "srcDirPath": pathJoin(tmpDirPath, "keycloak", "login", "resources"),
"destDirPath": pathJoin(themeDirPath, "resources") "destDirPath": pathJoin(themeDirPath, "resources")
@ -106,10 +101,7 @@ export function generateKeycloakThemeResources(
fs.writeFileSync( fs.writeFileSync(
pathJoin(themeDirPath, "theme.properties"), pathJoin(themeDirPath, "theme.properties"),
Buffer.from([ Buffer.from("parent=keycloak", "utf8")
`import=common/${themeName}`,
"locales=ca,cs,de,en,es,fr,it,ja,lt,nl,no,pl,pt-BR,ru,sk,sv,tr,zh-CN"
].join("\n"), "utf8")
); );
} }

View File

@ -44,7 +44,7 @@ export const Template = memo((props: TemplateProps) => {
displayInfoNode = null displayInfoNode = null
} = props; } = props;
console.log("Rendering this page with react using keycloak-react-theming"); useEffect(()=> { console.log("Rendering this page with react using keycloak-react-theming") },[]);
const { t } = useKcTranslation(); const { t } = useKcTranslation();
@ -138,9 +138,9 @@ export const Template = memo((props: TemplateProps) => {
<ul> <ul>
{ {
locale.supported.map( locale.supported.map(
({ languageTag }) => ({ languageTag, url }) =>
<li className="kc-dropdown-item"> <li className="kc-dropdown-item">
<a href="#" onClick={onChangeLanguageClickFactory(languageTag)}> <a href={url} onClick={onChangeLanguageClickFactory(languageTag)}>
{getKcLanguageTagLabel(languageTag)} {getKcLanguageTagLabel(languageTag)}
</a> </a>

View File

@ -55,12 +55,16 @@ export function getBestMatchAmongKcLanguageTag(
const iso2LanguageLike = languageLike.split("-")[0].toLowerCase(); const iso2LanguageLike = languageLike.split("-")[0].toLowerCase();
const language = availableLanguages.find(language => const kcLanguageTag = availableLanguages.find(language =>
language.toLowerCase().includes(iso2LanguageLike) || language.toLowerCase().includes(iso2LanguageLike) ||
getKcLanguageTagLabel(language).toLocaleLowerCase() === languageLike.toLocaleLowerCase() getKcLanguageTagLabel(language).toLocaleLowerCase() === languageLike.toLocaleLowerCase()
); );
if (language === undefined && languageLike !== navigator.language) { if (kcLanguageTag !== undefined) {
return kcLanguageTag;
}
if (languageLike !== navigator.language) {
return getBestMatchAmongKcLanguageTag(navigator.language); return getBestMatchAmongKcLanguageTag(navigator.language);
} }

View File

@ -9,5 +9,5 @@ export const { useKcLanguageTag } = createUseGlobalState(
kcContext?.locale?.["current" as never] ?? kcContext?.locale?.["current" as never] ??
navigator.language navigator.language
), ),
{ "persistance": "cookies" } { "persistance": "cookie" }
); );

View File

@ -27,7 +27,7 @@ export declare namespace KcContext {
/** Undefined if !realm.internationalizationEnabled */ /** Undefined if !realm.internationalizationEnabled */
locale?: { locale?: {
supported: { supported: {
//url: string; url: string;
languageTag: KcLanguageTag; languageTag: KcLanguageTag;
/** Is determined by languageTag. Ex: languageTag === "en" => label === "English" /** Is determined by languageTag. Ex: languageTag === "en" => label === "English"
* or getLanguageLabel(languageTag) === label * or getLanguageLabel(languageTag) === label

View File

@ -43,9 +43,9 @@
"@babel/helper-plugin-utils" "^7.12.13" "@babel/helper-plugin-utils" "^7.12.13"
"@babel/runtime@^7.7.2": "@babel/runtime@^7.7.2":
version "7.13.8" version "7.13.9"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.13.8.tgz#cc886a85c072df1de23670dc1aa59fc116c4017c" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.13.9.tgz#97dbe2116e2630c489f22e0656decd60aaa1fcee"
integrity sha512-CwQljpw6qSayc0fRG1soxHAKs1CnQMOChm4mlQP6My0kf9upVGizj/KhlTTgyUnETmHpcUXjaluNAkteRFuafg== integrity sha512-aY2kU+xgJ3dJ1eU6FMB9EH8dIe8dmusF1xEku52joLvw6eAFN0AI+WxCLDnpev2LEejWBAy2sBvBOBAjI3zmvA==
dependencies: dependencies:
regenerator-runtime "^0.13.4" regenerator-runtime "^0.13.4"
@ -176,10 +176,10 @@
"@octokit/types" "^6.0.3" "@octokit/types" "^6.0.3"
universal-user-agent "^6.0.0" universal-user-agent "^6.0.0"
"@octokit/openapi-types@^5.2.0": "@octokit/openapi-types@^5.3.0":
version "5.2.0" version "5.3.0"
resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-5.2.0.tgz#54e6ca0bc2cd54cd93f0a64658e893c32a5e69ec" resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-5.3.0.tgz#29e3faa119da90082dc653ea74c8bb345d197bf7"
integrity sha512-MInMij2VK5o96Ei6qaHjxBglSZWOXQs9dTZfnGX2Xnr2mhA+yk9L/QCH4RcJGISJJCBclLHuY3ytq+iRgDfX7w== integrity sha512-5q2qBz4iZ0xS/DEJ0ROusFbN4cVlbJE9GvOByen+mv7artuGXfVhONqcuRd7jYN2glTmCnzcZw+X6LrjRVqs0A==
"@octokit/plugin-paginate-rest@^2.6.2": "@octokit/plugin-paginate-rest@^2.6.2":
version "2.11.0" version "2.11.0"
@ -193,12 +193,12 @@
resolved "https://registry.yarnpkg.com/@octokit/plugin-request-log/-/plugin-request-log-1.0.3.tgz#70a62be213e1edc04bb8897ee48c311482f9700d" resolved "https://registry.yarnpkg.com/@octokit/plugin-request-log/-/plugin-request-log-1.0.3.tgz#70a62be213e1edc04bb8897ee48c311482f9700d"
integrity sha512-4RFU4li238jMJAzLgAwkBAw+4Loile5haQMQr+uhFq27BmyJXcXSKvoQKqh0agsZEiUlW6iSv3FAgvmGkur7OQ== integrity sha512-4RFU4li238jMJAzLgAwkBAw+4Loile5haQMQr+uhFq27BmyJXcXSKvoQKqh0agsZEiUlW6iSv3FAgvmGkur7OQ==
"@octokit/plugin-rest-endpoint-methods@4.13.0": "@octokit/plugin-rest-endpoint-methods@4.13.3":
version "4.13.0" version "4.13.3"
resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-4.13.0.tgz#59a90f59a564d416214ab191c3ffcd641f175e6a" resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-4.13.3.tgz#17ba3a24adce0933129cfefa6d44e7da2eeac04b"
integrity sha512-Ofusy7BwHkU7z4TNsVdf7wm5W3KR625KqlQj4AiWPnBvclmZU0Y2bVK8b8Mz8nW7sEX9TJcCdX6KeaincE/cLw== integrity sha512-nMGS2osFcWXRfHkDR0d+lB1zpMPTZJ0NjysPUfs7BT5/juNG/Q0+5UB6nC1f62jPzun154qekzwOb7Q5oahCXQ==
dependencies: dependencies:
"@octokit/types" "^6.11.0" "@octokit/types" "^6.12.0"
deprecation "^2.3.1" deprecation "^2.3.1"
"@octokit/request-error@^2.0.0": "@octokit/request-error@^2.0.0":
@ -225,21 +225,21 @@
universal-user-agent "^6.0.0" universal-user-agent "^6.0.0"
"@octokit/rest@^18.0.0": "@octokit/rest@^18.0.0":
version "18.3.0" version "18.3.3"
resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-18.3.0.tgz#c326475a2039ffeaec9a1498ebee14a561aae4e5" resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-18.3.3.tgz#a3b0f24bf5c42cacd93dbc48576b5d4d4e032a38"
integrity sha512-R45oBVhnq3HAOGVtC6lHY7LX7TGWqbbcD4KvBHoT4QIjgJzfqKag3m/DUJwLnp8xrokz1spZmspTIXiDeQqJSA== integrity sha512-OxElwBanZn1AShCaIrRTLM9PwhGE5/busMke/go30OWAQ+eJMD7Us/67mtapE77EYY4FM2tvb4Eg25rZaA/NPA==
dependencies: dependencies:
"@octokit/core" "^3.2.3" "@octokit/core" "^3.2.3"
"@octokit/plugin-paginate-rest" "^2.6.2" "@octokit/plugin-paginate-rest" "^2.6.2"
"@octokit/plugin-request-log" "^1.0.2" "@octokit/plugin-request-log" "^1.0.2"
"@octokit/plugin-rest-endpoint-methods" "4.13.0" "@octokit/plugin-rest-endpoint-methods" "4.13.3"
"@octokit/types@^6.0.3", "@octokit/types@^6.11.0", "@octokit/types@^6.7.1": "@octokit/types@^6.0.3", "@octokit/types@^6.11.0", "@octokit/types@^6.12.0", "@octokit/types@^6.7.1":
version "6.11.0" version "6.12.0"
resolved "https://registry.yarnpkg.com/@octokit/types/-/types-6.11.0.tgz#830a608882cde659be19a6e86568abaa619e2ee7" resolved "https://registry.yarnpkg.com/@octokit/types/-/types-6.12.0.tgz#8376fd60edfd5d1eebfeedb994c6bcb5b862c7a1"
integrity sha512-RMLAmpPZf/a33EsclBazKg02NCCj4rC69V9sUgf0SuWTjmnBD2QC1nIVtJo7RJrGnwG1+aoFBb2yTrWm/8AS7w== integrity sha512-KwOf16soD7aDEEi/PgNeJlHzjZPfrmmNy+7WezSdrpnqZ7YImBJcNnX9+5RUHt1MnA4h8oISRHTqaZDGsX9DRQ==
dependencies: dependencies:
"@octokit/openapi-types" "^5.2.0" "@octokit/openapi-types" "^5.3.0"
"@types/comment-json@^1.1.1": "@types/comment-json@^1.1.1":
version "1.1.1" version "1.1.1"
@ -615,10 +615,10 @@ event-emitter@^0.3.5:
d "1" d "1"
es5-ext "~0.10.14" es5-ext "~0.10.14"
evt@2.0.0-beta.12: evt@2.0.0-beta.13:
version "2.0.0-beta.12" version "2.0.0-beta.13"
resolved "https://registry.yarnpkg.com/evt/-/evt-2.0.0-beta.12.tgz#d24724ea4c70e78af3eb73dbbf3ece81d295a1e7" resolved "https://registry.yarnpkg.com/evt/-/evt-2.0.0-beta.13.tgz#a84828cc15b535fabdeaf551982d0705ed428a6f"
integrity sha512-KoDNXD73aKIGhylvFVYyEjoTTHKWofi0ozaRrvW4rjXZ1XbSUEat+iGSsy/S387v3ZkKB9UI499hT7WtNGzSrw== integrity sha512-Y71l8BU1r/hs7MOyaNb5PTf8Jp+5h8Vt6T8ixvJSqDmKhwCjjCVKP2b1E3UE+Qlr1bZnCOWnVTucTeTeJghWEQ==
dependencies: dependencies:
minimal-polyfills "^2.1.5" minimal-polyfills "^2.1.5"
run-exclusive "^2.2.14" run-exclusive "^2.2.14"
@ -932,12 +932,12 @@ path-type@^4.0.0:
resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b" resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b"
integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw== integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==
powerhooks@^0.0.14: powerhooks@^0.0.17:
version "0.0.14" version "0.0.17"
resolved "https://registry.yarnpkg.com/powerhooks/-/powerhooks-0.0.14.tgz#1456620de2d2b899f54509a8ef909c4c15694c81" resolved "https://registry.yarnpkg.com/powerhooks/-/powerhooks-0.0.17.tgz#840295271d989c27b83047fad44973434c509ba7"
integrity sha512-fse74qwumuETne++wc3asYlhuaQYvKHUUzsAbNQfBb5OK3J12KbBYM3kh+ZPOf5C9/OAJg/qAAXsz2G/5ROS4w== integrity sha512-9z0C5pnVJI3SRKgcoAjbOxVa1lf/e58N+YdByThue1C4DUqfp8umx9XvrRJJ3dGwl6A0RRrJlyPM1KXjVChQMQ==
dependencies: dependencies:
evt "2.0.0-beta.12" evt "2.0.0-beta.13"
memoizee "^0.4.15" memoizee "^0.4.15"
resize-observer-polyfill "^1.5.1" resize-observer-polyfill "^1.5.1"
@ -1130,9 +1130,9 @@ type@^2.0.0:
integrity sha512-rgPIqOdfK/4J9FhiVrZ3cveAjRRo5rsQBAIhnylX874y1DX/kEKSVdLsnuHB6l1KTjHyU01VjiMBHgU2adejyg== integrity sha512-rgPIqOdfK/4J9FhiVrZ3cveAjRRo5rsQBAIhnylX874y1DX/kEKSVdLsnuHB6l1KTjHyU01VjiMBHgU2adejyg==
typescript@^4.1.5: typescript@^4.1.5:
version "4.2.2" version "4.2.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.2.tgz#1450f020618f872db0ea17317d16d8da8ddb8c4c" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.3.tgz#39062d8019912d43726298f09493d598048c1ce3"
integrity sha512-tbb+NVrLfnsJy3M59lsDgrzWIflR4d4TIUjz+heUnHZwdF7YsrMTKoRERiIvI2lvBG95dfpLxB21WZhys1bgaQ== integrity sha512-qOcYwxaByStAWrBf4x0fibwZvMRG+r4cQoTjbPtUlrWjBHbmCAww1i448U0GJ+3cNNEtebDteo/cHOR3xJ4wEw==
universal-user-agent@^6.0.0: universal-user-agent@^6.0.0:
version "6.0.0" version "6.0.0"