All Downloads are FREE. Search and download functionalities are using the official Maven repository.

theme.keycloak.v2.admin.resources.assets.AddTranslationsDialog-rQeJZUHO.js Maven / Gradle / Ivy

There is a newer version: 26.0.7
Show newest version
import{o as _,u as K,a as a8,c as e8,dt as t8,g as s8,d$ as N,w as n8,ab as l8,M as o8,q as r8,i as V,aa as R,Z as P,$ as w,F as i8,r as c8,y as S,bd as d8,ac as u8,p as m8}from"./main-C7ps2lmX.js";import{jsx as e,jsxs as n}from"react/jsx-runtime";import{useState as h,useMemo as G,useEffect as C8}from"react";import{P as L8,L as $}from"./PaginatingTableToolbar-Cjsz5Jh4.js";import{u as h8}from"./useLocale-BsnKjfE6.js";import{F as p8,a as k}from"./FlexItem-BzZfUnQ1.js";import{U as f8,V as g8,W as D,X as x,Y as T8,Z as O}from"./Td-D2hVFK0Z.js";const b8={name:"GlobeRouteIcon",height:1024,width:1306,svgPath:"M1300.9,363.7 L1179,485.8 C1169,495.9 1151.7,488.8 1151.7,474.5 L1151.7,416 L816.4,416 C812.4,416 809,413.8 808.5,409.8 C805.3,386 801,362.733333 795.6,340 C792.3,326 788.5,312.4 784.4,299.2 C782.8,294 786.6,288 792,288 L1151.5,288 L1151.5,230.6 C1151.5,216.4 1168.7,209.2 1178.8,219.3 L1300.8,341 C1303.9,344.1 1306,348.2 1306,352.3 C1306,356.4 1303.9,360.5 1300.9,363.7 Z M469.2,746.7 L347.3,868.8 C337.3,878.9 320,871.8 320,857.5 L320,800 L16,800 C7.2,800 0,792.3 0,783.5 L0,687.5 C0,678.7 7.2,672 16,672 L320,672 L320,613.8 C320,599.6 337.2,592.4 347.3,602.5 L469.2,724.1 C475.430133,730.34524 475.430133,740.45476 469.2,746.7 Z M1087.6,495.6 C1087.38293,486.920039 1080.28267,479.997286 1071.6,480 L640,480 L640,352 L722.2,352 C727.4,352 731.3,346.5 729.9,341.5 C725.605596,325.013205 720.465463,308.75837 714.5,292.8 C713.258024,289.782121 710.260604,287.863772 707,288 L640,288 L640,101.7 C652.442178,106.259896 664.111225,112.70148 674.6,120.8 C699.3,139.4 723,168.1 743.1,203.9 C746.5,210 751.7,218.7 761.1,218.7 L809.4,218.7 C812.128705,218.672447 814.65964,217.271114 816.131205,214.973053 C817.602771,212.674992 817.816638,209.789922 816.7,207.3 C804.114384,179.721505 788.769504,153.487791 770.9,129 C818.290474,149.304728 861.543068,178.15109 898.5,214.1 C901.47783,216.980555 905.45693,218.593703 909.6,218.6 L971.4,218.6 C974.505675,218.614157 977.338903,216.829582 978.667492,214.022401 C979.996082,211.21522 979.579921,207.892766 977.6,205.5 C889.8,100 757.8,32.6 609.9,32 L605.5,32 C342.5,33.4 128,251.4 128,514.8 L128,528 C128,538.8 132.7,582.4 136.2,601 C136.9,604.8 140.2,608 144.1,608 L193,608 C198.1,608 201.9,602.8 200.8,597.8 C197.100285,580.050867 194.561569,562.079428 193.2,544 L576,544 L576,672 L533.4,672 C530.21925,671.879321 527.2913,673.725708 526.029429,676.647935 C524.767558,679.570163 525.43119,682.96746 527.7,685.2 L566.6,724.2 C572.610093,730.186212 575.992058,738.317319 576,746.8 L576,922.3 C563.557822,917.740104 551.888775,911.29852 541.4,903.2 C521.8,888.5 502.9,867.3 485.8,841.4 C484.483494,839.398843 482.339547,838.092908 479.95744,837.84114 C477.575334,837.589373 475.205755,838.418269 473.5,840.1 L438.9,874.7 C436.17839,877.437565 435.799809,881.728158 438,884.9 C440.4,888.3 442.8,891.7 445.2,895 C440.7,893.1 436.3,891.1 431.9,889.1 C428.86068,887.698101 425.269908,888.336461 422.9,890.7 L387,926.5 C385.206339,928.31874 384.380991,930.880062 384.775333,933.403854 C385.169676,935.927646 386.737022,938.11511 389,939.3 C456.763878,974.049946 531.84563,992.117563 608,992.00057 C862.3,992.00057 1070.5,794.3 1087,544.1 C1087.7,533.5 1088,522.9 1088,512.1 L1087.6,495.6 Z M338.6,480 L193.2,480 C196.476568,435.937781 206.913411,392.704253 224.1,352 L353.5,352 C345.141453,394.203188 340.159019,437.005305 338.6,480 L338.6,480 Z M257.8,288 C273.983601,262.695367 292.787318,239.165581 313.9,217.8 C351.55,180.03315 396.130875,149.88249 445.2,129 C413.9,171.2 387.8,225.9 369.3,288 L257.8,288 Z M576,480 L402.6,480 C404.246384,436.941681 409.667166,394.110815 418.8,352 L576,352 L576,480 Z M576,288 L436.4,288 C446.6,257.5 458.8,229.1 472.9,204 C493,168.2 516.7,139.5 541.4,120.9 C551.888775,112.80148 563.557822,106.359896 576,101.8 L576,288 Z M575.8,87.6 L576.7,87.6 L576.7,86.7 L575.8,86.7 L575.8,87.6 Z M640,544 L813.4,544 C811.819116,587.052386 806.465269,629.883162 797.4,672 L640,672 L640,544 Z M674.6,903.1 C664.111225,911.19852 652.442178,917.640104 640,922.2 L640,736 L779.9,736 C770.41424,765.137744 758.088355,793.272917 743.1,820 C723,855.8 699.3,884.6 674.6,903.1 L674.6,903.1 Z M902.2,806.2 C864.55,843.96685 819.969125,874.11751 770.9,895 C802.3,852.5 828.4,798.1 847,735.5 L959,735.5 C942.666041,761.042003 923.622375,784.746003 902.2,806.2 L902.2,806.2 Z M992.3,671.5 L862.7,671.5 C870.9358,629.451226 875.850963,586.819718 877.4,544 L1022.8,544 C1019.55195,587.863016 1009.25313,630.915455 992.3,671.5 L992.3,671.5 Z",yOffset:0,xOffset:0},Z8=_(b8),F8=({translationKey:c,translations:p,type:A,onCancel:B,toggleDialog:I,onTranslationsAdded:q})=>{const{adminClient:E}=K(),{t}=a8(),{realm:y,realmRepresentation:f}=e8(),o=h8(),{whoAmI:g}=t8(),[W,Z]=h(10),[j,d]=h(0),[i,z]=h(""),[F,H]=h({}),T=s8({mode:"onChange"}),{getValues:U,handleSubmit:X,setValue:u,formState:{isValid:Y}}=T,b=G(()=>f?.defaultLocale.length?[f.defaultLocale]:[],[f]),m=G(()=>o.filter(a=>N(a,g.getLocale()).toLowerCase().includes(i.toLowerCase())),[o,i,g]);n8(async()=>{const a=o.map(r=>r);return(await Promise.all(a.map(r=>E.realms.getRealmLocalizationTexts({realm:y,selectedLocale:r})))).map((r,L)=>{const v=a[L],M=r[c];return{key:c,translations:[{locale:v,value:M}]}}).reduce((r,L)=>{const v=L.translations[0].locale,M=L.translations[0].value;return{...r,[v]:M}},{})},a=>{H(s=>s!==a?a:s)},[o,c,y]),C8(()=>{o.forEach((a,s)=>{u(`translations.${s}.locale`,a),u(`translations.${s}.value`,p.translations.length>0?p.translations[s].value:F[a]||"")}),u("key",c)},[o,F,c,u,p]);const J=()=>{const a=U(),s=a.translations.map(l=>l.locale===i?{...l,value:a.translations.find(C=>C.locale===i)?.value??""}:l);q({key:a.key,translations:s}),I()},Q=l8({control:T.control,name:"translations.0.value"});return e(o8,{variant:r8.medium,title:t("addTranslationsModalTitle"),isOpen:!0,onClose:I,actions:[e(V,{"data-testid":"okTranslationBtn",variant:"primary",type:"submit",form:"add-translation",isDisabled:!Y||!Q,children:t("addTranslationDialogOkBtn")},"ok"),e(V,{"data-testid":"cancelTranslationBtn",variant:"link",onClick:B,children:t("cancel")},"cancel")],children:n(p8,{direction:{default:"column"},spaceItems:{default:"spaceItemsNone"},children:[e(k,{children:e(R,{children:n(P,{component:w.p,children:[t(A!=="displayHeader"?"addTranslationsModalSubTitleDescription":"addTranslationsModalSubTitle")," ",e("strong",{children:t("addTranslationsModalSubTitleBolded")})]})})}),e(k,{children:e(i8,{...T,children:n(c8,{id:"add-translation","data-testid":"addTranslationForm",onSubmit:X(J),children:[e(S,{name:"key",label:t("translationKey"),className:"pf-v5-u-mt-md","data-testid":"translation-key",isDisabled:!0}),n(k,{children:[e(R,{children:e(P,{className:"pf-v5-u-font-size-sm pf-v5-u-font-weight-bold",component:w.p,children:t("translationsTableHeading")})}),n(L8,{count:o.length,first:j,max:W,onNextClick:d,onPreviousClick:d,onPerPageSelect:(a,s)=>{d(a),Z(s)},inputGroupName:"search",inputGroupOnEnter:a=>{z(a),d(0),Z(10)},inputGroupPlaceholder:t("searchForLanguage"),children:[m.length===0&&!i&&e($,{hasIcon:!0,message:t("noLanguages"),instructions:t("noLanguagesInstructions")}),m.length===0&&i&&e($,{hasIcon:!0,icon:d8,isSearchVariant:!0,message:t("noSearchResults"),instructions:t("noLanguagesSearchResultsInstructions")}),m.length!==0&&n(f8,{"aria-label":t("addTranslationsDialogRowsTable"),"data-testid":"add-translations-dialog-rows-table",children:[e(g8,{children:n(D,{children:[e(x,{className:"pf-v5-u-py-lg",children:t("supportedLanguagesTableColumnName")}),e(x,{className:"pf-v5-u-py-lg",children:t("translationTableColumnName")}),e(x,{"aria-hidden":"true"})]})}),e(T8,{children:m.map((a,s)=>{const l=o.findIndex(C=>C===a);return n(D,{children:[e(O,{className:"pf-m-sm pf-v5-u-px-sm",dataLabel:t("supportedLanguage"),children:n(u8,{fieldId:"kc-supportedLanguage",children:[N(a,g.getLocale()),a===b.toString()&&e(m8,{className:"pf-v5-u-ml-xs",color:"blue",children:t("defaultLanguage")})]})}),n(O,{children:[a===b.toString()&&e(S,{name:`translations.${l}.value`,label:t("translationValue"),"data-testid":`translation-value-${l}`,rules:{required:{value:!0,message:t("required")}}}),a!==b.toString()&&e(S,{name:`translations.${l}.value`,label:t("translationValue"),"data-testid":`translation-value-${l}`})]})]},s)})})]})]})]})]})})})]})})};export{F8 as A,Z8 as G};
//# sourceMappingURL=AddTranslationsDialog-rQeJZUHO.js.map




© 2015 - 2025 Weber Informatics LLC | Privacy Policy