Your IP : 216.73.216.189


Current Path : /proc/thread-self/root/snap/lxd/current/share/lxd-ui/assets/
Upload File :
Current File : //proc/thread-self/root/snap/lxd/current/share/lxd-ui/assets/ProfileList-BGpTzJM3.js

import{j as e,ba as S,bN as C,cr as L,ad as H,d as s,T as w,c as O,I as M,r as U,O as _,b4 as $,p as K,R as q}from"./index-BFGypnt-.js";import{u as v,p as A}from"./usePanelParams-CV5ZHNeu.js";import{P as k,D as z,a as Q,b as W}from"./ProfileResourceLimits-DkY60ueM.js";import{H as Y}from"./HelpLink-l4aaXUp-.js";import{u as G}from"./useSortTableData-DMPSUVcX.js";import{P as j}from"./PageHeader-DZVSTM6q.js";import{E as J}from"./ExpandableList-DK5_MQFC.js";import{N as V}from"./NetworkRichChip-D2iomVd3.js";import{P as X}from"./ProfileInstances-DeLLcFxG.js";import{S as Z}from"./StoragePoolRichChip-CxRTjvv2.js";import{a as ee,u as se}from"./useProfiles-CErbukD2.js";import{u as te}from"./projects-DAlFlfjH.js";import{P as ae}from"./ProjectRichChip-CtiU36yR.js";import"./useNetworks-B1lu5MbM.js";import"./useClusterMembers-B29_ixY7.js";import"./cluster-members-CG6XHzn4.js";import"./useStoragePools-qBtKr1j9.js";import"./StoragePoolSize-ChYxPd_8.js";import"./Meter-VGEmUMfL.js";const re=({profile:a,project:r})=>e.jsx(e.Fragment,{children:Object.values(a.devices).some(S)?e.jsx(J,{items:Object.values(a.devices).filter(S).map(n=>e.jsx(V,{networkName:n.network,projectName:r},n.network))}):e.jsx("div",{className:"list-item",children:"-"})}),ie=({profile:a,project:r})=>{const n=r.name==="default",i=C(r.name,n,a.used_by).length,o=L(r),c=H(a);return e.jsx("table",{className:"u-table-layout--auto u-no-margin--bottom",children:e.jsxs("tbody",{children:[e.jsxs("tr",{children:[e.jsx("th",{className:"u-text--muted",children:"Name"}),e.jsx("td",{children:e.jsx(k,{profile:a})})]}),e.jsxs("tr",{children:[e.jsx("th",{className:"u-text--muted",children:"Description"}),e.jsx("td",{children:a.description?a.description:"-"})]}),e.jsxs("tr",{children:[e.jsx("th",{className:"u-text--muted",children:"Defined in"}),e.jsxs("td",{children:[o?"Current":"Default"," project"]})]}),e.jsxs("tr",{children:[e.jsx("th",{className:"u-text--muted",children:"Root storage"}),e.jsx("td",{children:c?e.jsx(Z,{poolName:c,projectName:r.name}):"-"})]}),e.jsxs("tr",{className:"list-wrapper",children:[e.jsx("th",{className:"u-text--muted",children:"Networks"}),e.jsx("td",{children:e.jsx(re,{profile:a,project:r.name})})]}),e.jsxs("tr",{className:"list-wrapper",children:[e.jsx("th",{className:"u-text--muted",children:"Devices"}),e.jsx("td",{children:e.jsx(z,{devices:Object.values(a.devices)})})]}),e.jsxs("tr",{className:"list-wrapper",children:[e.jsx("th",{className:"u-text--muted",children:"Limits"}),e.jsx("td",{children:e.jsx(Q,{profile:a})})]}),e.jsxs("tr",{children:[e.jsx("th",{className:"u-text--muted",children:"Configuration"}),e.jsx("td",{children:e.jsx(W,{profile:a})})]}),e.jsx("tr",{className:"used-by-header",children:e.jsx("th",{colSpan:2,children:e.jsxs("h3",{className:"p-muted-heading p-heading--5",children:["Used by (",i,")"]})})}),i>0?e.jsx(X,{profile:a,project:r.name,headingClassName:"u-text--muted"}):e.jsx("tr",{children:e.jsx("td",{colSpan:2,children:"No items found."})})]})})},ne=()=>{const a=s.useNotify(),r=v(),n=r.profile,i=r.project,{project:o,isLoading:c}=w(),{data:d,error:u,isLoading:h}=ee(n??"",i);u&&a.failure("Loading profile failed",u);const x=h||c;return e.jsxs(s.SidePanel,{loading:x,hasError:!d||!o,className:"u-hide--medium u-hide--small detail-panel profile-detail-panel",pinned:!0,width:"narrow",children:[e.jsx(s.SidePanel.Sticky,{children:e.jsxs(s.SidePanel.Header,{children:[e.jsx(s.SidePanel.HeaderTitle,{children:"Profile summary"}),e.jsx(s.SidePanel.HeaderControls,{children:e.jsx(s.Button,{appearance:"base",className:"u-no-margin--bottom",hasIcon:!0,onClick:r.clear,"aria-label":"Close",children:e.jsx(s.Icon,{name:"close"})})})]})}),e.jsx(s.SidePanel.Content,{children:!!(d&&o)&&e.jsx(ie,{profile:d,project:o})})]})},we=()=>{const a=O(),r=s.useNotify(),n=v(),{project:i}=M(),[o,c]=U.useState(""),d=_();if(!i)return e.jsx(e.Fragment,{children:"Missing project"});const u=i==="default",{project:h,isLoading:x}=w(),{canCreateProfiles:g}=te(),{data:m=[],error:N,isLoading:D}=se(i);N&&r.failure("Loading profiles failed",N);const I=D||x,P=L(h);m.sort($);const b=m.map(t=>{const l=C(i,u,t.used_by);return{name:t.name,count:l.filter(p=>p.project===i).length,total:l.length}}),y=m.filter(t=>{if(o){const l=o.toLowerCase();if(!t.name.toLowerCase().includes(l)&&!t.description.toLowerCase().includes(l))return!1}return!0}),R=[{content:"Name",sortKey:"name"},{content:"Description",sortKey:"description"},{content:"Used by",sortKey:"used_by"}],T=y.map(t=>{const l=()=>{n.openProfileSummary(t.name,i)},p=b.find(f=>t.name===f.name)?.count??0,F=b.find(f=>t.name===f.name)?.total??0;return{key:t.name,className:n.profile===t.name?"u-row-selected":"u-row",columns:[{content:e.jsx("div",{className:"u-truncate",title:`Profile ${t.name}`,children:e.jsx(k,{profile:t})}),role:"rowheader","aria-label":"Name",onClick:l},{content:e.jsx("div",{className:"table-description",title:`Description ${t.description}`,children:t.description}),role:"cell","aria-label":"Description",onClick:l,className:"clickable-cell"},{content:e.jsxs(e.Fragment,{children:[p," ",p===1?"instance":"instances",u&&e.jsx(e.Fragment,{children:e.jsxs("div",{className:"u-text--muted",children:[F," in all projects"]})})]}),role:"cell","aria-label":"Used by",onClick:l,className:"clickable-cell"}],sortData:{name:t.name.toLowerCase(),description:t.description.toLowerCase(),used_by:p}}}),{rows:E,updateSort:B}=G({rows:T});return I?e.jsx(s.Spinner,{className:"u-loader",text:"Loading...",isMainComponent:!0}):e.jsxs(e.Fragment,{children:[e.jsxs(s.CustomLayout,{mainClassName:"profile-list",contentClassName:"profile-content",header:e.jsxs(j,{children:[e.jsxs(j.Left,{children:[e.jsx(j.Title,{children:e.jsx(Y,{docPath:"/profiles/",title:"Learn how to use profiles",children:"Profiles"})}),m.length>0&&e.jsx(j.Search,{children:e.jsx(s.SearchBox,{className:"search-box margin-right--large u-no-margin--bottom",name:"search-profile",type:"text",onChange:t=>{c(t)},placeholder:"Search",value:o,"aria-label":"Search"})})]}),P&&e.jsx(j.BaseActions,{children:e.jsxs(s.Button,{appearance:"positive",className:"u-no-margin--bottom u-float-right",onClick:async()=>a(`${q}/ui/project/${encodeURIComponent(i)}/profiles/create`),hasIcon:!d,disabled:!g(h),title:g(h)?"":"You do not have permission to create profiles in this project",children:[!d&&e.jsx(s.Icon,{name:"plus",light:!0}),e.jsx("span",{children:"Create profile"})]})})]}),children:[e.jsx(K,{}),e.jsx(s.Row,{className:"no-grid-gap",children:e.jsxs(s.Col,{size:12,children:[!P&&e.jsxs(s.Notification,{severity:"information",children:["Showing profiles from the"," ",e.jsx(ae,{projectName:"default",urlSuffix:"/profiles"})," ","project.",e.jsx("br",{}),e.jsx("span",{className:"u-text--muted",children:"For project-specific profiles, enable profile isolation in the project configuration."})]}),m.length===0&&e.jsx(s.EmptyState,{className:"empty-state",image:e.jsx(s.Icon,{name:"repository",className:"empty-state-icon"}),title:"No profiles found",children:e.jsx("p",{children:"There are no profiles in this project."})}),m.length>0&&e.jsx(s.ScrollableTable,{dependencies:[y,r.notification],tableId:"profile-table",belowIds:["status-bar"],children:e.jsx(s.TablePagination,{id:"pagination",data:E,itemName:"profile",className:"u-no-margin--top","aria-label":"Table pagination control",children:e.jsx(s.MainTable,{id:"profile-table",headers:R,sortable:!0,emptyStateMsg:"No profile found matching this search",onUpdateSort:B})})})]})})]}),n.panel===A.profileSummary&&e.jsx(ne,{})]})};export{we as default};