skypilot-nightly 1.0.0.dev20251022__py3-none-any.whl → 1.0.0.dev20251024__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.

Potentially problematic release.


This version of skypilot-nightly might be problematic. Click here for more details.

Files changed (70) hide show
  1. sky/__init__.py +2 -2
  2. sky/client/cli/command.py +118 -30
  3. sky/client/cli/table_utils.py +14 -8
  4. sky/dashboard/out/404.html +1 -1
  5. sky/dashboard/out/_next/static/{IgACOQPupLbX9z-RYVEDx → KxZarRnMeQID-gZkBfhzv}/_buildManifest.js +1 -1
  6. sky/dashboard/out/_next/static/chunks/1141-145e542070a6b615.js +11 -0
  7. sky/dashboard/out/_next/static/chunks/1871-5f68bb683940d23f.js +6 -0
  8. sky/dashboard/out/_next/static/chunks/2755.210d4b7c92c6efb2.js +26 -0
  9. sky/dashboard/out/_next/static/chunks/3015-2dcace420c8939f4.js +1 -0
  10. sky/dashboard/out/_next/static/chunks/3294.bdfea6492fdf845a.js +1 -0
  11. sky/dashboard/out/_next/static/chunks/{3785.483a3dda2d52f26e.js → 3785.e4aaef3b6c460dfb.js} +1 -1
  12. sky/dashboard/out/_next/static/chunks/{4725.10f7a9a5d3ea8208.js → 4725.a830b5c9e7867c92.js} +1 -1
  13. sky/dashboard/out/_next/static/chunks/8632-396a81107ba407c3.js +1 -0
  14. sky/dashboard/out/_next/static/chunks/9360.07d78b8552bc9d17.js +31 -0
  15. sky/dashboard/out/_next/static/chunks/pages/{_app-ce361c6959bc2001.js → _app-7d2f4467a685de9b.js} +1 -1
  16. sky/dashboard/out/_next/static/chunks/pages/clusters/[cluster]/{[job]-602eeead010ec1d6.js → [job]-1d90fbf8f0ffd194.js} +1 -1
  17. sky/dashboard/out/_next/static/chunks/pages/clusters/[cluster]-5edf81da6677352c.js +1 -0
  18. sky/dashboard/out/_next/static/chunks/pages/{clusters-57221ec2e4e01076.js → clusters-d887733ca514d22e.js} +1 -1
  19. sky/dashboard/out/_next/static/chunks/pages/infra/{[context]-44ce535a0a0ad4ec.js → [context]-79b68556c00d284e.js} +1 -1
  20. sky/dashboard/out/_next/static/chunks/pages/{infra-872e6a00165534f4.js → infra-e1c3789e69102cdb.js} +1 -1
  21. sky/dashboard/out/_next/static/chunks/pages/jobs/[job]-10f12af2b199ff68.js +16 -0
  22. sky/dashboard/out/_next/static/chunks/pages/{users-3a543725492fb896.js → users-0befb1254ac5c965.js} +1 -1
  23. sky/dashboard/out/_next/static/chunks/pages/workspaces/{[name]-9ad108cd67d16d96.js → [name]-ecc38434a21e8a1e.js} +1 -1
  24. sky/dashboard/out/_next/static/chunks/{webpack-919e3c01ab6b2633.js → webpack-31acb2000f9b372c.js} +1 -1
  25. sky/dashboard/out/_next/static/css/4c052b4444e52a58.css +3 -0
  26. sky/dashboard/out/clusters/[cluster]/[job].html +1 -1
  27. sky/dashboard/out/clusters/[cluster].html +1 -1
  28. sky/dashboard/out/clusters.html +1 -1
  29. sky/dashboard/out/config.html +1 -1
  30. sky/dashboard/out/index.html +1 -1
  31. sky/dashboard/out/infra/[context].html +1 -1
  32. sky/dashboard/out/infra.html +1 -1
  33. sky/dashboard/out/jobs/[job].html +1 -1
  34. sky/dashboard/out/jobs/pools/[pool].html +1 -1
  35. sky/dashboard/out/jobs.html +1 -1
  36. sky/dashboard/out/users.html +1 -1
  37. sky/dashboard/out/volumes.html +1 -1
  38. sky/dashboard/out/workspace/new.html +1 -1
  39. sky/dashboard/out/workspaces/[name].html +1 -1
  40. sky/dashboard/out/workspaces.html +1 -1
  41. sky/jobs/client/sdk.py +28 -9
  42. sky/jobs/client/sdk_async.py +9 -3
  43. sky/jobs/server/core.py +3 -1
  44. sky/jobs/utils.py +33 -22
  45. sky/server/auth/oauth2_proxy.py +2 -5
  46. sky/server/requests/requests.py +39 -6
  47. sky/server/requests/serializers/decoders.py +23 -10
  48. sky/server/requests/serializers/encoders.py +4 -3
  49. sky/server/rest.py +35 -1
  50. sky/skylet/log_lib.py +8 -1
  51. sky/skylet/subprocess_daemon.py +103 -29
  52. sky/utils/db/db_utils.py +21 -0
  53. sky/utils/subprocess_utils.py +13 -1
  54. {skypilot_nightly-1.0.0.dev20251022.dist-info → skypilot_nightly-1.0.0.dev20251024.dist-info}/METADATA +33 -33
  55. {skypilot_nightly-1.0.0.dev20251022.dist-info → skypilot_nightly-1.0.0.dev20251024.dist-info}/RECORD +60 -60
  56. sky/dashboard/out/_next/static/chunks/1141-ec6f902ffb865853.js +0 -11
  57. sky/dashboard/out/_next/static/chunks/1871-df9f87fcb7f24292.js +0 -6
  58. sky/dashboard/out/_next/static/chunks/2755.9b1e69c921b5a870.js +0 -26
  59. sky/dashboard/out/_next/static/chunks/3015-d014dc5b9412fade.js +0 -1
  60. sky/dashboard/out/_next/static/chunks/3294.998db87cd52a1238.js +0 -1
  61. sky/dashboard/out/_next/static/chunks/6135-4b4d5e824b7f9d3c.js +0 -1
  62. sky/dashboard/out/_next/static/chunks/9360.14326e329484b57e.js +0 -31
  63. sky/dashboard/out/_next/static/chunks/pages/clusters/[cluster]-18b334dedbd9f6f2.js +0 -1
  64. sky/dashboard/out/_next/static/chunks/pages/jobs/[job]-8677af16befde039.js +0 -16
  65. sky/dashboard/out/_next/static/css/4614e06482d7309e.css +0 -3
  66. /sky/dashboard/out/_next/static/{IgACOQPupLbX9z-RYVEDx → KxZarRnMeQID-gZkBfhzv}/_ssgManifest.js +0 -0
  67. {skypilot_nightly-1.0.0.dev20251022.dist-info → skypilot_nightly-1.0.0.dev20251024.dist-info}/WHEEL +0 -0
  68. {skypilot_nightly-1.0.0.dev20251022.dist-info → skypilot_nightly-1.0.0.dev20251024.dist-info}/entry_points.txt +0 -0
  69. {skypilot_nightly-1.0.0.dev20251022.dist-info → skypilot_nightly-1.0.0.dev20251024.dist-info}/licenses/LICENSE +0 -0
  70. {skypilot_nightly-1.0.0.dev20251022.dist-info → skypilot_nightly-1.0.0.dev20251024.dist-info}/top_level.txt +0 -0
sky/__init__.py CHANGED
@@ -7,7 +7,7 @@ import urllib.request
7
7
  from sky.utils import directory_utils
8
8
 
9
9
  # Replaced with the current commit when building the wheels.
10
- _SKYPILOT_COMMIT_SHA = '460bf4d1b00bcac85ffb617452ccbc87501261c5'
10
+ _SKYPILOT_COMMIT_SHA = '22d11ebba6e4901078e7df41b10b08cce86bb280'
11
11
 
12
12
 
13
13
  def _get_git_commit():
@@ -37,7 +37,7 @@ def _get_git_commit():
37
37
 
38
38
 
39
39
  __commit__ = _get_git_commit()
40
- __version__ = '1.0.0.dev20251022'
40
+ __version__ = '1.0.0.dev20251024'
41
41
  __root_dir__ = directory_utils.get_sky_dir()
42
42
 
43
43
 
sky/client/cli/command.py CHANGED
@@ -118,6 +118,17 @@ _DEFAULT_REQUEST_FIELDS_TO_SHOW = [
118
118
  _VERBOSE_REQUEST_FIELDS_TO_SHOW = _DEFAULT_REQUEST_FIELDS_TO_SHOW + [
119
119
  'cluster_name'
120
120
  ]
121
+ _DEFAULT_MANAGED_JOB_FIELDS_TO_GET = [
122
+ 'job_id', 'task_id', 'workspace', 'job_name', 'task_name', 'resources',
123
+ 'submitted_at', 'end_at', 'job_duration', 'recovery_count', 'status', 'pool'
124
+ ]
125
+ _VERBOSE_MANAGED_JOB_FIELDS_TO_GET = _DEFAULT_MANAGED_JOB_FIELDS_TO_GET + [
126
+ 'current_cluster_name', 'job_id_on_pool_cluster', 'start_at', 'infra',
127
+ 'cloud', 'region', 'zone', 'cluster_resources', 'schedule_state', 'details',
128
+ 'failure_reason', 'metadata'
129
+ ]
130
+ _USER_NAME_FIELD = ['user_name']
131
+ _USER_HASH_FIELD = ['user_hash']
121
132
 
122
133
  _STATUS_PROPERTY_CLUSTER_NUM_ERROR_MESSAGE = (
123
134
  '{cluster_num} cluster{plural} {verb}. Please specify {cause} '
@@ -1333,11 +1344,15 @@ def exec(
1333
1344
 
1334
1345
 
1335
1346
  def _handle_jobs_queue_request(
1336
- request_id: server_common.RequestId[List[responses.ManagedJobRecord]],
1337
- show_all: bool,
1338
- show_user: bool,
1339
- max_num_jobs_to_show: Optional[int],
1340
- is_called_by_user: bool = False) -> Tuple[Optional[int], str]:
1347
+ request_id: server_common.RequestId[Union[
1348
+ List[responses.ManagedJobRecord],
1349
+ Tuple[List[responses.ManagedJobRecord], int, Dict[str, int], int]]],
1350
+ show_all: bool,
1351
+ show_user: bool,
1352
+ max_num_jobs_to_show: Optional[int],
1353
+ is_called_by_user: bool = False,
1354
+ only_in_progress: bool = False,
1355
+ ) -> Tuple[Optional[int], str]:
1341
1356
  """Get the in-progress managed jobs.
1342
1357
 
1343
1358
  Args:
@@ -1348,6 +1363,7 @@ def _handle_jobs_queue_request(
1348
1363
  and `sky jobs queue`.
1349
1364
  is_called_by_user: If this function is called by user directly, or an
1350
1365
  internal call.
1366
+ only_in_progress: If True, only return the number of in-progress jobs.
1351
1367
 
1352
1368
  Returns:
1353
1369
  A tuple of (num_in_progress_jobs, msg). If num_in_progress_jobs is None,
@@ -1358,11 +1374,27 @@ def _handle_jobs_queue_request(
1358
1374
  # TODO(SKY-980): remove unnecessary fallbacks on the client side.
1359
1375
  num_in_progress_jobs = None
1360
1376
  msg = ''
1377
+ status_counts: Optional[Dict[str, int]] = None
1361
1378
  try:
1362
1379
  if not is_called_by_user:
1363
1380
  usage_lib.messages.usage.set_internal()
1364
- managed_jobs_ = sdk.stream_and_get(request_id)
1365
- num_in_progress_jobs = len(set(job['job_id'] for job in managed_jobs_))
1381
+ result = sdk.stream_and_get(request_id)
1382
+ if isinstance(result, tuple):
1383
+ managed_jobs_, total, status_counts, _ = result
1384
+ if only_in_progress:
1385
+ num_in_progress_jobs = 0
1386
+ if status_counts:
1387
+ for status_value, count in status_counts.items():
1388
+ status_enum = managed_jobs.ManagedJobStatus(
1389
+ status_value)
1390
+ if not status_enum.is_terminal():
1391
+ num_in_progress_jobs += count
1392
+ else:
1393
+ num_in_progress_jobs = total
1394
+ else:
1395
+ managed_jobs_ = result
1396
+ num_in_progress_jobs = len(
1397
+ set(job['job_id'] for job in managed_jobs_))
1366
1398
  except exceptions.ClusterNotUpError as e:
1367
1399
  controller_status = e.cluster_status
1368
1400
  msg = str(e)
@@ -1406,10 +1438,13 @@ def _handle_jobs_queue_request(
1406
1438
  msg += ('Failed to query managed jobs: '
1407
1439
  f'{common_utils.format_exception(e, use_bracket=True)}')
1408
1440
  else:
1409
- msg = table_utils.format_job_table(managed_jobs_,
1410
- show_all=show_all,
1411
- show_user=show_user,
1412
- max_jobs=max_num_jobs_to_show)
1441
+ msg = table_utils.format_job_table(
1442
+ managed_jobs_,
1443
+ show_all=show_all,
1444
+ show_user=show_user,
1445
+ max_jobs=max_num_jobs_to_show,
1446
+ status_counts=status_counts,
1447
+ )
1413
1448
  return num_in_progress_jobs, msg
1414
1449
 
1415
1450
 
@@ -1798,9 +1833,16 @@ def status(verbose: bool, refresh: bool, ip: bool, endpoints: bool,
1798
1833
 
1799
1834
  # Phase 2: Parallel submission of all API requests
1800
1835
  def submit_managed_jobs():
1801
- return managed_jobs.queue(refresh=False,
1802
- skip_finished=True,
1803
- all_users=all_users)
1836
+ fields = _DEFAULT_MANAGED_JOB_FIELDS_TO_GET
1837
+ if all_users:
1838
+ fields = fields + _USER_NAME_FIELD
1839
+ return managed_jobs.queue(
1840
+ refresh=False,
1841
+ skip_finished=True,
1842
+ all_users=all_users,
1843
+ fields=fields,
1844
+ limit=_NUM_MANAGED_JOBS_TO_SHOW_IN_STATUS,
1845
+ )
1804
1846
 
1805
1847
  def submit_services(
1806
1848
  ) -> Optional[server_common.RequestId[List[Dict[str, Any]]]]:
@@ -1906,7 +1948,8 @@ def status(verbose: bool, refresh: bool, ip: bool, endpoints: bool,
1906
1948
  show_all=False,
1907
1949
  show_user=all_users,
1908
1950
  max_num_jobs_to_show=_NUM_MANAGED_JOBS_TO_SHOW_IN_STATUS,
1909
- is_called_by_user=False)
1951
+ is_called_by_user=False,
1952
+ only_in_progress=True)
1910
1953
  except KeyboardInterrupt:
1911
1954
  sdk.api_cancel(managed_jobs_queue_request_id, silent=True)
1912
1955
  managed_jobs_query_interrupted = True
@@ -2937,13 +2980,22 @@ def _hint_or_raise_for_down_jobs_controller(controller_name: str,
2937
2980
  controller_name, expect_exact_match=False)
2938
2981
  assert controller is not None, controller_name
2939
2982
 
2983
+ status_counts: Optional[Dict[str, int]] = None
2940
2984
  with rich_utils.client_status(
2941
2985
  '[bold cyan]Checking for in-progress managed jobs and pools[/]'):
2942
2986
  try:
2943
- request_id = managed_jobs.queue(refresh=False,
2944
- skip_finished=True,
2945
- all_users=True)
2946
- managed_jobs_ = sdk.stream_and_get(request_id)
2987
+ fields = _DEFAULT_MANAGED_JOB_FIELDS_TO_GET + _USER_NAME_FIELD
2988
+ request_id = managed_jobs.queue(
2989
+ refresh=False,
2990
+ skip_finished=True,
2991
+ all_users=True,
2992
+ fields=fields,
2993
+ )
2994
+ result = sdk.stream_and_get(request_id)
2995
+ if isinstance(result, tuple):
2996
+ managed_jobs_, _, status_counts, _ = result
2997
+ else:
2998
+ managed_jobs_ = result
2947
2999
  request_id_pools = managed_jobs.pool_status(pool_names=None)
2948
3000
  pools_ = sdk.stream_and_get(request_id_pools)
2949
3001
  except exceptions.ClusterNotUpError as e:
@@ -2974,10 +3026,17 @@ def _hint_or_raise_for_down_jobs_controller(controller_name: str,
2974
3026
  }}):
2975
3027
  # Check again with the consolidation mode disabled. This is to
2976
3028
  # make sure there is no in-progress managed jobs.
2977
- request_id = managed_jobs.queue(refresh=False,
2978
- skip_finished=True,
2979
- all_users=True)
2980
- managed_jobs_ = sdk.stream_and_get(request_id)
3029
+ request_id = managed_jobs.queue(
3030
+ refresh=False,
3031
+ skip_finished=True,
3032
+ all_users=True,
3033
+ fields=fields,
3034
+ )
3035
+ result = sdk.stream_and_get(request_id)
3036
+ if isinstance(result, tuple):
3037
+ managed_jobs_, _, status_counts, _ = result
3038
+ else:
3039
+ managed_jobs_ = result
2981
3040
  request_id_pools = managed_jobs.pool_status(pool_names=None)
2982
3041
  pools_ = sdk.stream_and_get(request_id_pools)
2983
3042
 
@@ -2988,9 +3047,12 @@ def _hint_or_raise_for_down_jobs_controller(controller_name: str,
2988
3047
  'jobs (output of `sky jobs queue`) will be lost.')
2989
3048
  click.echo(msg)
2990
3049
  if managed_jobs_:
2991
- job_table = table_utils.format_job_table(managed_jobs_,
2992
- show_all=False,
2993
- show_user=True)
3050
+ job_table = table_utils.format_job_table(
3051
+ managed_jobs_,
3052
+ show_all=False,
3053
+ show_user=True,
3054
+ status_counts=status_counts,
3055
+ )
2994
3056
  msg = controller.value.decline_down_for_dirty_controller_hint
2995
3057
  # Add prefix to each line to align with the bullet point.
2996
3058
  msg += '\n'.join(
@@ -4605,6 +4667,14 @@ def jobs_launch(
4605
4667
  @jobs.command('queue', cls=_DocumentedCodeCommand)
4606
4668
  @flags.config_option(expose_value=False)
4607
4669
  @flags.verbose_option()
4670
+ @click.option(
4671
+ '--limit',
4672
+ '-l',
4673
+ default=_NUM_MANAGED_JOBS_TO_SHOW,
4674
+ type=int,
4675
+ required=False,
4676
+ help=(f'Number of jobs to show, default is {_NUM_MANAGED_JOBS_TO_SHOW},'
4677
+ f' use "-a/--all" to show all jobs.'))
4608
4678
  @click.option(
4609
4679
  '--refresh',
4610
4680
  '-r',
@@ -4624,7 +4694,7 @@ def jobs_launch(
4624
4694
  @usage_lib.entrypoint
4625
4695
  # pylint: disable=redefined-builtin
4626
4696
  def jobs_queue(verbose: bool, refresh: bool, skip_finished: bool,
4627
- all_users: bool, all: bool):
4697
+ all_users: bool, all: bool, limit: int):
4628
4698
  """Show statuses of managed jobs.
4629
4699
 
4630
4700
  Each managed jobs can have one of the following statuses:
@@ -4675,12 +4745,29 @@ def jobs_queue(verbose: bool, refresh: bool, skip_finished: bool,
4675
4745
 
4676
4746
  watch -n60 sky jobs queue
4677
4747
 
4748
+ (Tip) To show only the latest 10 jobs, use ``-l/--limit 10``:
4749
+
4750
+ .. code-block:: bash
4751
+
4752
+ sky jobs queue -l 10
4753
+
4678
4754
  """
4679
4755
  click.secho('Fetching managed job statuses...', fg='cyan')
4680
4756
  with rich_utils.client_status('[cyan]Checking managed jobs[/]'):
4757
+ max_num_jobs_to_show = (limit if not all else None)
4758
+ fields = _DEFAULT_MANAGED_JOB_FIELDS_TO_GET
4759
+ if verbose:
4760
+ fields = _VERBOSE_MANAGED_JOB_FIELDS_TO_GET
4761
+ if all_users:
4762
+ fields = fields + _USER_NAME_FIELD
4763
+ if verbose:
4764
+ fields = fields + _USER_HASH_FIELD
4681
4765
  managed_jobs_request_id = managed_jobs.queue(
4682
- refresh=refresh, skip_finished=skip_finished, all_users=all_users)
4683
- max_num_jobs_to_show = (_NUM_MANAGED_JOBS_TO_SHOW if not all else None)
4766
+ refresh=refresh,
4767
+ skip_finished=skip_finished,
4768
+ all_users=all_users,
4769
+ limit=max_num_jobs_to_show,
4770
+ fields=fields)
4684
4771
  num_jobs, msg = _handle_jobs_queue_request(
4685
4772
  managed_jobs_request_id,
4686
4773
  show_all=verbose,
@@ -4699,7 +4786,8 @@ def jobs_queue(verbose: bool, refresh: bool, skip_finished: bool,
4699
4786
  f'{colorama.Fore.CYAN}'
4700
4787
  f'Only showing the latest {max_num_jobs_to_show} '
4701
4788
  f'managed jobs'
4702
- f'(use --all to show all managed jobs) {colorama.Style.RESET_ALL} ')
4789
+ f'(use --limit to show more managed jobs or '
4790
+ f'--all to show all managed jobs) {colorama.Style.RESET_ALL} ')
4703
4791
 
4704
4792
 
4705
4793
  @jobs.command('cancel', cls=_DocumentedCodeCommand)
@@ -88,15 +88,21 @@ def format_storage_table(storages: List[responses.StorageRecord],
88
88
  return 'No existing storage.'
89
89
 
90
90
 
91
- def format_job_table(jobs: List[responses.ManagedJobRecord],
92
- show_all: bool,
93
- show_user: bool,
94
- max_jobs: Optional[int] = None):
91
+ def format_job_table(
92
+ jobs: List[responses.ManagedJobRecord],
93
+ show_all: bool,
94
+ show_user: bool,
95
+ max_jobs: Optional[int] = None,
96
+ status_counts: Optional[Dict[str, int]] = None,
97
+ ):
95
98
  jobs = [job.model_dump() for job in jobs]
96
- return managed_jobs.format_job_table(jobs,
97
- show_all=show_all,
98
- show_user=show_user,
99
- max_jobs=max_jobs)
99
+ return managed_jobs.format_job_table(
100
+ jobs,
101
+ show_all=show_all,
102
+ show_user=show_user,
103
+ max_jobs=max_jobs,
104
+ job_status_counts=status_counts,
105
+ )
100
106
 
101
107
 
102
108
  _BASIC_COLUMNS = [
@@ -1 +1 @@
1
- <!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><meta name="next-head-count" content="2"/><link rel="preload" href="/dashboard/_next/static/css/4614e06482d7309e.css" as="style"/><link rel="stylesheet" href="/dashboard/_next/static/css/4614e06482d7309e.css" data-n-g=""/><noscript data-n-css=""></noscript><script defer="" nomodule="" src="/dashboard/_next/static/chunks/polyfills-78c92fac7aa8fdd8.js"></script><script src="/dashboard/_next/static/chunks/webpack-919e3c01ab6b2633.js" defer=""></script><script src="/dashboard/_next/static/chunks/framework-cf60a09ccd051a10.js" defer=""></script><script src="/dashboard/_next/static/chunks/main-f15ccb73239a3bf1.js" defer=""></script><script src="/dashboard/_next/static/chunks/pages/_app-ce361c6959bc2001.js" defer=""></script><script src="/dashboard/_next/static/chunks/pages/_error-c66a4e8afc46f17b.js" defer=""></script><script src="/dashboard/_next/static/IgACOQPupLbX9z-RYVEDx/_buildManifest.js" defer=""></script><script src="/dashboard/_next/static/IgACOQPupLbX9z-RYVEDx/_ssgManifest.js" defer=""></script></head><body><div id="__next"></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":404}},"page":"/_error","query":{},"buildId":"IgACOQPupLbX9z-RYVEDx","assetPrefix":"/dashboard","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
1
+ <!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><meta name="next-head-count" content="2"/><link rel="preload" href="/dashboard/_next/static/css/4c052b4444e52a58.css" as="style"/><link rel="stylesheet" href="/dashboard/_next/static/css/4c052b4444e52a58.css" data-n-g=""/><noscript data-n-css=""></noscript><script defer="" nomodule="" src="/dashboard/_next/static/chunks/polyfills-78c92fac7aa8fdd8.js"></script><script src="/dashboard/_next/static/chunks/webpack-31acb2000f9b372c.js" defer=""></script><script src="/dashboard/_next/static/chunks/framework-cf60a09ccd051a10.js" defer=""></script><script src="/dashboard/_next/static/chunks/main-f15ccb73239a3bf1.js" defer=""></script><script src="/dashboard/_next/static/chunks/pages/_app-7d2f4467a685de9b.js" defer=""></script><script src="/dashboard/_next/static/chunks/pages/_error-c66a4e8afc46f17b.js" defer=""></script><script src="/dashboard/_next/static/KxZarRnMeQID-gZkBfhzv/_buildManifest.js" defer=""></script><script src="/dashboard/_next/static/KxZarRnMeQID-gZkBfhzv/_ssgManifest.js" defer=""></script></head><body><div id="__next"></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":404}},"page":"/_error","query":{},"buildId":"KxZarRnMeQID-gZkBfhzv","assetPrefix":"/dashboard","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
@@ -1 +1 @@
1
- self.__BUILD_MANIFEST=function(s,c,e,a,t,f,u,n,o,b,j,r,i,k,d){return{__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},"/":["static/chunks/pages/index-444f1804401f04ea.js"],"/_error":["static/chunks/pages/_error-c66a4e8afc46f17b.js"],"/clusters":["static/chunks/pages/clusters-57221ec2e4e01076.js"],"/clusters/[cluster]":[s,c,e,f,u,j,b,a,t,n,r,o,i,k,d,"static/chunks/6856-5c94d394259cdb6e.js","static/chunks/1871-df9f87fcb7f24292.js","static/chunks/pages/clusters/[cluster]-18b334dedbd9f6f2.js"],"/clusters/[cluster]/[job]":[s,c,e,f,a,t,o,"static/chunks/pages/clusters/[cluster]/[job]-602eeead010ec1d6.js"],"/config":["static/chunks/pages/config-dfb9bf07b13045f4.js"],"/infra":["static/chunks/pages/infra-872e6a00165534f4.js"],"/infra/[context]":["static/chunks/pages/infra/[context]-44ce535a0a0ad4ec.js"],"/jobs":["static/chunks/pages/jobs-0dc34cf9a8710a9f.js"],"/jobs/pools/[pool]":[s,c,e,u,b,a,t,n,"static/chunks/pages/jobs/pools/[pool]-e020fd69dbe76cea.js"],"/jobs/[job]":[s,c,e,f,u,b,a,t,n,o,"static/chunks/pages/jobs/[job]-8677af16befde039.js"],"/users":["static/chunks/pages/users-3a543725492fb896.js"],"/volumes":["static/chunks/pages/volumes-d2af9d22e87cc4ba.js"],"/workspace/new":["static/chunks/pages/workspace/new-3f88a1c7e86a3f86.js"],"/workspaces":["static/chunks/pages/workspaces-6fc994fa1ee6c6bf.js"],"/workspaces/[name]":[s,c,e,f,u,j,a,t,n,r,o,i,k,d,"static/chunks/1141-ec6f902ffb865853.js","static/chunks/pages/workspaces/[name]-9ad108cd67d16d96.js"],sortedPages:["/","/_app","/_error","/clusters","/clusters/[cluster]","/clusters/[cluster]/[job]","/config","/infra","/infra/[context]","/jobs","/jobs/pools/[pool]","/jobs/[job]","/users","/volumes","/workspace/new","/workspaces","/workspaces/[name]"]}}("static/chunks/616-3d59f75e2ccf9321.js","static/chunks/6130-2be46d70a38f1e82.js","static/chunks/5739-d67458fcb1386c92.js","static/chunks/6989-01359c57e018caa4.js","static/chunks/3850-ff4a9a69d978632b.js","static/chunks/7411-b15471acd2cba716.js","static/chunks/1272-1ef0bf0237faccdb.js","static/chunks/8969-0389e2cb52412db3.js","static/chunks/6135-4b4d5e824b7f9d3c.js","static/chunks/6212-7bd06f60ba693125.js","static/chunks/7359-c8d04e06886000b3.js","static/chunks/6990-f6818c84ed8f1c86.js","static/chunks/4282-d2f3ef2fbf78e347.js","static/chunks/6601-06114c982db410b6.js","static/chunks/3015-d014dc5b9412fade.js"),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
1
+ self.__BUILD_MANIFEST=function(s,c,a,e,t,f,u,n,o,b,j,r,i,k,h){return{__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},"/":["static/chunks/pages/index-444f1804401f04ea.js"],"/_error":["static/chunks/pages/_error-c66a4e8afc46f17b.js"],"/clusters":["static/chunks/pages/clusters-d887733ca514d22e.js"],"/clusters/[cluster]":[s,c,a,f,u,j,b,e,t,n,r,o,i,k,h,"static/chunks/6856-5c94d394259cdb6e.js","static/chunks/1871-5f68bb683940d23f.js","static/chunks/pages/clusters/[cluster]-5edf81da6677352c.js"],"/clusters/[cluster]/[job]":[s,c,a,f,e,t,o,"static/chunks/pages/clusters/[cluster]/[job]-1d90fbf8f0ffd194.js"],"/config":["static/chunks/pages/config-dfb9bf07b13045f4.js"],"/infra":["static/chunks/pages/infra-e1c3789e69102cdb.js"],"/infra/[context]":["static/chunks/pages/infra/[context]-79b68556c00d284e.js"],"/jobs":["static/chunks/pages/jobs-0dc34cf9a8710a9f.js"],"/jobs/pools/[pool]":[s,c,a,u,b,e,t,n,"static/chunks/pages/jobs/pools/[pool]-e020fd69dbe76cea.js"],"/jobs/[job]":[s,c,a,f,u,b,e,t,n,o,"static/chunks/pages/jobs/[job]-10f12af2b199ff68.js"],"/users":["static/chunks/pages/users-0befb1254ac5c965.js"],"/volumes":["static/chunks/pages/volumes-d2af9d22e87cc4ba.js"],"/workspace/new":["static/chunks/pages/workspace/new-3f88a1c7e86a3f86.js"],"/workspaces":["static/chunks/pages/workspaces-6fc994fa1ee6c6bf.js"],"/workspaces/[name]":[s,c,a,f,u,j,e,t,n,r,o,i,k,h,"static/chunks/1141-145e542070a6b615.js","static/chunks/pages/workspaces/[name]-ecc38434a21e8a1e.js"],sortedPages:["/","/_app","/_error","/clusters","/clusters/[cluster]","/clusters/[cluster]/[job]","/config","/infra","/infra/[context]","/jobs","/jobs/pools/[pool]","/jobs/[job]","/users","/volumes","/workspace/new","/workspaces","/workspaces/[name]"]}}("static/chunks/616-3d59f75e2ccf9321.js","static/chunks/6130-2be46d70a38f1e82.js","static/chunks/5739-d67458fcb1386c92.js","static/chunks/6989-01359c57e018caa4.js","static/chunks/3850-ff4a9a69d978632b.js","static/chunks/7411-b15471acd2cba716.js","static/chunks/1272-1ef0bf0237faccdb.js","static/chunks/8969-0389e2cb52412db3.js","static/chunks/8632-396a81107ba407c3.js","static/chunks/6212-7bd06f60ba693125.js","static/chunks/7359-c8d04e06886000b3.js","static/chunks/6990-f6818c84ed8f1c86.js","static/chunks/4282-d2f3ef2fbf78e347.js","static/chunks/6601-06114c982db410b6.js","static/chunks/3015-2dcace420c8939f4.js"),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
@@ -0,0 +1,11 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1141],{99333:function(e,s,a){a.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,a(60998).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"}]])},98418:function(e,s,a){a.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,a(60998).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,a){a.d(s,{X:function(){return n}});var t=a(85893),r=a(67294);let l=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:a="Error",onDismiss:n}=e,[c,i]=(0,r.useState)(!1);if((0,r.useEffect)(()=>{s&&i(!1)},[s]),!s||c)return null;let o="string"==typeof s?s:l(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:[a,":"]})," ",o]})})]}),(0,t.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,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"})})})]})})}},69123:function(e,s,a){a.d(s,{g:function(){return n}});var t=a(85893),r=a(67294),l=a(32350);let n=r.forwardRef((e,s)=>{let{className:a,...r}=e;return(0,t.jsx)("textarea",{className:(0,l.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",a),ref:s,...r})});n.displayName="Textarea"},11141:function(e,s,a){a.r(s),a.d(s,{WorkspaceEditor:function(){return _}});var t=a(85893),r=a(67294),l=a(11163),n=a(17324),c=a(23266),i=a(68969);a(48632);var o=a(41664),d=a.n(o),u=a(9008),x=a.n(u),m=a(37673),h=a(30803),f=a(69123),g=a(55739),p=a(70282),b=a(6021),j=a(13626),y=a(98418),N=a(99333),k=a(50326);let v=e=>{let{className:s="",variant:a="default",children:r,...l}=e;return(0,t.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"}[a]," ").concat(s),...l,children:r})},w=e=>{let{className:s="",children:a,...r}=e;return(0,t.jsx)("div",{className:"text-sm leading-relaxed ".concat(s),...r,children:a})};var C=a(53850),L=a(1812),E=a(23015),S=a(1272),W=a(93225),A=a(53081),M=a(6378);let Z=e=>{let{message:s}=e;return s?(0,t.jsxs)(v,{className:"border-green-200 bg-green-50",children:[(0,t.jsx)(p.Z,{className:"h-4 w-4 text-green-600"}),(0,t.jsx)(w,{className:"text-green-800",children:s})]}):null},D=e=>{let{workspaceName:s,config:a,enabledClouds:r=[]}=e;if(!a)return null;let l="default"===s,n=0===Object.keys(a).length;if(l&&n)return(0,t.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(r.map(e=>e.toLowerCase()));Object.entries(a).forEach(e=>{let[s,a]=e;if("private"===s||"allowed_users"===s)return;let r=W.Z2[s.toLowerCase()]||s.toUpperCase(),l=null==r?void 0:r.toLowerCase(),n=d.has(l)||Array.from(d).some(e=>e.startsWith(l+"/")),u=()=>"kubernetes"===s.toLowerCase()?Array.from(d).filter(e=>e.startsWith(l+"/")).map(e=>e.split("/")[1]):[];if((null==a?void 0:a.disabled)===!0)i.push(r);else if(a&&Object.keys(a).length>0){let e="";if("gcp"===s.toLowerCase()&&a.project_id)e=" (Project ID: ".concat(a.project_id,")");else if("aws"===s.toLowerCase()&&a.region)e=" (Region: ".concat(a.region,")");else if("kubernetes"===s.toLowerCase()){let s=u();s.length>0&&(e=" (Contexts: ".concat(s.join(", "),")"))}n?c.push((0,t.jsxs)("span",{className:"block",children:[r,e," is enabled."]},"".concat(s,"-enabled"))):o.push((0,t.jsxs)("span",{className:"block text-amber-700",children:[r,e," is configured but not currently available."]},"".concat(s,"-configured-not-enabled")))}else if(n){let e="";if("kubernetes"===s.toLowerCase()){let s=u();s.length>0&&(e=" (Contexts: ".concat(s.join(", "),")"))}c.push((0,t.jsxs)("span",{className:"block",children:[r,e," is enabled (using default settings)."]},"".concat(s,"-default-enabled")))}else o.push((0,t.jsxs)("span",{className:"block text-amber-700",children:[r," 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,t.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,t.jsx)("div",{className:"text-sm text-gray-700 mb-3 p-3 bg-sky-50 rounded border border-sky-200",children:u}):!l&&n?(0,t.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},P=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"})},R=e=>{let{workspaceConfig:s,allUsers:a}=e;if(!s.private)return null;let r=s.allowed_users||[],l=(a||[]).filter(e=>"admin"===e.role).map(e=>e.username),n=[...new Set([...r,...l])];return 0===n.length?(0,t.jsxs)("div",{className:"mt-4",children:[(0,t.jsx)("h4",{className:"mb-2 text-xs text-gray-500 tracking-wider",children:"Allowed Users (0)"}),(0,t.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,t.jsxs)("div",{className:"mt-4",children:[(0,t.jsxs)("h4",{className:"mb-2 text-xs text-gray-500 tracking-wider",children:["Allowed Users (",n.length,")"]}),(0,t.jsx)("div",{className:"space-y-1 max-h-48 overflow-y-auto border border-gray-200 rounded",children:n.map(e=>{let s=l.includes(e);return(0,t.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,t.jsx)("span",{className:"font-medium text-gray-700",children:e}),s?(0,t.jsxs)("span",{className:"inline-flex items-center text-blue-600",children:[(0,t.jsx)(C.r7,{className:"w-3 h-3 mr-1"}),"Admin"]}):(0,t.jsxs)("span",{className:"inline-flex items-center text-gray-600",children:[(0,t.jsx)(b.Z,{className:"w-3 h-3 mr-1"}),"User"]})]},e)})})]})};function _(e){let{workspaceName:s,isNewWorkspace:a=!1}=e,o=(0,l.useRouter)(),[u,p]=(0,r.useState)({}),[b,v]=(0,r.useState)({}),[w,W]=(0,r.useState)(""),[_,z]=(0,r.useState)(!0),[O,U]=(0,r.useState)(!1),[T,Y]=(0,r.useState)(!1),[J,F]=(0,r.useState)(null),[I,V]=(0,r.useState)(null),[H,B]=(0,r.useState)(null),[X,G]=(0,r.useState)([]),[q,K]=(0,r.useState)({showDialog:!1,deleting:!1,error:null}),[Q,$]=(0,r.useState)({totalClusterCount:0,runningClusterCount:0,managedJobsCount:0,clouds:[]}),[ee,es]=(0,r.useState)(!1),ea=(0,r.useCallback)(async()=>{z(!0),F(null);try{let e;let[a,t]=await Promise.all([(0,n.getWorkspaces)(),(0,A.R)()]),r=a[s]||{};p(r),v(r),G(t||[]),e=0===Object.keys(r).length?"".concat(s,":\n # Empty workspace configuration - uses all accessible infrastructure\n"):S.ZP.dump({[s]:r},{indent:2,lineWidth:-1,noRefs:!0,skipInvalid:!0,flowLevel:-1}),W(e)}catch(e){console.error("Error fetching workspace config:",e),F(e)}finally{z(!1)}},[s]),et=(0,r.useCallback)(async()=>{if(!a){es(!0);try{let[e,a,t]=await Promise.all([M.dashboardCache.get(c.getClusters),M.dashboardCache.get(i.getManagedJobs,[{allUsers:!0,skipFinished:!0,workspaceMatch:s,fields:["workspace","status"]}]),M.dashboardCache.get(n.getEnabledClouds,[s,!0])]),r=e.filter(e=>(e.workspace||"default")===s),l=r.filter(e=>"RUNNING"===e.status||"LAUNCHING"===e.status),o={};e.forEach(e=>{o[e.cluster]=e.workspace||"default"});let d=a.jobs||[],u=new Set(E.statusGroups.active),x=0;d.forEach(e=>{e.workspace===s&&u.has(e.status)&&x++}),$({totalClusterCount:r.length,runningClusterCount:l.length,managedJobsCount:x,clouds:Array.isArray(t)?t:[]})}catch(e){console.error("Failed to fetch workspace stats:",e)}finally{es(!1)}}},[s,a]);(0,r.useEffect)(()=>{a?(z(!1),W("".concat(s,":\n # New workspace configuration\n # Leave empty to use all accessible infrastructure\n"))):(ea(),et())},[s,a,ea,et]),(0,r.useEffect)(()=>{Y(JSON.stringify(u)!==JSON.stringify(b))},[u,b]);let er=e=>{W(e),B(null);try{let a=S.ZP.load(e)||{},t=Object.keys(a);if(0===t.length)p({});else if(1===t.length){let e=t[0];if(e!==s){B('Workspace name cannot be changed. Expected "'.concat(s,'" but found "').concat(e,'".'));return}let r=a[s]||{};p(r)}else B("Configuration must contain only one workspace. Found: ".concat(t.join(", ")))}catch(e){B("Invalid YAML: ".concat(e.message))}},el=async()=>{U(!0),F(null),V(null);try{if(H)throw Error("Please fix YAML errors before saving");let e=S.ZP.load(w)||{},t=Object.keys(e);if(t.length>0&&t[0]!==s)throw Error('Workspace name cannot be changed. Expected "'.concat(s,'".'));a?(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!"),v(u),et())}catch(e){console.error("Error saving workspace:",e),F(e)}finally{U(!1)}},en=async()=>{K(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),K(s=>({...s,deleting:!1,error:e}))}},ec=()=>{K({showDialog:!1,deleting:!1,error:null})},ei=async()=>{await Promise.all([ea(),et()])};if(!o.isReady)return(0,t.jsx)("div",{children:"Loading..."});let eo=a?"Create New Workspace | SkyPilot Dashboard":"Workspace: ".concat(s," | SkyPilot Dashboard");return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(x(),{children:(0,t.jsx)("title",{children:eo})}),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4 h-5",children:[(0,t.jsxs)("div",{className:"text-base flex items-center",children:[(0,t.jsx)(d(),{href:"/workspaces",className:"text-sky-blue hover:underline",children:"Workspaces"}),(0,t.jsx)("span",{className:"mx-2 text-gray-500",children:"›"}),(0,t.jsx)(d(),{href:a?"/workspace/new":"/workspaces/".concat(s),className:"text-sky-blue hover:underline",children:a?"New Workspace":s}),T&&(0,t.jsx)("span",{className:"ml-3 px-2 py-1 bg-yellow-100 text-yellow-800 text-xs rounded",children:"Unsaved changes"})]}),(0,t.jsxs)("div",{className:"text-sm flex items-center",children:[(_||O||ee)&&(0,t.jsxs)("div",{className:"flex items-center mr-4",children:[(0,t.jsx)(g.Z,{size:15,className:"mt-0"}),(0,t.jsx)("span",{className:"ml-2 text-gray-500",children:O?"Saving...":"Loading..."})]}),(0,t.jsxs)("div",{className:"flex items-center space-x-4",children:[!a&&(0,t.jsxs)("button",{onClick:ei,disabled:_||O||ee,className:"text-sky-blue hover:text-sky-blue-bright font-medium inline-flex items-center",children:[(0,t.jsx)(j.Z,{className:"w-4 h-4 mr-1.5"}),"Refresh"]}),!a&&"default"!==s&&(0,t.jsxs)("button",{onClick:()=>K({...q,showDialog:!0}),disabled:q.deleting||O,className:"text-red-600 hover:text-red-700 font-medium inline-flex items-center",children:[(0,t.jsx)(y.Z,{className:"w-4 h-4 mr-1.5"}),"Delete"]})]})]})]}),_?(0,t.jsxs)("div",{className:"flex justify-center items-center py-12",children:[(0,t.jsx)(g.Z,{size:24,className:"mr-2"}),(0,t.jsx)("span",{className:"text-gray-500",children:"Loading workspace configuration..."})]}):(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsx)(L.X,{error:J,title:"Error",onDismiss:()=>F(null)}),(0,t.jsx)(Z,{message:I}),(0,t.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[!a&&(0,t.jsx)("div",{className:"lg:col-span-1",children:(0,t.jsxs)(m.Zb,{className:"h-full",children:[(0,t.jsx)(m.Ol,{children:(0,t.jsx)(m.ll,{className:"text-base font-normal",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"font-semibold",children:"Workspace:"})," ",s]}),(0,t.jsx)(P,{isPrivate:!0===b.private})]})})}),(0,t.jsxs)(m.aY,{className:"text-sm pb-2 flex-1",children:[(0,t.jsxs)("div",{className:"py-2 flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center text-gray-600",children:[(0,t.jsx)(C.QT,{className:"w-4 h-4 mr-2 text-gray-500"}),(0,t.jsx)("span",{children:"Clusters (Running / Total)"})]}),(0,t.jsx)("span",{className:"font-normal text-gray-800",children:ee?"...":"".concat(Q.runningClusterCount," / ").concat(Q.totalClusterCount)})]}),(0,t.jsxs)("div",{className:"py-2 flex items-center justify-between border-t border-gray-100",children:[(0,t.jsxs)("div",{className:"flex items-center text-gray-600",children:[(0,t.jsx)(C.Vp,{className:"w-4 h-4 mr-2 text-gray-500"}),(0,t.jsx)("span",{children:"Managed Jobs"})]}),(0,t.jsx)("span",{className:"font-normal text-gray-800",children:ee?"...":Q.managedJobsCount})]})]}),(0,t.jsxs)("div",{className:"px-6 pb-6 text-sm pt-3",children:[(0,t.jsx)("h4",{className:"mb-2 text-xs text-gray-500 tracking-wider",children:"Enabled Infra"}),(0,t.jsx)("div",{className:"flex flex-wrap gap-x-4 gap-y-1",children:ee?(0,t.jsx)("span",{className:"text-gray-500",children:"Loading..."}):Q.clouds.length>0?Q.clouds.map(e=>(0,t.jsxs)("div",{className:"flex items-center text-gray-700",children:[(0,t.jsx)(C.Ye,{className:"w-3.5 h-3.5 mr-1.5 text-green-500"}),(0,t.jsx)("span",{children:e})]},e)):(0,t.jsx)("span",{className:"text-gray-500 italic",children:"No enabled infrastructure"})}),(0,t.jsx)("div",{className:"mt-4",children:(0,t.jsx)(D,{workspaceName:s,config:b,enabledClouds:Q.clouds})}),(0,t.jsx)(R,{workspaceConfig:b,allUsers:X})]})]})}),(0,t.jsx)("div",{className:a?"lg:col-span-3":"lg:col-span-2",children:(0,t.jsxs)(m.Zb,{className:"h-full flex flex-col",children:[(0,t.jsx)(m.Ol,{children:(0,t.jsx)(m.ll,{className:"text-base font-normal",children:a?"New Workspace YAML":"Edit Workspace YAML"})}),(0,t.jsx)(m.aY,{className:"flex-1 flex flex-col",children:(0,t.jsxs)("div",{className:"space-y-4 flex-1 flex flex-col",children:[H&&(0,t.jsx)(L.X,{error:H,onDismiss:()=>B(null)}),(0,t.jsxs)("div",{className:"flex-1 flex flex-col",children:[(0,t.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,t.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,t.jsxs)("div",{className:"mb-4",children:[(0,t.jsx)("h4",{className:"text-sm font-medium text-gray-700 mb-2",children:"Example configuration:"}),(0,t.jsx)("div",{className:"p-3 bg-gray-50 border rounded-lg",children:(0,t.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,t.jsx)(f.g,{value:w,onChange:e=>er(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,t.jsx)("div",{className:"flex justify-end space-x-3 pt-3 border-gray-200",children:(0,t.jsxs)(h.z,{onClick:el,disabled:O||H||_,className:"inline-flex items-center bg-sky-600 hover:bg-sky-700 text-white",children:[(0,t.jsx)(N.Z,{className:"w-4 h-4 mr-1.5"}),O?"Applying...":"Apply"]})})]})]})})]})})]})]}),(0,t.jsx)(k.Vq,{open:q.showDialog,onOpenChange:ec,children:(0,t.jsxs)(k.cZ,{className:"sm:max-w-md",children:[(0,t.jsxs)(k.fK,{className:"",children:[(0,t.jsx)(k.$N,{children:"Delete Workspace"}),(0,t.jsxs)(k.Be,{children:['Are you sure you want to delete workspace "',s,'"? This action cannot be undone.']})]}),q.error&&(0,t.jsx)(L.X,{error:q.error,title:"Deletion Failed",onDismiss:()=>K(e=>({...e,error:null}))}),(0,t.jsxs)(k.cN,{className:"",children:[(0,t.jsx)(h.z,{variant:"outline",onClick:ec,disabled:q.deleting,children:"Cancel"}),(0,t.jsx)(h.z,{variant:"destructive",onClick:en,disabled:q.deleting,children:q.deleting?"Deleting...":"Delete"})]})]})})]})]})}}}]);
@@ -0,0 +1,6 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1871],{39037:function(e,s,t){t.r(s),t.d(s,{ClusterTable:function(){return _},Clusters:function(){return I},Status2Actions:function(){return F},enabledActions:function(){return H},handleVSCodeConnection:function(){return O}});var r=t(85893),l=t(67294),a=t(11163),n=t(55739),i=t(36989),c=t(41664),o=t.n(c),u=t(30803),d=t(37673),h=t(68764),x=t(23266),p=t(17324),m=t(94545),f=t(13626),j=t(60998);/**
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 v=(0,j.Z)("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]),g=(0,j.Z)("SquareCode",[["path",{d:"M10 9.5 8 12l2 2.5",key:"3mjy60"}],["path",{d:"m14 9.5 2 2.5-2 2.5",key:"1bir2l"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);t(48632);var y=t(92128),w=t(99307),b=t(23001),k=t(88950),N=t(6378),C=t(36856);t(1272);var S=t(20546);let L=[{label:"Status",value:"status"},{label:"Cluster",value:"cluster"},{label:"User",value:"user"},{label:"Workspace",value:"workspace"},{label:"Infra",value:"infra"}],M=(e,s)=>{let t="",r="";return e>=0&&(t=e+"m",r=" "),s&&(t+="".concat(r,"(down)")),""===t&&(t="-"),t},R=(e,s)=>{if(e&&e.includes("@")){let t=e.split("@")[0];return s&&s!==t?"".concat(t," (").concat(s,")"):t}let t=e||s||"N/A";return s&&s!==t?"".concat(t," (").concat(s,")"):t},E=e=>{if(!e||0===e)return"-";let s=e=Math.floor(e),t="",r=0;for(let e of[{value:31536e3,label:"y"},{value:2592e3,label:"mo"},{value:86400,label:"d"},{value:3600,label:"h"},{value:60,label:"m"},{value:1,label:"s"}])if(s>=e.value&&r<2){let l=Math.floor(s/e.value);t+="".concat(l).concat(e.label," "),s%=e.value,r++}return t.trim()||"0s"};function I(){let e=(0,a.useRouter)(),[s,t]=(0,l.useState)(!1),c=l.useRef(null),[u,d]=(0,l.useState)(!1),[h,m]=(0,l.useState)(!1),[j,v]=(0,l.useState)(null),[g,w]=(0,l.useState)(()=>!!e.isReady&&"true"===e.query.history),[S,M]=(0,l.useState)(!0),[E,I]=(0,l.useState)(()=>{if(e.isReady){let s=e.query.historyDays;if(s&&"string"==typeof s&&["1","5","10","30"].includes(s))return parseInt(s)}return 1}),O=(0,b.X)(),[q,H]=(0,l.useState)([]),[W,F]=(0,l.useState)({status:[],cluster:[],user:[],workspace:[],infra:[]}),[A,D]=(0,l.useState)(!1);(0,l.useEffect)(()=>{if(e.isReady){U();let s="true"===e.query.history;g!==s&&(M(!1),w(s),setTimeout(()=>M(!0),50));let t=e.query.historyDays;if(t&&"string"==typeof t&&["1","5","10","30"].includes(t)){let e=parseInt(t);E!==e&&I(e)}}},[e.isReady,e.query.history,e.query.historyDays]),(0,l.useEffect)(()=>{(async()=>{try{await C.ZP.preloadForPage("clusters");let e=await N.default.get(p.getWorkspaces),s=Object.keys(e),t=await N.default.get(x.getClusters),r=[...new Set(t.map(e=>e.workspace||"default").filter(e=>e))],l=new Set(s);r.includes("default")&&l.has("default"),r.forEach(e=>l.add(e));let a=[...new Set(t.map(e=>({userId:e.user_hash||e.user,username:e.user})).filter(e=>e.userId)).values()],n=new Map;a.forEach(e=>{n.set(e.userId,{userId:e.userId,username:e.username,display:R(e.username,e.userId)})}),D(!0)}catch(e){console.error("Error fetching data for filters:",e),D(!0)}})()},[]);let P=s=>{let t={...e.query},r=[],l=[],a=[];s.map((e,s)=>{var t;r.push(null!==(t=e.property.toLowerCase())&&void 0!==t?t:""),l.push(e.operator),a.push(e.value)}),t.property=r,t.operator=l,t.value=a,e.replace({pathname:e.pathname,query:t},void 0,{shallow:!0})},Z=s=>{let t={...e.query};t.history=s.toString(),e.replace({pathname:e.pathname,query:t},void 0,{shallow:!0})},B=s=>{let t={...e.query};t.historyDays=s.toString(),e.replace({pathname:e.pathname,query:t},void 0,{shallow:!0})},U=()=>{let s={...e.query},t=s.property,r=s.operator,l=s.value;if(void 0===t)return;let a=[],n=Array.isArray(t)?t.length:1,i=new Map;if(i.set("",""),i.set("status","Status"),i.set("cluster","Cluster"),i.set("user","User"),i.set("workspace","Workspace"),i.set("infra","Infra"),1===n)a.push({property:i.get(t),operator:r,value:l});else for(let e=0;e<n;e++)a.push({property:i.get(t[e]),operator:r[e],value:l[e]});H(a)};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2 mb-1 min-h-[20px]",children:[(0,r.jsx)("div",{className:"flex items-center gap-2",children:(0,r.jsx)(o(),{href:"/clusters",className:"text-sky-blue hover:underline leading-none text-base",children:"Sky Clusters"})}),(0,r.jsx)("div",{className:"w-full sm:w-auto",children:(0,r.jsx)(V,{propertyList:L,valueList:W,setFilters:H,updateURLParams:P,placeholder:"Filter clusters"})}),(0,r.jsxs)("div",{className:"flex items-center gap-2 ml-auto",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("label",{className:"flex items-center cursor-pointer",children:[(0,r.jsx)("input",{type:"checkbox",checked:g,onChange:e=>{let s=e.target.checked;w(s),Z(s)},className:"sr-only"}),(0,r.jsx)("div",{className:"relative inline-flex h-5 w-9 items-center rounded-full ".concat(S?"transition-colors":""," ").concat(g?"bg-sky-600":"bg-gray-300"),children:(0,r.jsx)("span",{className:"inline-block h-3 w-3 transform rounded-full bg-white ".concat(S?"transition-transform":""," ").concat(g?"translate-x-5":"translate-x-1")})}),(0,r.jsx)("span",{className:"ml-2 text-sm text-gray-700",children:"Show history"})]}),g&&(0,r.jsxs)(k.Ph,{value:E.toString(),onValueChange:e=>{let s=parseInt(e);I(s),B(s)},children:[(0,r.jsx)(k.i4,{className:"w-24 h-8 text-xs",children:(0,r.jsx)(k.ki,{})}),(0,r.jsxs)(k.Bw,{children:[(0,r.jsx)(k.Ql,{value:"1",children:"1 day"}),(0,r.jsx)(k.Ql,{value:"5",children:"5 days"}),(0,r.jsx)(k.Ql,{value:"10",children:"10 days"}),(0,r.jsx)(k.Ql,{value:"30",children:"30 days"})]})]})]}),s&&(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)(n.Z,{size:15,className:"mt-0"}),(0,r.jsx)("span",{className:"ml-2 text-gray-500 text-sm",children:"Loading..."})]}),(0,r.jsxs)("button",{onClick:()=>{N.default.invalidate(x.getClusters),N.default.invalidate(p.getWorkspaces),g&&N.default.invalidate(x.uR),D(!1),C.ZP.preloadForPage("clusters",{force:!0}).then(()=>{D(!0),c.current&&c.current()})},disabled:s,className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:[(0,r.jsx)(f.Z,{className:"h-4 w-4 mr-1.5"}),!O&&(0,r.jsx)("span",{children:"Refresh"})]})]})]}),(0,r.jsx)(z,{filters:q,setFilters:H,updateURLParams:P}),(0,r.jsx)(_,{refreshInterval:i.yc,setLoading:t,refreshDataRef:c,filters:q,showHistory:g,historyDays:E,onOpenSSHModal:e=>{v(e),d(!0)},onOpenVSCodeModal:e=>{v(e),m(!0)},setOptionValues:F,preloadingComplete:A}),(0,r.jsx)(y.Oh,{isOpen:u,onClose:()=>d(!1),cluster:j}),(0,r.jsx)(y._R,{isOpen:h,onClose:()=>m(!1),cluster:j})]})}function _(e){let{refreshInterval:s,setLoading:t,refreshDataRef:a,filters:c,showHistory:p,historyDays:f,onOpenSSHModal:j,onOpenVSCodeModal:v,setOptionValues:g,preloadingComplete:y}=e,[b,k]=(0,l.useState)([]),[C,L]=(0,l.useState)({key:null,direction:"ascending"}),[R,I]=(0,l.useState)(!1),[_,O]=(0,l.useState)(!0),[q,H]=(0,l.useState)(1),[W,V]=(0,l.useState)(10),z=e=>{let s={status:[],cluster:[],user:[],workspace:[],infra:[]},t=(e,s)=>{e.includes(s)||e.push(s)};return e.map(e=>{t(s.status,e.status),t(s.cluster,e.cluster),t(s.user,e.user),t(s.workspace,e.workspace),t(s.infra,e.infra)}),s},A=l.useCallback(async()=>{t(!0),I(!0);try{let e=await N.default.get(x.getClusters);if(p){let s=await N.default.get(x.uR,[null,f]),t=e.map(e=>({...e,isHistorical:!1})),r=s.map(e=>({...e,isHistorical:!0})),l=[...t];r.forEach(s=>{e.some(e=>e.cluster_hash===s.cluster_hash)||l.push(s)}),g(z(l)),k(l)}else{let s=e.map(e=>({...e,isHistorical:!1}));g(z(s)),k(s)}}catch(e){console.error("Error fetching cluster data:",e),g(z([])),k([])}t(!1),I(!1),O(!1)},[t,p,f,g]),D=(e,s)=>{var t;let{property:r,operator:l,value:a}=s;if(!a)return!0;if(!r){let s=a.toLowerCase();return Object.values(e).some(e=>null==e?void 0:e.toString().toLowerCase().includes(s))}let n=null===(t=e[r.toLowerCase()])||void 0===t?void 0:t.toString().toLowerCase(),i=a.toString().toLowerCase();switch(l){case"=":return n===i;case":":return null==n?void 0:n.includes(i);default:return!0}},P=l.useMemo(()=>{let e=0===c.length?b:b.filter(e=>{let s=null;for(let t=0;t<c.length;t++){let r=D(e,c[t]);s=null===s?r:s&&r}return s});return(0,m.R0)(e,C.key,C.direction)},[b,C,c]);l.useEffect(()=>{a&&(a.current=A)},[a,A]),(0,l.useEffect)(()=>{k([]);let e=!0;if(y){A();let t=setInterval(()=>{e&&"visible"===window.document.visibilityState&&A()},s);return()=>{e=!1,clearInterval(t)}}return()=>{e=!1}},[s,A,y]),(0,l.useEffect)(()=>{H(1)},[b.length]);let Z=e=>{let s="ascending";C.key===e&&"ascending"===C.direction&&(s="descending"),L({key:e,direction:s})},B=e=>C.key===e?"ascending"===C.direction?" ↑":" ↓":"",U=Math.ceil(P.length/W),Q=(q-1)*W,T=Q+W,X=P.slice(Q,T);return(0,r.jsxs)("div",{children:[(0,r.jsx)(d.Zb,{children:(0,r.jsx)("div",{className:"overflow-x-auto rounded-lg",children:(0,r.jsxs)(h.iA,{className:"min-w-full",children:[(0,r.jsx)(h.xD,{children:(0,r.jsxs)(h.SC,{children:[(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap",onClick:()=>Z("status"),children:["Status",B("status")]}),(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap",onClick:()=>Z("cluster"),children:["Cluster",B("cluster")]}),(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap",onClick:()=>Z("user"),children:["User",B("user")]}),(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap",onClick:()=>Z("workspace"),children:["Workspace",B("workspace")]}),(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap",onClick:()=>Z("infra"),children:["Infra",B("infra")]}),(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap",onClick:()=>Z("resources_str"),children:["Resources",B("resources_str")]}),(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap",onClick:()=>Z("time"),children:["Started",B("time")]}),p&&(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap",onClick:()=>Z("duration"),children:["Duration",B("duration")]}),(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap",onClick:()=>Z("autostop"),children:["Autostop",B("autostop")]}),(0,r.jsx)(h.ss,{className:"md:sticky md:right-0 md:bg-white",children:"Actions"})]})}),(0,r.jsx)(h.RM,{children:R||!y?(0,r.jsx)(h.SC,{children:(0,r.jsx)(h.pj,{colSpan:9,className:"text-center py-6 text-gray-500",children:(0,r.jsxs)("div",{className:"flex justify-center items-center",children:[(0,r.jsx)(n.Z,{size:20,className:"mr-2"}),(0,r.jsx)("span",{children:"Loading..."})]})})}):X.length>0?X.map((e,s)=>(0,r.jsxs)(h.SC,{children:[(0,r.jsx)(h.pj,{children:(0,r.jsx)(w.OE,{status:e.status})}),(0,r.jsx)(h.pj,{children:(0,r.jsx)(o(),{href:"/clusters/".concat(e.isHistorical?e.cluster_hash:e.cluster||e.name),className:"text-blue-600",children:e.cluster||e.name})}),(0,r.jsx)(h.pj,{children:(0,r.jsx)(S.H,{username:e.user,userHash:e.user_hash})}),(0,r.jsx)(h.pj,{children:(0,r.jsx)(o(),{href:"/workspaces",className:"text-gray-700 hover:text-blue-600 hover:underline",children:e.workspace||"default"})}),(0,r.jsx)(h.pj,{children:(0,r.jsx)(i.Md,{content:e.full_infra||e.infra,className:"text-sm text-muted-foreground",children:(0,r.jsxs)("span",{children:[(0,r.jsx)(o(),{href:"/infra",className:"text-blue-600 hover:underline",children:e.cloud}),e.infra.includes("(")&&(0,r.jsx)("span",{children:" "+e.infra.substring(e.infra.indexOf("("))})]})})}),(0,r.jsx)(h.pj,{children:(0,r.jsx)(i.Md,{content:e.resources_str_full||e.resources_str,className:"text-sm text-muted-foreground",children:(0,r.jsx)("span",{children:e.resources_str})})}),(0,r.jsx)(h.pj,{children:(0,r.jsx)(i.Zg,{date:e.time})}),p&&(0,r.jsx)(h.pj,{children:E(e.duration)}),(0,r.jsx)(h.pj,{children:e.isHistorical?"-":M(e.autostop,e.to_down)}),(0,r.jsx)(h.pj,{className:"text-left md:sticky md:right-0 md:bg-white",children:!e.isHistorical&&(0,r.jsx)(F,{cluster:e.cluster,status:e.status,onOpenSSHModal:j,onOpenVSCodeModal:v})})]},s)):(0,r.jsx)(h.SC,{children:(0,r.jsx)(h.pj,{colSpan:9,className:"text-center py-6 text-gray-500",children:p?"No clusters found":"No active clusters"})})})]})})}),b.length>0&&(0,r.jsx)("div",{className:"flex justify-end items-center py-2 px-4 text-sm text-gray-700",children:(0,r.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("span",{className:"mr-2",children:"Rows per page:"}),(0,r.jsxs)("div",{className:"relative inline-block",children:[(0,r.jsxs)("select",{value:W,onChange:e=>{V(parseInt(e.target.value,10)),H(1)},className:"py-1 pl-2 pr-6 appearance-none outline-none cursor-pointer border-none bg-transparent",style:{minWidth:"40px"},children:[(0,r.jsx)("option",{value:10,children:"10"}),(0,r.jsx)("option",{value:30,children:"30"}),(0,r.jsx)("option",{value:50,children:"50"}),(0,r.jsx)("option",{value:100,children:"100"}),(0,r.jsx)("option",{value:200,children:"200"})]}),(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 text-gray-500 absolute right-0 top-1/2 transform -translate-y-1/2 pointer-events-none",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})]}),(0,r.jsx)("div",{children:"".concat(Q+1," - ").concat(Math.min(T,P.length)," of ").concat(P.length)}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)(u.z,{variant:"ghost",size:"icon",onClick:()=>{H(e=>Math.max(e-1,1))},disabled:1===q,className:"text-gray-500 h-8 w-8 p-0",children:(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"chevron-left",children:(0,r.jsx)("path",{d:"M15 18l-6-6 6-6"})})}),(0,r.jsx)(u.z,{variant:"ghost",size:"icon",onClick:()=>{H(e=>Math.min(e+1,U))},disabled:q===U||0===U,className:"text-gray-500 h-8 w-8 p-0",children:(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"chevron-right",children:(0,r.jsx)("path",{d:"M9 18l6-6-6-6"})})})]})]})})]})}let O=(e,s)=>{s&&s(e)},q=(e,s)=>{s?s(e):window.open("ssh://".concat(e))},H=e=>"RUNNING"===e?["connect","VSCode"]:[],W={connect:(0,r.jsx)(v,{className:"w-4 h-4 text-gray-500 inline-block"}),VSCode:(0,r.jsx)(g,{className:"w-4 h-4 text-gray-500 inline-block"})};function F(e){let{withLabel:s=!1,cluster:t,status:l,onOpenSSHModal:a,onOpenVSCodeModal:n}=e,c=H(l),o=(0,b.X)(),u=e=>{switch(e){case"connect":q(t,a);break;case"VSCode":O(t,n);break;default:return}};return(0,r.jsx)(r.Fragment,{children:(0,r.jsx)("div",{className:"flex items-center space-x-4",children:Object.entries(W).map(e=>{let t,l,[a,n]=e;switch(a){case"connect":t="Connect",l="Connect with SSH";break;case"VSCode":t="VSCode",l="Open in VS Code"}return(s||(t=""),c.includes(a))?(0,r.jsx)(i.WH,{content:l,className:"capitalize text-sm text-muted-foreground",children:(0,r.jsxs)("button",{onClick:()=>u(a),className:"text-sky-blue hover:text-sky-blue-bright font-medium inline-flex items-center",children:[n,!o&&(0,r.jsx)("span",{className:"ml-1.5",children:t})]})},a):(0,r.jsx)(i.WH,{content:l,className:"capitalize text-sm text-muted-foreground",children:(0,r.jsxs)("span",{className:"opacity-30 flex items-center cursor-not-allowed text-sm",title:a,children:[n,!o&&(0,r.jsx)("span",{className:"ml-1.5",children:t})]})},a)})})})}let V=e=>{let{propertyList:s=[],valueList:t,setFilters:a,updateURLParams:n,placeholder:i="Filter clusters"}=e,c=(0,l.useRef)(null),o=(0,l.useRef)(null),[u,d]=(0,l.useState)(!1),[h,x]=(0,l.useState)(""),[p,m]=(0,l.useState)("status"),[f,j]=(0,l.useState)([]);(0,l.useEffect)(()=>{let e=e=>{o.current&&!o.current.contains(e.target)&&c.current&&!c.current.contains(e.target)&&d(!1)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[]),(0,l.useEffect)(()=>{let e=[];if(t&&"object"==typeof t)switch(p){case"status":e=t.status||[];break;case"user":e=t.user||[];break;case"cluster":e=t.cluster||[];break;case"workspace":e=t.workspace||[];break;case"infra":e=t.infra||[]}""!==h.trim()&&(e=e.filter(e=>e&&e.toString().toLowerCase().includes(h.toLowerCase()))),j(e)},[p,t,h]);let v=e=>{let t=s.find(s=>s.value===e);return t?t.label:e},g=e=>{a(s=>{let t=[...s,{property:v(p),operator:":",value:e}];return n(t),t}),d(!1),x(""),c.current.focus()};return(0,r.jsxs)("div",{className:"flex flex-row border border-gray-300 rounded-md overflow-visible",children:[(0,r.jsx)("div",{className:"border-r border-gray-300 flex-shrink-0",children:(0,r.jsxs)(k.Ph,{onValueChange:m,value:p,children:[(0,r.jsx)(k.i4,{"aria-label":"Filter Property",className:"focus:ring-0 focus:ring-offset-0 border-none rounded-l-md rounded-r-none w-20 sm:w-24 md:w-32 h-8 text-xs sm:text-sm",children:(0,r.jsx)(k.ki,{placeholder:"Status"})}),(0,r.jsx)(k.Bw,{children:s.map((e,s)=>(0,r.jsx)(k.Ql,{value:e.value,children:e.label},"property-item-".concat(s)))})]})}),(0,r.jsxs)("div",{className:"relative flex-1",children:[(0,r.jsx)("input",{type:"text",ref:c,placeholder:i,value:h,onChange:e=>{x(e.target.value),u||d(!0)},onFocus:()=>{d(!0)},onKeyDown:e=>{"Enter"===e.key&&""!==h.trim()?(a(e=>{let s=[...e,{property:v(p),operator:":",value:h}];return n(s),s}),x(""),d(!1)):"Escape"===e.key&&(d(!1),c.current.blur())},className:"h-8 w-full sm:w-96 px-3 pr-8 text-sm border-none rounded-l-none rounded-r-md focus:ring-0 focus:outline-none",autoComplete:"off"}),h&&(0,r.jsx)("button",{onClick:()=>{x(""),d(!1)},className:"absolute right-2 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-gray-600",title:"Clear filter",tabIndex:-1,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"})})}),u&&f.length>0&&(0,r.jsx)("div",{ref:o,className:"absolute z-50 mt-1 w-full bg-white border border-gray-200 rounded-md shadow-lg max-h-60 overflow-y-auto",style:{zIndex:9999},children:f.map((e,s)=>(0,r.jsx)("div",{className:"px-3 py-2 cursor-pointer hover:bg-gray-50 text-sm ".concat(s!==f.length-1?"border-b border-gray-100":""),onClick:()=>g(e),children:(0,r.jsx)("span",{className:"text-sm text-gray-700",children:e})},"".concat(e,"-").concat(s)))})]})]})},z=e=>{let{filters:s=[],setFilters:t,updateURLParams:l}=e,a=e=>{t(s=>{let t=s.filter((s,t)=>t!==e);return l(t),t})};return(0,r.jsx)(r.Fragment,{children:(0,r.jsx)("div",{className:"flex items-center gap-4 py-2 px-2",children:(0,r.jsxs)("div",{className:"flex flex-wrap items-content gap-2",children:[s.map((e,s)=>(0,r.jsx)(A,{filter:e,onRemove:()=>a(s)},"filteritem-".concat(s))),s.length>0&&(0,r.jsx)(r.Fragment,{children:(0,r.jsx)("button",{onClick:()=>{l([]),t([])},className:"rounded-full px-4 py-1 text-sm text-gray-700 bg-gray-200 hover:bg-gray-300",children:"Clear filters"})})]})})})},A=e=>{let{filter:s,onRemove:t}=e;return(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"flex items-center text-blue-600 bg-blue-100 px-1 py-1 rounded-full text-sm",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 px-2",children:[(0,r.jsx)("span",{children:"".concat(s.property," ")}),(0,r.jsx)("span",{children:"".concat(s.operator," ")}),(0,r.jsx)("span",{children:" ".concat(s.value)})]}),(0,r.jsx)("button",{onClick:()=>t(),className:"p-0.5 ml-1 transform text-gray-400 hover:text-gray-600 bg-blue-500 hover:bg-blue-600 rounded-full flex flex-col items-center",title:"Clear filter",children:(0,r.jsx)("svg",{className:"h-3 w-3",fill:"none",stroke:"white",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:5,d:"M6 18L18 6M6 6l12 12"})})})]})})}},12003:function(e,s,t){t.d(s,{j:function(){return n}});var r=t(90512);let l=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,a=r.W,n=(e,s)=>t=>{var r;if((null==s?void 0:s.variants)==null)return a(e,null==t?void 0:t.class,null==t?void 0:t.className);let{variants:n,defaultVariants:i}=s,c=Object.keys(n).map(e=>{let s=null==t?void 0:t[e],r=null==i?void 0:i[e];if(null===s)return null;let a=l(s)||l(r);return n[e][a]}),o=t&&Object.entries(t).reduce((e,s)=>{let[t,r]=s;return void 0===r||(e[t]=r),e},{});return a(e,c,null==s?void 0:null===(r=s.compoundVariants)||void 0===r?void 0:r.reduce((e,s)=>{let{class:t,className:r,...l}=s;return Object.entries(l).every(e=>{let[s,t]=e;return Array.isArray(t)?t.includes({...i,...o}[s]):({...i,...o})[s]===t})?[...e,t,r]:e},[]),null==t?void 0:t.class,null==t?void 0:t.className)}}}]);