Your IP : 216.73.216.52


Current Path : /snap/lxd/38768/share/lxd-ui/assets/
Upload File :
Current File : //snap/lxd/38768/share/lxd-ui/assets/ProfileList-C4RSGCOD.js

import{j as e,bw as S,c6 as C,cJ as w,ag as F,d as s,S as L,ae as K,c as M,C as O,r as U,H as _,a2 as $,cK as q,p as A,R as z}from"./index-BsQN_SZU.js";import{u as v,p as J}from"./usePanelParams-CNAJZsSX.js";import{a1 as k,K as Q,ab as W,ac as Y}from"./SshKeyForm-BNz7yPwa.js";import{H as G}from"./HelpLink-BJF9zWZL.js";import{u as V}from"./useSortTableData-DkMx8bMp.js";import{P as j}from"./PageHeader-BkhUaI4-.js";import{E as X}from"./ExpandableList-DsGr0BpD.js";import{N as Z}from"./NetworkRichChip-Cp8QBNS_.js";import{P as ee}from"./ProfileInstances-DsX_pANP.js";import{S as se}from"./StoragePoolRichChip-Daex_aZU.js";import{u as te}from"./projects-CczQ3aFg.js";import{P as ae}from"./ProjectRichChip-DZzjTfq6.js";import"./limits-yeXZOxhv.js";import"./AutoExpandingTextArea-Bd-45rZK.js";import"./formFields-DzJouV_d.js";import"./scroll-Dc7Cgzms.js";import"./ConfigFieldDescription-CjXKAIpa.js";import"./snapshots-LtzKNDw1.js";import"./useNetworks-1j5RF-bH.js";import"./StoragePoolSize-BNbqTfwA.js";import"./Meter-cq8smrSm.js";const ie=({profile:a,project:i})=>e.jsx(e.Fragment,{children:Object.values(a.devices).some(S)?e.jsx(X,{items:Object.values(a.devices).filter(S).map(n=>e.jsx(Z,{networkName:n.network,projectName:i},n.network))}):e.jsx("div",{className:"list-item",children:"-"})}),re=({profile:a,project:i})=>{const n=i.name==="default",r=C(i.name,n,a.used_by).length,o=w(i),c=F(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(se,{poolName:c,projectName:i.name}):"-"})]}),e.jsxs("tr",{className:"list-wrapper",children:[e.jsx("th",{className:"u-text--muted",children:"Networks"}),e.jsx("td",{children:e.jsx(ie,{profile:a,project:i.name})})]}),e.jsxs("tr",{className:"list-wrapper",children:[e.jsx("th",{className:"u-text--muted",children:"Devices"}),e.jsx("td",{children:e.jsx(Q,{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(W,{profile:a})})]}),e.jsxs("tr",{children:[e.jsx("th",{className:"u-text--muted",children:"Configuration"}),e.jsx("td",{children:e.jsx(Y,{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 (",r,")"]})})}),r>0?e.jsx(ee,{profile:a,project:i.name,headingClassName:"u-text--muted"}):e.jsx("tr",{children:e.jsx("td",{colSpan:2,children:"No items found."})})]})})},ne=()=>{const a=s.useNotify(),i=v(),n=i.profile,r=i.project,{project:o,isLoading:c}=L(),{data:d,error:u,isLoading:h}=K(n??"",r);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:i.clear,"aria-label":"Close",children:e.jsx(s.Icon,{name:"close"})})})]})}),e.jsx(s.SidePanel.Content,{children:!!(d&&o)&&e.jsx(re,{profile:d,project:o})})]})},ke=()=>{const a=M(),i=s.useNotify(),n=v(),{project:r}=O(),[o,c]=U.useState(""),d=_();if(!r)return e.jsx(e.Fragment,{children:"Missing project"});const u=r==="default",{project:h,isLoading:x}=L(),{canCreateProfiles:g}=te(),{data:m=[],error:N,isLoading:D}=$(r);N&&i.failure("Loading profiles failed",N);const I=D||x,P=w(h);m.sort(q);const b=m.map(t=>{const l=C(r,u,t.used_by);return{name:t.name,count:l.filter(p=>p.project===r).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,r)},p=b.find(f=>t.name===f.name)?.count??0,B=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:[B," 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:H}=V({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(G,{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 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(`${z}/ui/project/${encodeURIComponent(r)}/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(A,{}),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,i.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:H})})})]})})]}),n.panel===J.profileSummary&&e.jsx(ne,{})]})};export{ke as default};