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.178
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/41172/share/lxd-ui/assets/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /snap/lxd/41172/share/lxd-ui/assets/PermissionGroups-BAj8Q3_X.js
import{u as qe,z as me,s as ee,d as a,r as w,b as xe,j as e,B as F,t as M,a7 as Ke,cp as U,cO as Y,R as te,ax as ze,cP as He,E as Ye,M as Ue,q as X,v as ye,e as je,f as Ne,h as Se,o as se,cB as ae,cz as Qe,aO as Ve,w as We,G as Xe}from"./index-H4PaR1Ay.js";import{S as re}from"./SelectableMainTable-DVpI1gAH.js";import{S as Je}from"./SelectedTableNotification-BiyTngX2.js";import{u as le}from"./useSortTableData-Dpr3aigs.js";import{u as H,a as de,p as oe}from"./useEscCallback-zQN3vs8-.js";import{P as W}from"./PageHeader-B4TDXmgd.js";import{P as ce}from"./PermissionGroupExplanationTooltip-BuwVgl1e.js";import{d as Ze,c as et,r as tt,a as pe,u as st}from"./useAuthGroups-DoXs8Br2.js";import{R as he}from"./ResourceLabel-BMIFVwPY.js";import{L as Ie,u as ve,G as nt,S as it,A as ot,Q as at,P as rt}from"./GroupOrIdentityChangesTable-CTugDHiQ.js";import{A as lt}from"./AutoExpandingTextArea-BxIWUale.js";import{F as fe,B as dt}from"./BackLink-Cuy7YFjT.js";import{i as Ce,b as ct}from"./identity-vaJmuAxa.js";import{u as J}from"./useIdentities-BSj8RxAb.js";import{u as ut}from"./useConfigOptions-qesCQJVe.js";import{b as we,e as Ge}from"./resourceDetails-DtLpXei1.js";import{g as mt}from"./images-BuQHcoRx.js";import{h as Re}from"./useImages-BYHePzIj.js";import{R as ue}from"./ResourceLink-uXW9L0Ar.js";import{P as pt}from"./PermissionGroupsFilter-aMoqtdI7.js";import{u as ht,M as ft}from"./useEditHistory-DWscjFrh.js";import"./ExplanationTooltip-BtzkKEJm.js";import"./searchAndFilter-CpMRkW43.js";import"./promises-DrIa_NWl.js";import"./index-BCn5QfZZ.js";import"./imageRegistry-BR44AA00.js";import"./image-registries-CM9txDWK.js";const Q=()=>{const{isFineGrained:t}=qe();return{canDeleteGroup:o=>me(t,"can_delete",o?.access_entitlements),canEditGroup:o=>me(t,"can_edit",o?.access_entitlements)}},Pe=({groups:t,close:s})=>{const i=ee(),o=a.useNotify(),n=a.useToastNotification(),[c,g]=w.useState(!0),[r,l]=w.useState(!1),p="confirm-delete-group",{canDeleteGroup:y}=Q(),{data:f}=xe(),C=f?.auth_user_name??"",S=[],j=[];let u=!1;t.forEach(d=>{y(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,I=d=>{g(d.target.value!==p)},x=()=>{l(!0);const m=j.length===1?e.jsxs(e.Fragment,{children:["Group"," ",e.jsx(he,{bold:!0,type:"auth-group",value:j[0].name})," ","deleted."]}):`${j.length} groups deleted.`;Ze(j.map(v=>v.name)).then(()=>{i.invalidateQueries({predicate:v=>[M.identities,M.authGroups,M.currentIdentity].includes(v.queryKey[0])}),n.success(m),s()}).catch(v=>{o.failure(`Failed deleting ${j.length} ${F("group",j.length)}.`,v)}).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(he,{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:I,placeholder:p,className:"u-no-margin--bottom",disabled:!j.length})},"confirm-input"),e.jsxs(a.ActionButton,{appearance:"negative",className:"u-no-margin--bottom",onClick:x,loading:r,disabled:c||r,children:["Permanently delete ",j.length," ",F("group",j.length)]},"confirm-action-button")],children:G()})},z=t=>t?.name==="admins",Ee=(t,s)=>["deduplicate","A group with this name already exists",async i=>s&&i===s||Ke(i,"",t,"auth/groups")],gt=(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,y=!p&&r>0;if(p){o.push(g.id);continue}if(y){n.push(g.id);continue}c.push(g.id)}return{identityIdsInAllGroups:o,identityIdsInSomeGroups:n,identityIdsInNoGroups:c}},Ae=(t,s,i)=>t.filter(n=>s.has(n.id)||i.has(n.id)),Le=(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||[],y=new Set(p);for(const f of p)c.has(l.id)&&g.has(f)&&y.delete(f);for(const f of i)n.has(l.id)&&y.add(f.name);r[l.id]=Array.from(y)}return r},bt=(t,s,i,o)=>{const n=Ae(t,i,o),c=Le(i,o,s,n),g={};for(const r of n){const l=c[r.id];if(!l)continue;const p=new Set,y=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)||y.add(S);(p.size||y.size)&&(g[r.id]={added:p,removed:y,name:U(r)})}return g},xt=({group:t})=>{const s=H(),{openPortal:i,closePortal:o,isOpen:n,Portal:c}=a.usePortal(),{canDeleteGroup:g,canEditGroup:r}=Q(),l=()=>z(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(a.Icon,{name:"edit"})},"edit"),e.jsx(a.Button,{appearance:"base",dense:!0,hasIcon:!0,onClick:i,type:"button",title:l(),disabled:z(t)||!g(t),children:e.jsx(a.Icon,{name:"delete"})},"delete")]}),n&&e.jsx(c,{children:e.jsx(Pe,{groups:[t],close:o})})]})},Te=({formik:t,setSubForm:s,identityCount:i,identityModifyCount:o,permissionCount:n,permissionModifyCount:c,isEditing:g=!0,group:r})=>{const{canEditGroup:l}=Q(),p=I=>({id:I,name:I,onBlur:t.handleBlur,onChange:t.handleChange,value:t.values[I]??"",error:t.touched[I]?t.errors[I]:null,placeholder:`Enter ${I.replaceAll("_"," ")}`}),y=!g||l(r)?"":"You do not have permission to modify this group",f=!t.values.name||!!t.errors.name,C=!!y||f,S=f,u=(()=>{if(y)return y;if(r&&z(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:!!y||z(r),title:y||u}),e.jsx(lt,{...p("description"),label:"Description",disabled:C||z(r),title:u}),e.jsx(fe,{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(fe,{title:b()+F("permission",2),icon:"lock-locked",onClick:()=>{s("permission")},isModified:c>0,subText:n===0?`No ${F("permission",2)}`:`${n} ${F("permission",n)}`,disabled:S,onHoverText:u})]})},ke=({selected:t,setSelected:s,groupName:i,group:o})=>{const n=a.useNotify(),[c,g]=w.useState(null),{data:r=[],error:l}=J(),{canEditIdentity:p}=ve(),y=r.filter(d=>!p(d)).map(d=>d.id);l&&n.failure("Loading details failed",l);const f=r.filter(d=>!Ce(d)),C=new Set(Y(o)),S=C.size>0,j=d=>{if(y.includes(d))return;const m=t.find(v=>v.id===d);if(m){const v=t.filter(_=>_.id!==d),A={...m,isAdded:!m.isAdded,isRemoved:!m.isRemoved},$=m.groups?.includes(i);if(A.isRemoved&&!$){s(v);return}A.isAdded=!$,s([...v,A])}else{const v=r.find(A=>A.id===d);if(!v){n.failure("Selection failed",new Error("Identity not found"));return}s([...t,{...v,isAdded:!0,isRemoved:!1}])}},u=d=>{if(d.length===0){const v=[];t.forEach(A=>{A.groups?.includes(i)&&v.push({...A,isAdded:!1,isRemoved:!0})}),s(v);return}const m=r.filter(v=>d.includes(v.id)).map(v=>({...v,isAdded:!v.groups?.includes(i),isRemoved:!1}));s(m)},b=[{content:"Identity",sortKey:"name"},{content:"","aria-label":"Modified status",className:"modified-status"}],x=f.filter(d=>c?U(d).toLowerCase().includes(c.toLowerCase()):!0).map(d=>{const m=()=>{j(d.id)},v=t.find(D=>D.id===d.id),A=v?.isAdded||v?.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}=le({rows:x,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(re,{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:y,filteredNames:f.map(d=>d.id),indeterminateNames:[],onToggleRow:j,hideContextualMenu:!0,disableSelectAll:!!y.length})})]})},yt=async t=>{const s=new URLSearchParams;return s.set("entity-type",t),fetch(`${te}/1.0/auth/permissions?${s.toString()}`).then(ze).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)))},jt=({resource:t})=>{const i=we(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})},Nt=({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 ge=He();const St={disabled:!0,label:"None available",value:""},Fe=[{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"}],Z=(t,s)=>{const i=ge.getOptionText(t)||t.value,o=ge.getOptionText(s)||s.value;return i.localeCompare(o)},It=t=>{if(!t||!t.entities)return Fe.sort(Z);const s=[],i=Object.keys(t.entities);for(const o of i){const n=o.split("_");n[0]=Ye(n[0]),s.push({value:o,label:n.join(" ")})}return s},vt=(t,s,i,o)=>{if(!s.length||!t)return[];const n=[],c=new Set;for(const g of s){const r=Ge(t,g.url,i,o),l=$e(r);c.has(l)||(c.add(l),n.push({value:g.url,label:e.jsx(jt,{resource:r}),text:l}))}return n.sort(Z),n},Ct=(t,s)=>{const i={},o=t.entities[s].entitlements;for(const n of o)i[n.name]=n.description;return i},wt=(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(Z),c.sort(Z),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=Ct(i,t);for(const l of g)l.value&&typeof l.value=="string"&&r[l.value]&&(l.text=l.value,l.label=e.jsx(Nt,{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]},$e=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}`},ne=t=>t.entity_type+t.url+t.entitlement,Gt=t=>t.map(s=>ne(s)),De=(t,s,i)=>{const o=Ge(t.entity_type,t.url,s,i);return $e(o)},Me=t=>{const s={};for(const i of t)s[i.fingerprint]={...i,name:`${mt(i)} (${i.type})`};return s},_e=t=>{const s={};for(const i of t)s[i.id]=U(i);return s},Rt=()=>{const t={};return Fe.forEach((s,i)=>{t[s.value]=i}),t},be=Rt(),Pt=(t,s)=>{const i=be[t.entity_type]-be[s.entity_type],o=t.resourceLabel?.localeCompare(s.resourceLabel??""),n=t.entitlement.localeCompare(s.entitlement);return i||o||n},Et=({resourceType:t})=>{const s=we(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})},At=({onAddPermission:t,disableReason:s})=>{const i=a.useNotify(),[o,n]=w.useState(""),[c,g]=w.useState(""),[r,l]=w.useState(""),p=w.useRef(null),y=w.useRef(null),f=w.useRef(null),C=w.useRef(null),{data:S,isLoading:j,error:u}=Ue({queryKey:[M.permissions,o],queryFn:async()=>yt(o),enabled:!!o&&!s}),{data:b=[]}=Re(),{data:I=[]}=J(),x=Me(b),G=_e(I),{data:d,isLoading:m}=ut(),v=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;y.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()},_=R=>{l(R),document.getElementById("add-entitlement")?.focus()},E=()=>{const R={entity_type:o,url:c,entitlement:r};t({...R,id:ne(R),resourceLabel:De(R,x,G)}),l("")};u&&i.failure("Loading permissions failed",u);const B=vt(o,S??[],x,G),q=wt(o,S,d),O=o==="server",N=B.length;return e.jsxs("div",{className:X("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:y,searchable:"always",disabled:!!s}),e.jsx(a.CustomSelect,{id:"resource",name:"resource",label:e.jsx("strong",{children:"Resource"}),options:N?B:[St],toggleClassName:"u-no-margin--bottom","aria-label":"Resource",onChange:D,value:c,disabled:v||!o||O||!N,dropdownClassName:"permissions-select-dropdown",header:e.jsx(Et,{resourceType:o}),selectRef:f,searchable:"always"}),e.jsx(a.CustomSelect,{id:"entitlement",name:"entitlement",label:e.jsx("strong",{children:"Entitlement"}),options:q,toggleClassName:"u-no-margin--bottom","aria-label":"Entitlement",onChange:_,value:r,disabled:v||!c&&!O,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"})})]})},Be=({permissions:t,setPermissions:s,group:i})=>{const o=a.useNotify(),[n,c]=w.useState(""),{canViewPermissions:g}=ye(),{canEditGroup:r}=Q(),l=()=>i&&!r(i)?"You do not have permission to edit this group":g()?z(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 x=Gt(i?.permissions??[]).includes(u.id??""),G={...u,isAdded:!x,isRemoved:!1};if(b&&b.isRemoved){const d=t.map(m=>m.id===u.id?G:m);s(d);return}b||s([...t,G])},y=u=>{let b;i?.permissions?.some(x=>ne(x)===u)?b=t.map(x=>x.id===u?{...x,isRemoved:!0,isAdded:!1}:x):b=t.filter(x=>x.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(Pt),[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:X("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(a.Icon,{name:"restart"})}):e.jsx(a.Button,{appearance:"base",hasIcon:!0,dense:!0,onClick:()=>{y(u.id??"")},type:"button","aria-label":"Delete permission",title:l()??"Delete permission",className:"u-no-margin--right",disabled:!!l(),children:e.jsx(a.Icon,{name:"delete"})}),e.jsx(a.Icon,{name:"status-in-progress-small",className:X({"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(At,{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(a.Icon,{name:"plans",className:"empty-state-icon"}),title:"No permissions",children:e.jsx("p",{children:"Select a permission above and add to the group"})})]})},Oe=({subForm:t,setSubForm:s,group:i})=>{if(t===null)return e.jsx(ce,{children:i?`Edit auth group ${i?.name}`:"Create auth group"});const o=i?"Edit":"Add";return e.jsx(dt,{linkText:i?"Edit auth group":"Create auth group",title:`${o} ${F(t,2)}`,onClick:()=>{s(null)}})},Lt=()=>{const t=H(),s=a.useNotify(),i=a.useToastNotification(),o=ee(),n=w.useState(null),[c,g]=w.useState([]),[r,l]=w.useState([]),p=t.subForm,y=I=>{t.openCreateGroup(I)},f=()=>{t.clear(),s.clear()};de(()=>{p?y(null):f()});const S=je().shape({name:Ne().test(...Ee(n)).required("Group name is required")}),j=I=>{i.success(e.jsxs(e.Fragment,{children:["Group"," ",e.jsx(ue,{type:"auth-group",value:I,to:`${te}/ui/permissions/groups`})," ","created."]})),f()},u=I=>{if(c.length===0){j(I);return}const x=c.map(G=>{const d=G.groups||[];return G.groups=[...d,I],G});ae(x).then(()=>{j(I)}).catch(G=>{s.failure(`Group ${I} created, failed to add identities.`,G)}).finally(()=>{b.setSubmitting(!1),o.invalidateQueries({queryKey:[M.authGroups]})})},b=Se({initialValues:{name:"",description:""},validationSchema:S,onSubmit:I=>{et({name:I.name,description:I.description,permissions:r.filter(x=>!x.isRemoved)}).then(()=>{u(I.name)}).catch(x=>{s.failure("Group creation failed",x)}).finally(()=>{b.setSubmitting(!1),o.invalidateQueries({queryKey:[M.authGroups]})})}});return e.jsx(e.Fragment,{children:e.jsxs(a.SidePanel,{className:X({"edit-permissions-panel":p==="permission"}),children:[e.jsx(a.SidePanel.Header,{children:e.jsx(a.SidePanel.HeaderTitle,{children:e.jsx(Oe,{subForm:p,setSubForm:y})},p??"start")}),e.jsx(se,{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(Te,{formik:b,setSubForm:y,identityCount:c.length,identityModifyCount:c.length,permissionCount:r.length,permissionModifyCount:r.length,isEditing:!1}),p==="identity"&&e.jsx(ke,{selected:c,setSelected:g,groupName:b.values.name}),p==="permission"&&e.jsx(Be,{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"})]})]})})},Tt=({group:t,onClose:s})=>{const i=H(),o=a.useNotify(),n=a.useToastNotification(),c=ee(),g=w.useState(null),[r,l]=w.useState(!1),[p,y]=w.useState(Y(t).map(N=>({id:N}))),[f,C]=w.useState(t.permissions??[]),{data:S}=xe(),j=S?.auth_user_name??"",{canEditGroup:u}=Q(),b=i.subForm,I=N=>{i.openEditGroup(i.group??"",N)},{data:x=[],isLoading:G,isError:d}=J();w.useEffect(()=>{if(!G&&!d){const N=new Set(Y(t)),R=x.filter(P=>N.has(P.id));y(R)}},[G,d,x,t]);const{data:m=[],isLoading:v,isError:A}=Re();w.useEffect(()=>{if(!G&&!d&&!v&&!A){const N=Me(m),R=_e(x),P=(t.permissions??[]).map(k=>{const T=ne(k),h=De(k,N,R);return{...k,resourceLabel:h,id:T}});C(P)}},[G,d,v,A,x,m,t]);const $=je().shape({name:Ne().test(...Ee(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)]})}),ae(k)},_=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)||z(t)?D(P):R?tt(P,N.name).then(async()=>pe(k)).then(async()=>D(P)):pe(k).then(async()=>D(P)))().then(()=>{B(),n.success(e.jsxs(e.Fragment,{children:["Auth group"," ",e.jsx(ue,{type:"auth-group",value:N.name,to:`${te}/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=Se({initialValues:{name:t?.name??"",description:t?.description??""},enableReinitialize:!0,validationSchema:$,onSubmit:N=>{const R=Y(t).includes(j),P=p.find(T=>T.id===j)?.isRemoved,k=f.find(T=>T.isRemoved);P||R&&k?l(!0):_(N)}}),B=()=>{i.clear(),o.clear(),s?.()};de(()=>{b?I(null):B()});const O=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:X({"edit-permissions-panel":b==="permission"}),children:[e.jsx(a.SidePanel.Header,{children:e.jsx(a.SidePanel.HeaderTitle,{className:"u-truncate",children:e.jsx(Oe,{subForm:b,setSubForm:I,group:t})},b??"start")}),e.jsx(se,{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(Te,{formik:E,setSubForm:I,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(ke,{selected:p,setSelected:y,groupName:t.name,group:t}),b==="permission"&&e.jsx(Be,{permissions:f,setPermissions:C,group:t})]}),e.jsxs(a.SidePanel.Footer,{className:"u-align--right",children:[e.jsx(a.Button,{appearance:"base",onClick:B,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||O===0,children:O===0?"Save changes":`Save ${O} ${F("change",O)}`})]})]}),r&&e.jsx(a.ConfirmationModal,{confirmButtonLabel:"Confirm changes",confirmButtonAppearance:"positive",onConfirm:()=>{_(E.values)},close:()=>{l(!1),E.setSubmitting(!1)},title:"Confirm permission modification",className:"permission-confirm-modal",children:e.jsx(Ie,{isVisible:!0})})]})},kt=({groups:t,className:s})=>{const i=H();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(a.Icon,{name:"user-group"}),e.jsx("span",{children:"Manage identities"})]})})},Ft=({onConfirm:t,close:s,addedIdentities:i,removedIdentities:o,selectedGroups:n,allIdentities:c})=>{const[g,r]=w.useState(!1),l=a.useNotify(),p=H(),y=ee(),f=a.useToastNotification(),C=bt(c,n,i,o),S=Qe(C),j=()=>{r(!0);const u=Ae(c,i,o),b=Le(i,o,n,u),I=u.map(x=>({...x,groups:b[x.id]}));ae(I).then(()=>{y.invalidateQueries({predicate:d=>[M.identities,M.authGroups,M.currentIdentity].includes(d.queryKey[0])});const x=Object.keys(S),G=x.length>1?`Updated identities for ${x.length} groups`:e.jsxs(e.Fragment,{children:["Updated identities for"," ",e.jsx(ue,{type:"auth-group",value:x[0],to:`${te}/ui/permissions/groups`})]});f.success(G),p.clear(),l.clear()}).catch(x=>{l.failure("Update groups failed",x)}).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(nt,{identityGroupsChangeSummary:C,groupIdentitiesChangeSummary:S,identities:c,initialGroupBy:"group"})})},$t=({groups:t})=>{const s=H(),[i]=Ve(),o=a.useNotify(),[n,c]=w.useState(!1),{data:g=[],error:r,isLoading:l}=J(),{canEditIdentity:p}=ve(),y=g.filter(h=>!p(h)),{desiredState:f,save:C,undo:S}=ht({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=>!Ce(h)),{identityIdsInAllGroups:u,identityIdsInNoGroups:b,identityIdsInSomeGroups:I}=gt(t,j),x=new Set(f.identitiesAdded);for(const h of u)f.identitiesRemoved.has(h)||x.add(h);const G=new Set(I.filter(h=>!x.has(h)&&!f.identitiesRemoved.has(h))),d=new Set;t.forEach(h=>{Y(h).forEach(L=>d.add(L))});const m=d.size>0,v=()=>{const h=new Set;for(const L of u)x.has(L)||h.add(L);for(const L of I)G.has(L)||h.add(L);for(const L of b)x.has(L)&&h.add(L);return h},A=(h,L)=>{C(L?{identitiesAdded:new Set,identitiesRemoved:new Set(j.map(V=>V.id))}:{identitiesAdded:new Set(h),identitiesRemoved:new Set})},$=h=>{const L=x.has(h),V=G.has(h),K=new Set(f.identitiesAdded),ie=new Set(f.identitiesRemoved);L||V?(K.delete(h),ie.add(h)):(K.add(h),ie.delete(h)),C({identitiesAdded:K,identitiesRemoved:ie})},D=()=>{s.clear(),o.clear(),c(!1)};de(D);const _=()=>{o.clear(),c(!1)},E=v(),B=[{content:"Identity",sortKey:"name"},{content:"","aria-label":"Modified status",className:"modified-status"}],q={queries:i.getAll(at),authMethod:i.getAll(ot),systemIdentities:i.get(it)},N=j.filter(h=>!(q.systemIdentities==="hide"&&ct(h)||!q.queries.every(L=>U(h).toLowerCase().includes(L.toLowerCase())||h.id.toLowerCase().includes(L.toLowerCase()))||q.authMethod.length>0&&!q.authMethod.includes(h.authentication_method))).map(h=>{const L=t.length>1?"all selected groups":`group ${t[0].name}`,V=f.identitiesAdded.has(h.id)?`Identity will be added to ${L}`:f.identitiesRemoved.has(h.id)?`Identity will be removed from ${L}`:"",K=U(h);return{key:h.id,name:h.id,className:"u-row",columns:[{content:K,role:"rowheader","aria-label":"Identity",title:p(h)?K:"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:V}],sortData:{name:K.toLowerCase(),isPreselected:d.has(h.id)}}}),{rows:R}=le({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(re,{id:"group-identities-table",className:"group-identities-table",headers:B,rows:R,sortable:!0,emptyStateMsg:"No identities found",itemName:"identity",parentName:"server",selectedNames:Array.from(x),setSelectedNames:A,disabledNames:y.map(h=>h.id),filteredNames:j.map(h=>h.id),indeterminateNames:Array.from(G),onToggleRow:$,hideContextualMenu:!0,disableSelectAll:!!y.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(ce,{children:T})})}),e.jsx(se,{className:"u-no-padding"}),e.jsx(rt,{}),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(ft,{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(Ft,{close:_,onConfirm:_,selectedGroups:t,addedIdentities:f.identitiesAdded,removedIdentities:f.identitiesRemoved,allIdentities:j})]})},Dt=({groups:t,className:s,onDelete:i})=>{const[o,n]=w.useState(!1),{canDeleteGroup:c}=Q(),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(a.Icon,{name:"delete"}),e.jsx("span",{children:`Delete ${t.length} ${F("group",t.length)}`})]}),o&&e.jsx(Pe,{groups:t,close:l})]})},Mt=({group:t})=>{const{data:s=[]}=J(),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]})})},ms=()=>{const t=a.useNotify(),{data:s=[],error:i,isLoading:o}=st(),n=H(),[c,g]=w.useState(""),[r,l]=w.useState([]),{canCreateGroups:p}=ye(),y=We();i&&t.failure("Loading groups failed",i),w.useEffect(()=>{const m=r.filter(v=>s.some(A=>A.name===v));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 v=Y(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:v.length}),e.jsx(Mt,{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:v.length}}}),{rows:b,updateSort:I}=le({rows:u,defaultSort:"name"});if(o)return e.jsx(a.Spinner,{className:"u-loader",text:"Loading...",isMainComponent:!0});const x=()=>r.length>0?e.jsx(Je,{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:x(),children:e.jsx(re,{id:"groups-table",className:"groups-table",headers:f,rows:b,sortable:!0,responsive:!0,emptyStateMsg:"No groups found matching this search",onUpdateSort:I,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(a.Icon,{name:"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(Xe,{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()?"":"You do not have permission to create groups",hasIcon:!y,children:[!y&&e.jsx(a.Icon,{name:"plus",light:!0}),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(W,{children:[e.jsxs(W.Left,{children:[e.jsx(W.Title,{children:e.jsx(ce,{children:"Auth groups"})}),!r.length&&G&&e.jsx(W.Search,{children:e.jsx(pt,{onChange:g,value:c,disabled:!!n.group,className:"u-no-margin--bottom"})}),r.length>0&&!n.panel&&e.jsxs("div",{children:[e.jsx(kt,{groups:S,className:"u-no-margin--bottom"}),e.jsx(Dt,{groups:S,className:"u-no-margin--bottom",onDelete:()=>{l([])}})]})]}),G&&e.jsx(W.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()?"":"You do not have permission to create groups",hasIcon:!y,children:[!y&&e.jsx(a.Icon,{name:"plus",light:!0}),e.jsx("span",{children:"Create group"})]})})]}),children:[!n.panel&&e.jsx(se,{}),e.jsx(a.Row,{className:"permission-groups",children:d})]}),n.panel===oe.createGroup&&e.jsx(Lt,{}),n.panel===oe.editGroup&&j&&e.jsx(Tt,{group:j,onClose:()=>{l([])}}),n.panel===oe.groupIdentities&&!!S.length&&e.jsx($t,{groups:S})]})};export{ms as default};

Youez - 2016 - github.com/yon3zu
LinuXploit