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

theme.keycloak.v2.admin.resources.assets.ScopeDetails-c0209802.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-f33eb656.js";import{F as C}from"./FormAccess-29b78a4e.js";import{K as h}from"./KeycloakTextInput-e2751b88.js";import{V as B}from"./ViewHeader-5aaa6ccc.js";import{u as G}from"./useParams-74754a7c.js";import{u as K}from"./useToggle-d322044d.js";import{D as P}from"./DeleteScopeDialog-f3f4eaec.js";import{A as R}from"./Form-6c170f69.js";import"./copy-icon-c00ff2e0.js";import"./GridItem-8422f423.js";import"./Text-83f5a4d7.js";import"./ToolbarContent-f1a19b22.js";import"./ConfirmDialog-cc2aa7b4.js";import"./Modal-e76dd76f.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-c0209802.js.map




© 2015 - 2024 Weber Informatics LLC | Privacy Policy