| Current Path : /proc/thread-self/root/snap/lxd/39313/share/lxd-ui/assets/ |
| Current File : //proc/thread-self/root/snap/lxd/39313/share/lxd-ui/assets/GroupOrIdentityChangesTable-C5GyT60U.js |
import{r as p,b8 as D,j as e,d as g,A as j,u as F,B as I,s as C,b as P,dv as b,dw as G,dx as $,dk as B}from"./index-BFGypnt-.js";import{s as L,p as M}from"./searchAndFilter-DtC_P-vv.js";const R="query",w="auth-method",E="system-identities",Y=[j.TLS,j.OIDC],v=[R,w,E],W=t=>t.type.startsWith("Server certificate")||t.type.startsWith("Metrics certificate"),O=()=>{const[t,i]=D(),r=[{id:1,heading:"Auth method",chips:Y.map(n=>({lead:w,value:n}))},{id:2,heading:"System identities",chips:[{lead:E,value:"hide"}]}],o=n=>{const a=M(n,t,v);a.toString()!==t.toString()&&i(a)};return e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"u-off-screen",children:"Search and filter"}),e.jsx(g.SearchAndFilter,{existingSearchData:L(t,v),filterPanelData:r,returnSearchData:o,onExpandChange:()=>{window.dispatchEvent(new CustomEvent("resize",{detail:"search-and-filter"}))},onPanelToggle:()=>{window.dispatchEvent(new CustomEvent("sfp-toggle"))}})]})},q=p.memo(O),J=()=>{const{isFineGrained:t}=F();return{canDeleteIdentity:o=>I(t,"can_delete",o?.access_entitlements),canEditIdentity:o=>I(t,"can_edit",o?.access_entitlements)}},f=({isVisible:t,children:i,className:r})=>t?e.jsx("span",{className:C("tag",r),children:i}):null,k=({isVisible:t})=>t?e.jsxs(g.Notification,{severity:"caution",title:"Self-modification",className:"u-no-margin--bottom",id:"current-user-warning",children:["This action will modify the permissions of the current logged-in identity.",e.jsx("br",{}),e.jsx(f,{className:"u-no-margin--left",isVisible:t,children:"You"})," ","might not be able to reverse this change once you’ve made it."]}):null,U=(t,i)=>{const r=Object.keys(t),o=[];for(const n of r){const a=t[n],s=n===i,h=[],l=[];for(const d of a.added)h.push(e.jsxs("p",{className:"u-no-padding--top u-sv-1",children:["+ ",d]},`${n}-${d}-added`));for(const d of a.removed)l.push(e.jsxs("p",{className:"u-no-padding--top u-sv-1",children:["- ",e.jsx("span",{className:"removed",children:d})]},`${n}-${d}-removed`));o.push(e.jsxs("tr",{className:"modified-row",children:[e.jsx("td",{children:e.jsxs("p",{className:"u-no-padding--top u-sv-1",children:[a.name,e.jsx(f,{isVisible:s,children:"You"})]})}),e.jsx("td",{children:h.concat(l)})]},n))}return o},Q=(t,i,r)=>{const o=Object.keys(t),n={};r.forEach(s=>n[s.id]=B(s));const a=[];for(const s of o){const h=t[s],l=[],d=[];for(const c of h.added){const m=c===i;l.push(e.jsxs("p",{className:"u-no-padding--top u-sv-1",children:["+ ",n[c],e.jsx(f,{isVisible:m,children:"You"})]},`${s}-${c}-added`))}for(const c of h.removed){const m=c===i;d.push(e.jsxs("p",{className:"u-no-padding--top u-sv-1",children:["- ",e.jsx("span",{className:"removed",children:n[c]}),e.jsx(f,{isVisible:m,children:"You"})]},`${s}-${c}-removed`))}a.push(e.jsxs("tr",{className:"modified-row",children:[e.jsx("td",{children:e.jsx("p",{className:"u-no-padding--top u-sv-1",children:s})}),e.jsx("td",{children:l.concat(d)})]},s))}return a},K=({groupIdentitiesChangeSummary:t,identityGroupsChangeSummary:i,identities:r,initialGroupBy:o})=>{const{data:n}=P(),a=p.useRef(null),[s,h]=p.useState(o),l=n?.auth_user_name??"",d=l in i,c=()=>{const u=a.current;if(!u)return;u.setAttribute("style","height: auto;");const N=window.innerHeight-64,S=b(".p-modal__header"),T=G("current-user-warning"),A=b(".p-modal__footer"),H=$(u),y=N-T-S-A;if(H>=y){const _=`height: ${y}px;`;u.setAttribute("style",_)}};g.useListener(window,c,"resize",!0),p.useEffect(c,[s]);const m=()=>{h(u=>u==="identity"?"group":"identity")};let x=[];return s==="identity"&&(x=U(i,l)),s==="group"&&(x=Q(t,l,r)),e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:a,className:"confirm-table",children:e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsxs("th",{className:"display-by-header",children:[s==="identity"?"Identity":"Group",e.jsx(g.Button,{onClick:m,className:"display-by-button u-no-margin",hasIcon:!0,dense:!0,appearance:"base",children:e.jsx(g.Icon,{name:"change-version"})})]}),e.jsx("th",{children:s==="identity"?"Group":"Identity"})]})}),e.jsx("tbody",{children:x})]})}),e.jsx(k,{isVisible:d})]})};export{w as A,K as G,k as L,q as P,R as Q,E as S,f as T,W as i,J as u};