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

theme.keycloak.v2.admin.resources.assets.ResourceDetails-d31617a4.js Maven / Gradle / Ivy

There is a newer version: 25.0.1
Show newest version
import{u as N,a as _,r as u,q as V,j as e,F as i,h as l,C as D,g as m,d as B,e as E,b as U,a4 as z,A as F,aS as L,K as q,G,P as H,f as J,V as y,S as W,B as P,l as Q,L as X,z as Y,aJ as Z,y as $}from"./index-f33eb656.js";import{u as ee}from"./ConfirmDialog-cc2aa7b4.js";import{F as se}from"./FormAccess-29b78a4e.js";import{K as te}from"./KeyValueInput-7823c1d9.js";import{K as I}from"./KeycloakTextInput-e2751b88.js";import{M as re}from"./MultiLineInput-45573e30.js";import{V as ae}from"./ViewHeader-5aaa6ccc.js";import{u as ne}from"./useParams-74754a7c.js";import{S as oe,a as ie,b as le}from"./Select-802cd710.js";import{A as ce}from"./Form-6c170f69.js";import"./Modal-e76dd76f.js";import"./copy-icon-c00ff2e0.js";import"./GridItem-8422f423.js";import"./useToggle-d322044d.js";import"./minus-icon-9eecb50c.js";import"./minus-circle-icon-cb05a6be.js";import"./ActionListItem-96f54559.js";import"./plus-circle-icon-2ea0b4ed.js";import"./EmptyStateBody-de699127.js";import"./Text-83f5a4d7.js";import"./ToolbarContent-f1a19b22.js";import"./check-fc57dbe1.js";import"./star-icon-d7615f00.js";const de=({clientId:s})=>{const{t:c}=N("clients"),{control:v}=_(),[S,w]=u.useState(!1),[p,A]=u.useState(),[h,x]=u.useState("");V(()=>{const r={id:s,first:0,max:20,deep:!1,name:h};return m.clients.listAllScopes(r)},A,[h]);const f=r=>r?.map(n=>e.jsx(le,{value:n,children:n.name},n.id));return e.jsx(i,{label:c("authorizationScopes"),labelIcon:e.jsx(l,{helpText:c("clients-help:scopes"),fieldLabelId:"clients:scopes"}),fieldId:"scopes",children:e.jsx(D,{name:"scopes",defaultValue:[],control:v,render:({field:r})=>e.jsx(oe,{toggleId:"scopes",variant:ie.typeaheadMulti,chipGroupProps:{numChips:3,expandedText:c("common:hide"),collapsedText:c("common:showRemaining")},onToggle:w,isOpen:S,selections:r.value.map(n=>n.name),onFilter:(n,d)=>(x(d),f(p)),onSelect:(n,d)=>{const g=typeof d=="string"?d:d.name,T=r.value.find(a=>a.name===g)?r.value.filter(a=>a.name!==g):[...r.value,d];r.onChange(T)},onClear:n=>{n.stopPropagation(),x(""),r.onChange([])},typeAheadAriaLabel:c("authorizationScopes"),children:f(p)})})})};function De(){const{t:s}=N("clients"),[c,v]=u.useState(),[S,w]=u.useState(),[p,A]=u.useState(),{addAlert:h,addError:x}=B(),f=E({mode:"onChange"}),{register:r,formState:{errors:n},control:d,setValue:g,handleSubmit:T}=f,{id:a,resourceId:o,realm:C}=ne(),R=U(),M=(t={})=>{$(t,g)};V(()=>Promise.all([m.clients.findOne({id:a}),o?m.clients.getResource({id:a,resourceId:o}):Promise.resolve(void 0),o?m.clients.listPermissionsByResource({id:a,resourceId:o}):Promise.resolve(void 0)]),([t,j,b])=>{if(!t)throw new Error(s("common:notFound"));v(t),A(b),w(j),M(j)},[]);const k=async t=>{const j=Y(t);try{if(o)await m.clients.updateResource({id:a,resourceId:o},j);else{const b=await m.clients.createResource({id:a},j);R(Z({realm:C,id:a,resourceId:b._id}))}h(s((o?"update":"create")+"ResourceSuccess"),F.success)}catch(b){x("clients:resourceSaveError",b)}},[K,O]=ee({titleKey:"clients:deleteResource",children:e.jsxs(e.Fragment,{children:[s("deleteResourceConfirm"),p?.length!==0&&e.jsx(z,{variant:"warning",isInline:!0,isPlain:!0,title:s("deleteResourceWarning"),className:"pf-u-pt-lg",children:e.jsx("p",{className:"pf-u-pt-xs",children:p?.map(t=>e.jsx("strong",{className:"pf-u-pr-md",children:t.name},t.id))})})]}),continueButtonLabel:"clients:confirm",onConfirm:async()=>{try{await m.clients.delResource({id:a,resourceId:o}),h(s("resourceDeletedSuccess"),F.success),R(L({realm:C,clientId:a,tab:"resources"}))}catch(t){x("clients:resourceDeletedError",t)}}});return c?e.jsxs(e.Fragment,{children:[e.jsx(O,{}),e.jsx(ae,{titleKey:o?S?.name:"clients:createResource",dropdownItems:o?[e.jsx(G,{"data-testid":"delete-resource",onClick:()=>K(),children:s("common:delete")},"delete")]:void 0}),e.jsx(H,{variant:"light",children:e.jsx(J,{...f,children:e.jsxs(se,{isHorizontal:!0,role:"view-clients",className:"keycloak__resource-details__form",onSubmit:T(k),children:[e.jsx(i,{label:s("owner"),fieldId:"owner",labelIcon:e.jsx(l,{helpText:s("clients-help:owner"),fieldLabelId:"clients:owner"}),children:e.jsx(I,{id:"owner",value:c.clientId,isReadOnly:!0})}),e.jsx(i,{label:s("common:name"),fieldId:"name",labelIcon:e.jsx(l,{helpText:s("clients-help:resourceName"),fieldLabelId:"name"}),helperTextInvalid:s("common:required"),validated:n.name?y.error:y.default,isRequired:!0,children:e.jsx(I,{id:"name",validated:n.name?y.error:y.default,...r("name",{required:!0})})}),e.jsx(i,{label:s("displayName"),fieldId:"displayName",labelIcon:e.jsx(l,{helpText:s("clients-help:displayName"),fieldLabelId:"name"}),children:e.jsx(I,{id:"displayName",...r("displayName")})}),e.jsx(i,{label:s("type"),fieldId:"type",labelIcon:e.jsx(l,{helpText:s("clients-help:type"),fieldLabelId:"type"}),children:e.jsx(I,{id:"type",...r("type")})}),e.jsx(i,{label:s("uris"),fieldId:"uris",labelIcon:e.jsx(l,{helpText:s("clients-help:uris"),fieldLabelId:"clients:uris"}),children:e.jsx(re,{name:"uris",type:"url","aria-label":s("uris"),addButtonLabel:"clients:addUri"})}),e.jsx(de,{clientId:a}),e.jsx(i,{label:s("iconUri"),fieldId:"iconUri",labelIcon:e.jsx(l,{helpText:s("clients-help:iconUri"),fieldLabelId:"clients:iconUri"}),children:e.jsx(I,{id:"iconUri",type:"url",...r("icon_uri")})}),e.jsx(i,{hasNoPaddingTop:!0,label:s("ownerManagedAccess"),labelIcon:e.jsx(l,{helpText:s("clients-help:ownerManagedAccess"),fieldLabelId:"clients:ownerManagedAccess"}),fieldId:"ownerManagedAccess",children:e.jsx(D,{name:"ownerManagedAccess",control:d,defaultValue:!1,render:({field:t})=>e.jsx(W,{id:"ownerManagedAccess",label:s("common:on"),labelOff:s("common:off"),isChecked:t.value,onChange:t.onChange,"aria-label":s("ownerManagedAccess")})})}),e.jsx(i,{hasNoPaddingTop:!0,label:s("resourceAttribute"),labelIcon:e.jsx(l,{helpText:s("clients-help:resourceAttribute"),fieldLabelId:"clients:resourceAttribute"}),fieldId:"resourceAttribute",children:e.jsx(te,{name:"attributes"})}),e.jsx(ce,{children:e.jsxs("div",{className:"pf-u-mt-md",children:[e.jsx(P,{variant:Q.primary,type:"submit","data-testid":"save",children:s("common:save")}),e.jsx(P,{variant:"link","data-testid":"cancel",component:t=>e.jsx(X,{...t,to:L({realm:C,clientId:a,tab:"resources"})}),children:s("common:cancel")})]})})]})})})]}):e.jsx(q,{})}export{De as default};
//# sourceMappingURL=ResourceDetails-d31617a4.js.map




© 2015 - 2024 Weber Informatics LLC | Privacy Policy