Your IP : 216.73.216.52


Current Path : /snap/lxd/current/share/lxd-ui/assets/
Upload File :
Current File : //snap/lxd/current/share/lxd-ui/assets/StorageVolumeForm-C6mvm1BU.js

import{j as s,d as t,du as I,b3 as x,dv as N,r as F,dw as V,al as P,a3 as z,b_ as c,S as D,dx as E,dy as q,dz as i,C as L,t as R,aZ as Z,b as A,dA as B,dB as H,a6 as v}from"./index-BsQN_SZU.js";import{T as _,J as K,Q as O,L as r,ag as U,af as y,ah as Q}from"./SshKeyForm-BNz7yPwa.js";import{i as W}from"./snapshots-LtzKNDw1.js";import{S as $,g as j}from"./formFields-DzJouV_d.js";import{D as G}from"./DiskSizeSelector-C9kWj54D.js";import{S as J}from"./StoragePoolSelector-Bvqvds5t.js";const Y=({driver:e})=>{const n=e===I?s.jsxs(s.Fragment,{children:["Size limit might not be applied. See"," ",s.jsx(x,{docPath:"/reference/storage_dir/#quotas",children:"directory driver quotas"}),"."]}):e===N?s.jsxs(s.Fragment,{children:["Size limit might not be applied. See"," ",s.jsx(x,{docPath:"/reference/storage_btrfs/#quotas",children:"btrfs driver quotas"}),"."]}):null;return n?s.jsxs(s.Fragment,{children:[s.jsx(t.Icon,{name:"warning",style:{marginRight:"0.5rem"}}),n," Use a storage pool with another driver for full quota support.",s.jsx("br",{}),s.jsx("br",{})]}):null},C="Main configuration",M="Snapshots",w="Filesystem",T="ZFS",X=({active:e,setActive:a,formik:n,poolDriver:o,contentType:d})=>{const u=t.useNotify(),l={active:e,setActive:a},h=n.values.name.length>0?void 0:"Please enter a volume name to enable this section",m=()=>{z("form-navigation","p-bottom-controls")};return F.useEffect(m,[u.notification?.message]),t.useListener(window,m,"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(_,{label:C,...l}),s.jsx(_,{label:M,...l,disableReason:h}),d==="filesystem"&&V.includes(o)&&s.jsx(_,{label:w,...l,disableReason:h}),o===P&&s.jsx(_,{label:T,...l,disableReason:h})]})})})},k=(e,a,n)=>{const o=a.find(u=>u.name===e),d=n?.environment?.storage_supported_drivers.find(u=>u.Name===o?.driver);return d?!d.Remote:!1},ee=({formik:e,poolError:a,clusterMembers:n=[],pools:o=[],settings:d})=>{const u=o.find(l=>l.name===e.values.pool)?.driver;return s.jsxs($,{children:[s.jsx(t.Row,{children:s.jsxs(t.Col,{size:12,children:[s.jsx(t.Label,{forId:"storage-pool-selector-volume",required:e.values.isCreating,children:"Storage pool"}),s.jsx(J,{value:e.values.pool,setValue:l=>{e.setFieldValue("pool",l),k(l,o,d)&&n.length>0?e.setFieldValue("clusterMember",n[0].server_name):e.setFieldValue("clusterMember",void 0)},selectProps:{id:"storage-pool-selector-volume",disabled:!e.values.isCreating,error:a,help:e.values.isCreating?void 0:"Use the migrate button in the header to move the volume to a different storage pool."}}),e.values.clusterMember!==void 0&&e.values.clusterMember!=="none"&&s.jsx(t.Select,{id:"clusterMember",label:"Cluster member",onChange:l=>{e.setFieldValue("clusterMember",l.target.value)},value:e.values.clusterMember,options:n.map(l=>({label:l.server_name,value:l.server_name})),disabled:!e.values.isCreating,required:e.values.isCreating,help:e.values.isCreating?void 0:"Cluster member is immutable after creation."}),s.jsx(t.Input,{...S(e,"name"),type:"text",label:"Name",disabled:!e.values.isCreating,required:e.values.isCreating,help:e.values.isCreating?void 0:"Click the name in the header to rename the volume."}),s.jsx(G,{label:"Size",value:e.values.size,help:s.jsxs(s.Fragment,{children:[s.jsx(Y,{driver:u}),e.values.volumeType==="custom"?"Size of storage volume. If empty, volume will not have a size limit within its storage pool.":"Size is immutable for non-custom volumes."]}),setMemoryLimit:l=>{K(e),e.setFieldValue("size",l)},disabled:!!e.values.editRestriction||e.values.volumeType!=="custom"}),s.jsx(t.Select,{...S(e,"content_type"),options:[{label:"filesystem",value:"filesystem"},{label:"block",value:"block"}],label:"Content type",help:e.values.isCreating?"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.":"Content type is immutable after creation.",onChange:l=>{l.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",l.target.value)},disabled:!e.values.isCreating})]})}),e.values.content_type==="filesystem"&&s.jsx(O,{rows:[r({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(t.Select,{options:c})}),r({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(t.Select,{options:c})})]})]})},se=({formik:e})=>{const{project:a}=D(),n=W(a);return s.jsxs(s.Fragment,{children:[n&&s.jsx(t.Notification,{severity:"caution",title:`Snapshot creation has been disabled for volumes in the project ${a?.name}`,children:s.jsx(U,{project:a})}),s.jsx(y,{rows:[r({formik:e,label:"Snapshot name pattern",name:"snapshots_pattern",defaultValue:"",children:s.jsx(t.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(x,{docPath:"/reference/instance_options/#instance-options-snapshots-names",children:"Automatic snapshot names"})]}),type:"text"})}),r({formik:e,label:"Expire after",name:"snapshots_expiry",defaultValue:"",children:s.jsx(t.Input,{placeholder:"Enter expiry expression",type:"text",help:"Expects an expression like 1M 2H 3d 4w 5m 6y"})}),r({formik:e,label:"Schedule",name:"snapshots_schedule",defaultValue:"",children:s.jsx(Q,{value:e.values.snapshots_schedule,setValue:o=>{e.setFieldValue("snapshots_schedule",o)}})})]})]})},te=({formik:e,poolDriver:a})=>s.jsx(y,{rows:[r({formik:e,label:"Block filesystem",name:"block_filesystem",defaultValue:"",children:s.jsx(t.Select,{options:[{label:"auto",value:""},{label:"btrfs",value:"btrfs"},{label:"ext4",value:"ext4"},{label:"xfs",value:"xfs"}]})}),r({formik:e,label:"Block mount options",name:"block_mount_options",defaultValue:"",children:s.jsx(t.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"})]})})}),...a===E?[r({formik:e,label:"Block type",name:"block_type",defaultValue:"thin",children:s.jsx(t.Select,{options:[{label:"thin",value:"thin"},{label:"thick",value:"thick"}]})})]:[]]}),ae=({formik:e})=>s.jsx(y,{rows:[r({formik:e,label:"ZFS blocksize",name:"zfs_blocksize",defaultValue:"",children:s.jsx(t.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"}]})}),r({formik:e,label:"ZFS block mode",name:"zfs_block_mode",defaultValue:"",children:s.jsx(t.Select,{options:c})}),r({formik:e,label:"ZFS delegate",name:"zfs_delegate",defaultValue:"",children:s.jsx(t.Select,{options:c})}),r({formik:e,label:"ZFS remove snapshots",name:"zfs_remove_snapshots",defaultValue:"",children:s.jsx(t.Select,{options:c})}),r({formik:e,label:"ZFS use refquota",name:"zfs_use_refquota",defaultValue:"",children:s.jsx(t.Select,{options:c})}),r({formik:e,label:"ZFS reserve space",name:"zfs_reserve_space",defaultValue:"",children:s.jsx(t.Select,{options:c})})]}),de=(e,a,n)=>{const o=e.size?.match(/^\d/),d=j(n?.config||{},q()),u={name:e.name,config:{size:o?e.size:void 0,[i("security_shifted")]:e.security_shifted,[i("security_unmapped")]:e.security_unmapped,[i("snapshots_expiry")]:e.snapshots_expiry,[i("snapshots_pattern")]:e.snapshots_pattern,[i("snapshots_schedule")]:e.snapshots_schedule,[i("block_filesystem")]:e.block_filesystem,[i("block_mount_options")]:e.block_mount_options,[i("block_type")]:e.block_type,[i("zfs_blocksize")]:e.zfs_blocksize,[i("zfs_block_mode")]:e.zfs_block_mode,[i("zfs_delegate")]:e.zfs_delegate,[i("zfs_remove_snapshots")]:e.zfs_remove_snapshots,[i("zfs_use_refquota")]:e.zfs_use_refquota,[i("zfs_reserve_space")]:e.zfs_reserve_space,...d},project:a,type:e.volumeType,content_type:e.content_type,description:"",location:"",created_at:"",pool:e.pool},l=Object.keys(u),p=j(n||{},new Set(l));return{...u,...p}},S=(e,a)=>({id:a,name:a,onBlur:e.handleBlur,onChange:e.handleChange,value:e.values[a]??"",error:e.touched[a]?e.errors[a]:null,placeholder:`Enter ${a.replaceAll("_"," ")}`}),ce=({formik:e,section:a,setSection:n})=>{const o=t.useNotify(),{project:d}=L();if(!d)return s.jsx(s.Fragment,{children:"Missing project"});const{data:u=[]}=R(),{data:l=[],error:p}=Z(),{data:h}=A();p&&o.failure("Loading storage pools failed",p);const m=()=>{z("form","p-bottom-controls")};F.useEffect(m,[o.notification?.message]),t.useListener(window,m,"resize",!0);const g=l.find(b=>b.name===e.values.pool)?.driver??"";if(l.length>0){const b=[];V.includes(g)||b.push(...B()),g!=="zfs"&&b.push(...H());for(const f of b)e.values[f]!==void 0&&e.setFieldValue(f,void 0)}return s.jsxs(t.Form,{onSubmit:e.handleSubmit,className:"form",children:[s.jsx(t.Input,{type:"submit",hidden:!0,value:"Hidden input"}),s.jsx(X,{active:a,setActive:n,formik:e,poolDriver:g,contentType:e.values.content_type}),s.jsx(t.Row,{className:"form-contents",children:s.jsxs(t.Col,{size:12,children:[a===v(C)&&s.jsx(ee,{formik:e,clusterMembers:u,pools:l,settings:h}),a===v(M)&&s.jsx(se,{formik:e}),a===v(w)&&s.jsx(te,{formik:e,poolDriver:g}),a===v(T)&&s.jsx(ae,{formik:e})]})})]})};export{Y as D,C as M,ee as S,ce as a,se as b,k as h,de as v};