GIF89a=( õ' 7IAXKgNgYvYx\%wh…hŽth%ˆs%—x¨}9®Œ©€&©‰%¶†(¹–.¹5·œD¹&Çš)ÇŸ5ǘ;Í£*È¡&Õ²)ׯ7×µ<Ñ»4ï°3ø‘HÖ§KͯT÷¨Yÿšqÿ»qÿÔFØ !ù ' !ÿ NETSCAPE2.0 , =( þÀ“pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËíz¿à°xL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~Ïïûÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§gª«ªE¯°¨¬ª±²Œ¹º¹E¾­”´ÂB¶¯ §Åȸ»ÑD¾¿Á•ÄÅ®° ÝH¾ÒLÀÆDÙ«D¶BÝïðÀ¾DÑÑÔTÌÍíH òGö¨A RÎڐ |¥ ٭&ºìE8œ¹kGÔAÞpx­a¶­ã R2XB®åE8I€Õ6Xî:vT)äžþÀq¦è³¥ì仕F~%xñ  4#ZÔ‰O|-4Bs‘X:= QÉ œš lºÒyXJŠGȦ|s hÏíK–3l7·B|¥$'7Jީܪ‰‡àá”Dæn=Pƒ ¤Òëí‰`䌨ljóá¯Éüv>á–Á¼5 ½.69ûϸd«­ºÀûnlv©‹ªîf{¬ÜãPbŸ  l5‘ޝpß ´ ˜3aÅùäI«O’ý·‘áÞ‡˜¾Æ‚ÙÏiÇÿ‹Àƒ #öó)pâš Þ½ ‘Ý{ó)vmÞü%D~ 6f s}ŃƒDØW Eþ`‡þ À…L8xá†ç˜{)x`X/> Ì}mø‚–RØ‘*|`D=‚Ø_ ^ð5 !_…'aä“OÚ—7âcð`D”Cx`ÝÂ¥ä‹éY¹—F¼¤¥Š?¡Õ™ n@`} lď’ÄÉ@4>ñd œ à‘vÒxNÃ×™@žd=ˆgsžG±æ ´²æud &p8Qñ)ˆ«lXD©øÜéAžHìySun jª×k*D¤LH] †¦§C™Jä–´Xb~ʪwStŽ6K,°£qÁœ:9ت:¨þªl¨@¡`‚ûÚ ».Û¬¯t‹ÆSÉ[:°=Š‹„‘Nåû”Ìî{¿ÂA ‡Rà›ÀÙ6úë°Ÿð0Ä_ ½;ÃϱîÉì^ÇÛÇ#Ëë¼ôº!±Ä˜íUîÅÇ;0L1óÁµö«p% AÀºU̬ݵ¼á%霼€‡¯Á~`ÏG¯»À× ­²± =4ªnpð3¾¤³¯­ü¾¦îuÙuµÙ®|%2ÊIÿür¦#0·ÔJ``8È@S@5ê¢ ö×Þ^`8EÜ]ý.뜃Âç 7 ú ȉÞj œ½Dç zý¸iþœÑÙûÄë!ˆÞÀl§Ïw‹*DçI€nEX¯¬¼ &A¬Go¼QföõFç°¯;é¦÷îŽêJ°îúôF5¡ÌQ|îúöXªæ»TÁÏyñêï]ê² o óÎC=öõ›ÒÓPB@ D×½œä(>èCÂxŽ`±«Ÿ–JЀ»Û á¤±p+eE0`ëŽ`A Ú/NE€Ø†À9‚@¤à H½7”à‡%B‰`Àl*ƒó‘–‡8 2ñ%¸ —€:Ù1Á‰E¸àux%nP1ð!‘ðC)¾P81lÑɸF#ˆ€{´âé°ÈB„0>±û °b¡Š´±O‚3È–Ù()yRpbµ¨E.Z‘D8ÊH@% òŒx+%Ù˜Æcü »¸˜fõ¬b·d`Fê™8èXH"ÉÈ-±|1Ô6iI, 2““¬$+](A*jÐ QTÂo‰.ÛU슬Œã„Ž`¯SN¡–¶Äåyše¯ª’­¬‚´b¦Éož œ)åyâ@Ì®3 ÎtT̉°&Ø+žLÀf"Ø-|žçÔ>‡Ðv¦Ðžì\‚ Q1)Ž@Žh#aP72”ˆ™¨$‚ !ù " , =( …7IAXG]KgNgYvYxR"k\%w]'}hŽth%ˆg+ˆs%—r.—m3šx3˜x¨}9®€&©€+¨‡7§‰%¶†(¹–.¹œD¹&ǘ;Í•&ײ)×»4ïÌ6ò§KÍ þ@‘pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËíz¿à°xL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~Ïïûÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§g «¬ E ±± ¨­¶°ººE Á´”·®C¬²§Ç¶Œ»ÓDÃÕƷ¯Ê±H½ºM×ÁGÚ¬D¶BËÁ½î½DÓôTÏÛßîG»ôõC×CÌ l&âž:'òtU³6ɹ#·Ø)€'Ü.6±&ëÍÈ» K(8p0N?!æ2"ÛˆNIJX>R¼ÐO‚M '¡¨2¸*Ÿþ>#n↠å@‚<[:¡Iïf’ ¤TÚ˘CdbÜÙ“[«ŽEú5MBo¤×@€`@„€Êt W-3 ¶Ÿ¡BíêäjIÝ…Eò9[T…$íêﯧ„…•s»Óȳ¹€ÅÚdc®UUρ#±Ùïldj?´í¼²`\ŽÁðÞu|3'ÖŒ]ë6 ¶S#²‡˜FKLÈ *N E´‘áäŠ$˜›eÄYD„ºq«.è촁ƒs \-ÔjA 9²õ÷å- üúM[Âx(ís÷ì®x€|í¡Ù’p¦‚ ŽkÛTÇDpE@WÜ ²Ç]kŠ1¨ þ€·Yb ÓÁ‰l°*n0 ç™—žzBdОu¾7ĉBl€â‰-ºx~|UåU‰  h*Hœ|e"#"?vpÄiŠe6^ˆ„+qâŠm8 #VÇá ‘å–ÄV„œ|Аè•m"сœn|@›U¶ÆÎž—Špb¥G¨ED”€±Úê2FÌIç? >Éxå Œ± ¡¤„%‘žjŸ‘ꄯ<Ìaà9ijÐ2˜D¦È&›†Z`‚å]wþ¼Â:ç6àB¤7eFJ|õÒ§Õ,¨äàFÇ®cS·Ê¶+B°,‘Þ˜ºNûãØ>PADÌHD¹æž«ÄÀnÌ¥}­#Ë’ë QÀÉSÌÂÇ2ÌXÀ{æk²lQÁ2«ÊðÀ¯w|2Í h‹ÄÂG€,m¾¶ë3ÐÙ6-´ÅE¬L°ÆIij*K½ÀÇqï`DwVÍQXœÚÔpeœ±¬Ñ q˜§Tœ½µƒ°Œìu Â<¶aØ*At¯lmEØ ü ôÛN[P1ÔÛ¦­±$ÜÆ@`ùåDpy¶yXvCAyåB`ŽD¶ 0QwG#¯ æš[^Äþ $ÀÓÝǦ{„L™[±úKÄgÌ;ï£S~¹ìGX.ôgoT.»åˆ°ùŸûù¡?1zö¦Ÿž:ÅgÁ|ìL¹ „®£œŠ‚à0œ]PÁ^p F<"•ç?!,ñ‡N4—…PÄ Á„ö¨Û:Tè@hÀ‹%táÿ:ø-žI<`þ‹p I….)^ 40D#p@ƒj4–؀:²‰1Øâr˜¼F2oW¼#Z†;$Q q” ‘ ÂK¦ñNl#29 !’F@¥Bh·ᏀL!—XFóLH‘Kh¤.«hE&JòG¨¥<™WN!€ÑÙÚˆY„@†>Œž19J" 2,/ &.GXB%ÌRÈ9B6¹W]’î×ÔW¥’IÎ$ ñ‹ÓŒE8YÆ ¼³™ñA5“à®Q.aŸB€&Ø©³ JÁ—! ¦t)K%tœ-¦JF bòNMxLôþ)ÐR¸Ð™‘ èÝ6‘O!THÌ„HÛ ‰ !ù ) , =( …AXKgNgYvYxR"k\%wh…hŽh%ˆg+ˆs%—r.—x3˜x¨}9®€&©€+¨Œ,©‡7§‰%¶†(¹–.¹5·&Çš)ǘ;Í•&×£*Ȳ)ׯ7×»4ï°3øÌ6ò‘HÖ§KÍ»Hó¯T÷¨Yÿ»qÿÇhÿ þÀ”pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËíz¿à°xL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~Ïïûÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§g ª« E$±²¨ª­ · °²½$E$ÂÕ««D· Í ¿¦Ç¶¸ÌŒ¾³CÃÅÆ E ééH½MÛÂGâªD­ çBêêϾD²ÒaÀà€Š1r­ðÓ¤ ÔožzU!L˜C'¾yW½UGtäÇïÙllê0×àÂuGþ)AÀs[þ·xì ÁxO%ƒûX2ó—  P£n›R/¡ÑšHše+êDm?# —‘Ç£6¡8íJ¡ŸâDiäªM¥Ö„ôj“¬¹£5oQ7°- <‡ *´lãÓŒ2r/a!l)dÈ A™ÈE¢ôÔ͆…ð ;Ö˜c ¡%ß‚’Ùˆâ¸b½—pe~C"BíëÚHïeF2§æŠ8qb t_`urŠeü wÅu3êæPv§h•"ß`íÍxçLĹÜÖ3á  ~Öº“®›¸ÏMDfJÙ °„ÛµáWõ%§œ‚à©–‚X ÓØ)@®Ñ›Eþ´wëuÅSxb8y\mÖzœ¥§ZbºE—ÂLªÌw!y(>¡™wú=Ç|ÅÝs¢d €CÁW)HÜcC$€L Ä7„r.á\{)@ð` @ äXÈ$PD” `šaG:§æˆOˆ72EÐamn]ù"ŒcÊxÑŒ° &dR8`g«iÙŸLR!¦P …d’ä¡“¦ðÎTƒ¦ià|À _ ¥ Qi#¦Šg›Æ ›noMµ ›V ã£)p ç£ÎW…š=Âeªk§†j„ ´®1ß²sÉxéW«jšl|0¯B0Û, \jÛ´›6±¬¶C ÛíWþï|ëÙ‹¸ñzĸV {ì;Ýñn¼òVˆm³I¼³.Ðã¤PN¥ ²µ¼„µCã+¹ÍByî£Ñ¾HŸ›ëê 7ìYÆFTk¨SaoaY$Dµœìï¿Ã29RÈkt Çïfñ ÇÒ:ÀÐSp¹3ÇI¨â¥DZÄ ü9Ïýögñ½­uÔ*3)O‘˜Ö[_hv ,àî×Et Ÿé¶BH€ Õ[ü±64M@ÔSÌM7dÐl5-ÄÙU܍´©zߌ3Ô€3ž„ „ ¶ÛPô½5×g› êÚ˜kN„Ý…0Îj4€Ìë°“#{þÕ3S2çKÜ'ợlø¼Ú2K{° {Û¶?žm𸧠ËI¼nEò='êüóºè^üæÃ_Û=°óž‚ì#Oý¿Í'¡½áo..ÏYìnüñCœO±Áa¿¢Kô½o,üÄËbö²çºíï{ËC Ú— "”Ï{ËK ÍÒw„õ±Oz dÕ¨à:$ ƒô—«v»] A#ð «€¿šéz)Rx׿ˆ¥‚d``èw-îyÏf×K!ð€þ­Ð|ìPľ„=Ì`ý(f” 'Pa ¥ÐBJa%Ðâf§„%Š¡}FàáÝ×6>ÉäŠG"éŽè=ø!oа^FP¼Ø©Q„ÀCÙÁ`(Ž\ÄÝ® ©Â$<n@dÄ E#ììUÒI! ‚#lù‹`k¦ÐÇ'Rró’ZýNBÈMF Í[¤+‹ðɈ-áwj¨¥þ8¾rá ,VÂh„"|½œ=×G_¦Ñ™EØ 0i*%̲˜Æda0mV‚k¾)›;„&6 p>ÓjK “¦Ç# âDÂ:ûc?:R Ó¬fÞéI-Ì“•Ã<ä=™Ï7˜3œ¨˜c2ŒW ,ˆ”8(T™P‰F¡Jhç"‚ ; 403WebShell
403Webshell
Server IP : 143.110.188.43  /  Your IP : 216.73.217.31
Web Server : Apache/2.4.57 (Ubuntu)
System : Linux Client-Droplet 6.5.0-44-generic #44-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 7 15:10:09 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 8.2.10-2ubuntu2.2
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /snap/lxd/current/share/lxd-ui/assets/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /snap/lxd/current/share/lxd-ui/assets//PermissionGroups-DPkBBdzp.js
import{u as Ke,z as pe,s as te,d as a,r as w,b as xe,j as e,B as F,t as M,a8 as ze,cq as U,D as _,cP as Q,R as se,ay as He,cQ as Ye,F as Qe,O as Ue,q as J,v as je,e as Ne,f as Se,h as ve,o as ne,cC as re,cA as Ve,aP as We,w as Xe,H as Je}from"./index-C5moRkRM.js";import{S as le}from"./SelectableMainTable-wRMsxkIr.js";import{S as Ze}from"./SelectedTableNotification-DR6-T9f2.js";import{u as de}from"./useSortTableData-DOqSqaiW.js";import{u as Y,a as ce,p as ae}from"./useEscCallback-CiLQokzn.js";import{P as X}from"./PageHeader-BRr9_J16.js";import{P as ue}from"./PermissionGroupExplanationTooltip-C7iAtra7.js";import{d as et,c as tt,r as st,a as he,u as nt}from"./useAuthGroups-C-Po2Wwd.js";import{R as fe}from"./ResourceLabel-5vQU6ndJ.js";import{L as Ie,u as Ce,G as it,S as ot,A as at,Q as rt,P as lt}from"./GroupOrIdentityChangesTable-F46VQH7n.js";import{A as dt}from"./AutoExpandingTextArea-BtMcH1Et.js";import{F as ge,B as ct}from"./BackLink-CIO3yW-G.js";import{i as we,b as ut}from"./identity-vaJmuAxa.js";import{u as Z}from"./useIdentities-C0Vj9TWR.js";import{u as mt}from"./useConfigOptions-BxC1oiVQ.js";import{b as Ge,e as Re}from"./resourceDetails-XsDjMA3V.js";import{d as pt}from"./images-CQST2R8G.js";import{h as Pe}from"./useImages-B2pew3-d.js";import{R as me}from"./ResourceLink-CSSa-WON.js";import{P as ht}from"./PermissionGroupsFilter-BXndyO8l.js";import{u as ft,M as gt}from"./useEditHistory-CaQ4A7TN.js";import"./ExplanationTooltip-AfbgOckm.js";import"./searchAndFilter-CpMRkW43.js";import"./promises-DrIa_NWl.js";import"./index-BCn5QfZZ.js";import"./imageRegistry-DUJSvWII.js";import"./image-registries-CGiwo-wc.js";const V=()=>{const{isFineGrained:t}=Ke();return{canDeleteGroup:o=>pe(t,"can_delete",o?.access_entitlements),canEditGroup:o=>pe(t,"can_edit",o?.access_entitlements)}},Ee=({groups:t,close:s})=>{const i=te(),o=a.useNotify(),n=a.useToastNotification(),[c,g]=w.useState(!0),[r,l]=w.useState(!1),p="confirm-delete-group",{canDeleteGroup:x}=V(),{data:f}=xe(),C=f?.auth_user_name??"",S=[],j=[];let u=!1;t.forEach(d=>{x(d)?(d.identities?.oidc?.includes(C)&&(u=!0),d.identities?.tls?.includes(C)&&(u=!0),j.push(d)):S.push(d)});const b=j.length===1,v=d=>{g(d.target.value!==p)},y=()=>{l(!0);const m=j.length===1?e.jsxs(e.Fragment,{children:["Group"," ",e.jsx(fe,{bold:!0,type:"auth-group",value:j[0].name})," ","deleted."]}):`${j.length} groups deleted.`;et(j.map(I=>I.name)).then(()=>{i.invalidateQueries({predicate:I=>[M.identities,M.authGroups,M.currentIdentity].includes(I.queryKey[0])}),n.success(m),s()}).catch(I=>{o.failure(`Failed deleting ${j.length} ${F("group",j.length)}.`,I)}).finally(()=>{l(!1)})},G=()=>{const d=S.length?e.jsxs(e.Fragment,{children:[e.jsxs("li",{className:"p-list__item",children:["-"," ",`${j.length} ${F("group",j.length)} will be deleted.`]}),e.jsxs("li",{className:"p-list__item",children:["-"," ",`${S.length} ${F("group",S.length)} that you do not have permission to delete will be ignored.`]})]}):null,m=b?e.jsxs(e.Fragment,{children:[" ","the group"," ",e.jsx(fe,{type:"auth-group",value:j[0].name,bold:!0})]}):e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:j.length})," ",F("group",j.length)]});return e.jsxs(e.Fragment,{children:[d&&e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:[e.jsx("b",{children:t.length})," ",F("group",t.length)," ","selected:"]}),e.jsx("ul",{className:"p-list",children:d})]}),e.jsxs("p",{className:"u-no-padding--top",children:["This will permanently delete ",m,".",`
`,"This action cannot be undone and may result in users losing access to LXD, including the possibility that all users lose admin access."]}),u&&e.jsx("div",{className:"u-sv1",children:e.jsx(Ie,{isVisible:u})}),e.jsx("p",{children:"To continue, please type the confirmation text below."}),e.jsx("p",{children:e.jsx("strong",{children:p})})]})};return e.jsx(a.Modal,{title:"Confirm group deletion",className:"delete-group-confirm-modal",close:s,buttonRow:[e.jsx("span",{className:"u-float-left confirm-input",children:e.jsx(a.Input,{id:"confirm-delete-group-input",name:"confirm-delete-group-input",type:"text",onChange:v,placeholder:p,className:"u-no-margin--bottom",disabled:!j.length})},"confirm-input"),e.jsxs(a.ActionButton,{appearance:"negative",className:"u-no-margin--bottom",onClick:y,loading:r,disabled:c||r,children:["Permanently delete ",j.length," ",F("group",j.length)]},"confirm-action-button")],children:G()})},H=t=>t?.name==="admins",Ae=(t,s)=>["deduplicate","A group with this name already exists",async i=>s&&i===s||ze(i,"",t,"auth/groups")],bt=(t,s)=>{const i=t.length,o=[],n=[],c=[];for(const g of s){let r=0;const l=new Set(g.groups||[]);for(const f of t)l.has(f.name)&&r++;const p=r===i,x=!p&&r>0;if(p){o.push(g.id);continue}if(x){n.push(g.id);continue}c.push(g.id)}return{identityIdsInAllGroups:o,identityIdsInSomeGroups:n,identityIdsInNoGroups:c}},Le=(t,s,i)=>t.filter(n=>s.has(n.id)||i.has(n.id)),Te=(t,s,i,o)=>{const n=new Set(t),c=new Set(s),g=new Set(i.map(l=>l.name)),r={};for(const l of o){const p=l.groups||[],x=new Set(p);for(const f of p)c.has(l.id)&&g.has(f)&&x.delete(f);for(const f of i)n.has(l.id)&&x.add(f.name);r[l.id]=Array.from(x)}return r},yt=(t,s,i,o)=>{const n=Le(t,i,o),c=Te(i,o,s,n),g={};for(const r of n){const l=c[r.id];if(!l)continue;const p=new Set,x=new Set,f=new Set(r.groups);for(const S of l)f.has(S)||p.add(S);const C=new Set(l);for(const S of r.groups||[])C.has(S)||x.add(S);(p.size||x.size)&&(g[r.id]={added:p,removed:x,name:U(r)})}return g},xt=({group:t})=>{const s=Y(),{openPortal:i,closePortal:o,isOpen:n,Portal:c}=a.usePortal(),{canDeleteGroup:g,canEditGroup:r}=V(),l=()=>H(t)?"Admins group cannot be deleted":g(t)?"Delete group":"Delete group - You do not have permission to delete this group";return e.jsxs(e.Fragment,{children:[e.jsx(a.List,{inline:!0,className:"u-no-margin--bottom actions-list",items:[e.jsx(a.Button,{appearance:"base",dense:!0,hasIcon:!0,onClick:()=>{s.openEditGroup(t.name)},type:"button",title:r(t)?"Edit group":"Edit group - You do not have permission to edit this group",disabled:!r(t),children:e.jsx(_,{icon:"edit"})},"edit"),e.jsx(a.Button,{appearance:"base",dense:!0,hasIcon:!0,onClick:i,type:"button",title:l(),disabled:H(t)||!g(t),children:e.jsx(_,{icon:"delete"})},"delete")]}),n&&e.jsx(c,{children:e.jsx(Ee,{groups:[t],close:o})})]})},ke=({formik:t,setSubForm:s,identityCount:i,identityModifyCount:o,permissionCount:n,permissionModifyCount:c,isEditing:g=!0,group:r})=>{const{canEditGroup:l}=V(),p=v=>({id:v,name:v,onBlur:t.handleBlur,onChange:t.handleChange,value:t.values[v]??"",error:t.touched[v]?t.errors[v]:null,placeholder:`Enter ${v.replaceAll("_"," ")}`}),x=!g||l(r)?"":"You do not have permission to modify this group",f=!t.values.name||!!t.errors.name,C=!!x||f,S=f,u=(()=>{if(x)return x;if(r&&H(r))return"Admins group cannot be modified";if(f)return"Enter a valid group name first"})(),b=()=>r&&!l(r)?"View ":g?"Edit ":"Add ";return e.jsxs(a.Form,{onSubmit:t.handleSubmit,children:[e.jsx(a.Input,{type:"submit",hidden:!0,value:"Hidden input"}),e.jsx(a.Input,{...p("name"),type:"text",label:"Name",required:!0,autoFocus:!0,disabled:!!x||H(r),title:x||u}),e.jsx(dt,{...p("description"),label:"Description",disabled:C||H(r),title:u}),e.jsx(ge,{title:(g?"Edit ":"Add ")+F("identity",2),icon:"user-group",onClick:()=>{s("identity")},isModified:o>0,subText:i===0?`No ${F("identity",2)}`:`${i} ${F("identity",i)}`,disabled:C,onHoverText:u}),e.jsx(ge,{title:b()+F("permission",2),icon:"locked",onClick:()=>{s("permission")},isModified:c>0,subText:n===0?`No ${F("permission",2)}`:`${n} ${F("permission",n)}`,disabled:S,onHoverText:u})]})},Fe=({selected:t,setSelected:s,groupName:i,group:o})=>{const n=a.useNotify(),[c,g]=w.useState(null),{data:r=[],error:l}=Z(),{canEditIdentity:p}=Ce(),x=r.filter(d=>!p(d)).map(d=>d.id);l&&n.failure("Loading details failed",l);const f=r.filter(d=>!we(d)),C=new Set(Q(o)),S=C.size>0,j=d=>{if(x.includes(d))return;const m=t.find(I=>I.id===d);if(m){const I=t.filter(B=>B.id!==d),A={...m,isAdded:!m.isAdded,isRemoved:!m.isRemoved},$=m.groups?.includes(i);if(A.isRemoved&&!$){s(I);return}A.isAdded=!$,s([...I,A])}else{const I=r.find(A=>A.id===d);if(!I){n.failure("Selection failed",new Error("Identity not found"));return}s([...t,{...I,isAdded:!0,isRemoved:!1}])}},u=d=>{if(d.length===0){const I=[];t.forEach(A=>{A.groups?.includes(i)&&I.push({...A,isAdded:!1,isRemoved:!0})}),s(I);return}const m=r.filter(I=>d.includes(I.id)).map(I=>({...I,isAdded:!I.groups?.includes(i),isRemoved:!1}));s(m)},b=[{content:"Identity",sortKey:"name"},{content:"","aria-label":"Modified status",className:"modified-status"}],y=f.filter(d=>c?U(d).toLowerCase().includes(c.toLowerCase()):!0).map(d=>{const m=()=>{j(d.id)},I=t.find(D=>D.id===d.id),A=I?.isAdded||I?.isRemoved,$=U(d);return{key:d.id,name:d.id,className:"u-row u-truncate",columns:[{content:$,role:"rowheader","aria-label":"Identity",title:p(d)?$:"You do not have permission to allocate this identity to the group",onClick:m,className:"clickable-cell"},{content:A&&e.jsx(a.Icon,{name:"status-in-progress-small"}),role:"cell","aria-label":"Modified status",className:"modified-status u-align--right"}],sortData:{name:$.toLowerCase(),isPreselected:C.has(d.id)}}}),{rows:G}=de({rows:y,defaultSort:S?"isPreselected":"name",defaultSortDirection:S?"descending":"ascending"});return e.jsxs(e.Fragment,{children:[e.jsx(a.SearchBox,{onChange:d=>{g(d)}}),e.jsx(a.ScrollableTable,{dependencies:[r,t,n.notification],tableId:"group-identities-table",belowIds:["panel-footer"],children:e.jsx(le,{id:"group-identities-table",className:"group-identities-table",headers:b,rows:G,sortable:!0,emptyStateMsg:"No identities found",itemName:"identity",parentName:"server",selectedNames:t.filter(d=>!d.isRemoved).map(d=>d.id),setSelectedNames:u,disabledNames:x,filteredNames:f.map(d=>d.id),indeterminateNames:[],onToggleRow:j,hideContextualMenu:!0,disableSelectAll:!!x.length})})]})},jt=async t=>{const s=new URLSearchParams;return s.set("entity-type",t),fetch(`${se}/1.0/auth/permissions?${s.toString()}`).then(He).then(i=>i.metadata.sort((o,n)=>o.url===n.url?o.entitlement===n.entitlement?o.entity_type.localeCompare(n.entity_type):o.entitlement.localeCompare(n.entitlement):o.url.localeCompare(n.url)))},Nt=({resource:t})=>{const i=Ge(t.type).map(o=>{let n=t[o]||"-";return Array.isArray(n)&&(n=n.join(", ")||"-"),e.jsx("span",{title:n,className:"resource u-truncate",children:n},o)});return e.jsx("div",{className:"label",children:i})},St=({entitlement:t,description:s})=>e.jsxs("div",{className:"label",children:[e.jsx("span",{title:t,className:"entitlement u-truncate",children:t}),e.jsx("span",{title:s,className:"entitlement-description u-truncate u-text--muted",children:s})]});var be=Ye();const vt={disabled:!0,label:"None available",value:""},$e=[{value:"server",label:"Server"},{value:"identity",label:"Identity"},{value:"group",label:"Group"},{value:"certificate",label:"Certificate"},{value:"project",label:"Project"},{value:"profile",label:"Profile"},{value:"instance",label:"Instance"},{value:"image",label:"Image"},{value:"image_alias",label:"Image alias"},{value:"storage_pool",label:"Storage pool"},{value:"storage_volume",label:"Storage volume"},{value:"storage_bucket",label:"Storage bucket"},{value:"network",label:"Network"},{value:"network_acl",label:"Network ACL"},{value:"network_zone",label:"Network zone"}],ee=(t,s)=>{const i=be.getOptionText(t)||t.value,o=be.getOptionText(s)||s.value;return i.localeCompare(o)},It=t=>{if(!t||!t.entities)return $e.sort(ee);const s=[],i=Object.keys(t.entities);for(const o of i){const n=o.split("_");n[0]=Qe(n[0]),s.push({value:o,label:n.join(" ")})}return s},Ct=(t,s,i,o)=>{if(!s.length||!t)return[];const n=[],c=new Set;for(const g of s){const r=Re(t,g.url,i,o),l=De(r);c.has(l)||(c.add(l),n.push({value:g.url,label:e.jsx(Nt,{resource:r}),text:l}))}return n.sort(ee),n},wt=(t,s)=>{const i={},o=t.entities[s].entitlements;for(const n of o)i[n.name]=n.description;return i},Gt=(t,s,i)=>{if(!s||!t)return[];const o=s[0].url,n=[],c=[];for(const r of s){if(r.url!==o)continue;const l={value:r.entitlement,label:r.entitlement};if(r.entitlement.includes("can_")){c.push({...l});continue}n.push({...l})}n.sort(ee),c.sort(ee),n.length>1&&c.length&&(n.unshift({disabled:!0,label:"Broad entitlement sets",value:"group"}),c.unshift({disabled:!0,label:"Granular entitlements",value:"group"}));const g=[...n,...c];if(i&&i.entities){const r=wt(i,t);for(const l of g)l.value&&typeof l.value=="string"&&r[l.value]&&(l.text=l.value,l.label=e.jsx(St,{entitlement:l.value,description:r[l.value]})),l.value==="group"&&(l.label=e.jsx("div",{className:"header u-no-padding",children:e.jsx("span",{className:"u-no-margin",children:e.jsx("h5",{className:"u-no-margin u-no-padding",children:l.label})})}))}return[...n,...c]},De=t=>{const s=t.project?` (project: ${t.project}) `:"",i=t.target?` (target: ${t.target}) `:"",o=t.pool?` (pool: ${t.pool}) `:"",n=t.aliases?` (aliases: ${t.aliases.join(", ")}) `:"",c=t.fingerprint?` (fingerprint: ${t.fingerprint}) `:"";return`${t.name}${i}${o}${s}${n}${c}`},ie=t=>t.entity_type+t.url+t.entitlement,Rt=t=>t.map(s=>ie(s)),Me=(t,s,i)=>{const o=Re(t.entity_type,t.url,s,i);return De(o)},_e=t=>{const s={};for(const i of t)s[i.fingerprint]={...i,name:`${pt(i)} (${i.type})`};return s},Be=t=>{const s={};for(const i of t)s[i.id]=U(i);return s},Pt=()=>{const t={};return $e.forEach((s,i)=>{t[s.value]=i}),t},ye=Pt(),Et=(t,s)=>{const i=ye[t.entity_type]-ye[s.entity_type],o=t.resourceLabel?.localeCompare(s.resourceLabel??""),n=t.entitlement.localeCompare(s.entitlement);return i||o||n},At=({resourceType:t})=>{const s=Ge(t);if(s.length<2)return null;const i=s.map(o=>e.jsx("span",{className:"resource u-no-margin--bottom",children:o==="imageType"?"image type":o},o));return e.jsx("div",{className:"header",children:i})},Lt=({onAddPermission:t,disableReason:s})=>{const i=a.useNotify(),[o,n]=w.useState(""),[c,g]=w.useState(""),[r,l]=w.useState(""),p=w.useRef(null),x=w.useRef(null),f=w.useRef(null),C=w.useRef(null),{data:S,isLoading:j,error:u}=Ue({queryKey:[M.permissions,o],queryFn:async()=>jt(o),enabled:!!o&&!s}),{data:b=[]}=Pe(),{data:v=[]}=Z(),y=_e(b),G=Be(v),{data:d,isLoading:m}=mt(),I=j||m;w.useEffect(()=>{setTimeout(()=>{p.current&&(p.current.focus(),p.current.tabIndex=-1)},100)},[]);const A=(R,P,k)=>{if(P==="server")return C.current?.open(),P;if(!R&&P||R&&P===R){if(k?.length)return f.current?.open(),P;x.current?.focus()}return P};w.useEffect(()=>{A("",o,S)},[o,S]);const $=R=>{const P=R;l(""),n(k=>A(k,P,S)),g(P==="server"?"/1.0":"")},D=R=>{g(R),C.current?.open()},B=R=>{l(R),document.getElementById("add-entitlement")?.focus()},E=()=>{const R={entity_type:o,url:c,entitlement:r};t({...R,id:ie(R),resourceLabel:Me(R,y,G)}),l("")};u&&i.failure("Loading permissions failed",u);const O=Ct(o,S??[],y,G),K=Gt(o,S,d),q=o==="server",N=O.length;return e.jsxs("div",{className:J("permission-selector",{"dropdown-disabled":!!s}),tabIndex:0,ref:p,title:s,children:[e.jsx(a.CustomSelect,{id:"resourceType",name:"resourceType",label:e.jsx("strong",{children:"Resource type"}),options:It(d),toggleClassName:"u-no-margin--bottom","aria-label":"Resource type",onChange:$,value:o,selectRef:x,searchable:"always",disabled:!!s}),e.jsx(a.CustomSelect,{id:"resource",name:"resource",label:e.jsx("strong",{children:"Resource"}),options:N?O:[vt],toggleClassName:"u-no-margin--bottom","aria-label":"Resource",onChange:D,value:c,disabled:I||!o||q||!N,dropdownClassName:"permissions-select-dropdown",header:e.jsx(At,{resourceType:o}),selectRef:f,searchable:"always"}),e.jsx(a.CustomSelect,{id:"entitlement",name:"entitlement",label:e.jsx("strong",{children:"Entitlement"}),options:K,toggleClassName:"u-no-margin--bottom","aria-label":"Entitlement",onChange:B,value:r,disabled:I||!c&&!q,dropdownClassName:"permissions-select-dropdown",selectRef:C,searchable:"always",initialPosition:"right"}),e.jsx("div",{className:"add-entitlement",children:e.jsx(a.Button,{id:"add-entitlement",appearance:"positive",onClick:E,className:"u-no-margin--bottom",disabled:!r,tabIndex:r?void 0:-1,children:"Add"})})]})},Oe=({permissions:t,setPermissions:s,group:i})=>{const o=a.useNotify(),[n,c]=w.useState(""),{canViewPermissions:g}=je(),{canEditGroup:r}=V(),l=()=>i&&!r(i)?"You do not have permission to edit this group":g()?H(i)?"Permissions for this group cannot be modified":"":"You are not allowed to view permissions",p=u=>{const b=t.find(d=>d.id===u.id);if(b&&!b.isRemoved)return;const y=Rt(i?.permissions??[]).includes(u.id??""),G={...u,isAdded:!y,isRemoved:!1};if(b&&b.isRemoved){const d=t.map(m=>m.id===u.id?G:m);s(d);return}b||s([...t,G])},x=u=>{let b;i?.permissions?.some(y=>ie(y)===u)?b=t.map(y=>y.id===u?{...y,isRemoved:!0,isAdded:!1}:y):b=t.filter(y=>y.id!==u),s(b)},f=n?t.filter(u=>u.entitlement.includes(n)||u.entity_type.includes(n)||u.resourceLabel?.toLowerCase().includes(n)):t,C=w.useMemo(()=>f.sort(Et),[f]),S=[{content:"Resource type",sortKey:"resourceType",className:"resource-type"},{content:"Resource",sortKey:"resource",className:"resource"},{content:"Entitlement",sortKey:"entitlement",className:"entitlement"},{"aria-label":"Actions",className:"u-align--right actions"}],j=C.map(u=>{const b=u.isAdded||u.isRemoved;return{key:u.id,name:u.id,className:J("u-row",{strikeout:u.isRemoved}),columns:[{content:u.entity_type,title:u.entity_type,role:"rowheader","aria-label":"Resource type",className:"resource-type"},{content:u.resourceLabel,role:"cell","aria-label":"Resource",className:"u-truncate resource",title:u.resourceLabel},{content:u.entitlement,role:"cell","aria-label":"Entitlement",className:"u-truncate entitlement",title:u.entitlement},{className:"actions u-align--right",content:e.jsxs(e.Fragment,{children:[u.isRemoved?e.jsx(a.Button,{appearance:"base",hasIcon:!0,dense:!0,onClick:()=>{p(u)},type:"button","aria-label":"Restore permission",title:"Restore permission",className:"u-no-margin--right",children:e.jsx(_,{icon:"restart"})}):e.jsx(a.Button,{appearance:"base",hasIcon:!0,dense:!0,onClick:()=>{x(u.id??"")},type:"button","aria-label":"Delete permission",title:l()??"Delete permission",className:"u-no-margin--right",disabled:!!l(),children:e.jsx(_,{icon:"delete"})}),e.jsx(a.Icon,{name:"status-in-progress-small",className:J({"hide-modified-status":!b}),"aria-hidden":!b,"aria-label":"Permission modified"})]}),role:"cell","aria-label":"Delete permission"}],sortData:{resourceType:u.entity_type.toLowerCase(),resource:u.resourceLabel?.toLowerCase(),entitlement:u.entitlement.toLowerCase()}}});return e.jsxs(a.ScrollableContainer,{dependencies:[o.notification,t.length],belowIds:["panel-footer"],children:[e.jsxs(a.Card,{children:[e.jsx("strong",{children:e.jsx("p",{className:"u-no-margin--bottom",children:"Add permissions"})}),e.jsx("span",{children:"Entitlements need to be given in relation to a specific resource. Select the appropriate resource and entitlement below and add it to the list of permissions for this group."}),e.jsx(Lt,{onAddPermission:p,disableReason:l()})]}),e.jsx(a.SearchBox,{externallyControlled:!0,value:n,onChange:c}),t.length?e.jsx(a.MainTable,{id:"permissions-table",headers:S,sortable:!0,responsive:!0,emptyStateMsg:"No permissions match the search criteria.",rows:j,className:"permissions-table"}):e.jsx(a.EmptyState,{className:"empty-state empty-state__full-width",image:e.jsx(_,{icon:"plans",className:"empty-state-icon"}),title:"No permissions",children:e.jsx("p",{children:"Select a permission above and add to the group"})})]})},qe=({subForm:t,setSubForm:s,group:i})=>{if(t===null)return e.jsx(ue,{children:i?`Edit auth group ${i?.name}`:"Create auth group"});const o=i?"Edit":"Add";return e.jsx(ct,{linkText:i?"Edit auth group":"Create auth group",title:`${o} ${F(t,2)}`,onClick:()=>{s(null)}})},Tt=()=>{const t=Y(),s=a.useNotify(),i=a.useToastNotification(),o=te(),n=w.useState(null),[c,g]=w.useState([]),[r,l]=w.useState([]),p=t.subForm,x=v=>{t.openCreateGroup(v)},f=()=>{t.clear(),s.clear()};ce(()=>{p?x(null):f()});const S=Ne().shape({name:Se().test(...Ae(n)).required("Group name is required")}),j=v=>{i.success(e.jsxs(e.Fragment,{children:["Group"," ",e.jsx(me,{type:"auth-group",value:v,to:`${se}/ui/permissions/groups`})," ","created."]})),f()},u=v=>{if(c.length===0){j(v);return}const y=c.map(G=>{const d=G.groups||[];return G.groups=[...d,v],G});re(y).then(()=>{j(v)}).catch(G=>{s.failure(`Group ${v} created, failed to add identities.`,G)}).finally(()=>{b.setSubmitting(!1),o.invalidateQueries({queryKey:[M.authGroups]})})},b=ve({initialValues:{name:"",description:""},validationSchema:S,onSubmit:v=>{tt({name:v.name,description:v.description,permissions:r.filter(y=>!y.isRemoved)}).then(()=>{u(v.name)}).catch(y=>{s.failure("Group creation failed",y)}).finally(()=>{b.setSubmitting(!1),o.invalidateQueries({queryKey:[M.authGroups]})})}});return e.jsx(e.Fragment,{children:e.jsxs(a.SidePanel,{className:J({"edit-permissions-panel":p==="permission"}),children:[e.jsx(a.SidePanel.Header,{children:e.jsx(a.SidePanel.HeaderTitle,{children:e.jsx(qe,{subForm:p,setSubForm:x})},p??"start")}),e.jsx(ne,{className:"u-no-padding"}),e.jsx(a.SidePanel.Content,{className:"u-no-padding",children:e.jsxs(a.ScrollableContainer,{dependencies:[s.notification,p],belowIds:["panel-footer"],children:[p===null&&e.jsx(ke,{formik:b,setSubForm:x,identityCount:c.length,identityModifyCount:c.length,permissionCount:r.length,permissionModifyCount:r.length,isEditing:!1}),p==="identity"&&e.jsx(Fe,{selected:c,setSelected:g,groupName:b.values.name}),p==="permission"&&e.jsx(Oe,{permissions:r,setPermissions:l})]})}),e.jsxs(a.SidePanel.Footer,{className:"u-align--right",children:[e.jsx(a.Button,{appearance:"base",onClick:f,className:"u-no-margin--bottom",children:"Cancel"}),e.jsx(a.ActionButton,{appearance:"positive",loading:b.isSubmitting,onClick:()=>{b.submitForm()},className:"u-no-margin--bottom",disabled:!b.isValid||b.isSubmitting||!b.values.name,children:"Create group"})]})]})})},kt=({group:t,onClose:s})=>{const i=Y(),o=a.useNotify(),n=a.useToastNotification(),c=te(),g=w.useState(null),[r,l]=w.useState(!1),[p,x]=w.useState(Q(t).map(N=>({id:N}))),[f,C]=w.useState(t.permissions??[]),{data:S}=xe(),j=S?.auth_user_name??"",{canEditGroup:u}=V(),b=i.subForm,v=N=>{i.openEditGroup(i.group??"",N)},{data:y=[],isLoading:G,isError:d}=Z();w.useEffect(()=>{if(!G&&!d){const N=new Set(Q(t)),R=y.filter(P=>N.has(P.id));x(R)}},[G,d,y,t]);const{data:m=[],isLoading:I,isError:A}=Pe();w.useEffect(()=>{if(!G&&!d&&!I&&!A){const N=_e(m),R=Be(y),P=(t.permissions??[]).map(k=>{const T=ie(k),h=Me(k,N,R);return{...k,resourceLabel:h,id:T}});C(P)}},[G,d,I,A,y,m,t]);const $=Ne().shape({name:Se().test(...Ae(g,i.group??"")).required("Group name is required")}),D=async N=>{const R=p.filter(T=>T.isAdded),P=p.filter(T=>T.isRemoved);if(R.length===0&&P.length===0)return;const k=[];return R.map(T=>{k.push({...T,groups:[...T.groups||[],E.values.name]})}),P.map(T=>{k.push({...T,groups:[...(T.groups||[]).filter(h=>h!==N)]})}),re(k)},B=N=>{const R=N.name!==t?.name,P=t?.name??"",k={...t,name:N.name,description:N.description,permissions:f.filter(h=>!h.isRemoved)};(async()=>!u(t)||H(t)?D(P):R?st(P,N.name).then(async()=>he(k)).then(async()=>D(P)):he(k).then(async()=>D(P)))().then(()=>{O(),n.success(e.jsxs(e.Fragment,{children:["Auth group"," ",e.jsx(me,{type:"auth-group",value:N.name,to:`${se}/ui/permissions/groups`})," ","updated."]}))}).catch(h=>{o.failure("Group update failed",h)}).finally(()=>{E.setSubmitting(!1),c.invalidateQueries({queryKey:[M.authGroups]}),c.invalidateQueries({queryKey:[M.currentIdentity]})})},E=ve({initialValues:{name:t?.name??"",description:t?.description??""},enableReinitialize:!0,validationSchema:$,onSubmit:N=>{const R=Q(t).includes(j),P=p.find(T=>T.id===j)?.isRemoved,k=f.find(T=>T.isRemoved);P||R&&k?l(!0):B(N)}}),O=()=>{i.clear(),o.clear(),s?.()};ce(()=>{b?v(null):O()});const q=p.filter(N=>N.isAdded||N.isRemoved).length+f.filter(N=>N.isAdded||N.isRemoved).length+(E.values.name!==t.name?1:0)+(E.values.description!==t.description?1:0);return e.jsxs(e.Fragment,{children:[e.jsxs(a.SidePanel,{className:J({"edit-permissions-panel":b==="permission"}),children:[e.jsx(a.SidePanel.Header,{children:e.jsx(a.SidePanel.HeaderTitle,{className:"u-truncate",children:e.jsx(qe,{subForm:b,setSubForm:v,group:t})},b??"start")}),e.jsx(ne,{className:"u-no-padding"}),e.jsxs(a.SidePanel.Content,{className:"u-no-padding",children:[b===null&&e.jsx(a.ScrollableContainer,{dependencies:[o.notification,b],belowIds:["panel-footer"],children:e.jsx(ke,{formik:E,setSubForm:v,identityCount:p.filter(N=>!N.isRemoved).length,identityModifyCount:p.filter(N=>N.isAdded||N.isRemoved).length,permissionCount:f.filter(N=>!N.isRemoved).length,permissionModifyCount:f.filter(N=>N.isAdded||N.isRemoved).length,group:t})}),b==="identity"&&e.jsx(Fe,{selected:p,setSelected:x,groupName:t.name,group:t}),b==="permission"&&e.jsx(Oe,{permissions:f,setPermissions:C,group:t})]}),e.jsxs(a.SidePanel.Footer,{className:"u-align--right",children:[e.jsx(a.Button,{appearance:"base",onClick:O,className:"u-no-margin--bottom",children:"Cancel"}),e.jsx(a.ActionButton,{appearance:"positive",loading:E.isSubmitting,onClick:()=>{E.submitForm()},className:"u-no-margin--bottom",disabled:!E.isValid||E.isSubmitting||!E.values.name||q===0,children:q===0?"Save changes":`Save ${q} ${F("change",q)}`})]})]}),r&&e.jsx(a.ConfirmationModal,{confirmButtonLabel:"Confirm changes",confirmButtonAppearance:"positive",onConfirm:()=>{B(E.values)},close:()=>{l(!1),E.setSubmitting(!1)},title:"Confirm permission modification",className:"permission-confirm-modal",children:e.jsx(Ie,{isVisible:!0})})]})},Ft=({groups:t,className:s})=>{const i=Y();return e.jsx(e.Fragment,{children:e.jsxs(a.Button,{onClick:()=>{i.openGroupIdentities()},"aria-label":"Manage identities",title:"Manage identities",className:s,disabled:!t.length,hasIcon:!0,children:[e.jsx(_,{icon:"user-group"}),e.jsx("span",{children:"Manage identities"})]})})},$t=({onConfirm:t,close:s,addedIdentities:i,removedIdentities:o,selectedGroups:n,allIdentities:c})=>{const[g,r]=w.useState(!1),l=a.useNotify(),p=Y(),x=te(),f=a.useToastNotification(),C=yt(c,n,i,o),S=Ve(C),j=()=>{r(!0);const u=Le(c,i,o),b=Te(i,o,n,u),v=u.map(y=>({...y,groups:b[y.id]}));re(v).then(()=>{x.invalidateQueries({predicate:d=>[M.identities,M.authGroups,M.currentIdentity].includes(d.queryKey[0])});const y=Object.keys(S),G=y.length>1?`Updated identities for ${y.length} groups`:e.jsxs(e.Fragment,{children:["Updated identities for"," ",e.jsx(me,{type:"auth-group",value:y[0],to:`${se}/ui/permissions/groups`})]});f.success(G),p.clear(),l.clear()}).catch(y=>{l.failure("Update groups failed",y)}).finally(()=>{r(!1),t()})};return e.jsx(a.ConfirmationModal,{confirmButtonLabel:"Confirm changes",confirmButtonAppearance:"positive",onConfirm:j,close:s,title:"Confirm modification",className:"permission-confirm-modal",confirmButtonLoading:g,children:e.jsx(it,{identityGroupsChangeSummary:C,groupIdentitiesChangeSummary:S,identities:c,initialGroupBy:"group"})})},Dt=({groups:t})=>{const s=Y(),[i]=We(),o=a.useNotify(),[n,c]=w.useState(!1),{data:g=[],error:r,isLoading:l}=Z(),{canEditIdentity:p}=Ce(),x=g.filter(h=>!p(h)),{desiredState:f,save:C,undo:S}=ft({initialState:{identitiesAdded:new Set,identitiesRemoved:new Set}});r&&o.failure("Loading panel details failed",r),w.useEffect(()=>{if(!t.length){s.clear();return}},[t]);const j=g.filter(h=>!we(h)),{identityIdsInAllGroups:u,identityIdsInNoGroups:b,identityIdsInSomeGroups:v}=bt(t,j),y=new Set(f.identitiesAdded);for(const h of u)f.identitiesRemoved.has(h)||y.add(h);const G=new Set(v.filter(h=>!y.has(h)&&!f.identitiesRemoved.has(h))),d=new Set;t.forEach(h=>{Q(h).forEach(L=>d.add(L))});const m=d.size>0,I=()=>{const h=new Set;for(const L of u)y.has(L)||h.add(L);for(const L of v)G.has(L)||h.add(L);for(const L of b)y.has(L)&&h.add(L);return h},A=(h,L)=>{C(L?{identitiesAdded:new Set,identitiesRemoved:new Set(j.map(W=>W.id))}:{identitiesAdded:new Set(h),identitiesRemoved:new Set})},$=h=>{const L=y.has(h),W=G.has(h),z=new Set(f.identitiesAdded),oe=new Set(f.identitiesRemoved);L||W?(z.delete(h),oe.add(h)):(z.add(h),oe.delete(h)),C({identitiesAdded:z,identitiesRemoved:oe})},D=()=>{s.clear(),o.clear(),c(!1)};ce(D);const B=()=>{o.clear(),c(!1)},E=I(),O=[{content:"Identity",sortKey:"name"},{content:"","aria-label":"Modified status",className:"modified-status"}],K={queries:i.getAll(rt),authMethod:i.getAll(at),systemIdentities:i.get(ot)},N=j.filter(h=>!(K.systemIdentities==="hide"&&ut(h)||!K.queries.every(L=>U(h).toLowerCase().includes(L.toLowerCase())||h.id.toLowerCase().includes(L.toLowerCase()))||K.authMethod.length>0&&!K.authMethod.includes(h.authentication_method))).map(h=>{const L=t.length>1?"all selected groups":`group ${t[0].name}`,W=f.identitiesAdded.has(h.id)?`Identity will be added to ${L}`:f.identitiesRemoved.has(h.id)?`Identity will be removed from ${L}`:"",z=U(h);return{key:h.id,name:h.id,className:"u-row",columns:[{content:z,role:"rowheader","aria-label":"Identity",title:p(h)?z:"You do not have permission to manage this identity"},{content:E.has(h.id)&&e.jsx(a.Icon,{name:"status-in-progress-small"}),role:"cell","aria-label":"Modified status",className:"modified-status u-align--right",title:W}],sortData:{name:z.toLowerCase(),isPreselected:d.has(h.id)}}}),{rows:R}=de({rows:N,defaultSort:m?"isPreselected":"name",defaultSortDirection:m?"descending":"ascending"}),P=e.jsx(a.ScrollableTable,{dependencies:[g,E.size,o.notification],tableId:"group-identities-table",belowIds:["panel-footer"],children:e.jsx(le,{id:"group-identities-table",className:"group-identities-table",headers:O,rows:R,sortable:!0,emptyStateMsg:"No identities found",itemName:"identity",parentName:"server",selectedNames:Array.from(y),setSelectedNames:A,disabledNames:x.map(h=>h.id),filteredNames:j.map(h=>h.id),indeterminateNames:Array.from(G),onToggleRow:$,hideContextualMenu:!0,disableSelectAll:!!x.length})}),k=E.size?`Apply ${E.size} identity ${F("change",E.size)}`:"Modify identities",T=t.length>1?`Change identities for ${t.length} groups`:`Change identities for ${t[0]?.name}`;return e.jsxs(e.Fragment,{children:[e.jsxs(a.SidePanel,{loading:l,hasError:!g,children:[e.jsx(a.SidePanel.Header,{children:e.jsx(a.SidePanel.HeaderTitle,{children:e.jsx(ue,{children:T})})}),e.jsx(ne,{className:"u-no-padding"}),e.jsx(lt,{}),e.jsx(a.SidePanel.Content,{className:"u-no-padding",children:e.jsx(a.ScrollableContainer,{dependencies:[E.size,o.notification],belowIds:["panel-footer"],children:P})}),e.jsxs(a.SidePanel.Footer,{className:"u-align--right",children:[E.size?e.jsx(gt,{modifiedCount:E.size,onUndoChange:S,itemName:"identity"}):null,e.jsx(a.Button,{appearance:"base",onClick:D,className:"u-no-margin--bottom",children:"Cancel"}),e.jsx(a.ActionButton,{appearance:"positive",onClick:()=>{c(!0)},className:"u-no-margin--bottom",disabled:E.size===0,children:k})]})]}),n&&e.jsx($t,{close:B,onConfirm:B,selectedGroups:t,addedIdentities:f.identitiesAdded,removedIdentities:f.identitiesRemoved,allIdentities:j})]})},Mt=({groups:t,className:s,onDelete:i})=>{const[o,n]=w.useState(!1),{canDeleteGroup:c}=V(),g=t.filter(c),r=()=>{n(!0)},l=()=>{i(),n(!1)};return e.jsxs(e.Fragment,{children:[e.jsxs(a.Button,{onClick:r,title:g.length?"Delete groups":`You do not have permission to delete the selected ${F("group",t.length)}`,className:s,hasIcon:!0,disabled:!g.length,children:[e.jsx(_,{icon:"delete"}),e.jsx("span",{children:`Delete ${t.length} ${F("group",t.length)}`})]}),o&&e.jsx(Ee,{groups:t,close:l})]})},_t=({group:t})=>{const{data:s=[]}=Z(),i=new Set(t.identities?.oidc??[]),o=s.filter(n=>n.authentication_method!=="oidc"||i.has(n.name)?!1:n.effective_groups?.includes(t.name)).map(n=>n.name);return o.length===0?null:e.jsx(a.Tooltip,{className:"u-margin-left--small",message:e.jsxs(e.Fragment,{children:["Additional identities from Identity provider group mappings:",e.jsx(a.List,{className:"u-no-margin--bottom",items:o})]}),children:e.jsxs("span",{tabIndex:0,className:"u-text--muted","aria-label":`${o.length} additional ${F("identity",o.length)} through identity provider group mappings`,children:[" ","+",o.length]})})},ps=()=>{const t=a.useNotify(),{data:s=[],error:i,isLoading:o}=nt(),n=Y(),[c,g]=w.useState(""),[r,l]=w.useState([]),{canCreateGroups:p}=je(),x=Xe();i&&t.failure("Loading groups failed",i),w.useEffect(()=>{const m=r.filter(I=>s.some(A=>A.name===I));m.length!==r.length&&l(m)},[s]),w.useEffect(()=>{n.group&&l([n.group])},[n.group,s]);const f=[{content:"Name",className:"name",sortKey:"name"},{content:"Description",className:"description",sortKey:"description"},{content:"Identities",sortKey:"identities",className:"u-align--right identities"},{content:"Permissions",sortKey:"permissions",className:"u-align--right permissions"},{"aria-label":"Actions",className:"u-align--right actions",heading:"Actions"}],C=s.filter(m=>!c||m.name.toLowerCase().includes(c)||m.description.toLowerCase().includes(c)),S=s.filter(m=>r.includes(m.name)),j=s.find(m=>m.name===n.group),u=C.map(m=>{const I=Q(m);return{key:m.name,name:m.name,className:"u-row",columns:[{content:m.name,role:"rowheader","aria-label":"Name",className:"u-truncate name",title:m.name},{content:e.jsx("span",{children:m.description}),role:"cell","aria-label":"Description",className:"description",title:m.description},{content:e.jsxs(e.Fragment,{children:[e.jsx(a.Button,{appearance:"link",dense:!0,onClick:()=>{n.openEditGroup(m.name,"identity")},children:I.length}),e.jsx(_t,{group:m})]}),role:"cell",className:"u-align--right identities","aria-label":"Identities in this group"},{content:e.jsx(a.Button,{appearance:"link",dense:!0,onClick:()=>{n.openEditGroup(m.name,"permission")},children:m.permissions?.length||0}),role:"cell",className:"u-align--right permissions","aria-label":"Permissions for this group"},{className:"actions u-align--right",content:e.jsx(xt,{group:m}),role:"cell","aria-label":"Actions"}],sortData:{name:m.name.toLowerCase(),description:m.description.toLowerCase(),permissions:m.permissions?.length||0,identities:I.length}}}),{rows:b,updateSort:v}=de({rows:u,defaultSort:"name"});if(o)return e.jsx(a.Spinner,{className:"u-loader",text:"Loading...",isMainComponent:!0});const y=()=>r.length>0?e.jsx(Ze,{totalCount:s.length??0,itemName:"group",parentName:"",selectedNames:r,setSelectedNames:l,filteredNames:C.map(m=>m.name),hideActions:!!n.panel}):null,G=s.length>0,d=G?e.jsx(a.ScrollableTable,{dependencies:[s],tableId:"groups-table",belowIds:["status-bar"],children:e.jsx(a.TablePagination,{data:b,id:"pagination",itemName:"group",className:"u-no-margin--top","aria-label":"Table pagination control",description:y(),children:e.jsx(le,{id:"groups-table",className:"groups-table",headers:f,rows:b,sortable:!0,responsive:!0,emptyStateMsg:"No groups found matching this search",onUpdateSort:v,itemName:"group",parentName:"",selectedNames:r,setSelectedNames:l,disabledNames:[],filteredNames:C.map(m=>m.name),disableSelect:!!n.panel})})}):e.jsxs(a.EmptyState,{className:"empty-state",image:e.jsx(_,{icon:"user-group",className:"empty-state-icon"}),title:"No groups",children:[e.jsx("p",{children:"Auth groups are an easy way to manage the structured assignment of permissions"}),e.jsx("p",{children:e.jsx(Je,{docPath:"/explanation/authorization",hasExternalIcon:!0,children:"Learn more about permissions"})}),e.jsxs(a.Button,{className:"empty-state-button",appearance:"positive",onClick:()=>{n.openCreateGroup()},disabled:!p(),title:p()?void 0:"You do not have permission to create groups",hasIcon:!x,children:[!x&&e.jsx(_,{icon:"plus"}),e.jsx("span",{children:"Create group"})]})]});return e.jsxs(e.Fragment,{children:[e.jsxs(a.CustomLayout,{mainClassName:"permission-groups-list",contentClassName:"u-no-padding--bottom",header:e.jsxs(X,{children:[e.jsxs(X.Left,{children:[e.jsx(X.Title,{children:e.jsx(ue,{children:"Auth groups"})}),!r.length&&G&&e.jsx(X.Search,{children:e.jsx(ht,{onChange:g,value:c,disabled:!!n.group,className:"u-no-margin--bottom"})}),r.length>0&&!n.panel&&e.jsxs("div",{children:[e.jsx(Ft,{groups:S,className:"u-no-margin--bottom"}),e.jsx(Mt,{groups:S,className:"u-no-margin--bottom",onDelete:()=>{l([])}})]})]}),G&&e.jsx(X.BaseActions,{children:!r.length&&e.jsxs(a.Button,{appearance:"positive",className:"u-no-margin--bottom u-float-right",onClick:()=>{n.openCreateGroup()},disabled:!p(),title:p()?void 0:"You do not have permission to create groups",hasIcon:!x,children:[!x&&e.jsx(_,{icon:"plus"}),e.jsx("span",{children:"Create group"})]})})]}),children:[!n.panel&&e.jsx(ne,{}),e.jsx(a.Row,{className:"permission-groups",children:d})]}),n.panel===ae.createGroup&&e.jsx(Tt,{}),n.panel===ae.editGroup&&j&&e.jsx(kt,{group:j,onClose:()=>{l([])}}),n.panel===ae.groupIdentities&&!!S.length&&e.jsx(Dt,{groups:S})]})};export{ps as default};

Youez - 2016 - github.com/yon3zu
LinuXploit