/
snap
/
lxd
/
current
/
share
/
lxd-ui
/
assets
/
File Upload :
llllll
Current File: //snap/lxd/current/share/lxd-ui/assets/Settings-CJFa5XRF.js
import{r as j,j as e,d as t,k as P,u as M,l as V,E as D,D as q,m as K,bQ as Q,bO as G,q as E,n as H,G as z,z as Y,bR as A,bC as U,e as X,bD as $}from"./index-dL2n30-Z.js";import{C as B}from"./ConfigFieldDescription-B5-bOr1x.js";import{C as J}from"./ClusterSpecificInput-OscQ5yiR.js";import{C as W}from"./ClusterSpecificSelect-w4WndyK2.js";import{S as Z}from"./ScrollableTable-CQDmfMtz.js";import{H as F}from"./HelpLink-C3KAssP1.js";import{P as R}from"./PageHeader-5dI4zJHr.js";const ee=({initialValue:n,configField:s,onSubmit:i,onCancel:m})=>{var d,c;const[l,r]=j.useState(n?n==="true":String(s.default)==="true"),h=String(s.default)!==String(l),u=()=>{r(String(s.default)==="true")},p=((c=(d=s.key.split("."))==null?void 0:d.pop())==null?void 0:c.replaceAll("_"," "))??s.key;return e.jsxs(e.Fragment,{children:[e.jsx(t.Input,{label:p,id:I(s.key),wrapperClassName:"input-wrapper",type:"checkbox",checked:l,onChange:f=>{r(f.target.checked)},help:e.jsx(B,{description:s.longdesc})}),e.jsx(t.Button,{appearance:"base",onClick:m,children:"Cancel"}),e.jsx(t.Button,{appearance:"positive",onClick:()=>{i(l)},children:"Save"}),h&&e.jsxs(t.Button,{className:"reset-button",appearance:"base",onClick:u,hasIcon:!0,children:[e.jsx(t.Icon,{name:"restart",className:"flip-horizontally"}),e.jsx("span",{children:"Reset to default"})]})]})},te=({initialValue:n,configField:s,onSubmit:i,onCancel:m})=>{const[l,r]=j.useState(n),h=()=>{switch(s.type){case"integer":return"number";default:return"text"}},u=String(s.default)!==String(l),p=()=>{r(s.default)};return e.jsxs(t.Form,{onSubmit:d=>{d.preventDefault(),i(l)},children:[e.jsx(t.Input,{type:"submit",hidden:!0,value:"Hidden input"}),e.jsx(t.Input,{"aria-label":s.key,id:I(s.key),wrapperClassName:"input-wrapper",type:h(),value:s.type==="bool"?void 0:String(l),onChange:d=>{r(d.target.value)},help:e.jsx(B,{description:s.longdesc,className:"p-form-help-text"})}),e.jsx(t.Button,{appearance:"base",onClick:m,children:"Cancel"}),e.jsx(t.Button,{appearance:"positive",type:"submit",children:"Save"}),u&&e.jsxs(t.Button,{className:"reset-button",appearance:"base",onClick:p,hasIcon:!0,children:[e.jsx(t.Icon,{name:"restart",className:"flip-horizontally"}),e.jsx("span",{children:"Reset to default"})]})]})},se=({isSet:n,configField:s,onSubmit:i,onCancel:m})=>{const[l,r]=j.useState(!n),[h,u]=j.useState(!1),[p,d]=j.useState("");return e.jsxs(t.Form,{onSubmit:c=>{c.preventDefault(),i(p)},children:[e.jsx(t.Input,{type:"submit",hidden:!0,value:"Hidden input"}),l&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"input-row",children:[e.jsx(t.Input,{"aria-label":s.key,id:I(s.key),wrapperClassName:"input-wrapper",type:h?"text":"password",value:p,onChange:c=>{d(c.target.value)},help:e.jsx(B,{description:s.longdesc,className:"p-form-help-text"})}),e.jsx(t.Button,{appearance:"base",hasIcon:!0,onClick:()=>{u(c=>!c)},"aria-label":"toggle password visibility",children:e.jsx(t.Icon,{name:h?"hide":"show"})})]}),e.jsx(t.Button,{appearance:"base",onClick:m,children:"Cancel"}),e.jsx(t.Button,{appearance:"positive",onClick:()=>{i(p)},children:"Save"})]}),!l&&e.jsxs(e.Fragment,{children:[e.jsx(t.Button,{appearance:"base",onClick:m,children:"Cancel"}),e.jsx(t.Button,{onClick:()=>{r(!0)},children:"Change"}),e.jsx(t.Button,{appearance:"negative",onClick:()=>{i("")},children:"Remove"})]})]})},ae=({disableReason:n,initialValue:s,configField:i,onSubmit:m,onCancel:l,readonly:r=!1,toggleReadOnly:h})=>{const[u,p]=j.useState(s),{data:d=[]}=P(),c=d.map(o=>o.server_name),f=i.key==="core.syslog_socket",g=Object.values(u).some(o=>o!==i.default),v=()=>{const o={};c.forEach(b=>{o[b]=i.default}),p(o)},k=e.jsx(B,{className:"u-no-margin--bottom",description:i.longdesc});return e.jsxs(t.Form,{onSubmit:o=>{o.preventDefault(),m(u)},children:[f?e.jsx(W,{"aria-label":i.key,classname:r?"read-only":"",disableReason:n,id:I(i.key),values:u,isReadOnly:r,onChange:o=>{p(o)},toggleReadOnly:h,helpText:k,options:c.map(o=>({memberName:o,values:["true","false"]})),isDefaultSpecific:Object.values(u).some(o=>o!==Object.values(u)[0])}):e.jsx(J,{"aria-label":i.key,classname:r?"read-only":"",disableReason:n,id:I(i.key),values:u,isReadOnly:r,onChange:o=>{p(o)},memberNames:c,toggleReadOnly:h,helpText:k}),!r&&e.jsxs(e.Fragment,{children:[e.jsx(t.Button,{appearance:"base",onClick:l,children:"Cancel"}),e.jsx(t.Button,{appearance:"positive",type:"submit",children:"Save"}),g&&e.jsxs(t.Button,{className:"reset-button",appearance:"base",type:"button",onClick:v,hasIcon:!0,children:[e.jsx(t.Icon,{name:"restart",className:"flip-horizontally"}),e.jsx("span",{children:"Reset to default"})]})]})]})},I=n=>n.replace(".","___"),re=({configField:n,value:s,clusteredValue:i,isLast:m})=>{const{isRestricted:l}=M(),[r,h]=j.useState(!1),u=t.useNotify(),p=t.useToastNotification(),d=V(),{canEditServerConfiguration:c}=D(),f=q(),g=j.useRef(null),v=n.key==="core.trust_password",k=n.key==="loki.auth.password",o=v||k,b=f&&n.scope==="local",L=n.key==="user.ui_theme",w=e.jsx(K,{bold:!0,type:"setting",value:n.key}),C=y=>{(b||typeof y=="object"?Q(y,n.key):G({[n.key]:String(y)})).then(()=>{p.success(e.jsxs(e.Fragment,{children:["Setting ",w," updated."]})),h(!1)}).catch(S=>{u.failure("Setting update failed",S,w)}).finally(()=>{d.invalidateQueries({queryKey:[E.settings]}),d.invalidateQueries({queryKey:[E.settings,E.cluster]})})},a=()=>{h(!1)},x=()=>o?e.jsx("em",{children:s?"set":"not set"}):typeof s=="boolean"?String(s):s||"-";return j.useEffect(()=>{var y;r&&m&&((y=g.current)==null||y.scrollIntoView({behavior:"smooth"}))},[r]),b?e.jsx(ae,{initialValue:i??{},disableReason:c()?void 0:"You do not have permission to edit server configuration",configField:n,onSubmit:C,onCancel:a,readonly:!r,toggleReadOnly:()=>{h(!0)}},`${JSON.stringify(i)}-${r}`):L?e.jsx(t.ThemeSwitcher,{}):e.jsxs(e.Fragment,{children:[r&&e.jsxs("div",{ref:g,children:[o&&e.jsx(se,{isSet:!!s,configField:n,onSubmit:C,onCancel:a}),!o&&e.jsx(e.Fragment,{children:n.type==="bool"?e.jsx(ee,{initialValue:s,configField:n,onSubmit:C,onCancel:a}):e.jsx(te,{initialValue:s??"",configField:n,onSubmit:C,onCancel:a})})]}),!r&&e.jsx(e.Fragment,{children:l?e.jsx("span",{children:s??"-"}):e.jsxs(t.Button,{appearance:"base",className:"readmode-button u-no-margin",onClick:()=>{h(!0)},hasIcon:!0,disabled:!c(),title:c()?"":"You do not have permission to edit server configuration",children:[e.jsx("div",{className:"readmode-value u-truncate",children:x()}),e.jsx(t.Icon,{name:"edit",className:"edit-icon"})]})})]})},de=()=>{var C;const n=H(),[s,i]=j.useState(""),m=t.useNotify(),{hasMetadataConfiguration:l,settings:r,isSettingsLoading:h,settingsError:u}=z(),{canEditServerConfiguration:p}=D(),{data:d,isLoading:c}=Y({queryKey:[E.configOptions],queryFn:async()=>$(l)}),{data:f=[],error:g}=A();if(g&&m.failure("Loading clustered settings failed",g),c||h)return e.jsx(t.Spinner,{className:"u-loader",text:"Loading...",isMainComponent:!0});u&&m.failure("Loading settings failed",u);const v=a=>{for(const[x,y]of Object.entries((r==null?void 0:r.config)??{}))if(x===a.key)return y;if(a.type==="bool")return a.default==="true"?"true":"false";if(a.default!=="-")return a.default},k=(a,x)=>{const y={};return a==null||a.forEach(N=>{var S;y[N.memberName]=((S=N.config)==null?void 0:S[x.key])??x.default??""}),y},o=[{content:"Group",className:"group"},{content:"Key",className:"key"},{content:"Value"}],b=U(((C=d==null?void 0:d.configs)==null?void 0:C.server)??{});b.push({key:"user.ui_title",category:"user",default:"",shortdesc:"Title for the LXD-UI web page. Shows the hostname when unset.",type:"string"}),b.push({key:"user.ui_grafana_base_url",category:"user",default:"",longdesc:`e.g. https://example.org/dashboard?project={project}&name={instance} or https://192.0.2.1:3000/d/bGY-LSB7k/lxd?orgId=1`,shortdesc:"LXD will replace `{instance}` and `{project}` with project and instance names for deep-linking to individual grafana pages.\nSee {ref}`grafana` for more information.",type:"string"}),b.push({key:"user.ui_theme",category:"user",default:"",shortdesc:"Set UI to dark theme, light theme, or to match the system theme.",type:"string"});let L="";const w=b.filter(a=>{var x;return s?a.key.toLowerCase().includes(s.toLowerCase())||((x=a.shortdesc)==null?void 0:x.toLowerCase().includes(s.toLowerCase())):!0}).map((a,x,{length:y})=>{const N=!Object.keys((r==null?void 0:r.config)??{}).some(O=>O===a.key),S=v(a),T=k(f,a),_=L!==a.category;return L=a.category,{key:a.key,columns:[{content:_&&e.jsx("h2",{className:"p-heading--5",children:a.category}),role:"rowheader",className:"group","aria-label":"Group"},{content:e.jsxs("div",{className:"key-cell",children:[N?a.key:e.jsx("strong",{children:a.key}),e.jsx(B,{description:a.shortdesc,className:"p-text--small u-text--muted u-no-margin--bottom"})]}),role:"cell",className:"key","aria-label":"Key"},{content:e.jsx(re,{configField:a,value:S,clusteredValue:T,isLast:x===y-1}),role:"cell","aria-label":"Value",className:"u-vertical-align-middle"}]}});return e.jsx(e.Fragment,{children:e.jsxs(t.CustomLayout,{header:e.jsx(R,{children:e.jsxs(R.Left,{children:[e.jsx(R.Title,{children:e.jsx(F,{href:`${n}/server/`,title:"Learn more about server configuration",children:"Settings"})}),e.jsx(R.Search,{children:e.jsx(t.SearchBox,{name:"search-setting",type:"text",className:"u-no-margin--bottom",onChange:a=>{i(a)},placeholder:"Search",value:s})})]})}),contentClassName:"settings",children:[e.jsx(X,{}),e.jsxs(t.Row,{children:[!p()&&e.jsx(t.Notification,{severity:"caution",title:"Restricted permissions",titleElement:"h2",children:"You do not have permission to view or edit server settings"}),!l&&p()&&e.jsx(t.Notification,{severity:"information",title:"Get more server settings",titleElement:"h2",children:"Update to LXD v5.19.0 or later to access more server settings"}),p()&&e.jsx(Z,{dependencies:[m.notification,w],tableId:"settings-table",belowIds:["status-bar"],children:e.jsx(t.MainTable,{id:"settings-table",headers:o,rows:w,emptyStateMsg:"No data to display"})})]})]})})};export{de as default};
Copyright ©2k19 -
Hexid
|
Tex7ure