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

theme.keycloak.v2.admin.resources.assets.ScopeDetails-0a847d2a.js Maven / Gradle / Ivy

There is a newer version: 25.0.1
Show newest version
import{u as D,b as w,d as F,r as T,e as U,q as k,j as e,aS as c,G as z,P as V,F as d,h as m,V as r,B as p,l as q,L as E,g as u,A as L}from"./index-831988f6.js";import{F as C}from"./FormAccess-589a8032.js";import{K as h}from"./KeycloakTextInput-ead44014.js";import{V as B}from"./ViewHeader-2b1ad3ef.js";import{u as G}from"./useParams-6d64d61e.js";import{u as K}from"./useToggle-039c9b34.js";import{D as P}from"./DeleteScopeDialog-b53fcebb.js";import{A as R}from"./Form-bd3cf98e.js";import"./copy-icon-476b0d6d.js";import"./GridItem-2c75fd83.js";import"./Text-2a2c2dcc.js";import"./ToolbarContent-186be8fd.js";import"./ConfirmDialog-927d61dd.js";import"./Modal-5d8a3df4.js";function ie(){const{t}=D("clients"),{id:i,scopeId:o,realm:n}=G(),x=w(),{addAlert:I,addError:S}=F(),[v,f]=K(),[s,j]=T.useState(),{register:l,reset:g,handleSubmit:y,formState:{errors:b}}=U({mode:"onChange"});k(async()=>{if(o){const a=await u.clients.getAuthorizationScope({id:i,scopeId:o});if(!a)throw new Error(t("common:notFound"));return a}},a=>{j(a),g({...a})},[]);const A=async a=>{try{o?(await u.clients.updateAuthorizationScope({id:i,scopeId:o},a),j(a)):(await u.clients.createAuthorizationScope({id:i},{name:a.name,displayName:a.displayName,iconUri:a.iconUri}),x(c({realm:n,clientId:i,tab:"scopes"}))),I(t((o?"update":"create")+"ScopeSuccess"),L.success)}catch(N){S("clients:scopeSaveError",N)}};return e.jsxs(e.Fragment,{children:[e.jsx(P,{clientId:i,open:v,toggleDialog:f,selectedScope:s,refresh:()=>x(c({realm:n,clientId:i,tab:"scopes"}))}),e.jsx(B,{titleKey:o?s?.name:t("clients:createAuthorizationScope"),dropdownItems:o?[e.jsx(z,{"data-testid":"delete-resource",onClick:()=>f(),children:t("common:delete")},"delete")]:void 0}),e.jsx(V,{variant:"light",children:e.jsxs(C,{isHorizontal:!0,role:"view-clients",onSubmit:y(A),children:[e.jsx(d,{label:t("common:name"),fieldId:"name",labelIcon:e.jsx(m,{helpText:t("clients-help:scopeName"),fieldLabelId:"name"}),helperTextInvalid:t("common:required"),validated:b.name?r.error:r.default,isRequired:!0,children:e.jsx(h,{id:"name",validated:b.name?r.error:r.default,isRequired:!0,...l("name",{required:!0})})}),e.jsx(d,{label:t("displayName"),fieldId:"displayName",labelIcon:e.jsx(m,{helpText:t("clients-help:scopeDisplayName"),fieldLabelId:"displayName"}),children:e.jsx(h,{id:"displayName",...l("displayName")})}),e.jsx(d,{label:t("iconUri"),fieldId:"iconUri",labelIcon:e.jsx(m,{helpText:t("clients-help:iconUri"),fieldLabelId:"clients:iconUri"}),children:e.jsx(h,{id:"iconUri",...l("iconUri")})}),e.jsx(R,{children:e.jsxs("div",{className:"pf-u-mt-md",children:[e.jsx(p,{variant:q.primary,type:"submit","data-testid":"save",children:t("common:save")}),s?e.jsx(p,{variant:"link","data-testid":"revert",onClick:()=>g({...s}),children:t("common:revert")}):e.jsx(p,{variant:"link","data-testid":"cancel",component:a=>e.jsx(E,{...a,to:c({realm:n,clientId:i,tab:"scopes"})}),children:t("common:cancel")})]})})]})})]})}export{ie as default};
//# sourceMappingURL=ScopeDetails-0a847d2a.js.map




© 2015 - 2024 Weber Informatics LLC | Privacy Policy