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

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

There is a newer version: 26.0.7
Show newest version
import{jsx as e,jsxs as I,Fragment as R}from"react/jsx-runtime";import{useState as m}from"react";import{u as T,a as N,aj as _,w as L,a3 as k,ac as w,ad as C,ae as q,b5 as K,b6 as j,U as E,f as U,g as G,d as Q,b3 as W,ay as J,k as P,bB as x,D as X,P as Y,F as Z,y as g,A as $,i as H,B as ee,L as re,S as ae,bm as se,Q as te}from"./main-C7ps2lmX.js";import{D as oe}from"./SwitchControl-C_9Y74oV.js";import{u as ne}from"./ConfirmDialog-hx7XKLbN.js";import{F as ie}from"./FormAccess-DyLNkc18.js";import{K as le}from"./KeyValueInput-B0tpVTv9.js";import{M as ce}from"./MultiLineInput-DiPNQ1LE.js";import{V as ue}from"./ViewHeader-B7eeFzFA.js";import{u as de}from"./useParams-B67lSY02.js";import"react-dom";import"./copy-icon-ACZmDH8e.js";import"./KeySelect-jKxsKqdI.js";import"./useToggle-K3Kx99tM.js";import"./EmptyStateFooter-DqmBOP2I.js";const me=({clientId:i})=>{const{adminClient:r}=T(),{t:l}=N(),{control:y}=_(),[A,v]=m(!1),[u,S]=m(),[p,h]=m("");L(()=>{const n={id:i,first:0,max:20,deep:!1,name:p};return r.clients.listAllScopes(n)},S,[p]);const b=n=>n.map(a=>e(E,{value:a,children:a.name},a.id));return u?e(w,{label:l("authorizationScopes"),labelIcon:e(C,{helpText:l("clientScopesHelp"),fieldLabelId:"scopes"}),fieldId:"scopes",children:e(q,{name:"scopes",defaultValue:[],control:y,render:({field:n})=>e(K,{toggleId:"scopes",variant:j.typeaheadMulti,chipGroupProps:{numChips:3,expandedText:l("hide"),collapsedText:l("showRemaining")},onToggle:a=>v(a),isOpen:A,selections:n.value.map(a=>a.name),onFilter:a=>(h(a),b(u)),onSelect:a=>{const s=typeof a=="string"?a:a.name,t=n.value.find(c=>c.name===s)?n.value.filter(c=>c.name!==s):[...n.value,a];n.onChange(t)},onClear:()=>{h(""),n.onChange([])},typeAheadAriaLabel:l("authorizationScopes"),children:b(u)})})}):e(k,{})};function Pe(){const{adminClient:i}=T(),{t:r}=N(),[l,y]=m(),[A,v]=m(),[u,S]=m(),{addAlert:p,addError:h}=U(),b=G({mode:"onChange"}),{setValue:n,handleSubmit:a}=b,{id:s,resourceId:t,realm:c}=de(),D=Q(),V=(o={})=>{te(o,n)},{hasAccess:z}=W(),F=!z("manage-authorization");L(()=>Promise.all([i.clients.findOne({id:s}),t?i.clients.getResource({id:s,resourceId:t}):Promise.resolve(void 0),t?i.clients.listPermissionsByResource({id:s,resourceId:t}):Promise.resolve(void 0)]),([o,d,f])=>{if(!o)throw new Error(r("notFound"));y(o),S(f),v(d),V(d)},[]);const B=async o=>{const d=ae(o);try{if(t)await i.clients.updateResource({id:s,resourceId:t},d);else{const f=await i.clients.createResource({id:s},d);v(d),D(se({realm:c,id:s,resourceId:f._id}))}p(r((t?"update":"create")+"ResourceSuccess"),P.success)}catch(f){h("resourceSaveError",f)}},[M,O]=ne({titleKey:"deleteResource",children:I(R,{children:[r("deleteResourceConfirm"),u?.length!==0&&e(J,{variant:"warning",isInline:!0,isPlain:!0,title:r("deleteResourceWarning"),className:"pf-v5-u-pt-lg",children:e("p",{className:"pf-v5-u-pt-xs",children:u?.map(o=>e("strong",{className:"pf-v5-u-pr-md",children:o.name},o.id))})})]}),continueButtonLabel:"confirm",onConfirm:async()=>{try{await i.clients.delResource({id:s,resourceId:t}),p(r("resourceDeletedSuccess"),P.success),D(x({realm:c,clientId:s,tab:"resources"}))}catch(o){h("resourceDeletedError",o)}}});return l?I(R,{children:[e(O,{}),e(ue,{titleKey:t?A?.name:"createResource",dropdownItems:t?[e(X,{"data-testid":"delete-resource",isDisabled:F,onClick:()=>M(),children:r("delete")},"delete")]:void 0}),e(Y,{variant:"light",children:e(Z,{...b,children:I(ie,{isHorizontal:!0,role:"manage-authorization",className:"keycloak__resource-details__form",onSubmit:a(B),children:[e(g,{name:t?"owner.name":"",label:r("owner"),labelIcon:r("ownerHelp"),defaultValue:l.clientId,readOnly:!0}),e(g,{name:"name",label:r("name"),labelIcon:r("resourceNameHelp"),rules:{required:r("required")}}),e(g,{name:"displayName",label:r("displayName"),labelIcon:r("displayNameHelp"),rules:{required:r("required")}}),e(g,{name:"type",label:r("type"),labelIcon:r("resourceDetailsTypeHelp")}),e(w,{label:r("uris"),fieldId:"uris",labelIcon:e(C,{helpText:r("urisHelp"),fieldLabelId:"uris"}),children:e(ce,{name:"uris",type:"url","aria-label":r("uris"),addButtonLabel:"addUri"})}),e(me,{clientId:s}),e(g,{name:"icon_uri",label:r("iconUri"),labelIcon:r("iconUriHelp"),type:"url"}),e(oe,{name:"ownerManagedAccess",label:r("ownerManagedAccess"),labelIcon:r("ownerManagedAccessHelp")}),e(w,{hasNoPaddingTop:!0,label:r("resourceAttribute"),labelIcon:e(C,{helpText:r("resourceAttributeHelp"),fieldLabelId:"resourceAttribute"}),fieldId:"resourceAttribute",children:e(le,{name:"attributes",isDisabled:F})}),e($,{children:I("div",{className:"pf-v5-u-mt-md",children:[e(H,{variant:ee.primary,type:"submit","data-testid":"save",children:r("save")}),e(H,{variant:"link","data-testid":"cancel",component:o=>e(re,{...o,to:x({realm:c,clientId:s,tab:"resources"})}),children:r("cancel")})]})})]})})})]}):e(k,{})}export{Pe as default};
//# sourceMappingURL=ResourceDetails-DqME319T.js.map




© 2015 - 2025 Weber Informatics LLC | Privacy Policy