Your IP : 216.73.216.189


Current Path : /proc/thread-self/root/snap/lxd/current/share/lxd-ui/assets/
Upload File :
Current File : //proc/thread-self/root/snap/lxd/current/share/lxd-ui/assets/ImageRegistryRichChip-Fa2NUsp6.js

import{d as r,j as e,L as u,R as d,y as x,aM as j,cs as v,O as b,ct as y,v as P}from"./index-BFGypnt-.js";import{e as F}from"./useClusterLinks-CpODgtKY.js";import{a as I}from"./useImageRegistries-BcqfYS33.js";const C=t=>t.config?.public?.toLowerCase()==="true",S=({formik:t})=>{const{data:n=[],error:s}=F(),i=r.useNotify(),o=n.length===0;s&&i.failure("Loading cluster links failed",s);const l=n.map(a=>({value:a.name,text:a.name,label:e.jsxs("div",{className:"cluster-link-label",children:[e.jsx("span",{className:"cluster-link-name u-truncate",title:a.name,children:a.name}),e.jsx("span",{className:"cluster-link-description u-text--muted",children:a.type==="bidirectional"?"public and private images":"public images only"})]})})),c=o?e.jsxs(e.Fragment,{children:["Cluster containing the images. Create your first"," ",e.jsx(u,{to:`${d}/ui/cluster/links`,children:"cluster link"}),"."]}):e.jsxs(e.Fragment,{children:["Cluster containing the images. Manage your"," ",e.jsx(u,{to:`${d}/ui/cluster/links`,children:"cluster links"}),"."]});return e.jsx(r.CustomSelect,{...t.getFieldProps("cluster"),label:"Cluster",options:o?[{value:"",label:"No cluster links available."}]:[{value:"",label:"Select a cluster"},...l],value:t.values.cluster??"",help:c,onChange:a=>{t.setFieldValue("cluster",a)}})},L=({formik:t})=>e.jsxs("div",{className:"image-registry-protocol-selector",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"protocol",children:"Protocol"}),e.jsx(u,{to:"https://documentation.ubuntu.com/lxd/v5/reference/remote_image_servers/#remote-server-types",target:"_blank",rel:"noopener noreferrer",className:"help-text help-link",title:"Learn more about remote server types.",children:e.jsx(r.Icon,{name:"help",className:"help-link-icon"})})]}),e.jsxs("div",{id:"protocol",children:[e.jsx(r.RadioInput,{inline:!0,"aria-label":"LXD",labelClassName:"lxd-protocol-input",label:"LXD",checked:t.values.protocol==="lxd",onChange:()=>{t.setFieldValue("protocol","lxd")}}),e.jsx(r.RadioInput,{inline:!0,"aria-label":"SimpleStreams",label:"SimpleStreams",checked:t.values.protocol==="simplestreams",onChange:()=>{t.setFieldValue("protocol","simplestreams")}})]})]}),O=({formik:t})=>{const n=t.values.protocol==="simplestreams",s=l=>l.replace(/^https?:\/\//i,""),i=!t.values.isCreating,o=l=>t.touched[l]?t.errors[l]:void 0;return e.jsxs(r.Form,{onSubmit:t.handleSubmit,children:[e.jsx(r.Input,{type:"submit",hidden:!0,value:"Hidden input"}),i?e.jsx(r.OutputField,{id:"Name",label:"Name",value:t.values.name,help:"Click the name in the page header to rename the registry."}):e.jsx(r.Input,{...t.getFieldProps("name"),type:"text",autoFocus:!0,label:"Name",required:!0,error:o("name"),placeholder:"Enter name"}),e.jsx(r.Input,{...t.getFieldProps("description"),type:"text",autoFocus:i,label:"Description",placeholder:"Enter description",error:o("description")}),i?e.jsx(r.OutputField,{id:"Protocol",label:"Protocol",value:t.values.protocol,help:"Protocol cannot be changed."}):e.jsx(L,{formik:t}),n&&e.jsx(r.PrefixedInput,{...t.getFieldProps("url"),immutableText:"https://",value:t.values.url?s(t.values.url):"",label:"Server",placeholder:"example.org/releases",error:o("url"),onChange:l=>{const c=s(l.target.value);t.setFieldValue("url",c?`https://${c}`:"")},help:e.jsxs(e.Fragment,{children:["Enter the base folder for ",e.jsx("code",{children:"streams/v1"}),", such as"," ","https://cloud-images.ubuntu.com/releases/"]})}),!n&&e.jsxs(e.Fragment,{children:[e.jsx(S,{formik:t}),e.jsx(r.Input,{...t.getFieldProps("sourceProject"),type:"text",label:"Source project",placeholder:"Enter source project",error:o("sourceProject"),help:"Project with images on the remote cluster."})]})]})},T=({imageRegistryName:t,imageRegistryUrl:n})=>{const{data:s,isLoading:i}=I(t);if(!s&&!i)return e.jsxs(e.Fragment,{children:["Image registry"," ",e.jsx(x,{type:"image-registry",value:t,bold:!0})," ","not found"]});const o=s?.description,l=s?.protocol,c=s&&C(s),a=s?.config?.cluster,h=s?.config?.source_project,m=s?.config?.url,p=[{title:"Image Registry",value:s?e.jsx(u,{to:n,onClick:g=>{g.stopPropagation()},children:e.jsx(j,{item:{name:t}})}):e.jsx(r.Spinner,{}),valueTitle:t},{title:"Description",value:o||"-",valueTitle:o},{title:"Protocol",value:l||"-"},{title:"Public",value:c?"Yes":"No"},{title:"Built-in",value:s?.builtin?"Yes":"No"}];return s&&l==="simplestreams"&&p.push({title:"Server URL",value:m||"-",valueTitle:m}),s&&l==="lxd"&&(p.push({title:"Cluster",value:a?e.jsx(u,{to:`${d}/ui/cluster/links`,children:a}):"-",valueTitle:a}),p.push({title:"Source project",value:h||"-",valueTitle:h})),e.jsx(v,{rows:p,className:"image-registry-rich-tooltip-table"})},_=({imageRegistryName:t,className:n,disabled:s})=>{const i=!b(y,"height"),o=`${d}/ui/image-registry/${encodeURIComponent(t)}`,l=e.jsx(P,{type:"image-registry",value:t,to:o,hasTitle:!i,className:n,disabled:s});return i?e.jsx(r.Tooltip,{zIndex:1e3,position:"right",message:e.jsx(T,{imageRegistryName:t,imageRegistryUrl:o}),children:l}):e.jsx(e.Fragment,{children:l})};export{_ as I,O as a,C as i};