skypilot-nightly 1.0.0.dev20250715__py3-none-any.whl → 1.0.0.dev20250717__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sky/__init__.py +4 -2
- sky/adaptors/nebius.py +6 -0
- sky/backends/backend.py +8 -4
- sky/backends/cloud_vm_ray_backend.py +50 -1
- sky/backends/docker_utils.py +1 -1
- sky/backends/local_docker_backend.py +2 -1
- sky/catalog/common.py +60 -50
- sky/catalog/data_fetchers/fetch_gcp.py +1 -0
- sky/catalog/data_fetchers/fetch_nebius.py +308 -0
- sky/catalog/gcp_catalog.py +24 -7
- sky/catalog/kubernetes_catalog.py +5 -1
- sky/client/cli/command.py +180 -77
- sky/client/cli/git.py +549 -0
- sky/client/common.py +1 -1
- sky/clouds/gcp.py +1 -1
- sky/clouds/hyperbolic.py +2 -0
- sky/clouds/nebius.py +6 -4
- sky/dashboard/out/404.html +1 -1
- sky/dashboard/out/_next/static/Et5IQ5Y3WvH608nXClo4z/_buildManifest.js +1 -0
- sky/dashboard/out/_next/static/chunks/1141-d8c6404a7c6fffe6.js +11 -0
- sky/dashboard/out/_next/static/chunks/1746.27d40aedc22bd2d6.js +60 -0
- sky/dashboard/out/_next/static/chunks/2641.35edc9ccaeaad9e3.js +1 -0
- sky/dashboard/out/_next/static/chunks/{3785.b3cc2bc1d49d2c3c.js → 3785.95b94f18aaec7233.js} +1 -1
- sky/dashboard/out/_next/static/chunks/4869.bdd42f14b51d1d6f.js +16 -0
- sky/dashboard/out/_next/static/chunks/6990-dcb411b566e64cde.js +1 -0
- sky/dashboard/out/_next/static/chunks/{9025.a7c44babfe56ce09.js → 9025.133e9ba5c780afeb.js} +1 -1
- sky/dashboard/out/_next/static/chunks/9847.46e613d000c55859.js +30 -0
- sky/dashboard/out/_next/static/chunks/pages/{_app-e0f63ea4704026ad.js → _app-771a40cde532309b.js} +1 -1
- sky/dashboard/out/_next/static/chunks/pages/clusters/[cluster]/[job]-9096ea50b8e2cf9e.js +6 -0
- sky/dashboard/out/_next/static/chunks/pages/jobs/[job]-14d404b7dd28502a.js +16 -0
- sky/dashboard/out/_next/static/chunks/pages/{users-cd43fb3c122eedde.js → users-19e98664bdd61643.js} +1 -1
- sky/dashboard/out/_next/static/chunks/pages/volumes-61ea7ba7e56f8d06.js +1 -0
- sky/dashboard/out/_next/static/chunks/pages/{workspaces-06bde99155fa6292.js → workspaces-a1e43d9ef51a9cea.js} +1 -1
- sky/dashboard/out/_next/static/chunks/{webpack-4a336bff3bcec29a.js → webpack-c3b45b7b0eaef66f.js} +1 -1
- sky/dashboard/out/_next/static/css/219887b94512388c.css +3 -0
- sky/dashboard/out/clusters/[cluster]/[job].html +1 -1
- sky/dashboard/out/clusters/[cluster].html +1 -1
- sky/dashboard/out/clusters.html +1 -1
- sky/dashboard/out/config.html +1 -1
- sky/dashboard/out/index.html +1 -1
- sky/dashboard/out/infra/[context].html +1 -1
- sky/dashboard/out/infra.html +1 -1
- sky/dashboard/out/jobs/[job].html +1 -1
- sky/dashboard/out/jobs.html +1 -1
- sky/dashboard/out/users.html +1 -1
- sky/dashboard/out/volumes.html +1 -1
- sky/dashboard/out/workspace/new.html +1 -1
- sky/dashboard/out/workspaces/[name].html +1 -1
- sky/dashboard/out/workspaces.html +1 -1
- sky/exceptions.py +5 -0
- sky/execution.py +5 -1
- sky/provision/hyperbolic/__init__.py +1 -0
- sky/provision/hyperbolic/instance.py +10 -0
- sky/provision/kubernetes/utils.py +6 -0
- sky/server/common.py +4 -3
- sky/setup_files/MANIFEST.in +1 -0
- sky/setup_files/dependencies.py +3 -1
- sky/task.py +12 -2
- sky/utils/command_runner.py +144 -35
- sky/utils/controller_utils.py +4 -3
- sky/utils/git.py +9 -0
- sky/utils/git_clone.sh +460 -0
- sky/utils/schemas.py +15 -1
- sky/utils/tempstore.py +20 -1
- {skypilot_nightly-1.0.0.dev20250715.dist-info → skypilot_nightly-1.0.0.dev20250717.dist-info}/METADATA +5 -3
- {skypilot_nightly-1.0.0.dev20250715.dist-info → skypilot_nightly-1.0.0.dev20250717.dist-info}/RECORD +79 -75
- sky/dashboard/out/_next/static/chunks/1141-726e5a3f00b67185.js +0 -11
- sky/dashboard/out/_next/static/chunks/1691.44e378727a41f3b5.js +0 -21
- sky/dashboard/out/_next/static/chunks/3256.7257acd01b481bed.js +0 -11
- sky/dashboard/out/_next/static/chunks/4697.f5421144224da9fc.js +0 -20
- sky/dashboard/out/_next/static/chunks/6990-d0dc765474fa0eca.js +0 -1
- sky/dashboard/out/_next/static/chunks/8982.a2e214068f30a857.js +0 -1
- sky/dashboard/out/_next/static/chunks/pages/clusters/[cluster]/[job]-4608dc89f95eba89.js +0 -6
- sky/dashboard/out/_next/static/chunks/pages/jobs/[job]-980d6f6b64ca7833.js +0 -16
- sky/dashboard/out/_next/static/chunks/pages/volumes-4ebf6484f7216387.js +0 -1
- sky/dashboard/out/_next/static/css/eacc7d65a8686c76.css +0 -3
- sky/dashboard/out/_next/static/y4pSeZ-9XymSDfPlcWhVO/_buildManifest.js +0 -1
- /sky/dashboard/out/_next/static/{y4pSeZ-9XymSDfPlcWhVO → Et5IQ5Y3WvH608nXClo4z}/_ssgManifest.js +0 -0
- /sky/dashboard/out/_next/static/chunks/{1043-5e5ef6198735ff7e.js → 1043-90a88c46f27b3df5.js} +0 -0
- /sky/dashboard/out/_next/static/chunks/{1871-4d1f786e83bd9ffe.js → 1871-76491ac174a95278.js} +0 -0
- /sky/dashboard/out/_next/static/chunks/{3698-52ad1ca228faa776.js → 3698-9fa11dafb5cad4a6.js} +0 -0
- /sky/dashboard/out/_next/static/chunks/{6601-d38d10f957dff832.js → 6601-d4a381403a8bae91.js} +0 -0
- /sky/dashboard/out/_next/static/chunks/{8969-13bb52ce3cffa4e3.js → 8969-743abf4bc86baf48.js} +0 -0
- /sky/dashboard/out/_next/static/chunks/{938-8e25c8ea0baa271a.js → 938-6a9ffdaa21eee969.js} +0 -0
- /sky/dashboard/out/_next/static/chunks/{9470-21d059a1dfa03f61.js → 9470-b6f6a35283863a6f.js} +0 -0
- /sky/dashboard/out/_next/static/chunks/pages/clusters/{[cluster]-0fbfb1dd0b08c90c.js → [cluster]-0c37ee1ac5f3474d.js} +0 -0
- {skypilot_nightly-1.0.0.dev20250715.dist-info → skypilot_nightly-1.0.0.dev20250717.dist-info}/WHEEL +0 -0
- {skypilot_nightly-1.0.0.dev20250715.dist-info → skypilot_nightly-1.0.0.dev20250717.dist-info}/entry_points.txt +0 -0
- {skypilot_nightly-1.0.0.dev20250715.dist-info → skypilot_nightly-1.0.0.dev20250717.dist-info}/licenses/LICENSE +0 -0
- {skypilot_nightly-1.0.0.dev20250715.dist-info → skypilot_nightly-1.0.0.dev20250717.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,11 @@
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1141],{9333:function(e,s,r){r.d(s,{Z:function(){return a}});/**
|
2
|
+
* @license lucide-react v0.407.0 - ISC
|
3
|
+
*
|
4
|
+
* This source code is licensed under the ISC license.
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
6
|
+
*/let a=(0,r(998).Z)("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]])},8418:function(e,s,r){r.d(s,{Z:function(){return a}});/**
|
7
|
+
* @license lucide-react v0.407.0 - ISC
|
8
|
+
*
|
9
|
+
* This source code is licensed under the ISC license.
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
11
|
+
*/let a=(0,r(998).Z)("Trash",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}]])},1812:function(e,s,r){r.d(s,{X:function(){return n}});var a=r(5893),l=r(7294);let t=e=>{if(!(null==e?void 0:e.message))return"An unexpected error occurred.";let s=e.message;return s.includes("failed:")&&(s=s.split("failed:")[1].trim()),s},n=e=>{let{error:s,title:r="Error",onDismiss:n}=e,[c,i]=(0,l.useState)(!1);if((0,l.useEffect)(()=>{s&&i(!1)},[s]),!s||c)return null;let o="string"==typeof s?s:t(s);return(0,a.jsx)("div",{className:"bg-red-50 border border-red-200 rounded-md p-3 mb-4",children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)("div",{className:"flex-shrink-0",children:(0,a.jsx)("svg",{className:"h-5 w-5 text-red-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,a.jsx)("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})})}),(0,a.jsx)("div",{className:"ml-3",children:(0,a.jsxs)("div",{className:"text-sm text-red-800",children:[(0,a.jsxs)("strong",{children:[r,":"]})," ",o]})})]}),(0,a.jsx)("button",{onClick:()=>{i(!0),n&&n()},className:"flex-shrink-0 ml-4 text-red-400 hover:text-red-600 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2 focus:ring-offset-red-50 rounded","aria-label":"Dismiss error",children:(0,a.jsx)("svg",{className:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor",children:(0,a.jsx)("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]})})}},9123:function(e,s,r){r.d(s,{g:function(){return n}});var a=r(5893),l=r(7294),t=r(2350);let n=l.forwardRef((e,s)=>{let{className:r,...l}=e;return(0,a.jsx)("textarea",{className:(0,t.cn)("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",r),ref:s,...l})});n.displayName="Textarea"},1141:function(e,s,r){r.r(s),r.d(s,{WorkspaceEditor:function(){return R}});var a=r(5893),l=r(7294),t=r(1163),n=r(7324),c=r(3266),i=r(8969);r(9470);var o=r(1664),d=r.n(o),u=r(9008),x=r.n(u),m=r(7673),h=r(803),f=r(9123),g=r(5739),p=r(282),b=r(6021),j=r(3626),y=r(8418),N=r(9333),v=r(326);let w=e=>{let{className:s="",variant:r="default",children:l,...t}=e;return(0,a.jsx)("div",{role:"alert",className:"".concat("relative w-full rounded-lg border p-4 flex items-start space-x-2"," ").concat({default:"bg-blue-50 border-blue-200 text-blue-800",destructive:"bg-red-50 border-red-200 text-red-800"}[r]," ").concat(s),...t,children:l})},k=e=>{let{className:s="",children:r,...l}=e;return(0,a.jsx)("div",{className:"text-sm leading-relaxed ".concat(s),...l,children:r})};var C=r(3850),L=r(1812),S=r(938),E=r(1272),Z=r(3225),D=r(3081);let M=e=>{let{message:s}=e;return s?(0,a.jsxs)(w,{className:"border-green-200 bg-green-50",children:[(0,a.jsx)(p.Z,{className:"h-4 w-4 text-green-600"}),(0,a.jsx)(k,{className:"text-green-800",children:s})]}):null},A=e=>{let{workspaceName:s,config:r,enabledClouds:l=[]}=e;if(!r)return null;let t="default"===s,n=0===Object.keys(r).length;if(t&&n)return(0,a.jsx)("div",{className:"text-sm text-gray-500 mb-3 italic p-3 bg-sky-50 rounded border border-sky-200",children:"Workspace 'default' can use all accessible infrastructure."});let c=[],i=[],o=[],d=new Set(l.map(e=>e.toLowerCase()));Object.entries(r).forEach(e=>{let[s,r]=e;if("private"===s||"allowed_users"===s)return;let l=Z.Z2[s.toLowerCase()]||s.toUpperCase(),t=d.has(null==l?void 0:l.toLowerCase());if((null==r?void 0:r.disabled)===!0)i.push(l);else if(r&&Object.keys(r).length>0){let e="";"gcp"===s.toLowerCase()&&r.project_id?e=" (Project ID: ".concat(r.project_id,")"):"aws"===s.toLowerCase()&&r.region&&(e=" (Region: ".concat(r.region,")")),t?c.push((0,a.jsxs)("span",{className:"block",children:[l,e," is enabled."]},"".concat(s,"-enabled"))):o.push((0,a.jsxs)("span",{className:"block text-amber-700",children:[l,e," is configured but not currently available."]},"".concat(s,"-configured-not-enabled")))}else t?c.push((0,a.jsxs)("span",{className:"block",children:[l," is enabled (using default settings)."]},"".concat(s,"-default-enabled"))):o.push((0,a.jsxs)("span",{className:"block text-amber-700",children:[l," is configured but not currently available."]},"".concat(s,"-default-not-enabled")))});let u=[];if(i.length>0){let e=i.join(" and ");u.push((0,a.jsxs)("span",{className:"block",children:[e," ",1===i.length?"is":"are"," explicitly disabled."]},"disabled-clouds"))}return(u.push(...c),u.push(...o),u.length>0)?(0,a.jsx)("div",{className:"text-sm text-gray-700 mb-3 p-3 bg-sky-50 rounded border border-sky-200",children:u}):!t&&n?(0,a.jsx)("div",{className:"text-sm text-gray-500 mb-3 italic p-3 bg-sky-50 rounded border border-sky-200",children:"This workspace has no specific cloud resource configurations and can use all accessible infrastructure."}):null},W=e=>{let{isPrivate:s}=e;return s?(0,a.jsx)("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-gray-100 text-gray-700 border border-gray-300",children:"Private"}):(0,a.jsx)("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-green-100 text-green-700 border border-green-300",children:"Public"})},P=e=>{let{workspaceConfig:s,allUsers:r}=e;if(!s.private)return null;let l=s.allowed_users||[],t=(r||[]).filter(e=>"admin"===e.role).map(e=>e.username),n=[...new Set([...l,...t])];return 0===n.length?(0,a.jsxs)("div",{className:"mt-4",children:[(0,a.jsx)("h4",{className:"mb-2 text-xs text-gray-500 tracking-wider",children:"Allowed Users (0)"}),(0,a.jsx)("div",{className:"text-amber-600 text-xs italic p-2 bg-amber-50 rounded border border-amber-200",children:"No users configured (workspace may be inaccessible)"})]}):(0,a.jsxs)("div",{className:"mt-4",children:[(0,a.jsxs)("h4",{className:"mb-2 text-xs text-gray-500 tracking-wider",children:["Allowed Users (",n.length,")"]}),(0,a.jsx)("div",{className:"space-y-1 max-h-48 overflow-y-auto border border-gray-200 rounded",children:n.map(e=>{let s=t.includes(e);return(0,a.jsxs)("div",{className:"flex items-center justify-between text-xs p-2 bg-gray-50 hover:bg-gray-100 border-b border-gray-100 last:border-b-0",children:[(0,a.jsx)("span",{className:"font-medium text-gray-700",children:e}),s?(0,a.jsxs)("span",{className:"inline-flex items-center text-blue-600",children:[(0,a.jsx)(C.r7,{className:"w-3 h-3 mr-1"}),"Admin"]}):(0,a.jsxs)("span",{className:"inline-flex items-center text-gray-600",children:[(0,a.jsx)(b.Z,{className:"w-3 h-3 mr-1"}),"User"]})]},e)})})]})};function R(e){let{workspaceName:s,isNewWorkspace:r=!1}=e,o=(0,t.useRouter)(),[u,p]=(0,l.useState)({}),[b,w]=(0,l.useState)({}),[k,Z]=(0,l.useState)(""),[R,_]=(0,l.useState)(!0),[z,O]=(0,l.useState)(!1),[T,U]=(0,l.useState)(!1),[Y,J]=(0,l.useState)(null),[I,V]=(0,l.useState)(null),[F,H]=(0,l.useState)(null),[X,B]=(0,l.useState)([]),[G,q]=(0,l.useState)({showDialog:!1,deleting:!1,error:null}),[K,Q]=(0,l.useState)({totalClusterCount:0,runningClusterCount:0,managedJobsCount:0,clouds:[]}),[$,ee]=(0,l.useState)(!1),es=(0,l.useCallback)(async()=>{_(!0),J(null);try{let e;let[r,a]=await Promise.all([(0,n.fX)(),(0,D.R)()]),l=r[s]||{};p(l),w(l),B(a||[]),e=0===Object.keys(l).length?"".concat(s,":\n # Empty workspace configuration - uses all accessible infrastructure\n"):E.ZP.dump({[s]:l},{indent:2,lineWidth:-1,noRefs:!0,skipInvalid:!0,flowLevel:-1}),Z(e)}catch(e){console.error("Error fetching workspace config:",e),J(e)}finally{_(!1)}},[s]),er=(0,l.useCallback)(async()=>{if(!r){ee(!0);try{let[e,r,a]=await Promise.all([(0,c.getClusters)(),(0,i.getManagedJobs)(),(0,n.yz)(s,!0)]),l=e.filter(e=>(e.workspace||"default")===s),t=l.filter(e=>"RUNNING"===e.status||"LAUNCHING"===e.status),o={};e.forEach(e=>{o[e.cluster]=e.workspace||"default"});let d=r.jobs||[],u=new Set(S.statusGroups.active),x=0;d.forEach(e=>{let r=e.cluster_name||e.resources&&e.resources.cluster_name;r&&o[r]===s&&u.has(e.status)&&x++}),Q({totalClusterCount:l.length,runningClusterCount:t.length,managedJobsCount:x,clouds:Array.isArray(a)?a:[]})}catch(e){console.error("Failed to fetch workspace stats:",e)}finally{ee(!1)}}},[s,r]);(0,l.useEffect)(()=>{r?(_(!1),Z("".concat(s,":\n # New workspace configuration\n # Leave empty to use all accessible infrastructure\n"))):(es(),er())},[s,r,es,er]),(0,l.useEffect)(()=>{U(JSON.stringify(u)!==JSON.stringify(b))},[u,b]);let ea=e=>{Z(e),H(null);try{let r=E.ZP.load(e)||{},a=Object.keys(r);if(0===a.length)p({});else if(1===a.length){let e=a[0];if(e!==s){H('Workspace name cannot be changed. Expected "'.concat(s,'" but found "').concat(e,'".'));return}let l=r[s]||{};p(l)}else H("Configuration must contain only one workspace. Found: ".concat(a.join(", ")))}catch(e){H("Invalid YAML: ".concat(e.message))}},el=async()=>{O(!0),J(null),V(null);try{if(F)throw Error("Please fix YAML errors before saving");let e=E.ZP.load(k)||{},a=Object.keys(e);if(a.length>0&&a[0]!==s)throw Error('Workspace name cannot be changed. Expected "'.concat(s,'".'));r?(await (0,n.MB)(s,u),V("Workspace created successfully!"),setTimeout(()=>{o.push("/workspaces/".concat(s))},1500)):(await (0,n.eA)(s,u),V("Workspace updated successfully!"),w(u),er())}catch(e){console.error("Error saving workspace:",e),J(e)}finally{O(!1)}},et=async()=>{q(e=>({...e,deleting:!0,error:null}));try{await (0,n.zl)(s),V("Workspace deleted successfully!"),setTimeout(()=>{o.push("/workspaces")},1500)}catch(e){console.error("Error deleting workspace:",e),q(s=>({...s,deleting:!1,error:e}))}},en=()=>{q({showDialog:!1,deleting:!1,error:null})},ec=async()=>{await Promise.all([es(),er()])};if(!o.isReady)return(0,a.jsx)("div",{children:"Loading..."});let ei=r?"Create New Workspace | SkyPilot Dashboard":"Workspace: ".concat(s," | SkyPilot Dashboard");return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(x(),{children:(0,a.jsx)("title",{children:ei})}),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4 h-5",children:[(0,a.jsxs)("div",{className:"text-base flex items-center",children:[(0,a.jsx)(d(),{href:"/workspaces",className:"text-sky-blue hover:underline",children:"Workspaces"}),(0,a.jsx)("span",{className:"mx-2 text-gray-500",children:"›"}),(0,a.jsx)(d(),{href:r?"/workspace/new":"/workspaces/".concat(s),className:"text-sky-blue hover:underline",children:r?"New Workspace":s}),T&&(0,a.jsx)("span",{className:"ml-3 px-2 py-1 bg-yellow-100 text-yellow-800 text-xs rounded",children:"Unsaved changes"})]}),(0,a.jsxs)("div",{className:"text-sm flex items-center",children:[(R||z||$)&&(0,a.jsxs)("div",{className:"flex items-center mr-4",children:[(0,a.jsx)(g.Z,{size:15,className:"mt-0"}),(0,a.jsx)("span",{className:"ml-2 text-gray-500",children:z?"Saving...":"Loading..."})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-4",children:[!r&&(0,a.jsxs)("button",{onClick:ec,disabled:R||z||$,className:"text-sky-blue hover:text-sky-blue-bright font-medium inline-flex items-center",children:[(0,a.jsx)(j.Z,{className:"w-4 h-4 mr-1.5"}),"Refresh"]}),!r&&"default"!==s&&(0,a.jsxs)("button",{onClick:()=>q({...G,showDialog:!0}),disabled:G.deleting||z,className:"text-red-600 hover:text-red-700 font-medium inline-flex items-center",children:[(0,a.jsx)(y.Z,{className:"w-4 h-4 mr-1.5"}),"Delete"]})]})]})]}),R?(0,a.jsxs)("div",{className:"flex justify-center items-center py-12",children:[(0,a.jsx)(g.Z,{size:24,className:"mr-2"}),(0,a.jsx)("span",{className:"text-gray-500",children:"Loading workspace configuration..."})]}):(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsx)(L.X,{error:Y,title:"Error",onDismiss:()=>J(null)}),(0,a.jsx)(M,{message:I}),(0,a.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[!r&&(0,a.jsx)("div",{className:"lg:col-span-1",children:(0,a.jsxs)(m.Zb,{className:"h-full",children:[(0,a.jsx)(m.Ol,{children:(0,a.jsx)(m.ll,{className:"text-base font-normal",children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"font-semibold",children:"Workspace:"})," ",s]}),(0,a.jsx)(W,{isPrivate:!0===b.private})]})})}),(0,a.jsxs)(m.aY,{className:"text-sm pb-2 flex-1",children:[(0,a.jsxs)("div",{className:"py-2 flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center text-gray-600",children:[(0,a.jsx)(C.QT,{className:"w-4 h-4 mr-2 text-gray-500"}),(0,a.jsx)("span",{children:"Clusters (Running / Total)"})]}),(0,a.jsx)("span",{className:"font-normal text-gray-800",children:$?"...":"".concat(K.runningClusterCount," / ").concat(K.totalClusterCount)})]}),(0,a.jsxs)("div",{className:"py-2 flex items-center justify-between border-t border-gray-100",children:[(0,a.jsxs)("div",{className:"flex items-center text-gray-600",children:[(0,a.jsx)(C.Vp,{className:"w-4 h-4 mr-2 text-gray-500"}),(0,a.jsx)("span",{children:"Managed Jobs"})]}),(0,a.jsx)("span",{className:"font-normal text-gray-800",children:$?"...":K.managedJobsCount})]})]}),(0,a.jsxs)("div",{className:"px-6 pb-6 text-sm pt-3",children:[(0,a.jsx)("h4",{className:"mb-2 text-xs text-gray-500 tracking-wider",children:"Enabled Infra"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-x-4 gap-y-1",children:$?(0,a.jsx)("span",{className:"text-gray-500",children:"Loading..."}):K.clouds.length>0?K.clouds.map(e=>(0,a.jsxs)("div",{className:"flex items-center text-gray-700",children:[(0,a.jsx)(C.Ye,{className:"w-3.5 h-3.5 mr-1.5 text-green-500"}),(0,a.jsx)("span",{children:e})]},e)):(0,a.jsx)("span",{className:"text-gray-500 italic",children:"No enabled infrastructure"})}),(0,a.jsx)("div",{className:"mt-4",children:(0,a.jsx)(A,{workspaceName:s,config:b,enabledClouds:K.clouds})}),(0,a.jsx)(P,{workspaceConfig:b,allUsers:X})]})]})}),(0,a.jsx)("div",{className:r?"lg:col-span-3":"lg:col-span-2",children:(0,a.jsxs)(m.Zb,{className:"h-full flex flex-col",children:[(0,a.jsx)(m.Ol,{children:(0,a.jsx)(m.ll,{className:"text-base font-normal",children:r?"New Workspace YAML":"Edit Workspace YAML"})}),(0,a.jsx)(m.aY,{className:"flex-1 flex flex-col",children:(0,a.jsxs)("div",{className:"space-y-4 flex-1 flex flex-col",children:[F&&(0,a.jsx)(L.X,{error:F,onDismiss:()=>H(null)}),(0,a.jsxs)("div",{className:"flex-1 flex flex-col",children:[(0,a.jsxs)("p",{className:"text-sm text-gray-600 mb-3",children:["Configure infra-specific settings for this workspace. Leave empty to use all accessible infrastructure. Refer to"," ",(0,a.jsx)("a",{href:"https://docs.skypilot.co/en/latest/admin/workspaces.html#configuration",target:"_blank",rel:"noopener noreferrer",className:"text-blue-600",children:"SkyPilot Docs"})," ","for more details."]}),(0,a.jsxs)("div",{className:"mb-4",children:[(0,a.jsx)("h4",{className:"text-sm font-medium text-gray-700 mb-2",children:"Example configuration:"}),(0,a.jsx)("div",{className:"p-3 bg-gray-50 border rounded-lg",children:(0,a.jsx)("pre",{className:"text-xs font-mono text-gray-600 whitespace-pre-wrap",children:"".concat(s||"my-workspace",":\n private: true\n allowed_users:\n - user1@mydomain.com\n - user2@mydomain.com\n gcp:\n project_id: xxx\n disabled: false\n kubernetes:\n allowed_contexts:\n - context-1")})})]}),(0,a.jsx)(f.g,{value:k,onChange:e=>ea(e.target.value),className:"font-mono text-sm flex-1 resize-none",style:{minHeight:"350px"},spellCheck:!1,placeholder:"# Enter workspace configuration in YAML format"}),(0,a.jsx)("div",{className:"flex justify-end space-x-3 pt-3 border-gray-200",children:(0,a.jsxs)(h.z,{onClick:el,disabled:z||F||R,className:"inline-flex items-center bg-sky-600 hover:bg-sky-700 text-white",children:[(0,a.jsx)(N.Z,{className:"w-4 h-4 mr-1.5"}),z?"Applying...":"Apply"]})})]})]})})]})})]})]}),(0,a.jsx)(v.Vq,{open:G.showDialog,onOpenChange:en,children:(0,a.jsxs)(v.cZ,{className:"sm:max-w-md",children:[(0,a.jsxs)(v.fK,{className:"",children:[(0,a.jsx)(v.$N,{children:"Delete Workspace"}),(0,a.jsxs)(v.Be,{children:['Are you sure you want to delete workspace "',s,'"? This action cannot be undone.']})]}),G.error&&(0,a.jsx)(L.X,{error:G.error,title:"Deletion Failed",onDismiss:()=>q(e=>({...e,error:null}))}),(0,a.jsxs)(v.cN,{className:"",children:[(0,a.jsx)(h.z,{variant:"outline",onClick:en,disabled:G.deleting,children:"Cancel"}),(0,a.jsx)(h.z,{variant:"destructive",onClick:et,disabled:G.deleting,children:G.deleting?"Deleting...":"Delete"})]})]})})]})]})}}}]);
|
@@ -0,0 +1,60 @@
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1746,430,5491],{8671:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});/**
|
2
|
+
* @license lucide-react v0.407.0 - ISC
|
3
|
+
*
|
4
|
+
* This source code is licensed under the ISC license.
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
6
|
+
*/let r=(0,n(998).Z)("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]])},6826:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});/**
|
7
|
+
* @license lucide-react v0.407.0 - ISC
|
8
|
+
*
|
9
|
+
* This source code is licensed under the ISC license.
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
11
|
+
*/let r=(0,n(998).Z)("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]])},3685:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});/**
|
12
|
+
* @license lucide-react v0.407.0 - ISC
|
13
|
+
*
|
14
|
+
* This source code is licensed under the ISC license.
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
16
|
+
*/let r=(0,n(998).Z)("EyeOff",[["path",{d:"M9.88 9.88a3 3 0 1 0 4.24 4.24",key:"1jxqfv"}],["path",{d:"M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68",key:"9wicm4"}],["path",{d:"M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61",key:"1jreej"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]])},6741:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});/**
|
17
|
+
* @license lucide-react v0.407.0 - ISC
|
18
|
+
*
|
19
|
+
* This source code is licensed under the ISC license.
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
21
|
+
*/let r=(0,n(998).Z)("Eye",[["path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z",key:"rwhkz3"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]])},3936:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});/**
|
22
|
+
* @license lucide-react v0.407.0 - ISC
|
23
|
+
*
|
24
|
+
* This source code is licensed under the ISC license.
|
25
|
+
* See the LICENSE file in the root directory of this source tree.
|
26
|
+
*/let r=(0,n(998).Z)("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]])},5274:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});/**
|
27
|
+
* @license lucide-react v0.407.0 - ISC
|
28
|
+
*
|
29
|
+
* This source code is licensed under the ISC license.
|
30
|
+
* See the LICENSE file in the root directory of this source tree.
|
31
|
+
*/let r=(0,n(998).Z)("Pen",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]])},1260:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});/**
|
32
|
+
* @license lucide-react v0.407.0 - ISC
|
33
|
+
*
|
34
|
+
* This source code is licensed under the ISC license.
|
35
|
+
* See the LICENSE file in the root directory of this source tree.
|
36
|
+
*/let r=(0,n(998).Z)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},3626:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});/**
|
37
|
+
* @license lucide-react v0.407.0 - ISC
|
38
|
+
*
|
39
|
+
* This source code is licensed under the ISC license.
|
40
|
+
* See the LICENSE file in the root directory of this source tree.
|
41
|
+
*/let r=(0,n(998).Z)("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]])},7603:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});/**
|
42
|
+
* @license lucide-react v0.407.0 - ISC
|
43
|
+
*
|
44
|
+
* This source code is licensed under the ISC license.
|
45
|
+
* See the LICENSE file in the root directory of this source tree.
|
46
|
+
*/let r=(0,n(998).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},1109:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});/**
|
47
|
+
* @license lucide-react v0.407.0 - ISC
|
48
|
+
*
|
49
|
+
* This source code is licensed under the ISC license.
|
50
|
+
* See the LICENSE file in the root directory of this source tree.
|
51
|
+
*/let r=(0,n(998).Z)("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]])},3767:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});/**
|
52
|
+
* @license lucide-react v0.407.0 - ISC
|
53
|
+
*
|
54
|
+
* This source code is licensed under the ISC license.
|
55
|
+
* See the LICENSE file in the root directory of this source tree.
|
56
|
+
*/let r=(0,n(998).Z)("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},1163:function(e,t,n){e.exports=n(6036)},6327:function(e,t,n){"use strict";n.d(t,{x8:function(){return ea},VY:function(){return eo},dk:function(){return eu},aV:function(){return er},h_:function(){return en},fC:function(){return ee},Dx:function(){return ei},xz:function(){return et}});var r=n(7294),o=n(6206),i=n(8771),u=n(5360),a=n(1276),l=n(7342),s=n(6063),c=n(5420),d=n(2651),f=n(9981),p=e=>{let t,n;let{present:o,children:u}=e,a=function(e){var t,n;let[o,i]=r.useState(),u=r.useRef(null),a=r.useRef(e),l=r.useRef("none"),[s,c]=(t=e?"mounted":"unmounted",n={mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}},r.useReducer((e,t)=>n[e][t]??e,t));return r.useEffect(()=>{let e=y(u.current);l.current="mounted"===s?e:"none"},[s]),(0,f.b)(()=>{let t=u.current,n=a.current;if(n!==e){let r=l.current,o=y(t);e?c("MOUNT"):"none"===o||t?.display==="none"?c("UNMOUNT"):n&&r!==o?c("ANIMATION_OUT"):c("UNMOUNT"),a.current=e}},[e,c]),(0,f.b)(()=>{if(o){let e;let t=o.ownerDocument.defaultView??window,n=n=>{let r=y(u.current).includes(n.animationName);if(n.target===o&&r&&(c("ANIMATION_END"),!a.current)){let n=o.style.animationFillMode;o.style.animationFillMode="forwards",e=t.setTimeout(()=>{"forwards"===o.style.animationFillMode&&(o.style.animationFillMode=n)})}},r=e=>{e.target===o&&(l.current=y(u.current))};return o.addEventListener("animationstart",r),o.addEventListener("animationcancel",n),o.addEventListener("animationend",n),()=>{t.clearTimeout(e),o.removeEventListener("animationstart",r),o.removeEventListener("animationcancel",n),o.removeEventListener("animationend",n)}}c("ANIMATION_END")},[o,c]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:r.useCallback(e=>{u.current=e?getComputedStyle(e):null,i(e)},[])}}(o),l="function"==typeof u?u({present:a.isPresent}):r.Children.only(u),s=(0,i.e)(a.ref,(t=Object.getOwnPropertyDescriptor(l.props,"ref")?.get)&&"isReactWarning"in t&&t.isReactWarning?l.ref:(t=Object.getOwnPropertyDescriptor(l,"ref")?.get)&&"isReactWarning"in t&&t.isReactWarning?l.props.ref:l.props.ref||l.ref);return"function"==typeof u||a.isPresent?r.cloneElement(l,{ref:s}):null};function y(e){return e?.animationName||"none"}p.displayName="Presence";var m=n(5320),v=n(7552),g=n(6223),h=n(3541),x=n(8426),k=n(5893),M="Dialog",[N,D]=(0,u.b)(M),[j,w]=N(M),O=e=>{let{__scopeDialog:t,children:n,open:o,defaultOpen:i,onOpenChange:u,modal:s=!0}=e,c=r.useRef(null),d=r.useRef(null),[f,p]=(0,l.T)({prop:o,defaultProp:i??!1,onChange:u,caller:M});return(0,k.jsx)(j,{scope:t,triggerRef:c,contentRef:d,contentId:(0,a.M)(),titleId:(0,a.M)(),descriptionId:(0,a.M)(),open:f,onOpenChange:p,onOpenToggle:r.useCallback(()=>p(e=>!e),[p]),modal:s,children:n})};O.displayName=M;var b="DialogTrigger",R=r.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,u=w(b,n),a=(0,i.e)(t,u.triggerRef);return(0,k.jsx)(m.WV.button,{type:"button","aria-haspopup":"dialog","aria-expanded":u.open,"aria-controls":u.contentId,"data-state":K(u.open),...r,ref:a,onClick:(0,o.M)(e.onClick,u.onOpenToggle)})});R.displayName=b;var I="DialogPortal",[C,E]=N(I,{forceMount:void 0}),Z=e=>{let{__scopeDialog:t,forceMount:n,children:o,container:i}=e,u=w(I,t);return(0,k.jsx)(C,{scope:t,forceMount:n,children:r.Children.map(o,e=>(0,k.jsx)(p,{present:n||u.open,children:(0,k.jsx)(d.h,{asChild:!0,container:i,children:e})}))})};Z.displayName=I;var A="DialogOverlay",T=r.forwardRef((e,t)=>{let n=E(A,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,i=w(A,e.__scopeDialog);return i.modal?(0,k.jsx)(p,{present:r||i.open,children:(0,k.jsx)(F,{...o,ref:t})}):null});T.displayName=A;var _=(0,x.Z8)("DialogOverlay.RemoveScroll"),F=r.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,o=w(A,n);return(0,k.jsx)(g.Z,{as:_,allowPinchZoom:!0,shards:[o.contentRef],children:(0,k.jsx)(m.WV.div,{"data-state":K(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),P="DialogContent",V=r.forwardRef((e,t)=>{let n=E(P,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,i=w(P,e.__scopeDialog);return(0,k.jsx)(p,{present:r||i.open,children:i.modal?(0,k.jsx)(W,{...o,ref:t}):(0,k.jsx)(U,{...o,ref:t})})});V.displayName=P;var W=r.forwardRef((e,t)=>{let n=w(P,e.__scopeDialog),u=r.useRef(null),a=(0,i.e)(t,n.contentRef,u);return r.useEffect(()=>{let e=u.current;if(e)return(0,h.Ry)(e)},[]),(0,k.jsx)(L,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:(0,o.M)(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:(0,o.M)(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey;(2===t.button||n)&&e.preventDefault()}),onFocusOutside:(0,o.M)(e.onFocusOutside,e=>e.preventDefault())})}),U=r.forwardRef((e,t)=>{let n=w(P,e.__scopeDialog),o=r.useRef(!1),i=r.useRef(!1);return(0,k.jsx)(L,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(o.current||n.triggerRef.current?.focus(),t.preventDefault()),o.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(o.current=!0,"pointerdown"!==t.detail.originalEvent.type||(i.current=!0));let r=t.target;n.triggerRef.current?.contains(r)&&t.preventDefault(),"focusin"===t.detail.originalEvent.type&&i.current&&t.preventDefault()}})}),L=r.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:o,onOpenAutoFocus:u,onCloseAutoFocus:a,...l}=e,d=w(P,n),f=r.useRef(null),p=(0,i.e)(t,f);return(0,v.EW)(),(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(c.M,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:u,onUnmountAutoFocus:a,children:(0,k.jsx)(s.XB,{role:"dialog",id:d.contentId,"aria-describedby":d.descriptionId,"aria-labelledby":d.titleId,"data-state":K(d.open),...l,ref:p,onDismiss:()=>d.onOpenChange(!1)})}),(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(J,{titleId:d.titleId}),(0,k.jsx)(Q,{contentRef:f,descriptionId:d.descriptionId})]})]})}),S="DialogTitle",z=r.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,o=w(S,n);return(0,k.jsx)(m.WV.h2,{id:o.titleId,...r,ref:t})});z.displayName=S;var $="DialogDescription",q=r.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,o=w($,n);return(0,k.jsx)(m.WV.p,{id:o.descriptionId,...r,ref:t})});q.displayName=$;var H="DialogClose",B=r.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=w(H,n);return(0,k.jsx)(m.WV.button,{type:"button",...r,ref:t,onClick:(0,o.M)(e.onClick,()=>i.onOpenChange(!1))})});function K(e){return e?"open":"closed"}B.displayName=H;var X="DialogTitleWarning",[Y,G]=(0,u.k)(X,{contentName:P,titleName:S,docsSlug:"dialog"}),J=({titleId:e})=>{let t=G(X),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
57
|
+
|
58
|
+
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
59
|
+
|
60
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return r.useEffect(()=>{e&&!document.getElementById(e)&&console.error(n)},[n,e]),null},Q=({contentRef:e,descriptionId:t})=>{let n=G("DialogDescriptionWarning"),o=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${n.contentName}}.`;return r.useEffect(()=>{let n=e.current?.getAttribute("aria-describedby");t&&n&&!document.getElementById(t)&&console.warn(o)},[o,e,t]),null},ee=O,et=R,en=Z,er=T,eo=V,ei=z,eu=q,ea=B},2003:function(e,t,n){"use strict";n.d(t,{j:function(){return u}});var r=n(512);let o=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,i=r.W,u=(e,t)=>n=>{var r;if((null==t?void 0:t.variants)==null)return i(e,null==n?void 0:n.class,null==n?void 0:n.className);let{variants:u,defaultVariants:a}=t,l=Object.keys(u).map(e=>{let t=null==n?void 0:n[e],r=null==a?void 0:a[e];if(null===t)return null;let i=o(t)||o(r);return u[e][i]}),s=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return void 0===r||(e[n]=r),e},{});return i(e,l,null==t?void 0:null===(r=t.compoundVariants)||void 0===r?void 0:r.reduce((e,t)=>{let{class:n,className:r,...o}=t;return Object.entries(o).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...a,...s}[t]):({...a,...s})[t]===n})?[...e,n,r]:e},[]),null==n?void 0:n.class,null==n?void 0:n.className)}}}]);
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2641],{1812:function(e,s,t){t.d(s,{X:function(){return l}});var r=t(5893),n=t(7294);let a=e=>{if(!(null==e?void 0:e.message))return"An unexpected error occurred.";let s=e.message;return s.includes("failed:")&&(s=s.split("failed:")[1].trim()),s},l=e=>{let{error:s,title:t="Error",onDismiss:l}=e,[i,o]=(0,n.useState)(!1);if((0,n.useEffect)(()=>{s&&o(!1)},[s]),!s||i)return null;let c="string"==typeof s?s:a(s);return(0,r.jsx)("div",{className:"bg-red-50 border border-red-200 rounded-md p-3 mb-4",children:(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("div",{className:"flex-shrink-0",children:(0,r.jsx)("svg",{className:"h-5 w-5 text-red-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})})}),(0,r.jsx)("div",{className:"ml-3",children:(0,r.jsxs)("div",{className:"text-sm text-red-800",children:[(0,r.jsxs)("strong",{children:[t,":"]})," ",c]})})]}),(0,r.jsx)("button",{onClick:()=>{o(!0),l&&l()},className:"flex-shrink-0 ml-4 text-red-400 hover:text-red-600 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2 focus:ring-offset-red-50 rounded","aria-label":"Dismiss error",children:(0,r.jsx)("svg",{className:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]})})}},8764:function(e,s,t){t.d(s,{RM:function(){return o},SC:function(){return c},iA:function(){return l},pj:function(){return u},ss:function(){return d},xD:function(){return i}});var r=t(5893),n=t(7294),a=t(2350);let l=n.forwardRef((e,s)=>{let{className:t,...n}=e;return(0,r.jsx)("div",{className:"relative w-full overflow-auto",children:(0,r.jsx)("table",{ref:s,className:(0,a.cn)("w-full caption-bottom text-base",t),...n})})});l.displayName="Table";let i=n.forwardRef((e,s)=>{let{className:t,...n}=e;return(0,r.jsx)("thead",{ref:s,className:(0,a.cn)("[&_tr]:border-b",t),...n})});i.displayName="TableHeader";let o=n.forwardRef((e,s)=>{let{className:t,...n}=e;return(0,r.jsx)("tbody",{ref:s,className:(0,a.cn)("[&_tr:last-child]:border-0",t),...n})});o.displayName="TableBody",n.forwardRef((e,s)=>{let{className:t,...n}=e;return(0,r.jsx)("tfoot",{ref:s,className:(0,a.cn)("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",t),...n})}).displayName="TableFooter";let c=n.forwardRef((e,s)=>{let{className:t,...n}=e;return(0,r.jsx)("tr",{ref:s,className:(0,a.cn)("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",t),...n})});c.displayName="TableRow";let d=n.forwardRef((e,s)=>{let{className:t,...n}=e;return(0,r.jsx)("th",{ref:s,className:(0,a.cn)("h-12 px-4 text-left align-middle font-medium text-[hsl(var(--text-strong))] [&:has([role=checkbox])]:pr-0",t),...n})});d.displayName="TableHead";let u=n.forwardRef((e,s)=>{let{className:t,...n}=e;return(0,r.jsx)("td",{ref:s,className:(0,a.cn)("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...n})});u.displayName="TableCell",n.forwardRef((e,s)=>{let{className:t,...n}=e;return(0,r.jsx)("caption",{ref:s,className:(0,a.cn)("mt-4 text-base text-muted-foreground",t),...n})}).displayName="TableCaption"},2641:function(e,s,t){t.r(s),t.d(s,{Users:function(){return M}});var r=t(5893),n=t(7294),a=t(5697),l=t.n(a),i=t(5739),o=t(1664),c=t.n(o),d=t(1163),u=t(803),m=t(8764),x=t(3081),h=t(3266),g=t(8969),p=t(6378),f=t(6856),b=t(1214),j=t(4545),v=t(6989),y=t(1109),N=t(3626),w=t(1260),k=t(3685),C=t(6741),_=t(6826),S=t(282),R=t(3767),D=t(5274),E=t(3936),I=t(7603),L=t(8671);t(9470);var Z=t(3001),F=t(7673),U=t(7145),T=t(326),A=t(1812);let P=(e,s)=>e&&e.includes("@")?e.split("@")[0]:e||"N/A",z=(e,s)=>e&&e.includes("@")?e:s||"-",q=b.nb.REFRESH_INTERVAL,V=e=>{let{message:s,onDismiss:t}=e;return s?(0,r.jsx)("div",{className:"bg-green-50 border border-green-200 rounded p-4 mb-6",children:(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("div",{className:"flex-shrink-0",children:(0,r.jsx)("svg",{className:"h-5 w-5 text-green-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})})}),(0,r.jsx)("div",{className:"ml-3",children:(0,r.jsx)("p",{className:"text-sm font-medium text-green-800",children:s})})]}),t&&(0,r.jsx)("div",{className:"ml-auto pl-3",children:(0,r.jsx)("div",{className:"-mx-1.5 -my-1.5",children:(0,r.jsxs)("button",{type:"button",onClick:t,className:"inline-flex rounded-md bg-green-50 p-1.5 text-green-500 hover:bg-green-100 focus:outline-none focus:ring-2 focus:ring-green-600 focus:ring-offset-2 focus:ring-offset-green-50",children:[(0,r.jsx)("span",{className:"sr-only",children:"Dismiss"}),(0,r.jsx)("svg",{className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})]})})})]})}):null};function M(){let e=(0,d.useRouter)(),[s,t]=(0,n.useState)(!1),a=(0,n.useRef)(null),l=(0,Z.X)(),[o,c]=(0,n.useState)(!1),[m,f]=(0,n.useState)({username:"",password:"",role:"user"}),[b,j]=(0,n.useState)(!1),[v,S]=(0,n.useState)({open:!1,message:"",userName:""}),[R,D]=(0,n.useState)(null),[E,I]=(0,n.useState)(!1),[L,F]=(0,n.useState)(!1),[P,z]=(0,n.useState)(!1),[M,K]=(0,n.useState)(null),[H,$]=(0,n.useState)(!1),[J,W]=(0,n.useState)(null),[Q,X]=(0,n.useState)("import"),[Y,G]=(0,n.useState)(!1),[ee,es]=(0,n.useState)(null),[et,er]=(0,n.useState)(""),[en,ea]=(0,n.useState)(!1),[el,ei]=(0,n.useState)(null),[eo,ec]=(0,n.useState)(!1),[ed,eu]=(0,n.useState)(null),[em,ex]=(0,n.useState)(null),[eh,eg]=(0,n.useState)(!1),[ep,ef]=(0,n.useState)(null),[eb,ej]=(0,n.useState)(null),[ev,ey]=(0,n.useState)(void 0),[eN,ew]=(0,n.useState)("users"),[ek,eC]=(0,n.useState)(!1),[e_,eS]=(0,n.useState)(!1),[eR,eD]=(0,n.useState)(null),[eE,eI]=(0,n.useState)(!1),[eL,eZ]=(0,n.useState)(""),[eF,eU]=(0,n.useState)("");(0,n.useEffect)(()=>{e.isReady&&("service-accounts"===e.query.tab?ew("service-accounts"):ew("users"))},[e.isReady,e.query.tab]),(0,n.useEffect)(()=>{(async function(){try{let e=await U.x.get("/api/health");if(e.ok){let s=await e.json();ey(!!s.basic_auth_enabled)}else ey(!1)}catch(e){ey(!1)}})()},[]);let eT=(0,n.useCallback)(async()=>{if(R&&Date.now()-R.timestamp<3e5)return R;I(!0);try{let e=await U.x.get("/users/role");if(!e.ok){let s=await e.json();throw Error(s.detail||"Failed to get user role")}let s=await e.json(),t={role:s.role,name:s.name,id:s.id,timestamp:Date.now()};return D(t),I(!1),t}catch(e){throw I(!1),e}},[R]);(0,n.useEffect)(()=>{eT().catch(()=>{console.error("Failed to get user role")})},[eT]);let eA=async(e,s)=>{try{let t=await eT();if("admin"!==t.role)return S({open:!0,message:e,userName:t.name.toLowerCase()}),!1;return s(),!0}catch(e){return console.error("Failed to check user role:",e),S({open:!0,message:"Error: ".concat(e.message),userName:""}),!1}},eP=()=>{p.default.invalidate(x.R),p.default.invalidate(h.getClusters),p.default.invalidate(g.getManagedJobs,[{allUsers:!0}]),a.current&&a.current()},ez=async()=>{if(!m.username||!m.password){ej(Error("Username and password are required.")),c(!1);return}j(!0),ej(null),ef(null);try{let e=await U.x.post("/users/create",m);if(!e.ok){let s=await e.json();throw Error(s.detail||"Failed to create user")}ef('User "'.concat(m.username,'" created successfully!')),c(!1),f({username:"",password:"",role:"user"}),eP()}catch(e){ej(e),c(!1),f({username:"",password:"",role:"user"})}finally{j(!1)}},eq=async e=>{let s=e.target.files[0];s&&(K(s),W(null))},eV=async()=>{if(!M){alert("Please select a CSV file first.");return}$(!0);try{let e=new FileReader;e.onload=async e=>{try{let s=e.target.result,t=await U.x.post("/users/import",{csv_content:s});if(!t.ok){let e=await t.json();throw Error(e.detail||"Failed to import users")}let r=await t.json(),n="Import completed. ".concat(r.success_count," users created successfully.");r.error_count>0&&(n+="\n".concat(r.error_count," failed."),r.creation_errors.length>0&&(n+="\nErrors: ".concat(r.creation_errors.slice(0,3).join(", ")),r.creation_errors.length>3&&(n+=" and ".concat(r.creation_errors.length-3," more...")))),W({message:n}),r.success_count>0&&eP()}catch(e){alert("Error importing users: ".concat(e.message))}finally{$(!1)}},e.readAsText(M)}catch(e){alert("Error reading file: ".concat(e.message)),$(!1)}},eM=async e=>{es(e),er(""),G(!0)},eB=async()=>{if(!et){ej(Error("Please enter a new password."));return}ea(!0),ei(null);try{let e=await U.x.post("/users/update",{user_id:ee.userId,password:et});if(!e.ok){let s=await e.json();throw Error(s.detail||"Failed to reset password")}ef('Password reset successfully for user "'.concat(ee.usernameDisplay,'"!')),G(!1),es(null),er("")}catch(e){G(!1),es(null),er(""),ei(null),ej(e)}finally{ea(!1)}},eO=async()=>{if(ed){eg(!0),ex(null);try{let e=await U.x.post("/users/delete",{user_id:ed.userId});if(!e.ok){let s=await e.json();throw Error(s.detail||"Failed to delete user")}ef('User "'.concat(ed.usernameDisplay,'" deleted successfully!')),ec(!1),eu(null),eP()}catch(e){ec(!1),eu(null),ex(null),ej(e)}finally{eg(!1)}}},eK=()=>{ec(!1),eu(null)},eH=()=>{G(!1),es(null),er("")};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,r.jsxs)("div",{className:"text-base flex items-center",children:[(0,r.jsx)("button",{className:"leading-none mr-6 pb-2 px-2 border-b-2 ".concat("users"===eN?"text-sky-blue border-sky-500":"text-gray-500 hover:text-gray-700 border-transparent"),onClick:()=>{ew("users"),e.push("/users",void 0,{shallow:!0})},children:"Users"}),(0,r.jsx)("button",{className:"leading-none pb-2 px-2 border-b-2 ".concat("service-accounts"===eN?"text-sky-blue border-sky-500":"text-gray-500 hover:text-gray-700 border-transparent"),onClick:()=>{ew("service-accounts"),e.push("/users?tab=service-accounts",void 0,{shallow:!0})},children:"Service Accounts"})]}),(0,r.jsxs)("div",{className:"flex items-center",children:[s&&(0,r.jsxs)("div",{className:"flex items-center mr-2",children:[(0,r.jsx)(i.Z,{size:15,className:"mt-0"}),(0,r.jsx)("span",{className:"ml-2 text-gray-500",children:"Loading..."})]}),"users"===eN&&ev&&(null==R?void 0:R.role)==="admin"&&(0,r.jsx)("button",{onClick:async()=>{await eA("cannot create users",()=>{c(!0)})},className:"text-sky-blue hover:text-sky-blue-bright flex items-center rounded px-2 py-1 mr-2",title:"Create New User",children:"+ New User"}),"users"===eN&&ev&&(null==R?void 0:R.role)==="admin"&&(0,r.jsxs)("button",{onClick:async()=>{await eA("cannot import users",()=>{z(!0)})},className:"text-sky-blue hover:text-sky-blue-bright flex items-center rounded px-2 py-1 mr-2",title:"Import/Export Users",children:[(0,r.jsx)(y.Z,{className:"h-4 w-4 mr-1"}),"Import/Export"]}),(0,r.jsxs)("button",{onClick:eP,disabled:s,className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:[(0,r.jsx)(N.Z,{className:"h-4 w-4 mr-1.5"}),!l&&(0,r.jsx)("span",{children:"Refresh"})]})]})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsxs)("div",{className:"relative flex-1 max-w-md",children:[(0,r.jsx)("input",{type:"text",placeholder:"users"===eN?"Search users by name, email, or role":"Search by service account name, or created by",value:"users"===eN?eL:eF,onChange:e=>{"users"===eN?eZ(e.target.value):eU(e.target.value)},className:"h-8 w-full px-3 pr-8 text-sm border border-gray-300 rounded-md focus:ring-1 focus:ring-sky-500 focus:border-sky-500 outline-none"}),("users"===eN&&eL||"service-accounts"===eN&&eF)&&(0,r.jsx)("button",{onClick:()=>{"users"===eN?eZ(""):eU("")},className:"absolute right-2 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-gray-600",title:"Clear search",children:(0,r.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),"service-accounts"===eN&&(0,r.jsxs)("button",{onClick:()=>{eA("cannot create service account tokens",()=>{eC(!0)})},className:"ml-4 bg-sky-600 hover:bg-sky-700 text-white flex items-center rounded-md px-3 py-1 text-sm font-medium transition-colors duration-200",title:"Create Service Account",children:[(0,r.jsx)(w.Z,{className:"h-4 w-4 mr-2"}),"Create Service Account"]})]}),(0,r.jsxs)("div",{className:"fixed top-20 right-4 z-[9999] max-w-md",children:[(0,r.jsx)(V,{message:ep,onDismiss:()=>ef(null)}),(0,r.jsx)(A.X,{error:eb,title:"Error",onDismiss:()=>ej(null)})]}),"users"===eN?(0,r.jsx)(B,{refreshInterval:q,setLoading:t,refreshDataRef:a,checkPermissionAndAct:eA,roleLoading:E,onResetPassword:eM,onDeleteUser:e=>{eA("cannot delete users",()=>{eu(e),ec(!0)})},basicAuthEnabled:ev,currentUserRole:null==R?void 0:R.role,currentUserId:null==R?void 0:R.id,searchQuery:eL,setSearchQuery:eZ}):(0,r.jsx)(O,{checkPermissionAndAct:eA,userRoleCache:R,setCreateSuccess:ef,setCreateError:ej,showCreateDialog:ek,setShowCreateDialog:eC,showRotateDialog:e_,setShowRotateDialog:eS,tokenToRotate:eR,setTokenToRotate:eD,rotating:eE,setRotating:eI,searchQuery:eF,setSearchQuery:eU}),(0,r.jsx)(T.Vq,{open:o,onOpenChange:e=>{c(e),e||ej(null)},children:(0,r.jsxs)(T.cZ,{className:"sm:max-w-md",children:[(0,r.jsx)(T.fK,{children:(0,r.jsx)(T.$N,{children:"Create User"})}),(0,r.jsxs)("div",{className:"flex flex-col gap-4 py-4",children:[(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"Username"}),(0,r.jsx)("input",{className:"border rounded px-3 py-2 w-full",placeholder:"Username",value:m.username,onChange:e=>f({...m,username:e.target.value})})]}),(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"Password"}),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("input",{className:"border rounded px-3 py-2 w-full pr-10",placeholder:"Password",type:L?"text":"password",value:m.password,onChange:e=>f({...m,password:e.target.value})}),(0,r.jsx)("button",{type:"button",className:"absolute inset-y-0 right-0 pr-3 flex items-center text-gray-400 hover:text-gray-600",onClick:()=>F(!L),children:L?(0,r.jsx)(k.Z,{className:"h-4 w-4"}):(0,r.jsx)(C.Z,{className:"h-4 w-4"})})]})]}),(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"Role"}),(0,r.jsxs)("select",{className:"border rounded px-3 py-2 w-full",value:m.role,onChange:e=>f({...m,role:e.target.value}),children:[(0,r.jsx)("option",{value:"user",children:"User"}),(0,r.jsx)("option",{value:"admin",children:"Admin"})]})]})]}),(0,r.jsxs)(T.cN,{children:[(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 px-4 py-2",onClick:()=>c(!1),disabled:b,children:"Cancel"}),(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-sky-600 text-white hover:bg-sky-700 h-10 px-4 py-2",onClick:ez,disabled:b,children:b?"Creating...":"Create"})]})]})}),(0,r.jsx)(T.Vq,{open:v.open,onOpenChange:e=>{S(s=>({...s,open:e})),e||ej(null)},children:(0,r.jsxs)(T.cZ,{className:"sm:max-w-md transition-all duration-200 ease-in-out",children:[(0,r.jsxs)(T.fK,{children:[(0,r.jsx)(T.$N,{children:"Permission Denied"}),(0,r.jsx)(T.Be,{children:E?(0,r.jsxs)("div",{className:"flex items-center py-2",children:[(0,r.jsx)(i.Z,{size:16,className:"mr-2"}),(0,r.jsx)("span",{children:"Checking permissions..."})]}):(0,r.jsx)(r.Fragment,{children:v.userName?(0,r.jsxs)(r.Fragment,{children:[v.userName," is logged in as non-admin and ",v.message,"."]}):v.message})})]}),(0,r.jsx)(T.cN,{children:(0,r.jsx)(u.z,{variant:"outline",onClick:()=>S(e=>({...e,open:!1})),disabled:E,children:"OK"})})]})}),(0,r.jsx)(T.Vq,{open:P,onOpenChange:e=>{z(e),e||ej(null)},children:(0,r.jsxs)(T.cZ,{className:"sm:max-w-lg",children:[(0,r.jsx)(T.fK,{children:(0,r.jsx)(T.$N,{children:"Import/Export Users"})}),(0,r.jsxs)("div",{className:"flex border-b border-gray-200 mb-4",children:[(0,r.jsx)("button",{className:"px-4 py-2 text-sm font-medium ".concat("import"===Q?"border-b-2 border-sky-500 text-sky-600":"text-gray-500 hover:text-gray-700"),onClick:()=>X("import"),children:"Import"}),(0,r.jsx)("button",{className:"px-4 py-2 text-sm font-medium ".concat("export"===Q?"border-b-2 border-sky-500 text-sky-600":"text-gray-500 hover:text-gray-700"),onClick:()=>X("export"),children:"Export"})]}),(0,r.jsx)("div",{className:"flex flex-col gap-4 py-4",children:"import"===Q?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"CSV File"}),(0,r.jsx)("input",{type:"file",accept:".csv",onChange:eq,className:"border rounded px-3 py-2 w-full"}),(0,r.jsxs)("p",{className:"text-xs text-gray-500",children:["CSV should have columns: username, password, role",(0,r.jsx)("br",{}),"Supports both plain text passwords and exported password hashes."]})]}),J&&(0,r.jsx)("div",{className:"p-3 bg-green-50 border border-green-200 rounded text-green-700 text-sm",children:J.message})]}):(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"Export Users to CSV"}),(0,r.jsx)("p",{className:"text-xs text-gray-500",children:"Download all users as a CSV file with password hashes."}),(0,r.jsxs)("div",{className:"p-3 bg-amber-50 border border-amber-200 rounded",children:[(0,r.jsx)("p",{className:"text-sm text-amber-700",children:"⚠️ This will export all users with columns: username, password (hashed), role"}),(0,r.jsx)("p",{className:"text-xs text-amber-600 mt-1",children:"Password hashes can be imported directly for system backups."})]})]})})}),(0,r.jsxs)(T.cN,{children:[(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 px-4 py-2",onClick:()=>z(!1),disabled:H,children:"Cancel"}),"import"===Q?(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-sky-600 text-white hover:bg-sky-700 h-10 px-4 py-2",onClick:eV,disabled:H||!M,children:H?"Importing...":"Import"}):(0,r.jsxs)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-sky-600 text-white hover:bg-sky-700 h-10 px-4 py-2",onClick:async()=>{try{let e=await U.x.get("/users/export");if(!e.ok){let s=await e.json();throw Error(s.detail||"Failed to export users")}let s=await e.json(),t=s.csv_content,r=new Blob([t],{type:"text/csv;charset=utf-8;"}),n=URL.createObjectURL(r),a=document.createElement("a");a.href=n;let l=new Date,i=e=>String(e).padStart(2,"0"),o=l.getFullYear(),c=i(l.getMonth()+1),d=i(l.getDate()),u=i(l.getHours()),m=i(l.getMinutes()),x=i(l.getSeconds());a.download="users_export_".concat(o,"-").concat(c,"-").concat(d,"-").concat(u,"-").concat(m,"-").concat(x,".csv"),a.click(),URL.revokeObjectURL(n),alert("Successfully exported ".concat(s.user_count," users to CSV file."))}catch(e){alert("Error exporting users: ".concat(e.message))}},children:[(0,r.jsx)(_.Z,{className:"h-4 w-4 mr-1"}),"Export"]})]})]})}),(0,r.jsx)(T.Vq,{open:Y,onOpenChange:e=>{e||(eH(),ej(null))},children:(0,r.jsxs)(T.cZ,{className:"sm:max-w-md",children:[(0,r.jsxs)(T.fK,{children:[(0,r.jsx)(T.$N,{children:"Reset Password"}),(0,r.jsxs)(T.Be,{children:["Enter a new password for"," ",(null==ee?void 0:ee.usernameDisplay)||"this user","."]})]}),(0,r.jsx)("div",{className:"flex flex-col gap-4 py-4",children:(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"New Password"}),(0,r.jsx)("input",{type:"password",className:"border rounded px-3 py-2 w-full",placeholder:"Enter new password",value:et,onChange:e=>er(e.target.value),autoFocus:!0})]})}),(0,r.jsxs)(T.cN,{children:[(0,r.jsx)(u.z,{variant:"outline",onClick:eH,disabled:en,children:"Cancel"}),(0,r.jsx)(u.z,{variant:"default",onClick:eB,disabled:en||!et,className:"bg-sky-600 text-white hover:bg-sky-700",children:en?"Resetting...":"Reset Password"})]})]})}),(0,r.jsx)(T.Vq,{open:eo,onOpenChange:e=>{e||(eK(),ej(null))},children:(0,r.jsxs)(T.cZ,{className:"sm:max-w-md",children:[(0,r.jsxs)(T.fK,{children:[(0,r.jsx)(T.$N,{children:"Delete User"}),(0,r.jsxs)(T.Be,{children:['Are you sure you want to delete user "',(null==ed?void 0:ed.usernameDisplay)||"this user",'"? This action cannot be undone.']})]}),(0,r.jsxs)(T.cN,{children:[(0,r.jsx)(u.z,{variant:"outline",onClick:eK,disabled:eh,children:"Cancel"}),(0,r.jsx)(u.z,{variant:"destructive",onClick:eO,disabled:eh,children:eh?"Deleting...":"Delete"})]})]})})]})}function B(e){let{refreshInterval:s,setLoading:t,refreshDataRef:a,checkPermissionAndAct:l,roleLoading:o,onResetPassword:d,onDeleteUser:u,basicAuthEnabled:b,currentUserRole:y,currentUserId:N,searchQuery:w,setSearchQuery:k}=e,[C,_]=(0,n.useState)([]),[L,Z]=(0,n.useState)(!0),[T,A]=(0,n.useState)(!1),[q,V]=(0,n.useState)({key:"username",direction:"ascending"}),[M,B]=(0,n.useState)(null),[O,K]=(0,n.useState)(""),H=(0,n.useCallback)(async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];t&&e&&t(!0),e&&Z(!0);try{let s=await p.default.get(x.R),r=(s||[]).map(e=>({...e,usernameDisplay:P(e.username,e.userId),fullEmailID:z(e.username,e.userId),clusterCount:-1,jobCount:-1}));_(r),A(!0),t&&e&&t(!1),e&&Z(!1);let[n,a]=await Promise.all([p.default.get(h.getClusters),p.default.get(g.getManagedJobs,[{allUsers:!0}])]),l=a.jobs||[],i=(s||[]).map(e=>{let s=(n||[]).filter(s=>s.user_hash===e.userId),t=(l||[]).filter(s=>s.user_hash===e.userId);return{...e,usernameDisplay:P(e.username,e.userId),fullEmailID:z(e.username,e.userId),clusterCount:s.length,jobCount:t.length}});_(i)}catch(s){console.error("Failed to fetch or process user data:",s),_([]),A(!0),t&&e&&t(!1),e&&Z(!1)}},[t]);(0,n.useEffect)(()=>{a&&(a.current=()=>H(!0))},[a,H]),(0,n.useEffect)(()=>{(async()=>{A(!1),Z(!0),await f.ZP.preloadForPage("users"),H(!0)})();let e=setInterval(()=>{H(!1)},s);return()=>clearInterval(e)},[H,s]);let $=(0,n.useMemo)(()=>{let e=C;if(null==w?void 0:w.trim()){let s=w.toLowerCase();e=C.filter(e=>{var t,r,n;return(null===(t=e.usernameDisplay)||void 0===t?void 0:t.toLowerCase().includes(s))||(null===(r=e.fullEmailID)||void 0===r?void 0:r.toLowerCase().includes(s))||(null===(n=e.role)||void 0===n?void 0:n.toLowerCase().includes(s))})}return(0,j.R0)(e,q.key,q.direction)},[C,q,w]),J=e=>{let s="ascending";q.key===e&&"ascending"===q.direction&&(s="descending"),V({key:e,direction:s})},W=e=>q.key===e?"ascending"===q.direction?" ↑":" ↓":"",Q=async(e,s)=>{await l("cannot edit user role",()=>{B(e),K(s)})},X=()=>{B(null),K("")},Y=async e=>{if(!e||!O){console.error("User ID or role is missing."),alert("Error: User ID or role is missing.");return}Z(!0);try{let s=await U.x.post("/users/update",{user_id:e,role:O});if(!s.ok){let e=await s.json();throw Error(e.detail||"Failed to update role")}p.default.invalidate(x.R),await H(!0),X()}catch(e){console.error("Failed to update user role:",e),alert("Error updating role: ".concat(e.message))}finally{Z(!1)}};return L&&0===C.length&&!T?(0,r.jsx)("div",{className:"flex justify-center items-center h-64",children:(0,r.jsx)(i.Z,{})}):T?$&&0!==$.length?(0,r.jsx)(F.Zb,{children:(0,r.jsxs)(m.iA,{children:[(0,r.jsx)(m.xD,{children:(0,r.jsxs)(m.SC,{children:[(0,r.jsxs)(m.ss,{onClick:()=>J("usernameDisplay"),className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 w-1/6",children:["Name",W("usernameDisplay")]}),(0,r.jsxs)(m.ss,{onClick:()=>J("fullEmailID"),className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 w-1/6",children:["User ID",W("fullEmailID")]}),(0,r.jsxs)(m.ss,{onClick:()=>J("role"),className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 w-1/6",children:["Role",W("role")]}),(0,r.jsxs)(m.ss,{onClick:()=>J("created_at"),className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 w-1/6",children:["Joined",W("created_at")]}),(0,r.jsxs)(m.ss,{onClick:()=>J("clusterCount"),className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 w-1/6",children:["Clusters",W("clusterCount")]}),(0,r.jsxs)(m.ss,{onClick:()=>J("jobCount"),className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 w-1/6",children:["Jobs",W("jobCount")]}),b&&(0,r.jsx)(m.ss,{className:"whitespace-nowrap w-1/7",children:"Actions"})]})}),(0,r.jsx)(m.RM,{children:$.map(e=>(0,r.jsxs)(m.SC,{children:[(0,r.jsx)(m.pj,{className:"truncate",title:e.username,children:e.usernameDisplay}),(0,r.jsx)(m.pj,{className:"truncate",title:e.fullEmailID,children:e.fullEmailID}),(0,r.jsx)(m.pj,{className:"truncate",title:e.role,children:(0,r.jsx)("div",{className:"flex items-center gap-2",children:M===e.userId?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("select",{value:O,onChange:e=>K(e.target.value),className:"block w-auto p-1 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-sky-blue focus:border-sky-blue sm:text-sm",children:[(0,r.jsx)("option",{value:"admin",children:"Admin"}),(0,r.jsx)("option",{value:"user",children:"User"})]}),(0,r.jsx)("button",{onClick:()=>Y(e.userId),className:"text-green-600 hover:text-green-800 p-1",title:"Save",children:(0,r.jsx)(S.Z,{className:"h-4 w-4"})}),(0,r.jsx)("button",{onClick:X,className:"text-gray-500 hover:text-gray-700 p-1",title:"Cancel",children:(0,r.jsx)(R.Z,{className:"h-4 w-4"})})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"capitalize",children:e.role}),"admin"===y&&(0,r.jsx)("button",{onClick:()=>Q(e.userId,e.role),className:"text-blue-600 hover:text-blue-700 p-1",title:"Edit role",children:(0,r.jsx)(D.Z,{className:"h-3 w-3"})})]})})}),(0,r.jsx)(m.pj,{className:"truncate",children:e.created_at?(0,r.jsx)(v.Zg,{date:new Date(1e3*e.created_at)}):"-"}),(0,r.jsx)(m.pj,{children:-1===e.clusterCount?(0,r.jsxs)("span",{className:"px-2 py-0.5 bg-gray-100 text-gray-400 rounded text-xs font-medium flex items-center",children:[(0,r.jsx)(i.Z,{size:10,className:"mr-1"}),"Loading..."]}):(0,r.jsx)(c(),{href:"/clusters?user=".concat(encodeURIComponent(e.userId)),className:"px-2 py-0.5 rounded text-xs font-medium transition-colors duration-200 cursor-pointer inline-block ".concat(e.clusterCount>0?"bg-blue-100 text-blue-600 hover:bg-blue-200 hover:text-blue-700":"bg-gray-100 text-gray-500 hover:bg-gray-200 hover:text-gray-700"),title:"View ".concat(e.clusterCount," cluster").concat(1!==e.clusterCount?"s":""," for ").concat(e.usernameDisplay),children:e.clusterCount})}),(0,r.jsx)(m.pj,{children:-1===e.jobCount?(0,r.jsxs)("span",{className:"px-2 py-0.5 bg-gray-100 text-gray-400 rounded text-xs font-medium flex items-center",children:[(0,r.jsx)(i.Z,{size:10,className:"mr-1"}),"Loading..."]}):(0,r.jsx)(c(),{href:"/jobs?user=".concat(encodeURIComponent(e.userId)),className:"px-2 py-0.5 rounded text-xs font-medium transition-colors duration-200 cursor-pointer inline-block ".concat(e.jobCount>0?"bg-green-100 text-green-600 hover:bg-green-200 hover:text-green-700":"bg-gray-100 text-gray-500 hover:bg-gray-200 hover:text-gray-700"),title:"View ".concat(e.jobCount," job").concat(1!==e.jobCount?"s":""," for ").concat(e.usernameDisplay),children:e.jobCount})}),b&&(0,r.jsx)(m.pj,{className:"relative",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("button",{onClick:"admin"===y||e.userId===N?async()=>{d(e)}:void 0,className:"admin"===y||e.userId===N?"text-blue-600 hover:text-blue-700 p-1":"text-gray-300 cursor-not-allowed p-1",title:"admin"===y||e.userId===N?"Reset Password":"You can only reset your own password",disabled:"admin"!==y&&e.userId!==N,children:(0,r.jsx)(E.Z,{className:"h-4 w-4"})}),"admin"===y&&(0,r.jsx)("button",{onClick:()=>u(e),className:"text-red-600 hover:text-red-700 p-1",title:"Delete User",children:(0,r.jsx)(I.Z,{className:"h-4 w-4"})})]})})]},e.userId))})]})}):(0,r.jsxs)("div",{className:"text-center py-12",children:[(0,r.jsx)("p",{className:"text-lg font-semibold text-gray-500",children:(null==w?void 0:w.trim())?"No users match your search.":"No users found."}),(0,r.jsx)("p",{className:"text-sm text-gray-400 mt-1",children:(null==w?void 0:w.trim())?"Try adjusting your search terms.":"There are currently no users to display."})]}):(0,r.jsxs)("div",{className:"flex justify-center items-center h-64",children:[(0,r.jsx)(i.Z,{}),(0,r.jsx)("span",{className:"ml-2 text-gray-500",children:"Loading users..."})]})}function O(e){let{checkPermissionAndAct:s,userRoleCache:t,setCreateSuccess:a,setCreateError:l,showCreateDialog:o,setShowCreateDialog:d,showRotateDialog:u,setShowRotateDialog:x,tokenToRotate:f,setTokenToRotate:b,rotating:j,setRotating:y,searchQuery:w,setSearchQuery:k}=e,[C,_]=(0,n.useState)([]),[Z,A]=(0,n.useState)(!0),[P,z]=(0,n.useState)(!1),[q,V]=(0,n.useState)(null),[M,B]=(0,n.useState)(null),[O,K]=(0,n.useState)({token_name:"",expires_in_days:30}),[H,$]=(0,n.useState)(""),[J,W]=(0,n.useState)(!1),[Q,X]=(0,n.useState)(!1),[Y,G]=(0,n.useState)(""),[ee,es]=(0,n.useState)(null),[et,er]=(0,n.useState)(null),[en,ea]=(0,n.useState)(null),[el,ei]=(0,n.useState)(""),[eo,ec]=(0,n.useState)([]),ed=async()=>{try{A(!0);let e=await U.x.get("/users/service-account-tokens");if(!e.ok){console.error("Failed to fetch tokens"),_([]),ec([]);return}let s=await e.json();_(s||[]);let[t,r]=await Promise.all([p.default.get(h.getClusters),p.default.get(g.getManagedJobs,[{allUsers:!0}])]),n=t||[],a=(null==r?void 0:r.jobs)||[],l=(s||[]).map(e=>{let s=e.service_account_user_id,t=n.filter(e=>e.user_hash===s),r=a.filter(e=>e.user_hash===s);return{...e,clusterCount:t.length,jobCount:r.length,primaryRole:e.service_account_roles&&e.service_account_roles.length>0?e.service_account_roles[0]:"user"}});ec(l)}catch(e){console.error("Error fetching tokens and counts:",e),_([]),ec([])}finally{A(!1)}};(0,n.useEffect)(()=>{ed()},[]);let eu=async(e,t)=>{await s("cannot edit service account role",()=>{ea(e),ei(t)})},em=()=>{ea(null),ei("")},ex=async e=>{if(!e||!el){console.error("Token ID or role is missing."),l(Error("Token ID or role is missing."));return}A(!0);try{let s=await U.x.post("/users/service-account-tokens/update-role",{token_id:e,role:el});if(!s.ok){let e=await s.json();throw Error(e.detail||"Failed to update role")}a("Service account role updated successfully!"),await ed(),em()}catch(e){console.error("Failed to update service account role:",e),l(e)}finally{A(!1)}},eh=async e=>{try{await navigator.clipboard.writeText(e),G("Copied!"),setTimeout(()=>G(""),2e3)}catch(e){console.error("Failed to copy:",e)}},eg=async()=>{if(!O.token_name.trim()){l(Error("Token name is required"));return}W(!0);try{let e={token_name:O.token_name.trim(),expires_in_days:""===O.expires_in_days?null:O.expires_in_days},s=await U.x.post("/users/service-account-tokens",e);if(s.ok){let e=await s.json();es(e.token),K({token_name:"",expires_in_days:30}),await ed()}else{let e=await s.json();throw Error(e.detail||"Failed to create token")}}catch(e){l(e)}finally{W(!1)}},ep=async()=>{if(q){X(!0),B(null);try{let e=await U.x.post("/users/service-account-tokens/delete",{token_id:q.token_id});if(e.ok)a('Service account "'.concat(q.token_name,'" deleted successfully!')),z(!1),V(null),B(null),await ed();else{let s=await e.json();throw Error(s.detail||"Failed to delete service account")}}catch(e){z(!1),V(null),B(null),l(e)}finally{X(!1)}}},ef=async()=>{if(f){y(!0);try{let e={token_id:f.token_id,expires_in_days:""===H?null:parseInt(H)},s=await U.x.post("/users/service-account-tokens/rotate",e);if(s.ok){let e=await s.json();er(e.token),await ed()}else{let e=await s.json();throw Error(e.detail||"Failed to rotate token")}}catch(e){l(e)}finally{y(!1)}}},eb=eo.filter(e=>{var s,t,r,n;if(!(null==w?void 0:w.trim()))return!0;let a=w.toLowerCase();return(null===(s=e.token_name)||void 0===s?void 0:s.toLowerCase().includes(a))||(null===(t=e.creator_name)||void 0===t?void 0:t.toLowerCase().includes(a))||(null===(r=e.service_account_name)||void 0===r?void 0:r.toLowerCase().includes(a))||(null===(n=e.primaryRole)||void 0===n?void 0:n.toLowerCase().includes(a))});return Z&&0===eo.length?(0,r.jsxs)("div",{className:"flex items-center justify-center py-8",children:[(0,r.jsx)(i.Z,{size:32}),(0,r.jsx)("span",{className:"ml-3",children:"Loading tokens..."})]}):(0,r.jsxs)(r.Fragment,{children:[0===eb.length?(0,r.jsxs)("div",{className:"text-center py-12",children:[(0,r.jsx)(E.Z,{className:"mx-auto h-12 w-12 text-gray-400"}),(0,r.jsx)("h3",{className:"mt-2 text-sm font-medium text-gray-900",children:(null==w?void 0:w.trim())?"No tokens match your search":"No service accounts"}),(0,r.jsx)("p",{className:"mt-1 text-sm text-gray-500",children:(null==w?void 0:w.trim())?"Try adjusting your search terms.":"No service accounts have been created yet."})]}):(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(F.Zb,{children:(0,r.jsxs)(m.iA,{children:[(0,r.jsx)(m.xD,{children:(0,r.jsxs)(m.SC,{children:[(0,r.jsx)(m.ss,{children:"Name"}),(0,r.jsx)(m.ss,{children:"Created by"}),(0,r.jsx)(m.ss,{children:"Role"}),(0,r.jsx)(m.ss,{children:"Clusters"}),(0,r.jsx)(m.ss,{children:"Jobs"}),(0,r.jsx)(m.ss,{children:"Created"}),(0,r.jsx)(m.ss,{children:"Last used"}),(0,r.jsx)(m.ss,{children:"Expires"}),(0,r.jsx)(m.ss,{children:"Actions"})]})}),(0,r.jsx)(m.RM,{children:eb.map(e=>(0,r.jsxs)(m.SC,{children:[(0,r.jsx)(m.pj,{className:"truncate",title:e.token_name,children:e.token_name}),(0,r.jsx)(m.pj,{className:"truncate",children:(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("span",{children:e.creator_name||"Unknown"}),e.creator_user_hash!==(null==t?void 0:t.id)&&(0,r.jsx)("span",{className:"ml-2 px-1.5 py-0.5 text-xs bg-gray-100 text-gray-600 rounded",children:"Other"})]})}),(0,r.jsx)(m.pj,{className:"truncate",children:(0,r.jsx)("div",{className:"flex items-center gap-2",children:en===e.token_id?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("select",{value:el,onChange:e=>ei(e.target.value),className:"block w-auto p-1 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-sky-blue focus:border-sky-blue sm:text-sm",children:[(0,r.jsx)("option",{value:"admin",children:"Admin"}),(0,r.jsx)("option",{value:"user",children:"User"})]}),(0,r.jsx)("button",{onClick:()=>ex(e.token_id),className:"text-green-600 hover:text-green-800 p-1",title:"Save",children:(0,r.jsx)(S.Z,{className:"h-4 w-4"})}),(0,r.jsx)("button",{onClick:em,className:"text-gray-500 hover:text-gray-700 p-1",title:"Cancel",children:(0,r.jsx)(R.Z,{className:"h-4 w-4"})})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"capitalize",children:e.primaryRole}),((null==t?void 0:t.role)==="admin"||e.creator_user_hash===(null==t?void 0:t.id))&&(0,r.jsx)("button",{onClick:()=>eu(e.token_id,e.primaryRole),className:"text-blue-600 hover:text-blue-700 p-1",title:"Edit role",children:(0,r.jsx)(D.Z,{className:"h-3 w-3"})})]})})}),(0,r.jsx)(m.pj,{children:(0,r.jsx)(c(),{href:"/clusters?user=".concat(encodeURIComponent(e.service_account_user_id)),className:"px-2 py-0.5 rounded text-xs font-medium transition-colors duration-200 cursor-pointer inline-block ".concat(e.clusterCount>0?"bg-blue-100 text-blue-600 hover:bg-blue-200 hover:text-blue-700":"bg-gray-100 text-gray-500 hover:bg-gray-200 hover:text-gray-700"),title:"View ".concat(e.clusterCount," cluster").concat(1!==e.clusterCount?"s":""," for ").concat(e.token_name),children:e.clusterCount})}),(0,r.jsx)(m.pj,{children:(0,r.jsx)(c(),{href:"/jobs?user=".concat(encodeURIComponent(e.service_account_user_id)),className:"px-2 py-0.5 rounded text-xs font-medium transition-colors duration-200 cursor-pointer inline-block ".concat(e.jobCount>0?"bg-green-100 text-green-600 hover:bg-green-200 hover:text-green-700":"bg-gray-100 text-gray-500 hover:bg-gray-200 hover:text-gray-700"),title:"View ".concat(e.jobCount," job").concat(1!==e.jobCount?"s":""," for ").concat(e.token_name),children:e.jobCount})}),(0,r.jsx)(m.pj,{className:"truncate",children:e.created_at?(0,r.jsx)(v.Zg,{date:new Date(1e3*e.created_at)}):"Never"}),(0,r.jsx)(m.pj,{className:"truncate",children:e.last_used_at?(0,r.jsx)(v.Zg,{date:new Date(1e3*e.last_used_at)}):"Never"}),(0,r.jsx)(m.pj,{className:"truncate",children:e.expires_at?new Date(1e3*e.expires_at)<new Date?(0,r.jsx)("span",{className:"text-red-600",children:"Expired"}):(0,r.jsx)(v.Zg,{date:new Date(1e3*e.expires_at)}):"Never"}),(0,r.jsx)(m.pj,{children:(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[((null==t?void 0:t.role)==="admin"||e.creator_user_hash===(null==t?void 0:t.id))&&(0,r.jsx)(v.WH,{content:"Rotate token",className:"capitalize text-sm text-muted-foreground",children:(0,r.jsx)("button",{onClick:()=>{s("cannot rotate service account tokens",()=>{b(e),x(!0)})},className:"text-sky-blue hover:text-sky-blue-bright font-medium inline-flex items-center",children:(0,r.jsx)(N.Z,{className:"h-4 w-4"})})}),((null==t?void 0:t.role)==="admin"||e.creator_user_hash===(null==t?void 0:t.id))&&(0,r.jsx)(v.WH,{content:"Delete ".concat(e.token_name),className:"capitalize text-sm text-muted-foreground",children:(0,r.jsx)("button",{onClick:()=>{s("cannot delete service account tokens",()=>{V(e),z(!0)})},className:"text-red-600 hover:text-red-800 font-medium inline-flex items-center",children:(0,r.jsx)(I.Z,{className:"h-4 w-4"})})})]})})]},e.token_id))})]})})}),(0,r.jsx)(T.Vq,{open:o,onOpenChange:e=>{d(e),e||(es(null),l(null))},children:(0,r.jsxs)(T.cZ,{className:"sm:max-w-2xl",children:[(0,r.jsxs)(T.fK,{children:[(0,r.jsx)(T.$N,{children:"Create Service Account"}),(0,r.jsx)(T.Be,{children:"Create a new service account with an API token for programmatic access to SkyPilot."})]}),(0,r.jsx)("div",{className:"flex flex-col gap-4 py-4",children:ee?(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"p-4 bg-green-50 border border-green-200 rounded-lg",children:[(0,r.jsxs)("div",{className:"flex items-center mb-3",children:[(0,r.jsx)("h4",{className:"text-sm font-medium text-green-900",children:"⚠️ Service account created successfully - save this token now!"}),(0,r.jsx)(v.WH,{content:Y?"Copied!":"Copy token",className:"text-muted-foreground",children:(0,r.jsx)("button",{onClick:()=>eh(ee),className:"flex items-center text-green-600 hover:text-green-800 transition-colors duration-200 p-1 ml-2",children:Y?(0,r.jsx)(S.Z,{className:"w-4 h-4"}):(0,r.jsx)(L.Z,{className:"w-4 h-4"})})})]}),(0,r.jsx)("p",{className:"text-sm text-green-700 mb-3",children:"This service account token will not be shown again. Please copy and store it securely."}),(0,r.jsx)("div",{className:"bg-white border border-green-300 rounded-md p-3",children:(0,r.jsx)("code",{className:"text-sm text-gray-800 font-mono break-all block",children:ee})})]})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"Service Account Name"}),(0,r.jsx)("input",{className:"border rounded px-3 py-2 w-full",placeholder:"e.g., ci-pipeline, monitoring-system",value:O.token_name,onChange:e=>K({...O,token_name:e.target.value})})]}),(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"Expiration (days)"}),(0,r.jsx)("input",{type:"number",className:"border rounded px-3 py-2 w-full",placeholder:"e.g., 30",min:"0",max:"365",value:O.expires_in_days||"",onChange:e=>K({...O,expires_in_days:e.target.value?parseInt(e.target.value):null})}),(0,r.jsx)("p",{className:"text-xs text-gray-500",children:"Leave empty or enter 0 to never expire. Maximum 365 days."})]})]})}),(0,r.jsx)(T.cN,{children:ee?(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-sky-600 text-white hover:bg-sky-700 h-10 px-4 py-2",onClick:()=>{d(!1),es(null)},children:"Close"}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 px-4 py-2",onClick:()=>{d(!1),es(null)},disabled:J,children:"Cancel"}),(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-sky-600 text-white hover:bg-sky-700 h-10 px-4 py-2",onClick:eg,disabled:J||!O.token_name.trim(),children:J?"Creating...":"Create Token"})]})})]})}),(0,r.jsx)(T.Vq,{open:P,onOpenChange:e=>{z(e),e||(V(null),l(null))},children:(0,r.jsxs)(T.cZ,{className:"sm:max-w-md",children:[(0,r.jsxs)(T.fK,{children:[(0,r.jsx)(T.$N,{children:"Delete Service Account Token"}),(0,r.jsxs)(T.Be,{children:['Are you sure you want to delete the service account "',null==q?void 0:q.token_name,'"',(null==q?void 0:q.creator_user_hash)!==(null==t?void 0:t.id)&&(null==t?void 0:t.role)==="admin"?" owned by ".concat(null==q?void 0:q.creator_name):"","? This action cannot be undone and will immediately revoke access for any systems using this token."]})]}),(0,r.jsxs)(T.cN,{children:[(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 px-4 py-2",onClick:()=>{z(!1),V(null)},disabled:Q,children:"Cancel"}),(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-red-600 text-white hover:bg-red-700 h-10 px-4 py-2",onClick:ep,disabled:Q,children:Q?"Deleting...":"Delete Token"})]})]})}),(0,r.jsx)(T.Vq,{open:u,onOpenChange:e=>{x(e),e||(b(null),$(""),er(null),l(null))},children:(0,r.jsxs)(T.cZ,{className:"sm:max-w-2xl",children:[(0,r.jsxs)(T.fK,{children:[(0,r.jsx)(T.$N,{children:"Rotate Service Account Token"}),(0,r.jsxs)(T.Be,{children:['Rotate the service account token "',null==f?void 0:f.token_name,'"',(null==f?void 0:f.creator_user_hash)!==(null==t?void 0:t.id)&&(null==t?void 0:t.role)==="admin"?" owned by ".concat(null==f?void 0:f.creator_name):"",". This will generate a new token value and invalidate the current one."]})]}),(0,r.jsx)("div",{className:"flex flex-col gap-4 py-4",children:et?(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"p-4 bg-green-50 border border-green-200 rounded-lg",children:[(0,r.jsxs)("div",{className:"flex items-center mb-3",children:[(0,r.jsx)("h4",{className:"text-sm font-medium text-green-900",children:"\uD83D\uDD04 Service account token rotated successfully - save this new token now!"}),(0,r.jsx)(v.WH,{content:Y?"Copied!":"Copy token",className:"text-muted-foreground",children:(0,r.jsx)("button",{onClick:()=>eh(et),className:"flex items-center text-green-600 hover:text-green-800 transition-colors duration-200 p-1 ml-2",children:Y?(0,r.jsx)(S.Z,{className:"w-4 h-4"}):(0,r.jsx)(L.Z,{className:"w-4 h-4"})})})]}),(0,r.jsx)("p",{className:"text-sm text-green-700 mb-3",children:"This new token replaces the old one. Please copy and store it securely. The old token is now invalid."}),(0,r.jsx)("div",{className:"bg-white border border-green-300 rounded-md p-3",children:(0,r.jsx)("code",{className:"text-sm text-gray-800 font-mono break-all block",children:et})})]})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"New Expiration (days)"}),(0,r.jsx)("input",{type:"number",className:"border rounded px-3 py-2 w-full",placeholder:"Leave empty to preserve current expiration",min:"0",max:"365",value:H,onChange:e=>$(e.target.value)}),(0,r.jsx)("p",{className:"text-xs text-gray-500",children:"Leave empty to preserve current expiration. Enter number of days for new expiration, or enter 0 to set to never expire. Maximum 365 days."})]}),(0,r.jsx)("div",{className:"p-3 bg-amber-50 border border-amber-200 rounded",children:(0,r.jsx)("p",{className:"text-sm text-amber-700",children:"⚠️ Any systems using the current token will need to be updated with the new token."})})]})}),(0,r.jsx)(T.cN,{children:et?(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-green-600 text-white hover:bg-green-700 h-10 px-4 py-2",onClick:()=>{x(!1),b(null),$(""),er(null)},children:"Close"}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 px-4 py-2",onClick:()=>{x(!1),b(null),$(""),er(null)},disabled:j,children:"Cancel"}),(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-sky-600 text-white hover:bg-sky-700 h-10 px-4 py-2",onClick:ef,disabled:j,children:j?"Rotating...":"Rotate Token"})]})})]})})]})}B.propTypes={refreshInterval:l().number.isRequired,setLoading:l().func.isRequired,refreshDataRef:l().shape({current:l().func}).isRequired,checkPermissionAndAct:l().func.isRequired,roleLoading:l().bool.isRequired,onResetPassword:l().func.isRequired,onDeleteUser:l().func.isRequired,basicAuthEnabled:l().bool,currentUserRole:l().string,currentUserId:l().string}},4545:function(e,s,t){function r(e){return e.startsWith("sky-jobs-controller-")}function n(e,s,t){return null===s?e:[...e].sort((e,r)=>e[s]<r[s]?"ascending"===t?-1:1:e[s]>r[s]?"ascending"===t?1:-1:0)}t.d(s,{R0:function(){return n},Ym:function(){return r}})}}]);
|
@@ -1 +1 @@
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3785,430],{2557:function(e,s,t){"use strict";t.d(s,{I:function(){return l}});var r=t(5893),a=t(7294),n=t(2350);let l=a.forwardRef((e,s)=>{let{className:t,type:a,...l}=e;return(0,r.jsx)("input",{type:a,className:(0,n.cn)("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:s,...l})});l.displayName="Input"},6185:function(e,s,t){"use strict";t.d(s,{_:function(){return c}});var r=t(5893),a=t(7294),n=t(9102),l=t(2003),i=t(2350);let o=(0,l.j)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),c=a.forwardRef((e,s)=>{let{className:t,...a}=e;return(0,r.jsx)(n.f,{ref:s,className:(0,i.cn)(o(),t),...a})});c.displayName=n.f.displayName},3785:function(e,s,t){"use strict";t.r(s),t.d(s,{NewWorkspace:function(){return b}});var r=t(5893),a=t(7294),n=t(1163),l=t(1664),i=t.n(l),o=t(5152),c=t.n(o),u=t(7324),d=t(803),f=t(2557),m=t(6185),p=t(7673);let x=c()(()=>Promise.all([t.e(616),t.e(5739),t.e(804),t.e(1272),t.e(3947),t.e(6989),t.e(3698),t.e(9470),t.e(8969),t.e(1043),t.e(6601),t.e(938),t.e(1141)]).then(t.bind(t,1141)).then(e=>e.WorkspaceEditor),{loadableGenerated:{webpack:()=>[1141]},ssr:!1});function b(){(0,n.useRouter)();let[e,s]=(0,a.useState)(""),[t,l]=(0,a.useState)(!1),[o,c]=(0,a.useState)({}),[b,h]=(0,a.useState)(!0);(0,a.useEffect)(()=>{v()},[]);let v=async()=>{try{let e=await (0,u.fX)();c(e)}catch(e){console.error("Failed to fetch existing workspaces:",e)}finally{h(!1)}},
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3785,430],{2557:function(e,s,t){"use strict";t.d(s,{I:function(){return l}});var r=t(5893),a=t(7294),n=t(2350);let l=a.forwardRef((e,s)=>{let{className:t,type:a,...l}=e;return(0,r.jsx)("input",{type:a,className:(0,n.cn)("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:s,...l})});l.displayName="Input"},6185:function(e,s,t){"use strict";t.d(s,{_:function(){return c}});var r=t(5893),a=t(7294),n=t(9102),l=t(2003),i=t(2350);let o=(0,l.j)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),c=a.forwardRef((e,s)=>{let{className:t,...a}=e;return(0,r.jsx)(n.f,{ref:s,className:(0,i.cn)(o(),t),...a})});c.displayName=n.f.displayName},3785:function(e,s,t){"use strict";t.r(s),t.d(s,{NewWorkspace:function(){return b}});var r=t(5893),a=t(7294),n=t(1163),l=t(1664),i=t.n(l),o=t(5152),c=t.n(o),u=t(7324),d=t(803),f=t(2557),m=t(6185),p=t(7673);let x=c()(()=>Promise.all([t.e(616),t.e(5739),t.e(804),t.e(1272),t.e(3947),t.e(6989),t.e(3698),t.e(9470),t.e(8969),t.e(1043),t.e(6601),t.e(938),t.e(1141)]).then(t.bind(t,1141)).then(e=>e.WorkspaceEditor),{loadableGenerated:{webpack:()=>[1141]},ssr:!1});function b(){(0,n.useRouter)();let[e,s]=(0,a.useState)(""),[t,l]=(0,a.useState)(!1),[o,c]=(0,a.useState)({}),[b,h]=(0,a.useState)(!0);(0,a.useEffect)(()=>{v()},[]);let v=async()=>{try{let e=await (0,u.fX)();c(e)}catch(e){console.error("Failed to fetch existing workspaces:",e)}finally{h(!1)}},k=()=>{e.trim()&&!y&&l(!0)},y=e.trim()&&o.hasOwnProperty(e.trim()),w=e.trim()&&!y;return t?(0,r.jsx)(x,{workspaceName:e,isNewWorkspace:!0}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"flex items-center justify-between mb-4 h-5",children:(0,r.jsxs)("div",{className:"text-base flex items-center",children:[(0,r.jsx)(i(),{href:"/workspaces",className:"text-sky-blue hover:underline",children:"Workspaces"}),(0,r.jsx)("span",{className:"mx-2 text-gray-500",children:"›"}),(0,r.jsx)("span",{className:"text-sky-blue",children:"New Workspace"})]})}),(0,r.jsxs)(p.Zb,{className:"max-w-md",children:[(0,r.jsx)(p.Ol,{children:(0,r.jsx)(p.ll,{className:"text-base font-normal",children:"Create New Workspace"})}),(0,r.jsxs)(p.aY,{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(m._,{htmlFor:"workspace-name",className:"text-sm font-normal",children:"Workspace name"}),(0,r.jsx)(f.I,{id:"workspace-name",value:e,onChange:e=>s(e.target.value),placeholder:"Enter workspace name",autoFocus:!0,onKeyPress:e=>{"Enter"===e.key&&w&&k()}}),y?(0,r.jsxs)("p",{className:"text-sm text-gray-500 mt-1",children:['Workspace "',e,'" already exists.'," ",(0,r.jsx)(i(),{href:"/workspaces/".concat(e),className:"text-blue-600 hover:underline",children:"View the workspace"})]}):(0,r.jsx)("p",{className:"text-sm text-gray-500 mt-1",children:"Choose a unique name for your workspace"})]}),(0,r.jsx)(d.z,{onClick:k,disabled:!w||b,className:"w-full bg-sky-600 hover:bg-sky-700 text-white disabled:bg-gray-300 disabled:text-gray-500",children:b?"Loading...":"Next: Configure Workspace"})]})]})]})}},1163:function(e,s,t){e.exports=t(6036)},9102:function(e,s,t){"use strict";t.d(s,{f:function(){return i}});var r=t(7294),a=t(5320),n=t(5893),l=r.forwardRef((e,s)=>(0,n.jsx)(a.WV.label,{...e,ref:s,onMouseDown:s=>{s.target.closest("button, input, select, textarea")||(e.onMouseDown?.(s),!s.defaultPrevented&&s.detail>1&&s.preventDefault())}}));l.displayName="Label";var i=l},2003:function(e,s,t){"use strict";t.d(s,{j:function(){return l}});var r=t(512);let a=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,n=r.W,l=(e,s)=>t=>{var r;if((null==s?void 0:s.variants)==null)return n(e,null==t?void 0:t.class,null==t?void 0:t.className);let{variants:l,defaultVariants:i}=s,o=Object.keys(l).map(e=>{let s=null==t?void 0:t[e],r=null==i?void 0:i[e];if(null===s)return null;let n=a(s)||a(r);return l[e][n]}),c=t&&Object.entries(t).reduce((e,s)=>{let[t,r]=s;return void 0===r||(e[t]=r),e},{});return n(e,o,null==s?void 0:null===(r=s.compoundVariants)||void 0===r?void 0:r.reduce((e,s)=>{let{class:t,className:r,...a}=s;return Object.entries(a).every(e=>{let[s,t]=e;return Array.isArray(t)?t.includes({...i,...c}[s]):({...i,...c})[s]===t})?[...e,t,r]:e},[]),null==t?void 0:t.class,null==t?void 0:t.className)}}}]);
|
@@ -0,0 +1,16 @@
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4869,430],{1260:function(e,s,l){"use strict";l.d(s,{Z:function(){return t}});/**
|
2
|
+
* @license lucide-react v0.407.0 - ISC
|
3
|
+
*
|
4
|
+
* This source code is licensed under the ISC license.
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
6
|
+
*/let t=(0,l(998).Z)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},7603:function(e,s,l){"use strict";l.d(s,{Z:function(){return t}});/**
|
7
|
+
* @license lucide-react v0.407.0 - ISC
|
8
|
+
*
|
9
|
+
* This source code is licensed under the ISC license.
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
11
|
+
*/let t=(0,l(998).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},1812:function(e,s,l){"use strict";l.d(s,{X:function(){return n}});var t=l(5893),r=l(7294);let a=e=>{if(!(null==e?void 0:e.message))return"An unexpected error occurred.";let s=e.message;return s.includes("failed:")&&(s=s.split("failed:")[1].trim()),s},n=e=>{let{error:s,title:l="Error",onDismiss:n}=e,[i,c]=(0,r.useState)(!1);if((0,r.useEffect)(()=>{s&&c(!1)},[s]),!s||i)return null;let o="string"==typeof s?s:a(s);return(0,t.jsx)("div",{className:"bg-red-50 border border-red-200 rounded-md p-3 mb-4",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex",children:[(0,t.jsx)("div",{className:"flex-shrink-0",children:(0,t.jsx)("svg",{className:"h-5 w-5 text-red-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})})}),(0,t.jsx)("div",{className:"ml-3",children:(0,t.jsxs)("div",{className:"text-sm text-red-800",children:[(0,t.jsxs)("strong",{children:[l,":"]})," ",o]})})]}),(0,t.jsx)("button",{onClick:()=>{c(!0),n&&n()},className:"flex-shrink-0 ml-4 text-red-400 hover:text-red-600 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2 focus:ring-offset-red-50 rounded","aria-label":"Dismiss error",children:(0,t.jsx)("svg",{className:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]})})}},2077:function(e,s,l){"use strict";l.r(s),l.d(s,{Workspaces:function(){return M}});var t=l(5893),r=l(7294),a=l(1163),n=l(3266),i=l(8969),c=l(7324),o=l(7673),d=l(8764),u=l(803),m=l(5739),x=l(1272),h=l(326);l(3850);var p=l(1812),g=l(3626),f=l(1260);/**
|
12
|
+
* @license lucide-react v0.407.0 - ISC
|
13
|
+
*
|
14
|
+
* This source code is licensed under the ISC license.
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
16
|
+
*/let j=(0,l(998).Z)("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]);var v=l(7603),b=l(3001),w=l(938),N=l(6378),k=l(1214),y=l(6856),C=l(7145),L=l(4545),S=l(3225),z=l(1664),Z=l.n(z);let D=e=>{let{isPrivate:s}=e;return s?(0,t.jsx)("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-gray-100 text-gray-700 border border-gray-300",children:"Private"}):(0,t.jsx)("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-green-100 text-green-700 border border-green-300",children:"Public"})},E=k.nb.REFRESH_INTERVAL;function M(){let[e,s]=(0,r.useState)([]),[l,k]=(0,r.useState)({runningClusters:0,totalClusters:0,managedJobs:0}),[z,M]=(0,r.useState)(!0),[R,O]=(0,r.useState)(null),[J,A]=(0,r.useState)({key:"name",direction:"asc"}),[P,T]=(0,r.useState)(""),[W,F]=(0,r.useState)(!1),[B,V]=(0,r.useState)({confirmOpen:!1,workspaceToDelete:null,deleting:!1,error:null}),[X,q]=(0,r.useState)({open:!1,message:"",userName:""}),[I,_]=(0,r.useState)(null),[H,K]=(0,r.useState)(!1),[U,$]=(0,r.useState)(null),[G,Q]=(0,r.useState)(null),Y=(0,a.useRouter)(),ee=(0,b.X)(),es=async()=>{if(I&&Date.now()-I.timestamp<3e5)return I;K(!0);try{let e=await C.x.get("/users/role");if(!e.ok){let s=await e.json();throw Error(s.detail||"Failed to get user role")}let s=await e.json(),l={role:s.role,name:s.name,timestamp:Date.now()};return _(l),K(!1),l}catch(e){throw K(!1),e}},el=async(e,s)=>{try{let l=await es();if("admin"!==l.role)return q({open:!0,message:e,userName:l.name.toLowerCase()}),!1;return s(),!0}catch(e){return console.error("Failed to check user role:",e),q({open:!0,message:"Error: ".concat(e.message),userName:""}),!1}},et=async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];e&&M(!0);try{let[e,l,t]=await Promise.all([N.default.get(c.fX),N.default.get(n.getClusters),N.default.get(i.getManagedJobs,[{allUsers:!0}])]);O(e);let r=Object.keys(e),a=await Promise.all(r.map(e=>N.default.get(c.yz,[e]))),o=Object.fromEntries(r.map((e,s)=>[e,a[s]]));Object.fromEntries(l.map(e=>[e.cluster,e.workspace||"default"]));let d={};r.forEach(e=>{d[e]={name:e,totalClusterCount:0,runningClusterCount:0,managedJobsCount:0,clouds:new Set}});let u=0;l.forEach(e=>{let s=e.workspace||"default";d[s]||(d[s]={name:s,totalClusterCount:0,runningClusterCount:0,managedJobsCount:0,clouds:new Set}),d[s].totalClusterCount++,("RUNNING"===e.status||"LAUNCHING"===e.status)&&(d[s].runningClusterCount++,u++),e.cloud&&d[s].clouds.add(e.cloud)});let m=t.jobs||[],x=new Set(w.statusGroups.active),h=0;m.forEach(e=>{let s=e.workspace||"default";d[s]&&x.has(e.status)&&d[s].managedJobsCount++,x.has(e.status)&&h++});let p=Object.values(d).filter(e=>r.includes(e.name)).map(e=>({...e,clouds:Array.isArray(o[e.name])?o[e.name]:[]})).sort((e,s)=>e.name.localeCompare(s.name));s(p),k({runningClusters:u,totalClusters:l.length,managedJobs:h})}catch(e){console.error("Error fetching workspace data:",e),s([]),k({runningClusters:0,totalClusters:0,managedJobs:0})}e&&M(!1)};(0,r.useEffect)(()=>{(async()=>{await y.ZP.preloadForPage("workspaces"),et(!0)})();let e=setInterval(()=>{et(!1)},E);return()=>clearInterval(e)},[]);let er=e=>{let s="asc";J.key===e&&"asc"===J.direction&&(s="desc"),A({key:e,direction:s})},ea=e=>J.key===e?"asc"===J.direction?" ↑":" ↓":"",en=r.useMemo(()=>{if(!e)return[];let s=e;if(P&&""!==P.trim()){let l=P.toLowerCase().trim();s=e.filter(e=>!!(e.name.toLowerCase().includes(l)||e.clouds.some(e=>{let s=S.Z2[e.toLowerCase()]||e;return e.toLowerCase().includes(l)||s.toLowerCase().includes(l)}))||!!(!0===((null==R?void 0:R[e.name])||{}).private?"private":"public").includes(l))}return(0,L.R0)(s,J.key,J.direction)},[e,J,P,R]),ei=e=>{el("cannot delete workspace",()=>{V({confirmOpen:!0,workspaceToDelete:e,deleting:!1,error:null})})},ec=async()=>{if(B.workspaceToDelete){V(e=>({...e,deleting:!0,error:null}));try{await (0,c.zl)(B.workspaceToDelete),Q('Workspace "'.concat(B.workspaceToDelete,'" deleted successfully!')),V({confirmOpen:!1,workspaceToDelete:null,deleting:!1,error:null}),N.default.invalidate(c.fX),await et(!0)}catch(e){console.error("Error deleting workspace:",e),V(e=>({...e,deleting:!1,error:null})),$(e)}}},eo=()=>{V({confirmOpen:!1,workspaceToDelete:null,deleting:!1,error:null})},ed=e=>{el("cannot edit workspace",()=>{Y.push("/workspaces/".concat(e))})};return z&&0===e.length?(0,t.jsxs)("div",{className:"flex justify-center items-center h-64",children:[(0,t.jsx)(m.Z,{}),(0,t.jsx)("span",{className:"ml-2 text-gray-500",children:"Loading workspaces..."})]}):(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"fixed top-20 right-4 z-[9999] max-w-md",children:[G&&(0,t.jsx)("div",{className:"bg-green-50 border border-green-200 rounded p-4 mb-4",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)("div",{className:"flex-shrink-0",children:(0,t.jsx)("svg",{className:"h-5 w-5 text-green-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})})}),(0,t.jsx)("div",{className:"ml-3",children:(0,t.jsx)("p",{className:"text-sm font-medium text-green-800",children:G})})]}),(0,t.jsx)("div",{className:"ml-auto pl-3",children:(0,t.jsxs)("button",{type:"button",onClick:()=>Q(null),className:"inline-flex rounded-md bg-green-50 p-1.5 text-green-500 hover:bg-green-100",children:[(0,t.jsx)("span",{className:"sr-only",children:"Dismiss"}),(0,t.jsx)("svg",{className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})]})})]})}),(0,t.jsx)(p.X,{error:U,title:"Error",onDismiss:()=>$(null)})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between mb-2 h-5",children:[(0,t.jsx)("div",{className:"text-base flex items-center",children:(0,t.jsx)("span",{className:"text-sky-blue leading-none",children:"Workspaces"})}),(0,t.jsxs)("div",{className:"flex items-center",children:[z&&(0,t.jsxs)("div",{className:"flex items-center mr-2",children:[(0,t.jsx)(m.Z,{size:15,className:"mt-0"}),(0,t.jsx)("span",{className:"ml-2 text-gray-500 text-xs",children:"Refreshing..."})]}),(0,t.jsxs)("button",{onClick:()=>{N.default.invalidate(c.fX),N.default.invalidate(n.getClusters),N.default.invalidate(i.getManagedJobs,[{allUsers:!0}]),N.default.invalidateFunction(c.yz),et(!0)},disabled:z,className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:[(0,t.jsx)(g.Z,{className:"h-4 w-4 mr-1.5"}),!ee&&(0,t.jsx)("span",{children:"Refresh"})]})]})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,t.jsxs)("div",{className:"relative flex-1 max-w-md",children:[(0,t.jsx)("input",{type:"text",placeholder:"Filter workspaces",value:P,onChange:e=>T(e.target.value),className:"h-8 w-full px-3 pr-8 text-sm border border-gray-300 rounded-md focus:ring-1 focus:ring-sky-500 focus:border-sky-500 outline-none"}),P&&(0,t.jsx)("button",{onClick:()=>T(""),className:"absolute right-2 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-gray-600",title:"Clear search",children:(0,t.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,t.jsx)("button",{onClick:()=>{el("cannot create workspace",()=>{Y.push("/workspace/new")})},disabled:H,className:"ml-4 bg-sky-600 hover:bg-sky-700 text-white flex items-center rounded-md px-3 py-1 text-sm font-medium transition-colors duration-200",title:"Create Workspace",children:H?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(m.Z,{size:12,className:"mr-2"}),(0,t.jsx)("span",{children:"Create Workspace"})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(f.Z,{className:"h-4 w-4 mr-2"}),"Create Workspace"]})})]}),0!==e.length||z?(0,t.jsx)(o.Zb,{children:(0,t.jsx)("div",{className:"overflow-x-auto rounded-lg",children:(0,t.jsxs)(d.iA,{className:"min-w-full",children:[(0,t.jsx)(d.xD,{children:(0,t.jsxs)(d.SC,{children:[(0,t.jsxs)(d.ss,{className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50",onClick:()=>er("name"),children:["Workspace",ea("name")]}),(0,t.jsxs)(d.ss,{className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 hidden sm:table-cell",onClick:()=>er("totalClusterCount"),children:["Clusters ",ea("totalClusterCount")]}),(0,t.jsxs)(d.ss,{className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 hidden md:table-cell",onClick:()=>er("managedJobsCount"),children:["Jobs",ea("managedJobsCount")]}),(0,t.jsx)(d.ss,{className:"whitespace-nowrap hidden lg:table-cell",children:"Enabled infra"}),(0,t.jsx)(d.ss,{className:"whitespace-nowrap",children:"Actions"})]})}),(0,t.jsx)(d.RM,{children:z&&0===en.length?(0,t.jsx)(d.SC,{children:(0,t.jsx)(d.pj,{colSpan:5,className:"text-center py-6 text-gray-500",children:(0,t.jsxs)("div",{className:"flex justify-center items-center",children:[(0,t.jsx)(m.Z,{size:20,className:"mr-2"}),(0,t.jsx)("span",{children:"Loading..."})]})})}):en.length>0?en.map(e=>{let s=!0===((null==R?void 0:R[e.name])||{}).private;return(0,t.jsxs)(d.SC,{className:"hover:bg-gray-50",children:[(0,t.jsxs)(d.pj,{className:"",children:[(0,t.jsx)("button",{onClick:()=>ed(e.name),disabled:H,className:"text-blue-600 hover:text-blue-600 hover:underline text-left",children:e.name}),(0,t.jsx)("span",{className:"ml-2",children:(0,t.jsx)(D,{isPrivate:s})})]}),(0,t.jsx)(d.pj,{className:"hidden sm:table-cell",children:(0,t.jsxs)("button",{onClick:()=>{Y.push({pathname:"/clusters",query:{workspace:e.name}})},className:"text-gray-700 hover:text-blue-600 hover:underline",children:[e.runningClusterCount," running,"," ",e.totalClusterCount," total"]})}),(0,t.jsx)(d.pj,{className:"hidden md:table-cell",children:(0,t.jsx)("button",{onClick:()=>{Y.push({pathname:"/jobs",query:{workspace:e.name}})},className:"text-gray-700 hover:text-blue-600 hover:underline",children:e.managedJobsCount})}),(0,t.jsx)(d.pj,{className:"hidden lg:table-cell",children:e.clouds.length>0?[...e.clouds].sort().map((s,l)=>{let r=S.Z2[s.toLowerCase()]||s;return(0,t.jsxs)("span",{children:[(0,t.jsx)(Z(),{href:"/infra",className:"inline-flex items-center px-2 py-1 rounded text-sm bg-sky-100 text-sky-800 hover:bg-sky-200 hover:text-sky-900 transition-colors duration-200",children:r}),l<e.clouds.length-1&&" "]},s)}):(0,t.jsx)("span",{className:"text-gray-500 text-sm",children:"-"})}),(0,t.jsxs)(d.pj,{children:[(0,t.jsx)(u.z,{variant:"ghost",size:"sm",onClick:()=>ed(e.name),disabled:H,className:"text-gray-600 hover:text-gray-800 mr-1",children:(0,t.jsx)(j,{className:"w-4 h-4"})}),(0,t.jsx)(u.z,{variant:"ghost",size:"sm",onClick:()=>ei(e.name),disabled:"default"===e.name||H,title:"default"===e.name?"Cannot delete default workspace":"Delete workspace",className:"text-red-600 hover:text-red-700 hover:bg-red-50",children:(0,t.jsx)(v.Z,{className:"w-4 h-4"})})]})]},e.name)}):(0,t.jsx)(d.SC,{children:(0,t.jsx)(d.pj,{colSpan:5,className:"text-center py-6 text-gray-500",children:"No workspaces found"})})})]})})}):(0,t.jsxs)("div",{className:"text-center py-10",children:[(0,t.jsx)("p",{className:"text-lg text-gray-600",children:"No workspaces found."}),(0,t.jsx)("p",{className:"text-sm text-gray-500 mt-2",children:"Create a cluster to see its workspace here."})]}),R&&(0,t.jsx)(h.Vq,{open:W,onOpenChange:F,children:(0,t.jsxs)(h.cZ,{className:"sm:max-w-md md:max-w-lg lg:max-w-xl xl:max-w-2xl w-full max-h-[90vh] flex flex-col",children:[(0,t.jsx)(h.fK,{children:(0,t.jsx)(h.$N,{className:"pr-10",children:"All Workspaces Configuration"})}),(0,t.jsx)("div",{className:"flex-grow overflow-y-auto py-4",children:(0,t.jsx)("pre",{style:{backgroundColor:"#f5f5f5",padding:"16px",borderRadius:"8px",overflowX:"auto",whiteSpace:"pre",wordBreak:"normal"},children:x.ZP.dump(R,{indent:2})})})]})}),(0,t.jsx)(h.Vq,{open:X.open,onOpenChange:e=>{q(s=>({...s,open:e})),e||$(null)},children:(0,t.jsxs)(h.cZ,{className:"sm:max-w-md transition-all duration-200 ease-in-out",children:[(0,t.jsxs)(h.fK,{children:[(0,t.jsx)(h.$N,{children:"Permission Denied"}),(0,t.jsx)(h.Be,{children:H?(0,t.jsxs)("div",{className:"flex items-center py-2",children:[(0,t.jsx)(m.Z,{size:16,className:"mr-2"}),(0,t.jsx)("span",{children:"Checking permissions..."})]}):(0,t.jsx)(t.Fragment,{children:X.userName?(0,t.jsxs)(t.Fragment,{children:[X.userName," is logged in as non-admin and ",X.message,"."]}):X.message})})]}),(0,t.jsx)(h.cN,{children:(0,t.jsx)(u.z,{variant:"outline",onClick:()=>q(e=>({...e,open:!1})),disabled:H,children:"OK"})})]})}),(0,t.jsx)(h.Vq,{open:B.confirmOpen,onOpenChange:e=>{e||(eo(),$(null))},children:(0,t.jsxs)(h.cZ,{className:"sm:max-w-md",children:[(0,t.jsxs)(h.fK,{children:[(0,t.jsx)(h.$N,{children:"Delete Workspace"}),(0,t.jsxs)(h.Be,{children:['Are you sure you want to delete workspace "',B.workspaceToDelete,'"? This action cannot be undone.']})]}),(0,t.jsxs)(h.cN,{children:[(0,t.jsx)(u.z,{variant:"outline",onClick:eo,disabled:B.deleting,children:"Cancel"}),(0,t.jsx)(u.z,{variant:"destructive",onClick:ec,disabled:B.deleting,children:B.deleting?"Deleting...":"Delete"})]})]})})]})}},1163:function(e,s,l){e.exports=l(6036)},2003:function(e,s,l){"use strict";l.d(s,{j:function(){return n}});var t=l(512);let r=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,a=t.W,n=(e,s)=>l=>{var t;if((null==s?void 0:s.variants)==null)return a(e,null==l?void 0:l.class,null==l?void 0:l.className);let{variants:n,defaultVariants:i}=s,c=Object.keys(n).map(e=>{let s=null==l?void 0:l[e],t=null==i?void 0:i[e];if(null===s)return null;let a=r(s)||r(t);return n[e][a]}),o=l&&Object.entries(l).reduce((e,s)=>{let[l,t]=s;return void 0===t||(e[l]=t),e},{});return a(e,c,null==s?void 0:null===(t=s.compoundVariants)||void 0===t?void 0:t.reduce((e,s)=>{let{class:l,className:t,...r}=s;return Object.entries(r).every(e=>{let[s,l]=e;return Array.isArray(l)?l.includes({...i,...o}[s]):({...i,...o})[s]===l})?[...e,l,t]:e},[]),null==l?void 0:l.class,null==l?void 0:l.className)}}}]);
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6990],{803:function(e,r,t){t.d(r,{z:function(){return i}});var o=t(5893),a=t(7294),n=t(8426),s=t(2003),c=t(2350);let l=(0,s.j)("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),i=a.forwardRef((e,r)=>{let{className:t,variant:a,size:s,asChild:i=!1,...u}=e,d=i?n.g7:"button";return(0,o.jsx)(d,{className:(0,c.cn)(l({variant:a,size:s,className:t})),ref:r,...u})});i.displayName="Button"},7673:function(e,r,t){t.d(r,{Ol:function(){return i},Zb:function(){return l},aY:function(){return f},ll:function(){return u}});var o=t(5893),a=t(7294),n=t(5697),s=t.n(n),c=t(2350);let l=a.forwardRef((e,r)=>{let{className:t,children:a,...n}=e;return(0,o.jsx)("div",{ref:r,className:(0,c.cn)("rounded-lg border bg-card text-card-foreground shadow-sm",t),...n,children:a})});l.displayName="Card",l.propTypes={className:s().string,children:s().node};let i=a.forwardRef((e,r)=>{let{className:t,children:a,...n}=e;return(0,o.jsx)("div",{ref:r,className:(0,c.cn)("flex flex-col space-y-1.5 p-6",t),...n,children:a})});i.displayName="CardHeader",i.propTypes={className:s().string,children:s().node};let u=a.forwardRef((e,r)=>{let{className:t,children:a,...n}=e;return(0,o.jsx)("h3",{ref:r,className:(0,c.cn)("text-2xl font-semibold leading-none tracking-tight",t),...n,children:a})});u.displayName="CardTitle",u.propTypes={className:s().string,children:s().node};let d=a.forwardRef((e,r)=>{let{className:t,children:a,...n}=e;return(0,o.jsx)("p",{ref:r,className:(0,c.cn)("text-sm text-muted-foreground",t),...n,children:a})});d.displayName="CardDescription",d.propTypes={className:s().string,children:s().node};let f=a.forwardRef((e,r)=>{let{className:t,children:a,...n}=e;return(0,o.jsx)("div",{ref:r,className:(0,c.cn)("p-6 pt-0",t),...n,children:a})});f.displayName="CardContent",f.propTypes={className:s().string,children:s().node};let p=a.forwardRef((e,r)=>{let{className:t,children:a,...n}=e;return(0,o.jsx)("div",{ref:r,className:(0,c.cn)("flex items-center p-6 pt-0",t),...n,children:a})});p.displayName="CardFooter",p.propTypes={className:s().string,children:s().node}},7145:function(e,r,t){t.d(r,{x:function(){return a}});var o=t(3225);let a={fetch:async function(e,r){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"POST",a=window.location.origin,n="".concat(a).concat(o.f4).concat(e),s=await fetch(n,{method:t,headers:"POST"===t?{"Content-Type":"application/json"}:{},body:"POST"===t?JSON.stringify(r):void 0}),c=s.headers.get("X-Skypilot-Request-ID")||s.headers.get("X-Request-ID"),l=await fetch("".concat(a).concat(o.f4,"/api/get?request_id=").concat(c)),i=await l.json();return i.return_value?JSON.parse(i.return_value):[]},post:async(e,r)=>{let t=window.location.origin,a="".concat(t).concat(o.f4).concat(e);return await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})},stream:async(e,r,t)=>{let o=(await a.post(e,r)).body.getReader();try{for(;;){let{done:e,value:r}=await o.read();if(e)break;let a=new TextDecoder().decode(r);t(a)}}catch(e){throw console.error("Error in stream:",e),e}},get:async e=>{let r=window.location.origin,t="".concat(r).concat(o.f4).concat(e);return await fetch(t)}}},7324:function(e,r,t){t.d(r,{MB:function(){return l},eA:function(){return c},fX:function(){return a},iE:function(){return u},rF:function(){return d},yz:function(){return n},zl:function(){return i}});var o=t(7145);async function a(){try{let e=await o.x.get("/workspaces");if(!e.ok)throw Error("Error scheduling getWorkspaces: ".concat(e.statusText," (status ").concat(e.status,")"));let r=e.headers.get("X-Skypilot-Request-ID");if(!r){console.warn("X-Skypilot-Request-ID header not found in /workspaces response. Attempting to find request_id in response body as a fallback.");try{let t=await e.json();if(t&&t.request_id)r=t.request_id,console.log("Found request_id in /workspaces response body (fallback):",r);else throw Error("X-Skypilot-Request-ID header not found AND request_id not found in parsed response body from /workspaces.")}catch(r){let e=r.message||"Error processing fallback for request_id from /workspaces response body.";throw console.error("Error in /workspaces request_id fallback logic:",e),Error("X-Skypilot-Request-ID header not found, and fallback to read request_id from body failed: ".concat(e))}}if(!r)throw Error("Failed to obtain X-Skypilot-Request-ID from /workspaces response (checked header and attempted body fallback, but ID is still missing).");console.log("Fetching workspace data with request_id: ".concat(r));let t=await o.x.get("/api/get?request_id=".concat(r));if(!t.ok){let e="Error fetching workspace data for request ID ".concat(r,": ").concat(t.statusText," (status ").concat(t.status,")");try{let o=await t.json();if(o&&o.detail){let t=o.detail;try{let e=JSON.parse(t);e&&e.error?t=e.error:e&&e.result&&e.result.error&&(t=e.result.error)}catch(e){}e="Error fetching workspace data for request ID ".concat(r,": ").concat(t)}}catch(e){}throw Error(e)}let a=await t.json();if(console.log("[Connector Debug] Full resultData from /api/get:",a),"FAILED"===a.status){let e="Unknown error during task execution";if(a.error)"string"==typeof a.error?e=a.error:"object"==typeof a.error&&(e=a.error.message||a.error.detail||JSON.stringify(a.error));else if(a.result&&a.result.error)"string"==typeof a.result.error?e=a.result.error:"object"==typeof a.result.error&&(e=a.result.error.message||a.result.error.detail||JSON.stringify(a.result.error));else if(a.return_value)try{let r=JSON.parse(a.return_value);r.error&&(e="string"==typeof r.error?r.error:r.error.message||r.error.detail||JSON.stringify(r.error))}catch(r){(a.return_value.includes("Error")||a.return_value.includes("Cannot"))&&(e=a.return_value)}throw Error(e)}let n={};if("SUCCEEDED"===a.status&&a.return_value)try{n=JSON.parse(a.return_value),console.log("Successfully parsed workspace data from return_value:",n)}catch(e){throw console.error("Failed to parse workspace data from return_value:",e,"Raw return_value:",a.return_value),Error("Failed to parse workspace data for request ID ".concat(r,": ").concat(e.message))}else a.result&&(console.warn("Using resultData.result as fallback for status ".concat(a.status)),n=a.result);return console.log("Effectively fetched workspace data (to be returned):",n),n||{}}catch(e){throw console.error("Failed to fetch workspaces (in getWorkspaces function):",e.message,e.stack),e}}async function n(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];try{let t="/enabled_clouds",a=new URLSearchParams;e&&a.append("workspace",e),r&&a.append("expand","true"),a.toString()&&(t+="?".concat(a.toString()));let n=await o.x.get(t);if(!n.ok)throw Error("Error scheduling getEnabledClouds: ".concat(n.statusText," (status ").concat(n.status,")"));let s=n.headers.get("X-Skypilot-Request-ID");if(!s){console.warn("X-Skypilot-Request-ID header not found in /enabled_clouds response. Attempting to find request_id in response body as a fallback.");try{let e=await n.json();if(e&&e.request_id)s=e.request_id,console.log("Found request_id in /enabled_clouds response body (fallback):",s);else throw Error("X-Skypilot-Request-ID header not found AND request_id not found in parsed response body from /enabled_clouds.")}catch(r){let e=r.message||"Error processing fallback for request_id from /enabled_clouds response body.";throw console.error("Error in /enabled_clouds request_id fallback logic:",e),Error("X-Skypilot-Request-ID header not found, and fallback to read request_id from body failed: ".concat(e))}}if(!s)throw Error("Failed to obtain X-Skypilot-Request-ID from /enabled_clouds response (checked header and attempted body fallback, but ID is still missing).");console.log("Fetching enabled_clouds data with request_id: ".concat(s));let c=await o.x.get("/api/get?request_id=".concat(s));if(!c.ok){let e="Error fetching enabled_clouds data for request ID ".concat(s,": ").concat(c.statusText," (status ").concat(c.status,")");try{let r=await c.json();if(r&&r.detail){let t=r.detail;try{let e=JSON.parse(t);e&&e.error?t=e.error:e&&e.result&&e.result.error&&(t=e.result.error)}catch(e){}e="Error fetching enabled_clouds data for request ID ".concat(s,": ").concat(t)}}catch(e){}throw Error(e)}let l=await c.json();if(console.log("[Connector Debug] Full resultData from /api/get for enabled_clouds:",l),"FAILED"===l.status){let e=l.error||l.result&&l.result.error||"Unknown error during task execution for enabled_clouds";throw Error("Fetching enabled_clouds data failed for request ID ".concat(s,": ").concat(e))}let i=[];if("SUCCEEDED"===l.status&&l.return_value)try{i=JSON.parse(l.return_value),console.log("Successfully parsed enabled_clouds data from return_value:",i)}catch(e){throw console.error("Failed to parse enabled_clouds data from return_value:",e,"Raw return_value:",l.return_value),Error("Failed to parse enabled_clouds data for request ID ".concat(s,": ").concat(e.message))}else l.result&&(console.warn("Using resultData.result as fallback for enabled_clouds status ".concat(l.status)),i=l.result);return Array.isArray(i)?i:[]}catch(e){throw console.error("Failed to fetch enabled_clouds (in getEnabledClouds function):",e.message,e.stack),e}}async function s(e,r){console.log("Polling for ".concat(r," task completion with request_id: ").concat(e));let t=await o.x.get("/api/get?request_id=".concat(e));if(!t.ok){let o="Error fetching ".concat(r," data for request ID ").concat(e,": ").concat(t.statusText," (status ").concat(t.status,")");try{let e=await t.json();if(console.error("[Error Debug] ".concat(r," HTTP error response:"),JSON.stringify(e,null,2)),e&&e.detail){if("object"==typeof e.detail&&e.detail.error)try{let t=JSON.parse(e.detail.error);if(t&&t.message)o="".concat(r," failed: ").concat(t.message);else if(t&&"object"==typeof t){let e=t.type||JSON.stringify(t);o="".concat(r," failed: ").concat(e)}}catch(t){o="".concat(r," failed: ").concat(e.detail.error)}else if("string"==typeof e.detail)o="".concat(r," failed: ").concat(e.detail);else{let t=function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if("string"==typeof e&&(e.includes("Cannot")||e.includes("Error")||e.includes("Failed")))return e;if("object"==typeof e&&null!==e)for(let[o,a]of Object.entries(e)){let e=t(a,r?"".concat(r,".").concat(o):o);if(e)return e}return null},a=t(e.detail);a&&(o="".concat(r," failed: ").concat(a))}}}catch(e){console.error("[Error Debug] Failed to parse error response:",e)}throw Error(o)}let a=await t.json();if(console.log("[Connector Debug] ".concat(r," resultData:"),a),"FAILED"===a.status){console.error("[Error Debug] ".concat(r," failed. Full resultData:"),JSON.stringify(a,null,2)),console.error("[Error Debug] resultData.error:",a.error),console.error("[Error Debug] resultData.result:",a.result),console.error("[Error Debug] resultData.return_value:",a.return_value);let e="Unknown error during ".concat(r," task execution");if(a.error)"string"==typeof a.error?e=a.error:"object"==typeof a.error&&(e=a.error.message||a.error.detail||JSON.stringify(a.error));else if(a.result&&a.result.error)"string"==typeof a.result.error?e=a.result.error:"object"==typeof a.result.error&&(e=a.result.error.message||a.result.error.detail||JSON.stringify(a.result.error));else if(a.return_value)try{let r=JSON.parse(a.return_value);r.error&&(e="string"==typeof r.error?r.error:r.error.message||r.error.detail||JSON.stringify(r.error))}catch(r){a.return_value&&(a.return_value.includes("Error")||a.return_value.includes("Cannot"))&&(e=a.return_value)}if(e==="Unknown error during ".concat(r," task execution")){let r=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if("string"==typeof e&&(e.includes("Cannot")||e.includes("Error")||e.includes("Failed")))return e;if("object"==typeof e&&null!==e)for(let[o,a]of Object.entries(e)){let e=r(a,t?"".concat(t,".").concat(o):o);if(e)return e}return null},t=r(a);t&&(e=t)}throw Error(e)}let n={};if("SUCCEEDED"===a.status&&a.return_value)try{n=JSON.parse(a.return_value),console.log("Successfully parsed ".concat(r," data:"),n)}catch(t){throw console.error("Failed to parse ".concat(r," data from return_value:"),t,"Raw return_value:",a.return_value),Error("Failed to parse ".concat(r," data for request ID ").concat(e,": ").concat(t.message))}else a.result&&(console.warn("Using resultData.result as fallback for ".concat(r," status ").concat(a.status)),n=a.result);return n}async function c(e,r){try{console.log("Updating workspace ".concat(e," with config:"),r);let t=await o.x.post("/workspaces/update",{workspace_name:e,config:r});if(!t.ok)throw Error("Error scheduling updateWorkspace: ".concat(t.statusText," (status ").concat(t.status,")"));let a=t.headers.get("X-Skypilot-Request-ID");if(!a)throw Error("Failed to obtain request ID for updateWorkspace");return await s(a,"updateWorkspace")}catch(e){throw console.error("Failed to update workspace:",e),e}}let l=async(e,r)=>{try{let t=await o.x.post("/workspaces/create",{workspace_name:e,config:r});if(!t.ok)throw await t.text(),Error("Error scheduling createWorkspace: ".concat(t.statusText," (status ").concat(t.status,")"));let a=t.headers.get("X-Skypilot-Request-ID");if(!a)throw Error("Failed to obtain request ID for createWorkspace");return await s(a,"createWorkspace")}catch(e){throw console.error("Failed to create workspace:",e),e}};async function i(e){try{console.log("Deleting workspace ".concat(e));let r=await o.x.post("/workspaces/delete",{workspace_name:e});if(!r.ok)throw Error("Error scheduling deleteWorkspace: ".concat(r.statusText," (status ").concat(r.status,")"));let t=r.headers.get("X-Skypilot-Request-ID");if(!t)throw Error("Failed to obtain request ID for deleteWorkspace");console.log("[Delete Debug] Got request ID for deleteWorkspace: ".concat(t));try{let e=await s(t,"deleteWorkspace");return console.log("[Delete Debug] deleteWorkspace completed successfully:",e),e}catch(e){throw console.error("[Delete Debug] deleteWorkspace failed with error:",e),console.error("[Delete Debug] Error message:",e.message),e}}catch(e){throw console.error("Failed to delete workspace:",e),e}}async function u(){try{console.log("Getting entire SkyPilot configuration");let e=await o.x.get("/workspaces/config");if(!e.ok)throw Error("Error scheduling getConfig: ".concat(e.statusText," (status ").concat(e.status,")"));let r=e.headers.get("X-Skypilot-Request-ID");if(!r)throw Error("Failed to obtain request ID for getConfig");return await s(r,"getConfig")}catch(e){throw console.error("Failed to get config:",e),e}}async function d(e){try{console.log("Updating entire SkyPilot configuration with config:",e);let r=await o.x.post("/workspaces/config",{config:e});if(!r.ok)throw Error("Error scheduling updateConfig: ".concat(r.statusText," (status ").concat(r.status,")"));let t=r.headers.get("X-Skypilot-Request-ID");if(!t)throw Error("Failed to obtain request ID for updateConfig");return await s(t,"updateConfig")}catch(e){throw console.error("Failed to update config:",e),e}}},2350:function(e,r,t){t.d(r,{cn:function(){return n}});var o=t(512),a=t(8388);function n(){for(var e=arguments.length,r=Array(e),t=0;t<e;t++)r[t]=arguments[t];return(0,a.m6)((0,o.W)(r))}}}]);
|
@@ -3,4 +3,4 @@
|
|
3
3
|
*
|
4
4
|
* This source code is licensed under the ISC license.
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
6
|
-
*/let t=(0,r(998).Z)("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]])},4042:function(e,n,r){"use strict";r.r(n),r.d(n,{Config:function(){return g}});var t=r(5893),s=r(7294),l=r(1163),a=r(803),i=r(7673),o=r(7324),c=r(1812),u=r(5739),d=r(9333),m=r(1272),f=r(6989),x=r(7145);function h(){let[e,n]=(0,s.useState)(null),[r,l]=(0,s.useState)(null),a=async()=>{let e=await x.x.get("/api/health"),r=await e.json();r.version&&n(r.version),r.commit&&l(r.commit)};return((0,s.useEffect)(()=>{a()},[]),e)?(0,t.jsx)(f.Md,{content:r?"Commit: ".concat(r):"Commit information not available",className:"text-sm text-muted-foreground",children:(0,t.jsxs)("div",{className:"text-sm text-gray-500 cursor-help border-b border-dotted border-gray-400 inline-block",children:["Version: ",e]})}):null}var v=r(7853);function g(){let e=(0,l.useRouter)(),[n,r]=(0,s.useState)(""),[f,g]=(0,s.useState)(!0),[p,j]=(0,s.useState)(!1),[b,y]=(0,s.useState)(null),[w,N]=(0,s.useState)(!1),[k,C]=(0,s.useState)(!1),L=(0,s.useRef)(null);(0,s.useEffect)(()=>{A(),(async()=>{C(await (0,v.TO)())})()},[]),(0,s.useEffect)(()=>()=>{L.current&&clearTimeout(L.current)},[]);let A=async()=>{g(!0),y(null);try{let e=await (0,o.iE)();0===Object.keys(e).length?r(""):r(m.ZP.dump(e,{indent:2}))}catch(e){console.error("Error loading config:",e),y(e)}finally{g(!1)}},S=async()=>{j(!0),y(null),L.current&&(clearTimeout(L.current),L.current=null);try{let e=await x.x.get("/users/role");if(!e.ok){let n=await e.json();throw Error(n.detail||"Failed to get user role")}let r=await e.json(),t=r.role;if("admin"!=t){y(Error("".concat(r.name," is logged in as non-admin and cannot edit config"))),j(!1);return}let s=m.ZP.load(n);if(null==s&&(s={}),"object"!=typeof s||Array.isArray(s)){let e="Invalid config structure: Configuration must be a mapping (key-value pairs) in YAML format.";Array.isArray(s),e="Invalid config structure: Configuration must be a mapping (key-value pairs) in YAML format.",y(Error(e)),j(!1);return}await (0,o.rF)(s),N(!0),L.current=setTimeout(()=>{N(!1),L.current=null},5e3)}catch(e){console.error("Error saving config:",e),y(e)}finally{j(!1)}};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4 h-5",children:[(0,t.jsx)("div",{className:"text-base flex items-center",children:(0,t.jsx)("span",{className:"text-sky-blue",children:"SkyPilot API Server"})}),(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)("div",{className:"text-sm flex items-center",children:(f||p)&&(0,t.jsxs)("div",{className:"flex items-center mr-4",children:[(0,t.jsx)(u.Z,{size:15,className:"mt-0"}),(0,t.jsx)("span",{className:"ml-2 text-gray-500",children:p?"Applying...":"Loading..."})]})}),k&&(0,t.jsxs)("button",{onClick:()=>{let e=(0,v.ki)(),n=window.location.hostname;window.open("".concat(e,"/d/skypilot-apiserver-overview/skypilot-api-server?orgId=1&from=now-1h&to=now&timezone=browser&var-app=").concat(n),"_blank")},className:"inline-flex items-center px-3 py-2 text-sm font-medium text-white bg-sky-blue-bright border border-transparent rounded-md shadow-sm hover:bg-sky-blue focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-sky-blue mr-4",children:[(0,t.jsx)("svg",{className:"w-4 h-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})}),"View API Server Metrics"]}),(0,t.jsx)(h,{})]})]}),(0,t.jsxs)(i.Zb,{className:"w-full",children:[(0,t.jsx)(i.Ol,{children:(0,t.jsx)(i.ll,{className:"text-base font-normal flex items-center justify-between",children:(0,t.jsx)("span",{children:"Edit SkyPilot API Server Configuration"})})}),(0,t.jsxs)(i.aY,{className:"space-y-4",children:[(0,t.jsxs)("p",{className:"text-sm text-gray-600 mb-3",children:["Refer to the"," ",(0,t.jsx)("a",{href:"https://docs.skypilot.co/en/latest/reference/config.html",target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline",children:"SkyPilot Docs"})," ","for details. The configuration should be in YAML format."]}),w&&(0,t.jsx)("div",{className:"bg-green-50 border border-green-200 rounded p-4 mb-6",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)("div",{className:"flex-shrink-0",children:(0,t.jsx)("svg",{className:"h-5 w-5 text-green-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})})}),(0,t.jsx)("div",{className:"ml-3",children:(0,t.jsx)("p",{className:"text-sm font-medium text-green-800",children:"Configuration saved successfully!"})})]}),(0,t.jsx)("div",{className:"ml-auto pl-3",children:(0,t.jsx)("div",{className:"-mx-1.5 -my-1.5",children:(0,t.jsxs)("button",{type:"button",onClick:()=>{N(!1),L.current&&(clearTimeout(L.current),L.current=null)},className:"inline-flex rounded-md bg-green-50 p-1.5 text-green-500 hover:bg-green-100 focus:outline-none focus:ring-2 focus:ring-green-600 focus:ring-offset-2 focus:ring-offset-green-50",children:[(0,t.jsx)("span",{className:"sr-only",children:"Dismiss"}),(0,t.jsx)("svg",{className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})]})})})]})}),b&&(0,t.jsx)("div",{className:"mb-6",children:(0,t.jsx)(c.X,{error:b,title:"Failed to apply new configuration",onDismiss:()=>y(null)})}),(0,t.jsx)("div",{className:"w-full",children:(0,t.jsx)("textarea",{value:n,onChange:e=>r(e.target.value),className:"w-full h-96 p-3 border border-gray-300 rounded font-mono text-sm resize-vertical focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:f?"Loading configuration...":"# Enter SkyPilot configuration in YAML format\n# Example:\n# kubernetes:\n# allowed_contexts: [default, my-context]",disabled:f||p})}),(0,t.jsxs)("div",{className:"flex justify-end space-x-3 pt-3",children:[(0,t.jsx)(a.z,{variant:"outline",onClick:()=>{e.push("/workspaces")},disabled:p,children:"Cancel"}),(0,t.jsx)(a.z,{onClick:S,disabled:f||p,className:"inline-flex items-center bg-blue-600 hover:bg-blue-700 text-white",children:p?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(u.Z,{size:16,className:"mr-2"}),"Applying..."]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(d.Z,{className:"w-4 h-4 mr-1.5"}),"Apply"]})})]})]})]})]})}},1812:function(e,n,r){"use strict";r.d(n,{X:function(){return a}});var t=r(5893),s=r(7294);let l=e=>{if(!(null==e?void 0:e.message))return"An unexpected error occurred.";let n=e.message;return n.includes("failed:")&&(n=n.split("failed:")[1].trim()),n},a=e=>{let{error:n,title:r="Error",onDismiss:a}=e,[i,o]=(0,s.useState)(!1);if((0,s.useEffect)(()=>{n&&o(!1)},[n]),!n||i)return null;let c="string"==typeof n?n:l(n);return(0,t.jsx)("div",{className:"bg-red-50 border border-red-200 rounded-md p-3 mb-4",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex",children:[(0,t.jsx)("div",{className:"flex-shrink-0",children:(0,t.jsx)("svg",{className:"h-5 w-5 text-red-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})})}),(0,t.jsx)("div",{className:"ml-3",children:(0,t.jsxs)("div",{className:"text-sm text-red-800",children:[(0,t.jsxs)("strong",{children:[r,":"]})," ",c]})})]}),(0,t.jsx)("button",{onClick:()=>{o(!0),a&&a()},className:"flex-shrink-0 ml-4 text-red-400 hover:text-red-600 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2 focus:ring-offset-red-50 rounded","aria-label":"Dismiss error",children:(0,t.jsx)("svg",{className:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]})})}},7853:function(e,n,r){"use strict";r.d(n,{TO:function(){return l},ki:function(){return a}});let t=null,s=null,l=async()=>null!==t?t:s||(s=(async()=>{try{let e="".concat(window.location.origin,"/grafana"),n=await fetch("".concat(e,"/api/health"),{method:"GET",credentials:"include",headers:{Accept:"application/json"},signal:AbortSignal.timeout(5e3)});return 200==n.status}catch(e){return console.debug("Grafana availability check failed:",e),t=!1,!1}finally{s=null}})()),a=()=>"".concat(window.location.origin,"/grafana")},1163:function(e,n,r){e.exports=r(6036)},2003:function(e,n,r){"use strict";r.d(n,{j:function(){return a}});var t=r(512);let s=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,l=t.W,a=(e,n)=>r=>{var t;if((null==n?void 0:n.variants)==null)return l(e,null==r?void 0:r.class,null==r?void 0:r.className);let{variants:a,defaultVariants:i}=n,o=Object.keys(a).map(e=>{let n=null==r?void 0:r[e],t=null==i?void 0:i[e];if(null===n)return null;let l=s(n)||s(t);return a[e][l]}),c=r&&Object.entries(r).reduce((e,n)=>{let[r,t]=n;return void 0===t||(e[r]=t),e},{});return l(e,o,null==n?void 0:null===(t=n.compoundVariants)||void 0===t?void 0:t.reduce((e,n)=>{let{class:r,className:t,...s}=n;return Object.entries(s).every(e=>{let[n,r]=e;return Array.isArray(r)?r.includes({...i,...c}[n]):({...i,...c})[n]===r})?[...e,r,t]:e},[]),null==r?void 0:r.class,null==r?void 0:r.className)}}}]);
|
6
|
+
*/let t=(0,r(998).Z)("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]])},4042:function(e,n,r){"use strict";r.r(n),r.d(n,{Config:function(){return g}});var t=r(5893),s=r(7294),l=r(1163),a=r(803),i=r(7673),o=r(7324),c=r(1812),u=r(5739),d=r(9333),m=r(1272),f=r(6989),x=r(7145);function h(){let[e,n]=(0,s.useState)(null),[r,l]=(0,s.useState)(null),a=async()=>{let e=await x.x.get("/api/health"),r=await e.json();r.version&&n(r.version),r.commit&&l(r.commit)};return((0,s.useEffect)(()=>{a()},[]),e)?(0,t.jsx)(f.Md,{content:r?"Commit: ".concat(r):"Commit information not available",className:"text-sm text-muted-foreground",children:(0,t.jsxs)("div",{className:"text-sm text-gray-500 cursor-help border-b border-dotted border-gray-400 inline-block",children:["Version: ",e]})}):null}var v=r(7853);function g(){let e=(0,l.useRouter)(),[n,r]=(0,s.useState)(""),[f,g]=(0,s.useState)(!0),[p,j]=(0,s.useState)(!1),[b,y]=(0,s.useState)(null),[w,N]=(0,s.useState)(!1),[k,C]=(0,s.useState)(!1),L=(0,s.useRef)(null);(0,s.useEffect)(()=>{A(),(async()=>{C(await (0,v.TO)())})()},[]),(0,s.useEffect)(()=>()=>{L.current&&clearTimeout(L.current)},[]);let A=async()=>{g(!0),y(null);try{let e=await (0,o.iE)();0===Object.keys(e).length?r(""):r(m.ZP.dump(e,{indent:2}))}catch(e){console.error("Error loading config:",e),y(e)}finally{g(!1)}},S=async()=>{j(!0),y(null),L.current&&(clearTimeout(L.current),L.current=null);try{let e=await x.x.get("/users/role");if(!e.ok){let n=await e.json();throw Error(n.detail||"Failed to get user role")}let r=await e.json(),t=r.role;if("admin"!=t){y(Error("".concat(r.name," is logged in as non-admin and cannot edit config"))),j(!1);return}let s=m.ZP.load(n);if(null==s&&(s={}),"object"!=typeof s||Array.isArray(s)){let e="Invalid config structure: Configuration must be a mapping (key-value pairs) in YAML format.";Array.isArray(s),e="Invalid config structure: Configuration must be a mapping (key-value pairs) in YAML format.",y(Error(e)),j(!1);return}await (0,o.rF)(s),N(!0),L.current=setTimeout(()=>{N(!1),L.current=null},5e3)}catch(e){console.error("Error saving config:",e),y(e)}finally{j(!1)}};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4 h-5",children:[(0,t.jsx)("div",{className:"text-base flex items-center",children:(0,t.jsx)("span",{className:"text-sky-blue",children:"SkyPilot API Server"})}),(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)("div",{className:"text-sm flex items-center",children:(f||p)&&(0,t.jsxs)("div",{className:"flex items-center mr-4",children:[(0,t.jsx)(u.Z,{size:15,className:"mt-0"}),(0,t.jsx)("span",{className:"ml-2 text-gray-500",children:p?"Applying...":"Loading..."})]})}),k&&(0,t.jsxs)("button",{onClick:()=>{let e=(0,v.ki)(),n=window.location.hostname;window.open("".concat(e,"/d/skypilot-apiserver-overview/skypilot-api-server?orgId=1&from=now-1h&to=now&timezone=browser&var-app=").concat(n),"_blank")},className:"inline-flex items-center px-3 py-2 text-sm font-medium text-white bg-sky-blue-bright border border-transparent rounded-md shadow-sm hover:bg-sky-blue focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-sky-blue mr-4",children:[(0,t.jsx)("svg",{className:"w-4 h-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})}),"View API Server Metrics"]}),(0,t.jsx)(h,{})]})]}),(0,t.jsxs)(i.Zb,{className:"w-full",children:[(0,t.jsx)(i.Ol,{children:(0,t.jsx)(i.ll,{className:"text-base font-normal flex items-center justify-between",children:(0,t.jsx)("span",{children:"Edit SkyPilot API Server Configuration"})})}),(0,t.jsxs)(i.aY,{className:"space-y-4",children:[(0,t.jsxs)("p",{className:"text-sm text-gray-600 mb-3",children:["Refer to the"," ",(0,t.jsx)("a",{href:"https://docs.skypilot.co/en/latest/reference/config.html",target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline",children:"SkyPilot Docs"})," ","for details. The configuration should be in YAML format."]}),w&&(0,t.jsx)("div",{className:"bg-green-50 border border-green-200 rounded p-4 mb-6",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)("div",{className:"flex-shrink-0",children:(0,t.jsx)("svg",{className:"h-5 w-5 text-green-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})})}),(0,t.jsx)("div",{className:"ml-3",children:(0,t.jsx)("p",{className:"text-sm font-medium text-green-800",children:"Configuration saved successfully!"})})]}),(0,t.jsx)("div",{className:"ml-auto pl-3",children:(0,t.jsx)("div",{className:"-mx-1.5 -my-1.5",children:(0,t.jsxs)("button",{type:"button",onClick:()=>{N(!1),L.current&&(clearTimeout(L.current),L.current=null)},className:"inline-flex rounded-md bg-green-50 p-1.5 text-green-500 hover:bg-green-100 focus:outline-none focus:ring-2 focus:ring-green-600 focus:ring-offset-2 focus:ring-offset-green-50",children:[(0,t.jsx)("span",{className:"sr-only",children:"Dismiss"}),(0,t.jsx)("svg",{className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})]})})})]})}),b&&(0,t.jsx)("div",{className:"mb-6",children:(0,t.jsx)(c.X,{error:b,title:"Failed to apply new configuration",onDismiss:()=>y(null)})}),(0,t.jsx)("div",{className:"w-full",children:(0,t.jsx)("textarea",{value:n,onChange:e=>r(e.target.value),className:"w-full h-96 p-3 border border-gray-300 rounded font-mono text-sm resize-vertical focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:f?"Loading configuration...":"# Enter SkyPilot configuration in YAML format\n# Example:\n# kubernetes:\n# allowed_contexts: [default, my-context]",disabled:f||p})}),(0,t.jsxs)("div",{className:"flex justify-end space-x-3 pt-3",children:[(0,t.jsx)(a.z,{variant:"outline",onClick:()=>{e.push("/workspaces")},disabled:p,children:"Cancel"}),(0,t.jsx)(a.z,{onClick:S,disabled:f||p,className:"inline-flex items-center bg-sky-600 hover:bg-sky-700 text-white",children:p?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(u.Z,{size:16,className:"mr-2"}),"Applying..."]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(d.Z,{className:"w-4 h-4 mr-1.5"}),"Apply"]})})]})]})]})]})}},1812:function(e,n,r){"use strict";r.d(n,{X:function(){return a}});var t=r(5893),s=r(7294);let l=e=>{if(!(null==e?void 0:e.message))return"An unexpected error occurred.";let n=e.message;return n.includes("failed:")&&(n=n.split("failed:")[1].trim()),n},a=e=>{let{error:n,title:r="Error",onDismiss:a}=e,[i,o]=(0,s.useState)(!1);if((0,s.useEffect)(()=>{n&&o(!1)},[n]),!n||i)return null;let c="string"==typeof n?n:l(n);return(0,t.jsx)("div",{className:"bg-red-50 border border-red-200 rounded-md p-3 mb-4",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex",children:[(0,t.jsx)("div",{className:"flex-shrink-0",children:(0,t.jsx)("svg",{className:"h-5 w-5 text-red-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})})}),(0,t.jsx)("div",{className:"ml-3",children:(0,t.jsxs)("div",{className:"text-sm text-red-800",children:[(0,t.jsxs)("strong",{children:[r,":"]})," ",c]})})]}),(0,t.jsx)("button",{onClick:()=>{o(!0),a&&a()},className:"flex-shrink-0 ml-4 text-red-400 hover:text-red-600 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2 focus:ring-offset-red-50 rounded","aria-label":"Dismiss error",children:(0,t.jsx)("svg",{className:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]})})}},7853:function(e,n,r){"use strict";r.d(n,{TO:function(){return l},ki:function(){return a}});let t=null,s=null,l=async()=>null!==t?t:s||(s=(async()=>{try{let e="".concat(window.location.origin,"/grafana"),n=await fetch("".concat(e,"/api/health"),{method:"GET",credentials:"include",headers:{Accept:"application/json"},signal:AbortSignal.timeout(5e3)});return 200==n.status}catch(e){return console.debug("Grafana availability check failed:",e),t=!1,!1}finally{s=null}})()),a=()=>"".concat(window.location.origin,"/grafana")},1163:function(e,n,r){e.exports=r(6036)},2003:function(e,n,r){"use strict";r.d(n,{j:function(){return a}});var t=r(512);let s=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,l=t.W,a=(e,n)=>r=>{var t;if((null==n?void 0:n.variants)==null)return l(e,null==r?void 0:r.class,null==r?void 0:r.className);let{variants:a,defaultVariants:i}=n,o=Object.keys(a).map(e=>{let n=null==r?void 0:r[e],t=null==i?void 0:i[e];if(null===n)return null;let l=s(n)||s(t);return a[e][l]}),c=r&&Object.entries(r).reduce((e,n)=>{let[r,t]=n;return void 0===t||(e[r]=t),e},{});return l(e,o,null==n?void 0:null===(t=n.compoundVariants)||void 0===t?void 0:t.reduce((e,n)=>{let{class:r,className:t,...s}=n;return Object.entries(s).every(e=>{let[n,r]=e;return Array.isArray(r)?r.includes({...i,...c}[n]):({...i,...c})[n]===r})?[...e,r,t]:e},[]),null==r?void 0:r.class,null==r?void 0:r.className)}}}]);
|