Your IP : 216.73.216.189


Current Path : /proc/thread-self/root/snap/lxd/39313/share/lxd-ui/assets/
Upload File :
Current File : //proc/thread-self/root/snap/lxd/39313/share/lxd-ui/assets/ProfileSelector-CI2l1cmT.js

import{d as n,r as v,j as o,b4 as I}from"./index-BFGypnt-.js";import{u as N}from"./useProfiles-CErbukD2.js";const B=({project:h,selected:t,setSelected:a,title:j,readOnly:l=!1,disabledReason:r,initialProfiles:x})=>{const d=n.useNotify(),{data:c=[],error:p,isLoading:g}=N(h);if(v.useEffect(()=>{const e=document.getElementById("content-details");e&&(e.scrollTop=e.scrollHeight)},[t]),g)return o.jsx(n.Spinner,{className:"u-loader",text:"Loading profiles..."});p&&d.failure("Loading profiles failed",p),c.sort(I);const f=[...new Set(c.map(e=>e.name).concat(x??[]))],u=f.filter(e=>!t.includes(e)),b=()=>{const e=u[0];e&&a([...t,e])};return o.jsxs(o.Fragment,{children:[o.jsxs(n.Label,{forId:"profile-0",children:["Profiles"," ",o.jsx(n.Tooltip,{message:o.jsxs(o.Fragment,{children:["A profile stores a set of configuration, such as instance and device options.",o.jsx("br",{}),"Each profile overrides the configuration specified in previous profiles."]}),children:o.jsx(n.Icon,{name:"information"})})]}),t.map((e,s)=>o.jsxs("div",{className:"profile-select",children:[o.jsx("div",{children:o.jsx(n.Select,{id:`profile-${s}`,"aria-label":"Select a profile",onChange:i=>{const m=[...t];m[s]=i.target.value,a(m)},options:f.filter(i=>!t.includes(i)||t.indexOf(i)===s).map(i=>({label:i,value:i})),value:e,disabled:l||!!r,title:r??j})}),o.jsxs("div",{className:"profile-actions",children:[!l&&(s>0||t.length>1)&&o.jsxs("div",{children:[o.jsx(n.Button,{appearance:"base",className:"profile-action-btn",onClick:()=>{const i=[...t];i.splice(s,1),i.splice(s-1,0,e),a(i)},type:"button","aria-label":"move profile up",title:r??"move profile up",disabled:!!r||s===0,hasIcon:!0,children:o.jsx(n.Icon,{name:"chevron-up"})}),o.jsx(n.Button,{appearance:"base",className:"profile-action-btn",onClick:()=>{const i=[...t];i.splice(s,1),i.splice(s+1,0,e),a(i)},type:"button","aria-label":"move profile down",title:r??"move profile down",disabled:!!r||s===t.length-1,hasIcon:!0,children:o.jsx(n.Icon,{name:"chevron-down"})})]}),!l&&o.jsxs(n.Button,{appearance:"base",className:"profile-remove-btn",onClick:()=>{a(t.filter(i=>i!==e))},type:"button",disabled:!!r,title:r,hasIcon:!0,children:[o.jsx(n.Icon,{name:"delete"}),o.jsx("span",{children:"Remove"})]})]})]},e)),!l&&o.jsx("div",{children:o.jsxs(n.Button,{id:"addProfileButton",disabled:!!r||u.length===0,className:"profile-add-btn",onClick:b,type:"button",title:r,hasIcon:!0,children:[o.jsx(n.Icon,{name:"plus"}),o.jsx("span",{children:"Add profile"})]})})]})};export{B as P};