/
snap
/
lxd
/
current
/
share
/
lxd-ui
/
assets
/
File Upload :
llllll
Current File: //snap/lxd/current/share/lxd-ui/assets/StorageVolumeForm-0OnQ0JYw.js
import{j as s,d as a,cp as P,aJ as x,cq as q,r as z,cr as C,a8 as D,T as M,F as E,cs as R,ct as L,cu as r,p as Z,k as A,aG as B,b as H,cv as K,cw as O,V as g}from"./index-B3cgCbnJ.js";import{F as _,k as U,n as G,l as u,H as J,A as y,J as W}from"./FormMenuItem-BwEOqt61.js";import{i as $}from"./snapshots-Bt9cFkFc.js";import{o as m}from"./instanceOptions-D4bz_1Ev.js";import{S as Q,g as F}from"./FormFooterLayout-ChlQYZN0.js";import{D as Y}from"./DiskSizeSelector-CIkNkBL4.js";import{S as X}from"./StoragePoolSelector-_Ij9bIB_.js";const k=({driver:e})=>{const l=e===P?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===q?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 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},w="Main configuration",T="Snapshots",I="Filesystem",N="ZFS",ee=({active:e,setActive:t,formik:l,poolDriver:i,contentType:d})=>{var h;const c=a.useNotify(),o={active:e,setActive:t},p=l.values.name.length>0?void 0:"Please enter a volume name to enable this section",b=()=>{M("form-navigation","p-bottom-controls")};return z.useEffect(b,[(h=c.notification)==null?void 0:h.message]),a.useListener(window,b,"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:w,...o}),s.jsx(_,{label:T,...o,disableReason:p}),d==="filesystem"&&C.includes(i)&&s.jsx(_,{label:I,...o,disableReason:p}),i===D&&s.jsx(_,{label:N,...o,disableReason:p})]})})})},se=(e,t,l)=>{var c;const i=t.find(o=>o.name===e),d=(c=l==null?void 0:l.environment)==null?void 0:c.storage_supported_drivers.find(o=>o.Name===(i==null?void 0:i.driver));return d?!d.Remote:!1},te=({formik:e,poolError:t,clusterMembers:l=[],pools:i=[],settings:d})=>{var o;const c=(o=i.find(n=>n.name===e.values.pool))==null?void 0:o.driver;return s.jsxs(Q,{children:[s.jsx(a.Row,{children:s.jsxs(a.Col,{size:12,children:[s.jsx(a.Label,{forId:"storage-pool-selector-volume",required:e.values.isCreating,children:"Storage pool"}),s.jsx(X,{value:e.values.pool,setValue:n=>{e.setFieldValue("pool",n),se(n,i,d)&&l.length>0?e.setFieldValue("clusterMember",l[0].server_name):e.setFieldValue("clusterMember",void 0)},selectProps:{id:"storage-pool-selector-volume",disabled:!e.values.isCreating,error:t,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(a.Select,{id:"clusterMember",label:"Cluster member",onChange:n=>{e.setFieldValue("clusterMember",n.target.value)},value:e.values.clusterMember,options:l.map(n=>({label:n.server_name,value:n.server_name})),disabled:!e.values.isCreating,required:e.values.isCreating,help:e.values.isCreating?void 0:"Cluster member is immutable after creation."}),s.jsx(a.Input,{...V(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(Y,{label:"Size",value:e.values.size,help:s.jsxs(s.Fragment,{children:[s.jsx(k,{driver:c}),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:n=>{U(e),e.setFieldValue("size",n)},disabled:!!e.values.editRestriction||e.values.volumeType!=="custom"}),s.jsx(a.Select,{...V(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:n=>{n.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",n.target.value)},disabled:!e.values.isCreating})]})}),e.values.content_type==="filesystem"&&s.jsx(G,{rows:[u({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:m})}),u({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:m})})]})]})},ae=({formik:e})=>{const{project:t}=E(),l=$(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==null?void 0:t.name}`,children:s.jsx(J,{project:t})}),s.jsx(y,{rows:[u({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(x,{docPath:"/reference/instance_options/#instance-options-snapshots-names",children:"Automatic snapshot names"})]}),type:"text"})}),u({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"})}),u({formik:e,label:"Schedule",name:"snapshots_schedule",defaultValue:"",children:s.jsx(W,{value:e.values.snapshots_schedule,setValue:i=>void e.setFieldValue("snapshots_schedule",i)})})]})]})},le=({formik:e,poolDriver:t})=>s.jsx(y,{rows:[u({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"}]})}),u({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===R?[u({formik:e,label:"Block type",name:"block_type",defaultValue:"thin",children:s.jsx(a.Select,{options:[{label:"thin",value:"thin"},{label:"thick",value:"thick"}]})})]:[]]}),ne=({formik:e})=>s.jsx(y,{rows:[u({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"}]})}),u({formik:e,label:"ZFS block mode",name:"zfs_block_mode",defaultValue:"",children:s.jsx(a.Select,{options:m})}),u({formik:e,label:"ZFS delegate",name:"zfs_delegate",defaultValue:"",children:s.jsx(a.Select,{options:m})}),u({formik:e,label:"ZFS remove snapshots",name:"zfs_remove_snapshots",defaultValue:"",children:s.jsx(a.Select,{options:m})}),u({formik:e,label:"ZFS use refquota",name:"zfs_use_refquota",defaultValue:"",children:s.jsx(a.Select,{options:m})}),u({formik:e,label:"ZFS reserve space",name:"zfs_reserve_space",defaultValue:"",children:s.jsx(a.Select,{options:m})})]}),he=(e,t,l)=>{var p;const i=(p=e.size)==null?void 0:p.match(/^\d/),d=F((l==null?void 0:l.config)||{},L()),c={name:e.name,config:{size:i?e.size:void 0,[r("security_shifted")]:e.security_shifted,[r("security_unmapped")]:e.security_unmapped,[r("snapshots_expiry")]:e.snapshots_expiry,[r("snapshots_pattern")]:e.snapshots_pattern,[r("snapshots_schedule")]:e.snapshots_schedule,[r("block_filesystem")]:e.block_filesystem,[r("block_mount_options")]:e.block_mount_options,[r("block_type")]:e.block_type,[r("zfs_blocksize")]:e.zfs_blocksize,[r("zfs_block_mode")]:e.zfs_block_mode,[r("zfs_delegate")]:e.zfs_delegate,[r("zfs_remove_snapshots")]:e.zfs_remove_snapshots,[r("zfs_use_refquota")]:e.zfs_use_refquota,[r("zfs_reserve_space")]:e.zfs_reserve_space,...d},project:t,type:e.volumeType,content_type:e.content_type,description:"",location:"",created_at:"",pool:e.pool},o=Object.keys(c),n=F(l||{},new Set(o));return{...c,...n}},V=(e,t)=>({id:t,name:t,onBlur:e.handleBlur,onChange:e.handleChange,value:e.values[t]??"",error:e.touched[t]?e.errors[t]:null,placeholder:`Enter ${t.replaceAll("_"," ")}`}),me=({formik:e,section:t,setSection:l})=>{var f,S;const i=a.useNotify(),{project:d}=Z();if(!d)return s.jsx(s.Fragment,{children:"Missing project"});const{data:c=[]}=A(),{data:o=[],error:n}=B(),{data:p}=H();n&&i.failure("Loading storage pools failed",n);const b=()=>{M("form","p-bottom-controls")};z.useEffect(b,[(f=i.notification)==null?void 0:f.message]),a.useListener(window,b,"resize",!0);const h=((S=o.find(v=>v.name===e.values.pool))==null?void 0:S.driver)??"";if(o.length>0){const v=[];C.includes(h)||v.push(...K()),h!=="zfs"&&v.push(...O());for(const j of v)e.values[j]!==void 0&&e.setFieldValue(j,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(ee,{active:t,setActive:l,formik:e,poolDriver:h,contentType:e.values.content_type}),s.jsx(a.Row,{className:"form-contents",children:s.jsxs(a.Col,{size:12,children:[t===g(w)&&s.jsx(te,{formik:e,clusterMembers:c,pools:o,settings:p}),t===g(T)&&s.jsx(ae,{formik:e}),t===g(I)&&s.jsx(le,{formik:e,poolDriver:h}),t===g(N)&&s.jsx(ne,{formik:e})]})})]})};export{k as D,w as M,te as S,me as a,ae as b,se as h,he as v};
Copyright ©2k19 -
Hexid
|
Tex7ure