/
snap
/
lxd
/
current
/
share
/
lxd-ui
/
assets
/
File Upload :
llllll
Current File: //snap/lxd/current/share/lxd-ui/assets/ProjectConfiguration-COocko6D.js
import{bO as B,a2 as q,a3 as H,bQ as V,y as z,d as a,l as L,r as v,c as k,bR as K,j as t,v as O,n as j,bS as Q,q as F,b0 as A,L as M,t as Y,f as N,g as T,Y as W,i as E,R as b,bT as G,u as J,p as D,G as Z,a1 as X,bU as ee,V as C,T as te,F as se}from"./index-B3cgCbnJ.js";import{n as ie,d as ne,i as oe,c as re,r as ae,p as ce,a as de,b as le,P as S}from"./ProjectForm-CXZGsrd5.js";import{g as I,F as ue}from"./FormFooterLayout-ChlQYZN0.js";import{R as me}from"./RenameHeader-7HM7rJrm.js";import{u as x}from"./projects-9DerJg4m.js";import{H as fe}from"./HelpLink-D9xEWgz5.js";import{F as ge}from"./FormSubmitBtn-CI9Q_IyH.js";import"./FormMenuItem-BwEOqt61.js";import"./limits-CLEFMbq-.js";import"./AutoExpandingTextArea-BmFqLvbw.js";import"./scroll-BEbDVMxI.js";import"./instanceOptions-D4bz_1Ev.js";import"./ConfigFieldDescription-C9KDhW5s.js";import"./snapshots-Bt9cFkFc.js";import"./StoragePoolSelector-_Ij9bIB_.js";import"./StoragePoolSize-34u3KM6q.js";import"./Meter-v0AAwaqr.js";import"./NetworkSelector-DygdY6TH.js";import"./useNetworks-DC9cTd9P.js";import"./networks-DBYE4DQa.js";import"./DiskSizeSelector-CIkNkBL4.js";import"./useClusterGroups-DvMC8idl.js";const pe=(e,s,o)=>({name:e.name,readOnly:!0,description:e.description,default_instance_storage_pool:s?H(s):"",default_project_network:s?q(s):"",restricted:e.config.restricted==="true",features_images:e.config["features.images"]==="true",features_profiles:B(e),features_networks:e.config["features.networks"]==="true",features_networks_zones:e.config["features.networks.zones"]==="true",features_storage_buckets:e.config["features.storage.buckets"]==="true",features_storage_volumes:e.config["features.storage.volumes"]==="true",entityType:"project",limits_instances:e.config["limits.instances"]?parseInt(e.config["limits.instances"]):void 0,limits_containers:e.config["limits.containers"]?parseInt(e.config["limits.containers"]):void 0,limits_virtual_machines:e.config["limits.virtual-machines"]?parseInt(e.config["limits.virtual-machines"]):void 0,limits_disk:e.config["limits.disk"],limits_networks:e.config["limits.networks"]?parseInt(e.config["limits.networks"]):void 0,limits_cpu:e.config["limits.cpu"]?parseInt(e.config["limits.cpu"]):void 0,limits_memory:e.config["limits.memory"]?e.config["limits.memory"]:void 0,limits_processes:e.config["limits.processes"]?parseInt(e.config["limits.processes"]):void 0,restricted_cluster_groups:e.config["restricted.cluster.groups"],restricted_cluster_target:e.config["restricted.cluster.target"],restricted_virtual_machines_low_level:e.config["restricted.virtual-machines.lowlevel"],restricted_containers_low_level:e.config["restricted.containers.lowlevel"],restricted_containers_nesting:e.config["restricted.containers.nesting"],restricted_containers_privilege:e.config["restricted.containers.privilege"],restricted_container_interception:e.config["restricted.containers.interception"],restrict_backups:e.config["restricted.backups"],restrict_snapshots:e.config["restricted.snapshots"],restricted_idmap_uid:e.config["restricted.idmap.uid"],restricted_idmap_gid:e.config["restricted.idmap.gid"],restricted_devices_disk:e.config["restricted.devices.disk"],restricted_devices_disk_paths:e.config["restricted.devices.disk.paths"],restricted_devices_gpu:e.config["restricted.devices.gpu"],restricted_devices_infiniband:e.config["restricted.devices.infiniband"],restricted_devices_nic:e.config["restricted.devices.nic"],restricted_devices_pci:e.config["restricted.devices.pci"],restricted_devices_unix_block:e.config["restricted.devices.unix-block"],restricted_devices_unix_char:e.config["restricted.devices.unix-char"],restricted_devices_unix_hotplug:e.config["restricted.devices.unix-hotplug"],restricted_devices_usb:e.config["restricted.devices.usb"],restricted_network_access:e.config["restricted.networks.access"],restricted_network_subnets:e.config["restricted.networks.subnets"],restricted_network_uplinks:e.config["restricted.networks.uplinks"],restricted_network_zones:e.config["restricted.networks.zones"],editRestriction:o}),_e=(e,s)=>{const o=V(),r=new Set(["name","description","config"]);return{...de(s),config:{...ce(s),...ae(s),...s.restricted?{...re(s),...oe(s),...ne(s),...ie(s)}:{},...I(e.config,o)},...I(e,r)}},he=e=>{var l;const s={instance:{label:"Instances",link:`/ui/project/${encodeURIComponent(e.name)}/instances`},profile:{label:"Profiles",link:`/ui/project/${encodeURIComponent(e.name)}/profiles`},image:{label:"Images",link:`/ui/project/${encodeURIComponent(e.name)}/images`},volume:{label:"Custom volumes",link:`/ui/project/${encodeURIComponent(e.name)}/storage/volumes`}},o=Object.keys(s),r=[];for(const c of o){const d=A(c,(l=e.used_by)==null?void 0:l.filter(i=>!i.startsWith("/1.0/profiles/default")));if(d.length>0){const i=s[c].label,u=s[c].link;r.push(t.jsxs("li",{className:"p-list__item is-dark u-no-margin--bottom",children:[t.jsx(M,{to:u,children:i})," (",d.length,")"]},c))}}return t.jsxs(t.Fragment,{children:["Non-empty project cannot be deleted.",t.jsx("p",{className:"u-no-margin--bottom",children:"Project is used by:"}),t.jsx("ul",{className:"p-list u-no-margin--bottom",children:r})]})},ye=({project:e})=>{const s=z(),o=a.useNotify(),r=a.useToastNotification(),l=L(),[c,d]=v.useState(!1),i=k(),{canDeleteProject:u}=x(),n=e.name==="default",m=K(e),f=()=>u(e)?n?"The default project cannot be deleted":m?"Delete project":"":"You do not have permission to delete this project",g=()=>{d(!0),Q(e).then(()=>{i("/ui/project/default/instances"),r.success(t.jsxs(t.Fragment,{children:["Project ",t.jsx(j,{bold:!0,type:"project",value:e.name})," ","deleted."]}))}).catch(h=>{d(!1),o.failure("Project deletion failed",h)}).finally(()=>{l.invalidateQueries({queryKey:[F.projects]})})};return t.jsx(a.ConfirmationButton,{onHoverText:f(),className:O("u-no-margin--bottom",{"has-icon":!s}),loading:c,disabled:!u(e)||n||!m||c,confirmationModalProps:{title:"Confirm delete",confirmButtonLabel:"Delete",onConfirm:g,children:t.jsxs("p",{children:["This will permanently delete project"," ",t.jsx(j,{type:"project",value:e.name,bold:!0}),".",t.jsx("br",{}),"This action cannot be undone, and can result in data loss."]})},shiftClickEnabled:!0,showShiftClickHint:!0,children:t.jsxs(a.Tooltip,{message:!m&&!n?he(e):"",children:[!s&&t.jsx(a.Icon,{name:"delete"}),t.jsx("span",{children:"Delete project"})]})})},be=({project:e})=>{const s=Y(),o=k(),r=a.useToastNotification(),l=v.useState(null),{canEditProject:c}=x(),d=N().shape({name:T().test("deduplicate","A project with this name already exists",async n=>e.name===n||W(n,"",l,"projects")).required("Project name is required")}),i=E({initialValues:{name:e.name,isRenaming:!1},validationSchema:d,onSubmit:n=>{if(e.name===n.name){i.setFieldValue("isRenaming",!1),i.setSubmitting(!1);return}const m=t.jsx(b,{type:"project",value:n.name,to:`/ui/project/${encodeURIComponent(e.name)}/configuration`});G(e.name,n.name).then(f=>{s.set(f.metadata.id,()=>{const g=`/ui/project/${encodeURIComponent(n.name)}/configuration`;o(g),r.success(t.jsxs(t.Fragment,{children:["Project ",t.jsx("strong",{children:e.name})," renamed to"," ",t.jsx(b,{type:"project",value:n.name,to:g}),"."]})),i.setFieldValue("isRenaming",!1)},g=>r.failure(`Renaming project ${e.name} failed`,new Error(g),m),()=>{i.setSubmitting(!1)})}).catch(f=>{i.setSubmitting(!1),r.failure(`Renaming project ${e.name} failed`,f,m)})}}),u=()=>{if(!c(e))return"You do not have permission to rename this project";if(e.name==="default")return"Cannot rename the default project"};return t.jsx(me,{name:e.name,parentItems:[t.jsx(fe,{docPath:"/reference/projects/",title:"Learn more about project configuration",children:"Project configuration"},"project-configuration")],renameDisabledReason:u(),controls:t.jsx(ye,{project:e}),isLoaded:!!e,formik:i})},ve=({project:e})=>{var R;const s=k(),{isRestricted:o}=J(),r=a.useNotify(),l=a.useToastNotification(),c=L(),{section:d}=D(),{hasProjectsNetworksZones:i,hasStorageBuckets:u}=Z(),{canEditProject:n}=x(),{data:m}=X("default",e.name),f=()=>{te("form-contents","p-bottom-controls")};v.useEffect(f,[(R=r.notification)==null?void 0:R.message,d]),a.useListener(window,f,"resize",!0);const g=N().shape({name:T().required()}),h=n(e)?void 0:"You do not have permission to edit this project",P=pe(e,m,h),p=E({initialValues:P,validationSchema:g,enableReinitialize:!0,onSubmit:_=>{i||(_.features_networks_zones=void 0),u||(_.features_storage_buckets=void 0);const w=_e(e,_);w.etag=e.etag,ee(w).then(()=>{l.success(t.jsxs(t.Fragment,{children:["Project"," ",t.jsx(b,{type:"project",value:e.name,to:`/ui/project/${encodeURIComponent(e.name)}/instances`})," ","updated."]})),p.setFieldValue("readOnly",!0)}).catch($=>{r.failure("Project update failed",$)}).finally(()=>{p.setSubmitting(!1),c.invalidateQueries({queryKey:[F.projects]})})}}),y=`/ui/project/${encodeURIComponent(e.name)}/configuration`,U=_=>{s(_===S?y:`${y}/${C(_)}`)};return t.jsxs(a.CustomLayout,{header:t.jsx(be,{project:e}),contentClassName:"edit-project",children:[t.jsx(le,{formik:p,project:e,section:d??C(S),updateSection:U,isEdit:!0}),!o&&t.jsx(ue,{children:p.values.readOnly?null:t.jsxs(t.Fragment,{children:[t.jsx(a.Button,{appearance:"base",onClick:async()=>p.setValues(P),children:"Cancel"}),t.jsx(ge,{formik:p,baseUrl:y,disabled:!p.values.name})]})})]})},Ke=()=>{const{project:e}=D();if(!e)return t.jsx(t.Fragment,{children:"Missing project"});const{project:s,isLoading:o}=se();return o?t.jsx(a.Spinner,{className:"u-loader",text:"Loading...",isMainComponent:!0}):s?t.jsx(ve,{project:s},s.name):t.jsx(t.Fragment,{children:"Loading project failed"})};export{Ke as default};
Copyright ©2k19 -
Hexid
|
Tex7ure