%PDF- %PDF-
Direktori : /snap/lxd/current/share/lxd-ui/assets/ |
Current File : //snap/lxd/current/share/lxd-ui/assets/StorageVolumeDetail-513f1051.js |
import{e as x,d as o,r as y,bd as z,bv as V,j as e,c as F,bw as $,A as C,bx as R,bc as k,W as v,by as q,i as L,m as u,bz as T,q as p,G as f,f as w,L as D,b as O,ap as M,bA as E}from"./index-13b2882d.js";import{R as B}from"./RenameHeader-c74d9adb.js";import{c as b,a as S,u as N}from"./index.esm-82c30f37.js";import{S as I}from"./StorageUsedBy-2e98cb1b.js";import{u as U,S as A}from"./updateMaxHeight-325b3cd4.js";import{v as G,c as H}from"./StorageVolumeForm-228515f8.js";import{M as j}from"./StorageVolumeFormMenu-e90b9f5c.js";import"./ConfigurationTable-1a9d4d6f.js";import"./ConfigFieldDescription-00c1a193.js";import"./DiskSizeSelector-dd5e138a.js";import"./FormMenuItem-c8a1a121.js";const K=({volume:s,project:t})=>{var a;const i=x(),n=o.useNotify(),l=y.useState(null),c=b().shape({name:S().test(...z(t,s.type,l,s.name)).required("This field is required")}),r=N({initialValues:{name:s.name,isRenaming:!1,pool:s.pool},validationSchema:c,onSubmit:d=>{if(s.name===d.name){r.setFieldValue("isRenaming",!1),r.setSubmitting(!1);return}V(t,s,d.name).then(()=>{i(`/ui/project/${t}/storage/detail/${s.pool}/${s.type}/${d.name}`,n.queue(n.success("Storage volume renamed."))),r.setFieldValue("isRenaming",!1)}).catch(h=>{n.failure("Renaming failed",h)}).finally(()=>{r.setSubmitting(!1)})}});return e.jsx(B,{name:s.name,parentItems:[e.jsx(F,{to:`/ui/project/${t}/storage/volumes`,children:"Storage volumes"},1)],controls:e.jsx($,{label:"Delete volume",volume:s,project:t,appearance:"",hasIcon:!1,onFinish:()=>{i(`/ui/project/${t}/storage/volumes`,n.queue(n.success(`Storage volume ${s.name} deleted.`)))}}),isLoaded:!0,formik:r,renameDisabledReason:(((a=s.used_by)==null?void 0:a.length)??0)>0?"Can not rename, volume is currently in use.":void 0})},Q=({project:s,volume:t})=>{var n;const i=()=>{U("storage-overview-tab")};return y.useEffect(i,[t]),C("resize",i),e.jsxs("div",{className:"storage-overview-tab",children:[e.jsxs(o.Row,{className:"section",children:[e.jsx(o.Col,{size:3,children:e.jsx("h2",{className:"p-heading--5",children:"General"})}),e.jsx(o.Col,{size:7,children:e.jsx("table",{children:e.jsxs("tbody",{children:[e.jsxs("tr",{children:[e.jsx("th",{className:"p-muted-heading",children:"Name"}),e.jsx("td",{children:t.name})]}),e.jsxs("tr",{children:[e.jsx("th",{className:"p-muted-heading",children:"Type"}),e.jsx("td",{children:R(t)})]}),e.jsxs("tr",{children:[e.jsx("th",{className:"p-muted-heading",children:"Content type"}),e.jsx("td",{children:k(t)})]}),e.jsxs("tr",{children:[e.jsx("th",{className:"p-muted-heading",children:"Description"}),e.jsx("td",{children:t.description?t.description:"-"})]}),e.jsxs("tr",{children:[e.jsx("th",{className:"p-muted-heading",children:"Location"}),e.jsx("td",{children:t.location})]}),e.jsxs("tr",{children:[e.jsx("th",{className:"p-muted-heading",children:"Date created"}),e.jsx("td",{children:v(t.created_at)})]}),e.jsxs("tr",{children:[e.jsx("th",{className:"p-muted-heading",children:"Size"}),e.jsx("td",{children:e.jsx(q,{volume:t})})]}),e.jsxs("tr",{children:[e.jsx("th",{className:"p-muted-heading",children:"Custom config"}),e.jsx("td",{children:Object.entries(t.config).length===0?"-":e.jsx("table",{children:e.jsx("tbody",{children:Object.entries(t.config).map(([l,c],r)=>e.jsxs("tr",{children:[e.jsx("th",{className:"u-text--muted",children:l}),e.jsx("td",{children:c})]},r))})})})]})]})})})]}),e.jsxs(o.Row,{className:"section",children:[e.jsx(o.Col,{size:3,children:e.jsxs("h2",{className:"p-heading--5",children:["Used by (",((n=t.used_by)==null?void 0:n.length)??0,")"]})}),e.jsx(o.Col,{size:7,children:e.jsx(I,{storage:t,project:s})})]})]})},g=s=>({name:s.name,project:s.project,pool:s.pool,size:s.config.size??"GiB",content_type:s.content_type,type:s.type,security_shifted:s.config["security.shifted"],security_unmapped:s.config["security.unmapped"],snapshots_expiry:s.config["snapshots.expiry"],snapshots_pattern:s.config["snapshots.pattern"],snapshots_schedule:s.config["snapshots.schedule"],block_filesystem:s.config["block.filesystem"],block_mount_options:s.config["block.mount_options"],zfs_blocksize:s.config["zfs.blocksize"],zfs_block_mode:s.config["zfs.block_mode"],zfs_delegate:s.config["zfs.delegate"],zfs_remove_snapshots:s.config["zfs.remove_snapshots"],zfs_use_refquota:s.config["zfs.use_refquota"],zfs_reserve_space:s.config["zfs.reserve_space"],isReadOnly:!0,isCreating:!1}),P=({volume:s})=>{const t=x(),i=o.useNotify(),n=L(),{activeSection:l}=u(),{project:c}=u();if(!c)return e.jsx(e.Fragment,{children:"Missing project"});const r=b().shape({name:S().required("This field is required")}),a=N({initialValues:g(s),validationSchema:r,onSubmit:h=>{const m=G(h,c);T(h.pool,c,{...m,etag:s.etag}).then(()=>{a.setValues(g(m)),n.invalidateQueries({queryKey:[p.storage]}),n.invalidateQueries({queryKey:[p.storage,s.pool,c,m.type,m.name]}),i.success("Storage volume updated.")}).catch(_=>{i.failure("Storage volume update failed",_)}).finally(()=>a.setSubmitting(!1))}}),d=h=>{const m=`/ui/project/${c}/storage/detail/${s.pool}/${s.type}/${s.name}/configuration`;t(h===j?m:`${m}/${f(h)}`)};return e.jsxs("div",{className:"storage-volume-form",children:[e.jsx(H,{formik:a,section:l??f(j),setSection:d}),e.jsxs("div",{className:"l-footer--sticky p-bottom-controls",children:[e.jsx("hr",{}),e.jsx(o.Row,{className:"u-align--right",children:e.jsx(o.Col,{size:12,children:a.values.isReadOnly?e.jsx(o.Button,{appearance:"positive",onClick:()=>void a.setFieldValue("isReadOnly",!1),children:"Edit volume"}):e.jsxs(e.Fragment,{children:[e.jsx(o.Button,{appearance:"base",onClick:()=>a.setValues(g(s)),children:"Cancel"}),e.jsx(A,{isSubmitting:a.isSubmitting,isDisabled:!a.isValid||!a.values.name,buttonLabel:"Save changes",onClick:()=>void a.submitForm()})]})})})]})]})},W=["Overview","Configuration"],oe=()=>{const s=o.useNotify(),{pool:t,project:i,activeTab:n,type:l,volume:c}=u();if(!t)return e.jsx(e.Fragment,{children:"Missing storage pool"});if(!i)return e.jsx(e.Fragment,{children:"Missing project"});if(!l)return e.jsx(e.Fragment,{children:"Missing type"});if(!c)return e.jsx(e.Fragment,{children:"Missing volume"});const{data:r,error:a,isLoading:d}=w({queryKey:[p.storage,t,i,l,c],queryFn:()=>E(t,i,l,c)});return a&&s.failure("Loading storage volume failed",a),d?e.jsx(D,{text:"Loading storage volume..."}):r?e.jsx("main",{className:"l-main",children:e.jsxs("div",{className:"p-panel",children:[e.jsx(K,{volume:r,project:i}),e.jsxs("div",{className:"p-panel__content storage-volume-form",children:[e.jsx(O,{}),e.jsxs(o.Row,{children:[e.jsx(M,{tabs:W,activeTab:n,tabUrl:`/ui/project/${i}/storage/detail/${t}/${l}/${r.name}`}),!n&&e.jsx("div",{role:"tabpanel","aria-labelledby":"overview",children:e.jsx(Q,{volume:r,project:i})}),n==="configuration"&&e.jsx("div",{role:"tabpanel","aria-labelledby":"configuration",children:e.jsx(P,{volume:r})})]})]})]})}):e.jsx(e.Fragment,{children:"Loading storage volume failed"})};export{oe as default};