| Current Path : /proc/thread-self/root/snap/lxd/current/share/lxd-ui/assets/ |
| Current File : //proc/thread-self/root/snap/lxd/current/share/lxd-ui/assets/StorageVolumeForm-CW2hs3vZ.js |
import{r as f,j as s,d as a,u as T,L as P,R as V,v as D,M as y,c1 as E,a0 as S,a2 as C,cJ as F,bH as h,T as L,cK as q,cI as c,I as A,b as O,cL as Z,cM as H,a5 as v}from"./index-BFGypnt-.js";import{F as x,e as U}from"./FormMenuItem-fhYfVpHc.js";import{j as $,k as B,l as K,m as M,z as W,p as Y,u as G}from"./useStoragePools-qBtKr1j9.js";import{C as J,g as d}from"./ConfigurationTable-CmO6jSmV.js";import{D as Q}from"./DiskSizeSelector-C_YZZUSe.js";import{S as X}from"./StoragePoolSelector-CIzPJc24.js";import{S as k}from"./ScrollableForm-D-7nf2YI.js";import{a as ee,u as se}from"./useClusterMembers-B29_ixY7.js";import{u as te}from"./StoragePoolSize-ChYxPd_8.js";import{P as ae}from"./ProjectRichChip-CtiU36yR.js";import{i as le}from"./snapshots-DETOqD-5.js";import{S as j}from"./ScrollableConfigurationTable-Cdfv_OdM.js";import{B as z}from"./instanceAndProfilePayloads-DSYCnS-r.js";const ne=[{label:"Every minute",value:"* * * * *"},{label:"Hourly",value:"@hourly"},{label:"Daily",value:"@daily"},{label:"Weekly",value:"@weekly"},{label:"Monthly",value:"@monthly"},{label:"Yearly",value:"@yearly"}],oe=({value:e,setValue:t})=>{const[l,n]=f.useState(!e?.startsWith("@"));return s.jsxs("div",{children:[s.jsxs("div",{className:"snapshot-schedule",children:[s.jsx(a.RadioInput,{label:"Cron syntax",checked:l,onChange:()=>{n(!0),t("")}}),s.jsx(a.RadioInput,{label:"Choose interval",checked:!l,onChange:()=>{n(!1),t("@daily")}})]}),l?s.jsx(a.Input,{id:"snapshots_schedule",name:"snapshots_schedule",placeholder:"Enter cron expression",help:"<minute> <hour> <dom> <month> <dow>, a comma-separated list of schedule aliases (@hourly, @daily, @midnight, @weekly, @monthly, @annually, @yearly), or empty to disable automatic snapshots (the default)",type:"text",value:e,onChange:o=>{t(o.target.value)}}):s.jsx(a.Select,{id:"snapshots_schedule",name:"snapshots_schedule",value:e,onChange:o=>{t(o.target.value)},options:ne})]})},re=({project:e})=>{const{isRestricted:t}=T();return t?s.jsx(s.Fragment,{children:"Please ask your project administrator to change this setting."}):s.jsxs(s.Fragment,{children:["You can change this setting in"," ",s.jsxs(P,{to:`${V}/ui/project/${encodeURIComponent(e?.name??"")}/configuration`,children:["project configuration",s.jsx(a.Icon,{className:"external-link-icon",name:"external-link"})]})]})},ie=(e,t,l,n)=>{const o=Math.min(...e),r=Math.max(...e);return e.length===0||n&&Number(n)<o?{min:Number(n),max:Number(n),sourceType:n?"project":void 0,sourceName:n?l?.name??"default":void 0}:!n||r<n?{min:o,max:r,sourceType:t?"cluster-member":void 0,sourceName:t}:{min:o,max:n,sourceType:void 0,sourceName:void 0}},ue=({source:e,sourceType:t})=>t==="project"?s.jsxs(s.Fragment,{children:["in project ",s.jsx(ae,{projectName:e})]}):t==="cluster-member"?s.jsxs(s.Fragment,{children:["on cluster member ",s.jsx(D,{type:"cluster-member",value:e,to:`${V}/ui/cluster/member/${encodeURIComponent(e)}`})]}):null,ce=({driver:e})=>{const l=e===$?s.jsxs(s.Fragment,{children:["Size limit might not be applied. See"," ",s.jsx(y,{docPath:"/reference/storage_dir/#quotas",children:"directory driver quotas"}),"."]}):e===B?s.jsxs(s.Fragment,{children:["Size limit might not be applied. See"," ",s.jsx(y,{docPath:"/reference/storage_btrfs/#quotas",children:"btrfs driver quotas"}),"."]}):null;return l?s.jsxs(s.Fragment,{children:[s.jsx(a.Icon,{name:"warning",style:{marginRight:"0.5rem"}}),l," Use a storage pool with another driver for full quota support.",s.jsx("br",{}),s.jsx("br",{})]}):null},de=(e,t)=>{const l=a.useNotify(),{data:n}=ee(t??""),{data:o,isLoading:r,error:i}=te(e,n);if(i)return l.failure("Loading resources failed",i),null;if(r||!o)return null;const u=E(o).map(p=>p.space.total-(p.space.used??0));return ie(u,!t||t==="none"?"":t)},me=({pool:e,clusterMember:t})=>{const l=de(e,t);if(!l)return null;const{min:n,max:o,sourceName:r}=l,i=n!==o;return s.jsxs(s.Fragment,{children:["Available space:"," ",s.jsxs("b",{children:[S(n),n!==o&&` - ${S(o)}`,i&&s.jsxs(s.Fragment,{children:[" ",s.jsx(a.Icon,{name:"information",className:"help-link-icon",title:"The available space depends on the target cluster member."})]})]}),r&&K(e?.driver??"")&&s.jsxs(s.Fragment,{children:[" ",s.jsx(ue,{source:r,sourceType:"cluster-member"})]}),"."]})},I="Main configuration",R="Snapshots",w="Filesystem",N="ZFS",pe=({active:e,setActive:t,formik:l,poolDriver:n,contentType:o})=>{const r=a.useNotify(),i={active:e,setActive:t},u=l.values.name.length>0?void 0:"Please enter a volume name to enable this section",p=()=>{C("form-navigation","p-bottom-controls")};return f.useEffect(p,[r.notification?.message]),a.useListener(window,p,"resize",!0),s.jsx("div",{className:"p-side-navigation--accordion form-navigation",children:s.jsx("nav",{"aria-label":"Storage volume form navigation",children:s.jsxs("ul",{className:"p-side-navigation__list",children:[s.jsx(x,{label:I,...i}),s.jsx(x,{label:R,...i,disableReason:u}),o==="filesystem"&&M.includes(n)&&s.jsx(x,{label:w,...i,disableReason:u}),n===W&&s.jsx(x,{label:N,...i,disableReason:u})]})})})},he=(e,t,l)=>{const n=t.find(r=>r.name===e),o=l?.environment?.storage_supported_drivers.find(r=>r.Name===n?.driver);return o?!o.Remote:!1},be=({formik:e,clusterMembers:t})=>e.values.clusterMember===void 0||e.values.clusterMember==="none"?null:e.values.isCreating?s.jsx(a.Select,{id:"clusterMember",label:"Cluster member",onChange:l=>{e.setFieldValue("clusterMember",l.target.value)},value:e.values.clusterMember,options:t.map(l=>({label:l.server_name,value:l.server_name})),disabled:e.values.isClusterMemberLocked,required:!0}):s.jsx(a.OutputField,{id:"clusterMember",label:"Cluster member",value:e.values.clusterMember,help:"Use the migrate button in the header to move the storage volume to a another cluster member."}),ge=({formik:e,poolError:t,clusterMembers:l=[],pools:n=[],settings:o})=>{const r=n.find(u=>u.name===e.values.pool),i=r?.driver,m=e.values.isCreating;return s.jsxs(k,{children:[s.jsx(a.Row,{children:s.jsxs(a.Col,{size:12,children:[m?s.jsxs(s.Fragment,{children:[s.jsx(a.Label,{forId:"storage-pool-selector-volume",required:m,children:"Storage pool"}),s.jsx(X,{value:e.values.pool,setValue:u=>{e.setFieldValue("pool",u),he(u,n,o)&&l.length>0?e.setFieldValue("clusterMember",l[0].server_name):e.setFieldValue("clusterMember",void 0)},selectProps:{id:"storage-pool-selector-volume",error:t}})]}):s.jsx(a.OutputField,{id:"storage-pool-selector-volume",label:"Storage pool",value:e.values.pool,help:"Use the migrate button in the header to move the volume to a different storage pool."}),s.jsx(be,{formik:e,clusterMembers:l}),m?s.jsx(a.Input,{...F(e,"name"),type:"text",label:"Name",required:!0}):s.jsx(a.OutputField,{id:"storage-volume-name",label:"Name",value:e.values.name,help:"Click the name in the header to rename the volume."}),s.jsx(Q,{label:"Size",value:e.values.size,help:s.jsxs(s.Fragment,{children:[s.jsx(ce,{driver:i}),e.values.volumeType==="custom"?"If empty, volume will not have a size limit within its storage pool.":"Size is immutable for non-custom volumes.",s.jsx("br",{}),s.jsx(me,{pool:r,clusterMember:e.values.clusterMember})]}),setMemoryLimit:u=>{U(e),e.setFieldValue("size",u)},disabled:!!e.values.editRestriction||e.values.volumeType!=="custom"}),m?s.jsx(a.Select,{...F(e,"content_type"),options:[{label:"filesystem",value:"filesystem"},{label:"block",value:"block"}],label:"Content type",help:"Type filesystem is ready to mount and write files to. Type block can only be attached to VMs, and is treated like an empty block device.",onChange:u=>{u.target.value==="block"&&(e.setFieldValue("block_filesystem",void 0),e.setFieldValue("block_mount_options",void 0),e.setFieldValue("block_type",void 0),e.setFieldValue("security_shifted",void 0),e.setFieldValue("security_unmapped",void 0)),e.setFieldValue("content_type",u.target.value)}}):s.jsx(a.OutputField,{id:"storage-volume-content-type",label:"Content type",value:e.values.content_type,help:"Content type is immutable after creation."})]})}),e.values.content_type==="filesystem"&&s.jsx("div",{children:s.jsx(J,{rows:[d({formik:e,label:"Security shifted",name:"security_shifted",defaultValue:"",disabled:e.values.security_unmapped==="true",disabledReason:"This setting can't be changed while security unmapped is set to true",children:s.jsx(a.Select,{options:h})}),d({formik:e,label:"Security unmapped",name:"security_unmapped",defaultValue:"",disabled:e.values.security_shifted==="true",disabledReason:"This setting can't be changed while security shifted is set to true",children:s.jsx(a.Select,{options:h})})]})})]})},ve=({formik:e})=>{const{project:t}=L(),l=le(t);return s.jsxs(s.Fragment,{children:[l&&s.jsx(a.Notification,{severity:"caution",title:`Snapshot creation has been disabled for volumes in the project ${t?.name}`,children:s.jsx(re,{project:t})}),s.jsx(j,{rows:[d({formik:e,label:"Snapshot name pattern",name:"snapshots_pattern",defaultValue:"",children:s.jsx(a.Input,{placeholder:"Enter name pattern",help:s.jsxs(s.Fragment,{children:["Pongo2 template string that represents the snapshot name (used for scheduled snapshots and unnamed snapshots), see"," ",s.jsx(y,{docPath:"/reference/instance_options/#instance-options-snapshots-names",children:"Automatic snapshot names"})]}),type:"text"})}),d({formik:e,label:"Expire after",name:"snapshots_expiry",defaultValue:"",children:s.jsx(a.Input,{placeholder:"Enter expiry expression",type:"text",help:"Expects an expression like 1M 2H 3d 4w 5m 6y"})}),d({formik:e,label:"Schedule",name:"snapshots_schedule",defaultValue:"",children:s.jsx(oe,{value:e.values.snapshots_schedule,setValue:n=>{e.setFieldValue("snapshots_schedule",n)}})})]})]})},xe=({formik:e,poolDriver:t})=>s.jsx(j,{rows:[d({formik:e,label:"Block filesystem",name:"block_filesystem",defaultValue:"",children:s.jsx(a.Select,{options:[{label:"auto",value:""},{label:"btrfs",value:"btrfs"},{label:"ext4",value:"ext4"},{label:"xfs",value:"xfs"}]})}),d({formik:e,label:"Block mount options",name:"block_mount_options",defaultValue:"",children:s.jsx(a.Input,{type:"text",help:s.jsxs(s.Fragment,{children:["For a list of available options visit"," ",s.jsx("a",{target:"_blank",rel:"noopener noreferrer",href:"https://manpages.ubuntu.com/manpages/jammy/en/man8/mount.8.html#filesystem-independent%20mount%20options",children:"mount manpages"})]})})}),...t===Y?[d({formik:e,label:"Block type",name:"block_type",defaultValue:"thin",children:s.jsx(a.Select,{options:[{label:"thin",value:"thin"},{label:"thick",value:"thick"}]})})]:[]]}),ye=({formik:e})=>s.jsx(j,{rows:[d({formik:e,label:"ZFS blocksize",name:"zfs_blocksize",defaultValue:"",children:s.jsx(a.Select,{options:[{label:"default",value:""},{label:"512",value:"512"},{label:"1024",value:"1024"},{label:"2048",value:"2048"},{label:"4096",value:"4096"},{label:"8192",value:"8192"},{label:"16384",value:"16384"}]})}),d({formik:e,label:"ZFS block mode",name:"zfs_block_mode",defaultValue:"",children:s.jsx(a.Select,{options:h})}),d({formik:e,label:"ZFS delegate",name:"zfs_delegate",defaultValue:"",children:s.jsx(a.Select,{options:h})}),d({formik:e,label:"ZFS remove snapshots",name:"zfs_remove_snapshots",defaultValue:"",children:s.jsx(a.Select,{options:h})}),d({formik:e,label:"ZFS use refquota",name:"zfs_use_refquota",defaultValue:"",children:s.jsx(a.Select,{options:h})}),d({formik:e,label:"ZFS reserve space",name:"zfs_reserve_space",defaultValue:"",children:s.jsx(a.Select,{options:h})})]}),Te=(e,t,l)=>{const n=e.size?.match(/^\d/),o=z(l?.config||{},q()),r={name:e.name,config:{size:n?e.size:void 0,[c("security_shifted")]:e.security_shifted,[c("security_unmapped")]:e.security_unmapped,[c("snapshots_expiry")]:e.snapshots_expiry,[c("snapshots_pattern")]:e.snapshots_pattern,[c("snapshots_schedule")]:e.snapshots_schedule,[c("block_filesystem")]:e.block_filesystem,[c("block_mount_options")]:e.block_mount_options,[c("block_type")]:e.block_type,[c("zfs_blocksize")]:e.zfs_blocksize,[c("zfs_block_mode")]:e.zfs_block_mode,[c("zfs_delegate")]:e.zfs_delegate,[c("zfs_remove_snapshots")]:e.zfs_remove_snapshots,[c("zfs_use_refquota")]:e.zfs_use_refquota,[c("zfs_reserve_space")]:e.zfs_reserve_space,...o},project:t,type:e.volumeType,content_type:e.content_type,description:"",location:"",created_at:"",pool:e.pool},i=Object.keys(r),m=z(l||{},new Set(i));return{...r,...m}},Pe=({formik:e,section:t,setSection:l})=>{const n=a.useNotify(),{project:o}=A();if(!o)return s.jsx(s.Fragment,{children:"Missing project"});const{data:r=[]}=se(),{data:i=[],error:m}=G(),{data:u}=O();m&&n.failure("Loading storage pools failed",m);const p=()=>{C("form","p-bottom-controls")};f.useEffect(p,[n.notification?.message]),a.useListener(window,p,"resize",!0);const g=i.find(b=>b.name===e.values.pool)?.driver??"";if(i.length>0){const b=[];M.includes(g)||b.push(...Z()),g!=="zfs"&&b.push(...H());for(const _ of b)e.values[_]!==void 0&&e.setFieldValue(_,void 0)}return s.jsxs(a.Form,{onSubmit:e.handleSubmit,className:"form",children:[s.jsx(a.Input,{type:"submit",hidden:!0,value:"Hidden input"}),s.jsx(pe,{active:t,setActive:l,formik:e,poolDriver:g,contentType:e.values.content_type}),s.jsx(a.Row,{className:"form-contents",children:s.jsxs(a.Col,{size:12,children:[t===v(I)&&s.jsx(ge,{formik:e,clusterMembers:r,pools:i,settings:u}),t===v(R)&&s.jsx(ve,{formik:e}),t===v(w)&&s.jsx(xe,{formik:e,poolDriver:g}),t===v(N)&&s.jsx(ye,{formik:e})]})})]})};export{ce as D,I as M,ue as R,re as S,oe as a,me as b,ge as c,Pe as d,ve as e,ie as g,he as h,Te as v};