/
snap
/
lxd
/
current
/
share
/
lxd-ui
/
assets
/
File Upload :
llllll
Current File: //snap/lxd/current/share/lxd-ui/assets/GroupOrIdentityChangesTable-BR7xFl1a.js
import{r as p,aW as _,j as e,d as g,u as F,ah as y,v as D,b as P,di as I,dj as C,dk as G,d5 as $}from"./index-B3cgCbnJ.js";import{s as B,p as M}from"./searchAndFilter-B29FrImZ.js";const R="query",v="auth-method",w="system-identities",L=["tls","oidc"],b=[R,v,w],W=t=>t.type.startsWith("Server certificate")||t.type.startsWith("Metrics certificate"),Y=()=>{const[t,a]=_(),r=[{id:1,heading:"Auth method",chips:L.map(s=>({lead:v,value:s}))},{id:2,heading:"System identities",chips:[{lead:w,value:"hide"}]}],n=s=>{const i=M(s,t,b);i.toString()!==t.toString()&&a(i)};return e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"u-off-screen",children:"Search and filter"}),e.jsx(g.SearchAndFilter,{existingSearchData:B(t,b),filterPanelData:r,returnSearchData:n,onExpandChange:()=>{window.dispatchEvent(new CustomEvent("resize",{detail:"search-and-filter"}))},onPanelToggle:()=>{window.dispatchEvent(new CustomEvent("sfp-toggle"))}})]})},z=p.memo(Y),q=()=>{const{isFineGrained:t}=F();return{canDeleteIdentity:n=>y(t,"can_delete",n==null?void 0:n.access_entitlements),canEditIdentity:n=>y(t,"can_edit",n==null?void 0:n.access_entitlements)}},f=({isVisible:t,children:a,className:r})=>t?e.jsx("span",{className:D("tag",r),children:a}):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,O=(t,a)=>{const r=Object.keys(t),n=[];for(const s of r){const i=t[s],o=s===a,h=[],l=[];for(const c of i.added)h.push(e.jsxs("p",{className:"u-no-padding--top u-sv-1",children:["+ ",c]},`${s}-${c}-added`));for(const c of i.removed)l.push(e.jsxs("p",{className:"u-no-padding--top u-sv-1",children:["- ",e.jsx("span",{className:"removed",children:c})]},`${s}-${c}-removed`));n.push(e.jsxs("tr",{className:"modified-row",children:[e.jsx("td",{children:e.jsxs("p",{className:"u-no-padding--top u-sv-1",children:[i.name,e.jsx(f,{isVisible:o,children:"You"})]})}),e.jsx("td",{children:h.concat(l)})]},s))}return n},U=(t,a,r)=>{const n=Object.keys(t),s={};r.forEach(o=>s[o.id]=$(o));const i=[];for(const o of n){const h=t[o],l=[],c=[];for(const d of h.added){const m=d===a;l.push(e.jsxs("p",{className:"u-no-padding--top u-sv-1",children:["+ ",s[d],e.jsx(f,{isVisible:m,children:"You"})]},`${o}-${d}-added`))}for(const d of h.removed){const m=d===a;c.push(e.jsxs("p",{className:"u-no-padding--top u-sv-1",children:["- ",e.jsx("span",{className:"removed",children:s[d]}),e.jsx(f,{isVisible:m,children:"You"})]},`${o}-${d}-removed`))}i.push(e.jsxs("tr",{className:"modified-row",children:[e.jsx("td",{children:e.jsx("p",{className:"u-no-padding--top u-sv-1",children:o})}),e.jsx("td",{children:l.concat(c)})]},o))}return i},J=({groupIdentitiesChangeSummary:t,identityGroupsChangeSummary:a,identities:r,initialGroupBy:n})=>{const{data:s}=P(),i=p.useRef(null),[o,h]=p.useState(n),l=(s==null?void 0:s.auth_user_name)??"",c=l in a,d=()=>{const u=i.current;if(!u)return;u.setAttribute("style","height: auto;");const N=window.innerHeight-64,E=I(".p-modal__header"),S=C("current-user-warning"),A=I(".p-modal__footer"),H=G(u),j=N-S-E-A;if(H>=j){const T=`height: ${j}px;`;u.setAttribute("style",T)}};g.useListener(window,d,"resize",!0),p.useEffect(d,[o]);const m=()=>{h(u=>u==="identity"?"group":"identity")};let x=[];return o==="identity"&&(x=O(a,l)),o==="group"&&(x=U(t,l,r)),e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:i,className:"confirm-table",children:e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsxs("th",{className:"display-by-header",children:[o==="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:o==="identity"?"Group":"Identity"})]})}),e.jsx("tbody",{children:x})]})}),e.jsx(k,{isVisible:c})]})};export{v as A,J as G,k as L,z as P,R as Q,w as S,f as T,W as i,q as u};
Copyright ©2k19 -
Hexid
|
Tex7ure