skypilot-nightly 1.0.0.dev20250915__py3-none-any.whl → 1.0.0.dev20250918__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.
- sky/__init__.py +4 -2
- sky/adaptors/primeintellect.py +1 -0
- sky/adaptors/seeweb.py +68 -4
- sky/authentication.py +25 -0
- sky/backends/__init__.py +3 -2
- sky/backends/backend_utils.py +16 -12
- sky/backends/cloud_vm_ray_backend.py +61 -4
- sky/catalog/primeintellect_catalog.py +95 -0
- sky/client/sdk.py +6 -0
- sky/clouds/__init__.py +2 -0
- sky/clouds/primeintellect.py +314 -0
- sky/core.py +10 -3
- sky/dashboard/out/404.html +1 -1
- sky/dashboard/out/_next/static/chunks/3015-ba5be550eb80fd8c.js +1 -0
- sky/dashboard/out/_next/static/chunks/5339.4a881570243431a5.js +51 -0
- sky/dashboard/out/_next/static/chunks/{6856-e0754534b3015377.js → 6856-9a2538f38c004652.js} +1 -1
- sky/dashboard/out/_next/static/chunks/{6990-11c8e9b982e8ffec.js → 6990-f6818c84ed8f1c86.js} +1 -1
- sky/dashboard/out/_next/static/chunks/8969-a3e3f0683e19d340.js +1 -0
- sky/dashboard/out/_next/static/chunks/9037-472ee1222cb1e158.js +6 -0
- sky/dashboard/out/_next/static/chunks/{webpack-d1e29b3aa66bf4cf.js → webpack-487697b47d8c5e50.js} +1 -1
- sky/dashboard/out/_next/static/{dG6B0i0HO4jIoKb4ZFYJ_ → k1mo5xWZrV9djgjd0moOT}/_buildManifest.js +1 -1
- 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/pools/[pool].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/global_user_state.py +42 -34
- sky/jobs/server/server.py +14 -1
- sky/jobs/state.py +26 -1
- sky/provision/__init__.py +1 -0
- sky/provision/docker_utils.py +50 -3
- sky/provision/instance_setup.py +15 -1
- sky/provision/lambda_cloud/instance.py +12 -11
- sky/provision/primeintellect/__init__.py +10 -0
- sky/provision/primeintellect/config.py +11 -0
- sky/provision/primeintellect/instance.py +454 -0
- sky/provision/primeintellect/utils.py +398 -0
- sky/resources.py +9 -1
- sky/schemas/generated/servev1_pb2.py +58 -0
- sky/schemas/generated/servev1_pb2.pyi +115 -0
- sky/schemas/generated/servev1_pb2_grpc.py +322 -0
- sky/serve/serve_rpc_utils.py +179 -0
- sky/serve/serve_utils.py +29 -12
- sky/serve/server/core.py +37 -19
- sky/serve/server/impl.py +221 -129
- sky/server/common.py +13 -0
- sky/server/constants.py +3 -0
- sky/server/requests/executor.py +23 -6
- sky/server/server.py +10 -5
- sky/setup_files/dependencies.py +1 -0
- sky/skylet/constants.py +5 -3
- sky/skylet/services.py +98 -0
- sky/skylet/skylet.py +3 -1
- sky/skypilot_config.py +10 -3
- sky/templates/kubernetes-ray.yml.j2 +22 -12
- sky/templates/primeintellect-ray.yml.j2 +71 -0
- {skypilot_nightly-1.0.0.dev20250915.dist-info → skypilot_nightly-1.0.0.dev20250918.dist-info}/METADATA +39 -38
- {skypilot_nightly-1.0.0.dev20250915.dist-info → skypilot_nightly-1.0.0.dev20250918.dist-info}/RECORD +74 -62
- sky/dashboard/out/_next/static/chunks/3015-2ea98b57e318bd6e.js +0 -1
- sky/dashboard/out/_next/static/chunks/5339.c033b29835da0f35.js +0 -51
- sky/dashboard/out/_next/static/chunks/8969-0487dfbf149d9e53.js +0 -1
- sky/dashboard/out/_next/static/chunks/9037-f9800e64eb05dd1c.js +0 -6
- /sky/dashboard/out/_next/static/chunks/pages/{workspaces-7598c33a746cdc91.js → workspaces-7528cc0ef8c522c5.js} +0 -0
- /sky/dashboard/out/_next/static/{dG6B0i0HO4jIoKb4ZFYJ_ → k1mo5xWZrV9djgjd0moOT}/_ssgManifest.js +0 -0
- {skypilot_nightly-1.0.0.dev20250915.dist-info → skypilot_nightly-1.0.0.dev20250918.dist-info}/WHEEL +0 -0
- {skypilot_nightly-1.0.0.dev20250915.dist-info → skypilot_nightly-1.0.0.dev20250918.dist-info}/entry_points.txt +0 -0
- {skypilot_nightly-1.0.0.dev20250915.dist-info → skypilot_nightly-1.0.0.dev20250918.dist-info}/licenses/LICENSE +0 -0
- {skypilot_nightly-1.0.0.dev20250915.dist-info → skypilot_nightly-1.0.0.dev20250918.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
""" Prime Intellect Cloud. """
|
|
2
|
+
import json
|
|
3
|
+
import os
|
|
4
|
+
import typing
|
|
5
|
+
from typing import Dict, Iterator, List, Optional, Tuple, Union
|
|
6
|
+
|
|
7
|
+
from sky import catalog
|
|
8
|
+
from sky import clouds
|
|
9
|
+
from sky.provision.primeintellect import utils
|
|
10
|
+
from sky.utils import registry
|
|
11
|
+
from sky.utils import resources_utils
|
|
12
|
+
|
|
13
|
+
if typing.TYPE_CHECKING:
|
|
14
|
+
from sky import resources as resources_lib
|
|
15
|
+
from sky.utils import volume as volume_lib
|
|
16
|
+
|
|
17
|
+
CredentialCheckResult = Tuple[bool, Optional[Union[str, Dict[str, str]]]]
|
|
18
|
+
|
|
19
|
+
_CREDENTIAL_FILES = [
|
|
20
|
+
'config.json',
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@registry.CLOUD_REGISTRY.register
|
|
25
|
+
class PrimeIntellect(clouds.Cloud):
|
|
26
|
+
"""Prime Intellect GPU Cloud"""
|
|
27
|
+
_REPR = 'PrimeIntellect'
|
|
28
|
+
_CLOUD_UNSUPPORTED_FEATURES = {
|
|
29
|
+
clouds.CloudImplementationFeatures.AUTOSTOP: 'Stopping not supported.',
|
|
30
|
+
clouds.CloudImplementationFeatures.AUTODOWN:
|
|
31
|
+
('Auto down not supported yet.'),
|
|
32
|
+
clouds.CloudImplementationFeatures.STOP: 'Stopping not supported.',
|
|
33
|
+
clouds.CloudImplementationFeatures.MULTI_NODE:
|
|
34
|
+
('Multi-node not supported yet.'),
|
|
35
|
+
clouds.CloudImplementationFeatures.CUSTOM_DISK_TIER:
|
|
36
|
+
('Custom disk tier not supported yet.'),
|
|
37
|
+
clouds.CloudImplementationFeatures.CUSTOM_NETWORK_TIER:
|
|
38
|
+
('Custom network tier not supported yet.'),
|
|
39
|
+
clouds.CloudImplementationFeatures.CUSTOM_MULTI_NETWORK:
|
|
40
|
+
('Customized multiple network interfaces are not supported'),
|
|
41
|
+
clouds.CloudImplementationFeatures.IMAGE_ID:
|
|
42
|
+
('Custom image not supported yet.'),
|
|
43
|
+
clouds.CloudImplementationFeatures.DOCKER_IMAGE:
|
|
44
|
+
('Custom docker image not supported yet.'),
|
|
45
|
+
}
|
|
46
|
+
PROVISIONER_VERSION = clouds.ProvisionerVersion.SKYPILOT
|
|
47
|
+
STATUS_VERSION = clouds.StatusVersion.SKYPILOT
|
|
48
|
+
_MAX_CLUSTER_NAME_LEN_LIMIT = 120
|
|
49
|
+
_regions: List[clouds.Region] = []
|
|
50
|
+
|
|
51
|
+
@classmethod
|
|
52
|
+
def _cloud_unsupported_features(
|
|
53
|
+
cls) -> Dict[clouds.CloudImplementationFeatures, str]:
|
|
54
|
+
return cls._CLOUD_UNSUPPORTED_FEATURES
|
|
55
|
+
|
|
56
|
+
@classmethod
|
|
57
|
+
def _max_cluster_name_length(cls) -> Optional[int]:
|
|
58
|
+
return cls._MAX_CLUSTER_NAME_LEN_LIMIT
|
|
59
|
+
|
|
60
|
+
@classmethod
|
|
61
|
+
def regions_with_offering(
|
|
62
|
+
cls,
|
|
63
|
+
instance_type: str,
|
|
64
|
+
accelerators: Optional[Dict[str, int]],
|
|
65
|
+
use_spot: bool,
|
|
66
|
+
region: Optional[str],
|
|
67
|
+
zone: Optional[str],
|
|
68
|
+
) -> List[clouds.Region]:
|
|
69
|
+
"""Returns the regions that offer the specified resources."""
|
|
70
|
+
del accelerators
|
|
71
|
+
regions = catalog.get_region_zones_for_instance_type(
|
|
72
|
+
instance_type, use_spot, 'primeintellect')
|
|
73
|
+
|
|
74
|
+
if region is not None:
|
|
75
|
+
regions = [r for r in regions if r.name == region]
|
|
76
|
+
if zone is not None:
|
|
77
|
+
for r in regions:
|
|
78
|
+
assert r.zones is not None, r
|
|
79
|
+
r.set_zones([z for z in r.zones if z.name == zone])
|
|
80
|
+
regions = [r for r in regions if r.zones]
|
|
81
|
+
return regions
|
|
82
|
+
|
|
83
|
+
@classmethod
|
|
84
|
+
def get_vcpus_mem_from_instance_type(
|
|
85
|
+
cls,
|
|
86
|
+
instance_type: str,
|
|
87
|
+
) -> Tuple[Optional[float], Optional[float]]:
|
|
88
|
+
"""Returns the #vCPUs and memory that the instance type offers."""
|
|
89
|
+
return catalog.get_vcpus_mem_from_instance_type(instance_type,
|
|
90
|
+
clouds='primeintellect')
|
|
91
|
+
|
|
92
|
+
@classmethod
|
|
93
|
+
def zones_provision_loop(
|
|
94
|
+
cls,
|
|
95
|
+
*,
|
|
96
|
+
region: str,
|
|
97
|
+
num_nodes: int,
|
|
98
|
+
instance_type: str,
|
|
99
|
+
accelerators: Optional[Dict[str, int]] = None,
|
|
100
|
+
use_spot: bool = False,
|
|
101
|
+
) -> Iterator[Optional[List['clouds.Zone']]]:
|
|
102
|
+
"""Returns an iterator over zones for provisioning."""
|
|
103
|
+
regions = cls.regions_with_offering(instance_type,
|
|
104
|
+
accelerators,
|
|
105
|
+
use_spot,
|
|
106
|
+
region=region,
|
|
107
|
+
zone=None)
|
|
108
|
+
for r in regions:
|
|
109
|
+
assert r.zones is not None, r
|
|
110
|
+
yield r.zones
|
|
111
|
+
|
|
112
|
+
def instance_type_to_hourly_cost(self,
|
|
113
|
+
instance_type: str,
|
|
114
|
+
use_spot: bool,
|
|
115
|
+
region: Optional[str] = None,
|
|
116
|
+
zone: Optional[str] = None) -> float:
|
|
117
|
+
"""Returns the cost, or the cheapest cost among all zones for spot."""
|
|
118
|
+
return catalog.get_hourly_cost(instance_type,
|
|
119
|
+
use_spot=use_spot,
|
|
120
|
+
region=region,
|
|
121
|
+
zone=zone,
|
|
122
|
+
clouds='primeintellect')
|
|
123
|
+
|
|
124
|
+
def accelerators_to_hourly_cost(self,
|
|
125
|
+
accelerators: Dict[str, int],
|
|
126
|
+
use_spot: bool,
|
|
127
|
+
region: Optional[str] = None,
|
|
128
|
+
zone: Optional[str] = None) -> float:
|
|
129
|
+
"""Returns the cost, or the cheapest cost among all zones for spot."""
|
|
130
|
+
del accelerators, use_spot, region, zone # Unused.
|
|
131
|
+
return 0.0
|
|
132
|
+
|
|
133
|
+
def get_egress_cost(self, num_gigabytes: float) -> float:
|
|
134
|
+
return 0.0
|
|
135
|
+
|
|
136
|
+
def is_same_cloud(self, other: clouds.Cloud) -> bool:
|
|
137
|
+
return isinstance(other, PrimeIntellect)
|
|
138
|
+
|
|
139
|
+
@classmethod
|
|
140
|
+
def get_default_instance_type(cls,
|
|
141
|
+
cpus: Optional[str] = None,
|
|
142
|
+
memory: Optional[str] = None,
|
|
143
|
+
disk_tier: Optional[
|
|
144
|
+
resources_utils.DiskTier] = None,
|
|
145
|
+
region: Optional[str] = None,
|
|
146
|
+
zone: Optional[str] = None) -> Optional[str]:
|
|
147
|
+
"""Returns the default instance type for Prime Intellect."""
|
|
148
|
+
return catalog.get_default_instance_type(cpus=cpus,
|
|
149
|
+
memory=memory,
|
|
150
|
+
disk_tier=disk_tier,
|
|
151
|
+
region=region,
|
|
152
|
+
zone=zone,
|
|
153
|
+
clouds='primeintellect')
|
|
154
|
+
|
|
155
|
+
@classmethod
|
|
156
|
+
def get_accelerators_from_instance_type(
|
|
157
|
+
cls, instance_type: str) -> Optional[Dict[str, Union[int, float]]]:
|
|
158
|
+
return catalog.get_accelerators_from_instance_type(
|
|
159
|
+
instance_type, clouds='primeintellect')
|
|
160
|
+
|
|
161
|
+
@classmethod
|
|
162
|
+
def get_zone_shell_cmd(cls) -> Optional[str]:
|
|
163
|
+
return None
|
|
164
|
+
|
|
165
|
+
def make_deploy_resources_variables(
|
|
166
|
+
self,
|
|
167
|
+
resources: 'resources_lib.Resources',
|
|
168
|
+
cluster_name: resources_utils.ClusterName,
|
|
169
|
+
region: 'clouds.Region',
|
|
170
|
+
zones: Optional[List['clouds.Zone']],
|
|
171
|
+
num_nodes: int,
|
|
172
|
+
dryrun: bool = False,
|
|
173
|
+
volume_mounts: Optional[List['volume_lib.VolumeMount']] = None
|
|
174
|
+
) -> Dict[str, Optional[str]]:
|
|
175
|
+
del dryrun, cluster_name, num_nodes, volume_mounts
|
|
176
|
+
assert zones is not None, (region, zones)
|
|
177
|
+
|
|
178
|
+
resources = resources.assert_launchable()
|
|
179
|
+
acc_dict = self.get_accelerators_from_instance_type(
|
|
180
|
+
resources.instance_type)
|
|
181
|
+
if acc_dict is not None:
|
|
182
|
+
custom_resources = json.dumps(acc_dict, separators=(',', ':'))
|
|
183
|
+
else:
|
|
184
|
+
custom_resources = None
|
|
185
|
+
|
|
186
|
+
return {
|
|
187
|
+
'instance_type': resources.instance_type,
|
|
188
|
+
'custom_resources': custom_resources,
|
|
189
|
+
'region': region.name,
|
|
190
|
+
'zones': zones[0].name,
|
|
191
|
+
'availability_zone': zones[0].name,
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
def _get_feasible_launchable_resources(
|
|
195
|
+
self, resources: 'resources_lib.Resources'
|
|
196
|
+
) -> 'resources_utils.FeasibleResources':
|
|
197
|
+
"""Returns a list of feasible resources for the given resources."""
|
|
198
|
+
if resources.instance_type is not None:
|
|
199
|
+
assert resources.is_launchable(), resources
|
|
200
|
+
resources = resources.copy(accelerators=None)
|
|
201
|
+
return resources_utils.FeasibleResources([resources], [], None)
|
|
202
|
+
|
|
203
|
+
def _make(instance_list):
|
|
204
|
+
resource_list = []
|
|
205
|
+
for instance_type in instance_list:
|
|
206
|
+
r = resources.copy(
|
|
207
|
+
cloud=PrimeIntellect(),
|
|
208
|
+
instance_type=instance_type,
|
|
209
|
+
accelerators=None,
|
|
210
|
+
cpus=None,
|
|
211
|
+
)
|
|
212
|
+
resource_list.append(r)
|
|
213
|
+
return resource_list
|
|
214
|
+
|
|
215
|
+
# Currently, handle a filter on accelerators only.
|
|
216
|
+
accelerators = resources.accelerators
|
|
217
|
+
if accelerators is None:
|
|
218
|
+
default_instance_type = PrimeIntellect.get_default_instance_type(
|
|
219
|
+
cpus=resources.cpus,
|
|
220
|
+
memory=resources.memory,
|
|
221
|
+
disk_tier=resources.disk_tier)
|
|
222
|
+
if default_instance_type is None:
|
|
223
|
+
# TODO(pokgak): Add hints to all return values in this method
|
|
224
|
+
# to help users understand why the resources are not
|
|
225
|
+
# launchable.
|
|
226
|
+
return resources_utils.FeasibleResources([], [], None)
|
|
227
|
+
else:
|
|
228
|
+
return resources_utils.FeasibleResources(
|
|
229
|
+
_make([default_instance_type]), [], None)
|
|
230
|
+
|
|
231
|
+
assert len(accelerators) == 1, resources
|
|
232
|
+
acc, acc_count = list(accelerators.items())[0]
|
|
233
|
+
(instance_list,
|
|
234
|
+
fuzzy_candidate_list) = catalog.get_instance_type_for_accelerator(
|
|
235
|
+
acc,
|
|
236
|
+
acc_count,
|
|
237
|
+
use_spot=resources.use_spot,
|
|
238
|
+
cpus=resources.cpus,
|
|
239
|
+
region=resources.region,
|
|
240
|
+
zone=resources.zone,
|
|
241
|
+
clouds='primeintellect')
|
|
242
|
+
if instance_list is None:
|
|
243
|
+
return resources_utils.FeasibleResources([], fuzzy_candidate_list,
|
|
244
|
+
None)
|
|
245
|
+
return resources_utils.FeasibleResources(_make(instance_list),
|
|
246
|
+
fuzzy_candidate_list, None)
|
|
247
|
+
|
|
248
|
+
@classmethod
|
|
249
|
+
def _check_credentials(cls) -> Tuple[bool, Optional[str]]:
|
|
250
|
+
"""Verify that the user has valid credentials for Prime Intellect."""
|
|
251
|
+
|
|
252
|
+
primeintellect_config_file = '~/.prime/config.json'
|
|
253
|
+
if not os.path.isfile(os.path.expanduser(primeintellect_config_file)):
|
|
254
|
+
return (False, f'{primeintellect_config_file} does not exist.')
|
|
255
|
+
|
|
256
|
+
with open(os.path.expanduser(primeintellect_config_file),
|
|
257
|
+
encoding='UTF-8') as f:
|
|
258
|
+
data = json.load(f)
|
|
259
|
+
api_key = data.get('api_key')
|
|
260
|
+
if not api_key:
|
|
261
|
+
print('API key is missing or empty')
|
|
262
|
+
|
|
263
|
+
client = utils.PrimeIntellectAPIClient()
|
|
264
|
+
try:
|
|
265
|
+
client.list_instances()
|
|
266
|
+
except utils.PrimeintellectAPIError as e:
|
|
267
|
+
if e.status_code == 403:
|
|
268
|
+
return False, (
|
|
269
|
+
'Please check that your API key has the correct '
|
|
270
|
+
'permissions, generate a new one at '
|
|
271
|
+
'https://app.primeintellect.ai/dashboard/tokens, '
|
|
272
|
+
'or run \'prime login\' to configure a new API key.')
|
|
273
|
+
return True, None
|
|
274
|
+
|
|
275
|
+
@classmethod
|
|
276
|
+
def _check_compute_credentials(cls) -> CredentialCheckResult:
|
|
277
|
+
"""Checks if the user has access credentials to Prime Intellect's
|
|
278
|
+
compute service."""
|
|
279
|
+
return cls._check_credentials()
|
|
280
|
+
|
|
281
|
+
def get_credential_file_mounts(self) -> Dict[str, str]:
|
|
282
|
+
"""Returns a dict of credential file paths to mount paths."""
|
|
283
|
+
return {
|
|
284
|
+
f'~/.prime/{filename}': f'~/.prime/{filename}'
|
|
285
|
+
for filename in _CREDENTIAL_FILES
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
@classmethod
|
|
289
|
+
def get_current_user_identity(cls) -> Optional[List[str]]:
|
|
290
|
+
return None
|
|
291
|
+
|
|
292
|
+
def instance_type_exists(self, instance_type: str) -> bool:
|
|
293
|
+
return catalog.instance_type_exists(instance_type, 'primeintellect')
|
|
294
|
+
|
|
295
|
+
def validate_region_zone(self, region: Optional[str], zone: Optional[str]):
|
|
296
|
+
return catalog.validate_region_zone(region,
|
|
297
|
+
zone,
|
|
298
|
+
clouds='primeintellect')
|
|
299
|
+
|
|
300
|
+
@classmethod
|
|
301
|
+
def _unsupported_features_for_resources(
|
|
302
|
+
cls, resources: 'resources_lib.Resources'
|
|
303
|
+
) -> Dict[clouds.CloudImplementationFeatures, str]:
|
|
304
|
+
"""The features not supported based on the resources provided.
|
|
305
|
+
|
|
306
|
+
This method is used by check_features_are_supported() to check if the
|
|
307
|
+
cloud implementation supports all the requested features.
|
|
308
|
+
|
|
309
|
+
Returns:
|
|
310
|
+
A dict of {feature: reason} for the features not supported by the
|
|
311
|
+
cloud implementation.
|
|
312
|
+
"""
|
|
313
|
+
del resources # unused
|
|
314
|
+
return cls._CLOUD_UNSUPPORTED_FEATURES
|
sky/core.py
CHANGED
|
@@ -182,9 +182,16 @@ def status(
|
|
|
182
182
|
cluster_names=cluster_names,
|
|
183
183
|
all_users=all_users,
|
|
184
184
|
include_credentials=include_credentials)
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
185
|
+
|
|
186
|
+
status_responses = []
|
|
187
|
+
for cluster in clusters:
|
|
188
|
+
try:
|
|
189
|
+
status_responses.append(
|
|
190
|
+
responses.StatusResponse.model_validate(cluster))
|
|
191
|
+
except Exception as e: # pylint: disable=broad-except
|
|
192
|
+
logger.warning('Failed to validate status responses for cluster '
|
|
193
|
+
f'{cluster.get("name")}: {e}')
|
|
194
|
+
return status_responses
|
|
188
195
|
|
|
189
196
|
|
|
190
197
|
def status_kubernetes(
|
sky/dashboard/out/404.html
CHANGED
|
@@ -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-
|
|
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-487697b47d8c5e50.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/k1mo5xWZrV9djgjd0moOT/_buildManifest.js" defer=""></script><script src="/dashboard/_next/static/k1mo5xWZrV9djgjd0moOT/_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":"k1mo5xWZrV9djgjd0moOT","assetPrefix":"/dashboard","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3015],{23015:function(e,s,t){t.r(s),t.d(s,{ClusterJobs:function(){return H},ManagedJobs:function(){return Z},ManagedJobsTable:function(){return B},Status2Actions:function(){return q},filterJobsByName:function(){return J},filterJobsByPool:function(){return O},filterJobsByUser:function(){return W},filterJobsByWorkspace:function(){return U},statusGroups:function(){return z}});var a=t(85893),r=t(67294),l=t(11163),n=t(41664),i=t.n(n),c=t(55739),o=t(30803),d=t(37673),u=t(68764),h=t(36989),x=t(51214),m=t(68969),p=t(6378);class j{_generateFilterKey(e){let{allUsers:s=!0,nameMatch:t,userMatch:a,workspaceMatch:r,poolMatch:l,statuses:n}=e;return["allUsers:".concat(s),t?"name:".concat(t):"",a?"user:".concat(a):"",r?"workspace:".concat(r):"",l?"pool:".concat(l):"",n&&n.length>0?"statuses:".concat(n.sort().join(",")):""].filter(Boolean).join("|")||"default"}_getCacheStatus(e){let s=this.fullDataCache.get(e),t=Date.now();if(!s)return{isCached:!1,isFresh:!1,age:0,maxAge:12e4,hasData:!1};let a=t-s.timestamp;return{isCached:!0,isFresh:a<12e4,age:a,maxAge:12e4,hasData:s.jobs&&Array.isArray(s.jobs),data:s}}async getPaginatedJobs(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{page:s=1,limit:t=10,...a}=e,r=this._generateFilterKey(a);try{let e=this._getCacheStatus(r);if(e.isCached&&e.hasData){let l=e.data,n=(s-1)*t,i=l.jobs.slice(n,n+t);if(!this.prefetching.has(r)&&(!e.isFresh||e.age>e.maxAge/2)){let e=this._loadFullDataset(a,r).catch(()=>{}).finally(()=>this.prefetching.delete(r));this.prefetching.set(r,e)}return{jobs:i,total:l.total,totalNoFilter:l.totalNoFilter||l.total,controllerStopped:l.controllerStopped,statusCounts:l.statusCounts||{},fromCache:!0,cacheStatus:e.isFresh?"local_cache_hit":"local_cache_stale_hit"}}let l=await p.default.get(m.getManagedJobs,[{...a,page:s,limit:t}]),n=(null==l?void 0:l.jobs)||[],i="number"==typeof(null==l?void 0:l.total)?l.total:n.length,c=!!(null==l?void 0:l.controllerStopped);if(!this.prefetching.has(r)){let e=this._loadFullDataset(a,r).catch(e=>{console.warn("Background prefetch of full jobs failed:",e)}).finally(()=>{this.prefetching.delete(r)});this.prefetching.set(r,e)}return{jobs:n,total:i,totalNoFilter:(null==l?void 0:l.totalNoFilter)||i,controllerStopped:c,statusCounts:(null==l?void 0:l.statusCounts)||{},fromCache:!1,cacheStatus:"server_page_fetch"}}catch(e){return console.error("Error in getPaginatedJobs:",e),{jobs:[],total:0,totalNoFilter:0,controllerStopped:!1,statusCounts:{},fromCache:!1,cacheStatus:"error"}}}async _loadFullDataset(e,s){let t=await p.default.get(m.getManagedJobs,[e]);if(t.controllerStopped||!t.jobs)return t;let a={jobs:t.jobs,total:t.jobs.length,totalNoFilter:t.totalNoFilter||t.jobs.length,controllerStopped:!1,statusCounts:t.statusCounts||{},timestamp:Date.now()};return this.fullDataCache.set(s,a),a}isDataLoading(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=this._generateFilterKey(e);return this.isLoading.has(s)||this.prefetching.has(s)}isDataCached(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=this._generateFilterKey(e),t=this._getCacheStatus(s);return t.isCached&&t.isFresh&&t.hasData}getCacheStatus(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=this._generateFilterKey(e);return this._getCacheStatus(s)}invalidateCache(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(e){let s=this._generateFilterKey(e);this.fullDataCache.delete(s),this.isLoading.delete(s),this.prefetching.delete(s)}else this.fullDataCache.clear(),this.isLoading.clear(),this.prefetching.clear();p.default.invalidateFunction(m.getManagedJobs)}getCacheStats(){let e={cachedFilters:Array.from(this.fullDataCache.keys()),loadingFilters:Array.from(this.isLoading.keys()),prefetchingFilters:Array.from(this.prefetching.keys()),cacheSize:this.fullDataCache.size,loadingCount:this.isLoading.size,prefetchingCount:this.prefetching.size};for(let[s,t]of(e.detailedStatus={},this.fullDataCache.entries())){let a=this._getCacheStatus(s);e.detailedStatus[s]={age:a.age,isFresh:a.isFresh,hasData:a.hasData,jobCount:t.jobs?t.jobs.length:0}}return e}constructor(){this.fullDataCache=new Map,this.isLoading=new Map,this.prefetching=new Map}}let f=new j;var g=t(23266),b=t(17324),v=t(53081),w=t(13626),N=t(23293),y=t(6521),k=t(16826),C=t(92128),S=t(94545),_=t(99307),L=t(20546),E=t(23001),R=t(88950);let D=(e,s)=>{let t={...e.query},a=[],r=[],l=[];s.map((e,s)=>{var t;a.push(null!==(t=e.property.toLowerCase())&&void 0!==t?t:""),r.push(e.operator),l.push(e.value)}),t.property=a,t.operator=r,t.value=l,e.replace({pathname:e.pathname,query:t},void 0,{shallow:!0})},F=(e,s)=>{let t={...e.query},a=t.property,r=t.operator,l=t.value;if(void 0===a)return[];let n=[],i=Array.isArray(a)?a.length:1;if(1===i)n.push({property:s.get(a),operator:r,value:l});else for(let e=0;e<i;e++)n.push({property:s.get(a[e]),operator:r[e],value:l[e]});return n},M=e=>{var s,t;let{propertyList:l=[],valueList:n,setFilters:i,updateURLParams:c,placeholder:o="Filter items"}=e,d=(0,r.useRef)(null),u=(0,r.useRef)(null),[h,x]=(0,r.useState)(!1),[m,p]=(0,r.useState)(""),[j,f]=(0,r.useState)((null===(s=l[0])||void 0===s?void 0:s.value)||"status"),[g,b]=(0,r.useState)([]);(0,r.useEffect)(()=>{let e=e=>{u.current&&!u.current.contains(e.target)&&d.current&&!d.current.contains(e.target)&&x(!1)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[]),(0,r.useEffect)(()=>{let e=[];n&&"object"==typeof n&&(e=n[j]||[]),""!==m.trim()&&(e=e.filter(e=>e&&e.toString().toLowerCase().includes(m.toLowerCase()))),b(e)},[j,n,m]);let v=e=>{let s=l.find(s=>s.value===e);return s?s.label:e},w=e=>{i(s=>{let t=[...s,{property:v(j),operator:":",value:e}];return c(t),t}),x(!1),p(""),d.current.focus()};return(0,a.jsxs)("div",{className:"flex flex-row border border-gray-300 rounded-md overflow-visible",children:[(0,a.jsx)("div",{className:"border-r border-gray-300 flex-shrink-0",children:(0,a.jsxs)(R.Ph,{onValueChange:f,value:j,children:[(0,a.jsx)(R.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,a.jsx)(R.ki,{placeholder:(null===(t=l[0])||void 0===t?void 0:t.label)||"Status"})}),(0,a.jsx)(R.Bw,{children:l.map((e,s)=>(0,a.jsx)(R.Ql,{value:e.value,children:e.label},"property-item-".concat(s)))})]})}),(0,a.jsxs)("div",{className:"relative flex-1",children:[(0,a.jsx)("input",{type:"text",ref:d,placeholder:o,value:m,onChange:e=>{p(e.target.value),h||x(!0)},onFocus:()=>{x(!0)},onKeyDown:e=>{"Enter"===e.key&&""!==m.trim()?(i(e=>{let s=[...e,{property:v(j),operator:":",value:m}];return c(s),s}),p(""),x(!1)):"Escape"===e.key&&(x(!1),d.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"}),m&&(0,a.jsx)("button",{onClick:()=>{p(""),x(!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,a.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),h&&g.length>0&&(0,a.jsx)("div",{ref:u,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:g.map((e,s)=>(0,a.jsx)("div",{className:"px-3 py-2 cursor-pointer hover:bg-gray-50 text-sm ".concat(s!==g.length-1?"border-b border-gray-100":""),onClick:()=>w(e),children:(0,a.jsx)("span",{className:"text-sm text-gray-700",children:e})},"".concat(e,"-").concat(s)))})]})]})},I=e=>{let{filters:s=[],setFilters:t,updateURLParams:r}=e,l=e=>{t(s=>{let t=s.filter((s,t)=>t!==e);return r(t),t})};return(0,a.jsx)(a.Fragment,{children:(0,a.jsx)("div",{className:"flex items-center gap-4 py-2 px-2",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-content gap-2",children:[s.map((e,s)=>(0,a.jsx)(A,{filter:e,onRemove:()=>l(s)},"filteritem-".concat(s))),s.length>0&&(0,a.jsx)(a.Fragment,{children:(0,a.jsx)("button",{onClick:()=>{r([]),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,a.jsx)(a.Fragment,{children:(0,a.jsxs)("div",{className:"flex items-center text-blue-600 bg-blue-100 px-1 py-1 rounded-full text-sm",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1 px-2",children:[(0,a.jsx)("span",{children:"".concat(s.property," ")}),(0,a.jsx)("span",{children:"".concat(s.operator," ")}),(0,a.jsx)("span",{children:" ".concat(s.value)})]}),(0,a.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,a.jsx)("svg",{className:"h-3 w-3",fill:"none",stroke:"white",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:5,d:"M6 18L18 6M6 6l12 12"})})})]})})},z={active:["PENDING","RUNNING","RECOVERING","SUBMITTED","STARTING","CANCELLING"],finished:["SUCCEEDED","FAILED","CANCELLED","FAILED_SETUP","FAILED_PRECHECKS","FAILED_NO_RESOURCE","FAILED_CONTROLLER"]},P=[{label:"Name",value:"name"},{label:"User",value:"user"},{label:"Workspace",value:"workspace"},{label:"Pool",value:"pool"}];function J(e,s){if(!s||""===s.trim())return e;let t=s.toLowerCase().trim();return e.filter(e=>(e.name||"").toLowerCase().includes(t))}function U(e,s){return s&&"ALL_WORKSPACES"!==s?e.filter(e=>(e.workspace||"default").toLowerCase()===s.toLowerCase()):e}function W(e,s){return s&&"ALL_USERS"!==s?e.filter(e=>(e.user_hash||e.user)===s):e}function O(e,s){if(!s||""===s.trim())return e;let t=s.toLowerCase().trim();return e.filter(e=>(e.pool||"").toLowerCase().includes(t))}let T=e=>{if(!e)return"-";let s=e instanceof Date?e:new Date(1e3*e);return(0,a.jsx)(h.Zg,{date:s})};function Z(){let e=(0,l.useRouter)(),[s,t]=(0,r.useState)(!1),[n,c]=(0,r.useState)(!0),[o,d]=(0,r.useState)(!0),u=r.useRef(null),x=r.useRef(null),[j,g]=(0,r.useState)([]),[w,N]=(0,r.useState)([]),y=async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];t(!0),!e&&o&&c(!0);try{let[e]=await Promise.all([p.default.get(m.vs,[{}])]);g(e.pools||[])}catch(e){console.error("Error fetching data:",e)}finally{t(!1),!e&&o&&(c(!1),d(!1))}};(0,r.useEffect)(()=>{y()},[]);let k=s=>{D(e,s)},C=r.useCallback(()=>{let s=new Map;s.set("",""),s.set("status","Status"),s.set("name","Name"),s.set("user","User"),s.set("workspace","Workspace"),s.set("pool","Pool"),N(F(e,s))},[e,N]);return(0,r.useEffect)(()=>{e.isReady&&C()},[e.isReady,e.query.tab,C]),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 mb-1",children:[(0,a.jsx)("div",{className:"text-base",children:(0,a.jsx)(i(),{href:"/jobs",className:"text-sky-blue hover:underline leading-none",children:"Managed Jobs"})}),(0,a.jsx)("div",{className:"w-full sm:w-auto",children:(0,a.jsx)(M,{propertyList:P,valueList:{},setFilters:N,updateURLParams:k,placeholder:"Filter jobs"})})]}),(0,a.jsx)(I,{filters:w,setFilters:N,updateURLParams:k}),(0,a.jsx)(B,{refreshInterval:h.yc,setLoading:t,refreshDataRef:u,filters:w,onRefresh:()=>{f.invalidateCache(),p.default.invalidate(m.vs,[{}]),p.default.invalidate(b.getWorkspaces),p.default.invalidate(v.R),u.current&&u.current(),x.current&&x.current()},poolsData:j,poolsLoading:n}),(0,a.jsx)("div",{className:"mb-4",children:(0,a.jsx)(V,{refreshInterval:h.yc,setLoading:t,refreshDataRef:x})})]})}function B(e){let{refreshInterval:s,setLoading:t,refreshDataRef:l,filters:n,onRefresh:j,poolsData:b,poolsLoading:v}=e,[y,k]=(0,r.useState)([]),[R,D]=(0,r.useState)(0),[F,M]=(0,r.useState)(0),[I,A]=(0,r.useState)({key:null,direction:"ascending"}),[P,J]=(0,r.useState)(!1),[U,W]=(0,r.useState)(!0),[O,Z]=(0,r.useState)(1),[B,H]=(0,r.useState)(10),[V,Y]=(0,r.useState)(null),Q=(0,r.useRef)(null),[X,$]=(0,r.useState)([]),[ee,es]=(0,r.useState)({}),[et,ea]=(0,r.useState)({}),[er,el]=(0,r.useState)(!1),[en,ei]=(0,r.useState)(!1),[ec,eo]=(0,r.useState)(!1),[ed,eu]=(0,r.useState)("all"),[eh,ex]=(0,r.useState)(!0),[em,ep]=(0,r.useState)({isOpen:!1,title:"",message:"",onConfirm:null}),ej=(0,E.X)(),ef=async()=>{ep({isOpen:!0,title:"Restart Controller",message:"Are you sure you want to restart the controller?",onConfirm:async()=>{try{eo(!0),J(!0),await (0,m.Ce)("restartcontroller"),await eg()}catch(e){console.error("Error restarting controller:",e)}finally{eo(!1),J(!1)}}})},eg=r.useCallback(async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=!1!==e.includeStatus;J(!0),t(!0);try{let e,t;let a=e=>{let s=(n||[]).find(s=>(s.property||"").toLowerCase()===e);return s&&s.value?String(s.value):void 0};X.length>0?t=X:eh?"active"===ed?t=z.active:"finished"===ed&&(t=z.finished):t=[];let r={allUsers:!0,nameMatch:a("name"),userMatch:a("user"),workspaceMatch:a("workspace"),poolMatch:a("pool"),statuses:t,page:O,limit:B},l=null;if(f.isDataCached(r),f.isDataLoading(r),s){let[s,t]=await Promise.all([f.getPaginatedJobs(r),p.default.get(g.getClusters)]);e=s,l=t}else e=await f.getPaginatedJobs(r);let{jobs:i=[],total:c=0,totalNoFilter:o=0,controllerStopped:d=!1,cacheStatus:u="unknown",statusCounts:h={}}=e||{},x=!1,m=!1;if(s&&l){let e=null==l?void 0:l.find(e=>(0,S.Ym)(e.cluster)),s=e?e.status:"NOT_FOUND";"STOPPED"==s&&d&&(x=!0),"LAUNCHING"==s&&(m=!0)}k(i),D(c||0),M(o||0),el(!!x),ei(!!m),ea(h),W(!1)}catch(e){console.error("Error fetching data:",e),k([]),el(!1),W(!1)}finally{J(!1),t(!1)}},[t,n,O,B,X,eh,ed]);r.useEffect(()=>{l&&(l.current=eg)},[l,eg]);let eb=r.useRef(eg);r.useEffect(()=>{eb.current=eg},[eg]),r.useEffect(()=>{eg({includeStatus:!0})},[]),r.useEffect(()=>{eg({includeStatus:!1})},[O]),r.useEffect(()=>{eg({includeStatus:!0})},[n,B]),r.useEffect(()=>{eg({includeStatus:!0})},[ed,X,eh]),(0,r.useEffect)(()=>{let e=setInterval(()=>{eb.current&&eb.current({includeStatus:!0})},s);return()=>{clearInterval(e)}},[s]),(0,r.useEffect)(()=>{Z(1)},[ed]),(0,r.useEffect)(()=>{Z(1)},[n,B]),(0,r.useEffect)(()=>{$([]),ex(!0)},[ed]);let ev=e=>{let s="ascending";I.key===e&&"ascending"===I.direction&&(s="descending"),A({key:e,direction:s})},ew=e=>I.key===e?"ascending"===I.direction?" ↑":" ↓":"";r.useMemo(()=>{let e=y||[];return{active:e.filter(e=>z.active.includes(e.status)).length,finished:e.filter(e=>z.finished.includes(e.status)).length}},[y]);let eN=e=>X.length>0?X.includes(e):"all"===ed||z[ed].includes(e),ey=r.useMemo(()=>y,[y]),ek=r.useMemo(()=>I.key?[...ey].sort((e,s)=>e[I.key]<s[I.key]?"ascending"===I.direction?-1:1:e[I.key]>s[I.key]?"ascending"===I.direction?1:-1:0):ey,[ey,I]),eC=(O-1)*B,eS=R>0?Math.ceil(R/B):0,e_=R>0?Math.min(eC+ek.length,R):0,eL=e=>{if(X.includes(e)){let s=X.filter(s=>s!==e);0===s.length?(ex(!0),$([])):($(s),ex(!1))}else $([...X,e]),ex(!1);Z(1)};return(0,r.useEffect)(()=>{es(et)},[et]),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("div",{className:"flex flex-col space-y-1 mb-1",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between text-sm mb-1",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center",children:[(0,a.jsx)("span",{className:"mr-2 text-sm font-medium",children:"Statuses:"}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2 items-center",children:[!P&&0===F&&!U&&(0,a.jsx)("span",{className:"text-gray-500 mr-2",children:"No jobs found"}),Object.entries(ee).map(e=>{let[s,t]=e;return(0,a.jsxs)("button",{onClick:()=>eL(s),className:"px-3 py-0.5 rounded-full flex items-center space-x-2 ".concat(eN(s)||X.includes(s)?(0,_.Cl)(s):"bg-gray-50 text-gray-600 hover:bg-gray-100"),children:[(0,a.jsx)("span",{children:s}),(0,a.jsx)("span",{className:"text-xs ".concat(eN(s)||X.includes(s)?"bg-white/50":"bg-gray-200"," px-1.5 py-0.5 rounded"),children:t})]},s)}),F>0&&(0,a.jsxs)("div",{className:"flex items-center ml-2 gap-2",children:[(0,a.jsx)("span",{className:"text-gray-500",children:"("}),(0,a.jsx)("button",{onClick:()=>{r.startTransition(()=>{eu("all"),$([]),ex(!0),Z(1)})},className:"text-sm font-medium ".concat("all"===ed&&eh?"text-purple-700 underline":"text-gray-600 hover:text-purple-700 hover:underline"),children:"show all jobs"}),(0,a.jsx)("span",{className:"text-gray-500 mx-1",children:"|"}),(0,a.jsx)("button",{onClick:()=>{r.startTransition(()=>{eu("active"),$([]),ex(!0),Z(1)})},className:"text-sm font-medium ".concat("active"===ed&&eh?"text-green-700 underline":"text-gray-600 hover:text-green-700 hover:underline"),children:"show all active jobs"}),(0,a.jsx)("span",{className:"text-gray-500 mx-1",children:"|"}),(0,a.jsx)("button",{onClick:()=>{r.startTransition(()=>{eu("finished"),$([]),ex(!0),Z(1)})},className:"text-sm font-medium ".concat("finished"===ed&&eh?"text-blue-700 underline":"text-gray-600 hover:text-blue-700 hover:underline"),children:"show all finished jobs"}),(0,a.jsx)("span",{className:"text-gray-500",children:")"})]})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[P&&(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(c.Z,{size:15,className:"mt-0"}),(0,a.jsx)("span",{className:"ml-2 text-gray-500 text-sm",children:"Loading..."})]}),(0,a.jsxs)("button",{onClick:()=>{j&&j()},disabled:P,className:"text-sky-blue hover:text-sky-blue-bright flex items-center text-sm",children:[(0,a.jsx)(w.Z,{className:"h-4 w-4 mr-1.5"}),(0,a.jsx)("span",{children:"Refresh"})]})]})]})}),ej&&er&&0===ek.length&&!P&&!U&&(0,a.jsx)("div",{className:"mb-4 p-4 bg-gray-50 rounded-lg border",children:(0,a.jsxs)("div",{className:"flex flex-col items-center space-y-3",children:[(0,a.jsxs)("p",{className:"text-gray-700 text-center text-sm",children:["Job controller stopped.",(0,a.jsx)("br",{}),"Restart to check status."]}),(0,a.jsx)(o.z,{variant:"outline",size:"sm",onClick:ef,className:"text-sky-blue hover:text-sky-blue-bright",disabled:P||ec,children:ec?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(c.Z,{size:12,className:"mr-2"}),"Restarting..."]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(N.Z,{className:"h-4 w-4 mr-2"}),"Restart"]})})]})}),(0,a.jsx)(d.Zb,{children:(0,a.jsx)("div",{className:"overflow-x-auto rounded-lg",children:(0,a.jsxs)(u.iA,{className:"min-w-full",children:[(0,a.jsx)(u.xD,{children:(0,a.jsxs)(u.SC,{children:[(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ev("id"),children:["ID",ew("id")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ev("name"),children:["Name",ew("name")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ev("user"),children:["User",ew("user")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ev("workspace"),children:["Workspace",ew("workspace")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ev("submitted_at"),children:["Submitted",ew("submitted_at")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ev("job_duration"),children:["Duration",ew("job_duration")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ev("status"),children:["Status",ew("status")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ev("resources_str"),children:["Requested",ew("resources_str")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ev("infra"),children:["Infra",ew("infra")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ev("cluster"),children:["Resources",ew("cluster")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ev("recoveries"),children:["Recoveries",ew("recoveries")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ev("pool"),children:["Worker Pool",ew("pool")]}),(0,a.jsx)(u.ss,{children:"Details"}),(0,a.jsx)(u.ss,{children:"Logs"})]})}),(0,a.jsx)(u.RM,{children:P&&U?(0,a.jsx)(u.SC,{children:(0,a.jsx)(u.pj,{colSpan:12,className:"text-center py-6 text-gray-500",children:(0,a.jsxs)("div",{className:"flex justify-center items-center",children:[(0,a.jsx)(c.Z,{size:20,className:"mr-2"}),(0,a.jsx)("span",{children:"Loading..."})]})})}):ek.length>0?(0,a.jsx)(a.Fragment,{children:ek.map(e=>(0,a.jsxs)(r.Fragment,{children:[(0,a.jsxs)(u.SC,{children:[(0,a.jsx)(u.pj,{children:(0,a.jsx)(i(),{href:"/jobs/".concat(e.id),className:"text-blue-600",children:e.id})}),(0,a.jsx)(u.pj,{children:(0,a.jsx)(i(),{href:"/jobs/".concat(e.id),className:"text-blue-600",children:e.name})}),(0,a.jsx)(u.pj,{children:(0,a.jsx)(L.H,{username:e.user,userHash:e.user_hash})}),(0,a.jsx)(u.pj,{children:(0,a.jsx)(i(),{href:"/workspaces",className:"text-gray-700 hover:text-blue-600 hover:underline",children:e.workspace||"default"})}),(0,a.jsx)(u.pj,{children:T(e.submitted_at)}),(0,a.jsx)(u.pj,{children:(0,h.LU)(e.job_duration)}),(0,a.jsx)(u.pj,{children:(0,a.jsx)(_.OE,{status:e.status})}),(0,a.jsx)(u.pj,{children:e.requested_resources}),(0,a.jsx)(u.pj,{children:e.infra&&"-"!==e.infra?(0,a.jsx)(h.Md,{content:e.full_infra||e.infra,className:"text-sm text-muted-foreground",children:(0,a.jsxs)("span",{children:[(0,a.jsx)(i(),{href:"/infra",className:"text-blue-600 hover:underline",children:e.cloud||e.infra.split("(")[0].trim()}),e.infra.includes("(")&&(0,a.jsx)("span",{children:" "+(()=>{let s=x.MO.NAME_TRUNCATE_LENGTH,t=e.infra.substring(e.infra.indexOf("(")),a=t.substring(1,t.length-1);if(a.length<=s)return t;let r="".concat(a.substring(0,Math.floor((s-3)/2)),"...").concat(a.substring(a.length-Math.ceil((s-3)/2)));return"(".concat(r,")")})()})]})}):(0,a.jsx)("span",{children:e.infra||"-"})}),(0,a.jsx)(u.pj,{children:(0,a.jsx)(h.Md,{content:e.resources_str_full||e.resources_str,className:"text-sm text-muted-foreground",children:(0,a.jsx)("span",{children:e.resources_str})})}),(0,a.jsx)(u.pj,{children:e.recoveries}),(0,a.jsx)(u.pj,{children:(0,a.jsx)("div",{className:v?"blur-sm transition-all duration-300":"",children:v?"-":(0,h.os)(e.pool,e.pool_hash,b)})}),(0,a.jsx)(u.pj,{children:e.details?(0,a.jsx)(G,{text:e.details,rowId:e.id,expandedRowId:V,setExpandedRowId:Y}):"-"}),(0,a.jsx)(u.pj,{children:(0,a.jsx)(q,{jobParent:"/jobs",jobId:e.id,managed:!0,workspace:e.workspace})})]}),V===e.id&&(0,a.jsx)(K,{text:e.details,colSpan:13,innerRef:Q})]},e.task_job_id))}):(0,a.jsx)(u.SC,{children:(0,a.jsx)(u.pj,{colSpan:13,className:"text-center py-6",children:(0,a.jsxs)("div",{className:"flex flex-col items-center space-y-4",children:[en&&(0,a.jsxs)("div",{className:"flex flex-col items-center space-y-2",children:[(0,a.jsx)("p",{className:"text-gray-700",children:"The managed job controller is launching. It will be ready shortly."}),(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(c.Z,{size:12,className:"mr-2"}),(0,a.jsx)("span",{className:"text-gray-500",children:"Launching..."})]})]}),!er&&!en&&(0,a.jsx)("p",{className:"text-gray-500",children:"No active jobs"}),!ej&&er&&(0,a.jsxs)("div",{className:"flex flex-col items-center space-y-3 px-4",children:[(0,a.jsx)("p",{className:"text-gray-700 text-center text-sm sm:text-base max-w-md",children:"The managed job controller has been stopped. Restart to check the latest job status."}),(0,a.jsx)(o.z,{variant:"outline",size:"sm",onClick:ef,className:"text-sky-blue hover:text-sky-blue-bright",disabled:P||ec,children:ec?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(c.Z,{size:12,className:"mr-2"}),"Restarting..."]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(N.Z,{className:"h-4 w-4 mr-2"}),"Restart Controller"]})})]})]})})})})]})})}),(0,a.jsx)("div",{className:"flex justify-end items-center py-2 px-4 text-sm text-gray-700",children:(0,a.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("span",{className:"mr-2",children:"Rows per page:"}),(0,a.jsxs)("div",{className:"relative inline-block",children:[(0,a.jsxs)("select",{value:B,onChange:e=>{H(parseInt(e.target.value,10)),Z(1)},className:"py-1 pl-2 pr-6 appearance-none outline-none cursor-pointer border-none bg-transparent",style:{minWidth:"40px"},children:[(0,a.jsx)("option",{value:10,children:"10"}),(0,a.jsx)("option",{value:30,children:"30"}),(0,a.jsx)("option",{value:50,children:"50"}),(0,a.jsx)("option",{value:100,children:"100"}),(0,a.jsx)("option",{value:200,children:"200"})]}),(0,a.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,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})]}),(0,a.jsx)("div",{children:R>0?"".concat(eC+1," – ").concat(e_," of ").concat(R):"0 – 0 of 0"}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)(o.z,{variant:"ghost",size:"icon",onClick:()=>{Z(e=>Math.max(e-1,1))},disabled:1===O||!ek||0===ek.length,className:"text-gray-500 h-8 w-8 p-0",children:(0,a.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,a.jsx)("path",{d:"M15 18l-6-6 6-6"})})}),(0,a.jsx)(o.z,{variant:"ghost",size:"icon",onClick:()=>{eS>0&&O<eS&&Z(e=>e+1)},disabled:0===eS||O>=eS||!ek||0===ek.length,className:"text-gray-500 h-8 w-8 p-0",children:(0,a.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,a.jsx)("path",{d:"M9 18l6-6-6-6"})})})]})]})}),(0,a.jsx)(C.cV,{isOpen:em.isOpen,onClose:()=>ep({...em,isOpen:!1}),onConfirm:em.onConfirm,title:em.title,message:em.message,confirmClassName:"bg-blue-600 hover:bg-blue-700 text-white"})]})}function q(e){let{withLabel:s=!1,jobParent:t,jobId:r,managed:n,workspace:i="default"}=e,c=(0,l.useRouter)(),o=(e,s)=>{e.preventDefault(),e.stopPropagation(),c.push({pathname:"".concat(t,"/").concat(r),query:{tab:s}})},d=function(e){let s=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(e.preventDefault(),e.stopPropagation(),n)(0,m.jh)({jobId:parseInt(r),controller:s});else{let e=t.match(/\/clusters\/(.+)/);if(e){let s=e[1];(0,g.GH)({clusterName:s,jobIds:[r],workspace:i})}}};return(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)(h.WH,{content:"View Job Logs",className:"capitalize text-sm text-muted-foreground",children:(0,a.jsxs)("button",{onClick:e=>o(e,"logs"),className:"text-sky-blue hover:text-sky-blue-bright font-medium inline-flex items-center h-8",children:[(0,a.jsx)(y.Z,{className:"w-4 h-4"}),s&&(0,a.jsx)("span",{className:"ml-1.5",children:"Logs"})]})},"logs"),(0,a.jsx)(h.WH,{content:"Download Job Logs",className:"capitalize text-sm text-muted-foreground",children:(0,a.jsxs)("button",{onClick:e=>d(e,!1),className:"text-sky-blue hover:text-sky-blue-bright font-medium inline-flex items-center h-8",children:[(0,a.jsx)(k.Z,{className:"w-4 h-4"}),s&&(0,a.jsx)("span",{className:"ml-1.5",children:"Download"})]})},"downloadlogs")]})}function H(e){let{clusterName:s,clusterJobData:t,loading:l,refreshClusterJobsOnly:n,userFilter:x=null,nameFilter:m=null,workspace:p="default"}=e,[j,f]=(0,r.useState)(null),[g,b]=(0,r.useState)({key:null,direction:"ascending"}),[v,N]=(0,r.useState)(1),[y,k]=(0,r.useState)(10),C=(0,r.useRef)(null),[S,E]=(0,r.useState)(null);(0,r.useEffect)(()=>{let e=e=>{j&&C.current&&!C.current.contains(e.target)&&f(null)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[j]);let R=r.useMemo(()=>{let e=t||[];return x&&"ALL_USERS"!==x&&(e=W(e,x)),m&&(e=J(e,m)),e},[t,x,m]);(0,r.useEffect)(()=>{JSON.stringify(t)!==JSON.stringify(S)&&E(t)},[t,S]);let D=r.useMemo(()=>g.key?[...R].sort((e,s)=>e[g.key]<s[g.key]?"ascending"===g.direction?-1:1:e[g.key]>s[g.key]?"ascending"===g.direction?1:-1:0):R,[R,g]),F=e=>{let s="ascending";g.key===e&&"ascending"===g.direction&&(s="descending"),b({key:e,direction:s})},M=e=>g.key===e?"ascending"===g.direction?" ↑":" ↓":"",I=Math.ceil(D.length/y),A=(v-1)*y,z=A+y,P=D.slice(A,z);return(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsxs)(d.Zb,{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between p-4",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold",children:"Cluster Jobs"}),(0,a.jsx)("div",{className:"flex items-center",children:n&&(0,a.jsxs)("button",{onClick:n,disabled:l,className:"text-sky-blue hover:text-sky-blue-bright font-medium inline-flex items-center text-sm ml-2",children:[(0,a.jsx)(w.Z,{className:"w-4 h-4 mr-1"}),"Refresh Jobs"]})})]}),(0,a.jsxs)(u.iA,{children:[(0,a.jsx)(u.xD,{children:(0,a.jsxs)(u.SC,{children:[(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>F("id"),children:["ID",M("id")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>F("job"),children:["Name",M("job")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>F("user"),children:["User",M("user")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>F("workspace"),children:["Workspace",M("workspace")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>F("submitted_at"),children:["Submitted",M("submitted_at")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>F("job_duration"),children:["Duration",M("job_duration")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>F("status"),children:["Status",M("status")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>F("resources"),children:["Resources",M("resources")]}),(0,a.jsx)(u.ss,{className:"whitespace-nowrap",children:"Logs"})]})}),(0,a.jsx)(u.RM,{children:l?(0,a.jsx)(u.SC,{children:(0,a.jsx)(u.pj,{colSpan:9,className:"text-center py-12 text-gray-500",children:(0,a.jsxs)("div",{className:"flex justify-center items-center",children:[(0,a.jsx)(c.Z,{size:24,className:"mr-2"}),(0,a.jsx)("span",{children:"Loading cluster jobs..."})]})})}):P.length>0?P.map(e=>(0,a.jsxs)(r.Fragment,{children:[(0,a.jsxs)(u.SC,{className:j===e.id?"selected-row":"",children:[(0,a.jsx)(u.pj,{children:(0,a.jsx)(i(),{href:"/clusters/".concat(s,"/").concat(e.id),className:"text-blue-600",children:e.id})}),(0,a.jsx)(u.pj,{children:(0,a.jsx)(i(),{href:"/clusters/".concat(s,"/").concat(e.id),className:"text-blue-600",children:(0,a.jsx)(G,{text:e.job||"Unnamed job",rowId:e.id,expandedRowId:j,setExpandedRowId:f})})}),(0,a.jsx)(u.pj,{children:(0,a.jsx)(L.H,{username:e.user,userHash:e.user_hash})}),(0,a.jsx)(u.pj,{children:(0,a.jsx)(i(),{href:"/workspaces",className:"text-gray-700 hover:text-blue-600 hover:underline",children:e.workspace||"default"})}),(0,a.jsx)(u.pj,{children:T(e.submitted_at)}),(0,a.jsx)(u.pj,{children:(0,h.LU)(e.job_duration)}),(0,a.jsx)(u.pj,{children:(0,a.jsx)(_.OE,{status:e.status})}),(0,a.jsx)(u.pj,{children:e.resources}),(0,a.jsx)(u.pj,{className:"flex content-center items-center",children:(0,a.jsx)(q,{jobParent:"/clusters/".concat(s),jobId:e.id,managed:!1,workspace:p})})]}),j===e.id&&(0,a.jsx)(K,{text:e.job||"Unnamed job",colSpan:9,innerRef:C})]},e.id)):(0,a.jsx)(u.SC,{children:(0,a.jsx)(u.pj,{colSpan:8,className:"text-center py-6 text-gray-500",children:"No jobs found"})})})]})]}),D&&D.length>0&&(0,a.jsx)("div",{className:"flex justify-end items-center py-2 px-4 text-sm text-gray-700",children:(0,a.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("span",{className:"mr-2",children:"Rows per page:"}),(0,a.jsxs)("div",{className:"relative inline-block",children:[(0,a.jsxs)("select",{value:y,onChange:e=>{k(parseInt(e.target.value,10)),N(1)},className:"py-1 pl-2 pr-6 appearance-none outline-none cursor-pointer border-none bg-transparent",style:{minWidth:"40px"},children:[(0,a.jsx)("option",{value:5,children:"5"}),(0,a.jsx)("option",{value:10,children:"10"}),(0,a.jsx)("option",{value:20,children:"20"}),(0,a.jsx)("option",{value:50,children:"50"})]}),(0,a.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,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})]}),(0,a.jsxs)("div",{children:[A+1," – ",Math.min(z,D.length)," of"," ",D.length]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)(o.z,{variant:"ghost",size:"icon",onClick:()=>{N(e=>Math.max(e-1,1))},disabled:1===v,className:"text-gray-500 h-8 w-8 p-0",children:(0,a.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,a.jsx)("path",{d:"M15 18l-6-6 6-6"})})}),(0,a.jsx)(o.z,{variant:"ghost",size:"icon",onClick:()=>{N(e=>Math.min(e+1,I))},disabled:v===I||0===I,className:"text-gray-500 h-8 w-8 p-0",children:(0,a.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,a.jsx)("path",{d:"M9 18l6-6-6-6"})})})]})]})})]})}function K(e){let{text:s,colSpan:t,innerRef:r}=e;return(0,a.jsx)(u.SC,{className:"expanded-details",children:(0,a.jsx)(u.pj,{colSpan:t,children:(0,a.jsx)("div",{className:"p-4 bg-gray-50 rounded-md border border-gray-200",ref:r,children:(0,a.jsx)("div",{className:"flex justify-between items-start",children:(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"text-sm font-medium text-gray-900",children:"Full Details"}),(0,a.jsx)("p",{className:"mt-1 text-sm text-gray-700",style:{whiteSpace:"pre-wrap"},children:s})]})})})})})}function G(e){let{text:s,rowId:t,expandedRowId:l,setExpandedRowId:n}=e,i=s||"",c=i.length>50,o=l===t,d=c?"".concat(i.substring(0,50)):i,u=(0,r.useRef)(null);return(0,a.jsxs)("div",{className:"truncated-details relative max-w-full flex items-center",children:[(0,a.jsx)("span",{className:"truncate",children:d}),c&&(0,a.jsx)("button",{ref:u,type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation(),n(o?null:t)},className:"text-blue-600 hover:text-blue-800 font-medium ml-1 flex-shrink-0","data-button-type":"show-more-less",children:o?"... show less":"... show more"})]})}function V(e){let{refreshInterval:s,setLoading:t,refreshDataRef:l}=e,[n,o]=(0,r.useState)([]),[x,j]=(0,r.useState)({key:null,direction:"ascending"}),[f,g]=(0,r.useState)(!1),[b,v]=(0,r.useState)(!0),[w,N]=(0,r.useState)(1),[y,k]=(0,r.useState)(10),C=r.useCallback(async()=>{g(!0),t(!0);try{let{pools:e=[]}=await p.default.get(m.vs,[{}])||{};o(e),v(!1)}catch(e){console.error("Error fetching pools data:",e),o([]),v(!1)}finally{g(!1),t(!1)}},[t]);r.useEffect(()=>{l&&(l.current=C)},[l,C]),(0,r.useEffect)(()=>{o([]);let e=!0;C();let t=setInterval(()=>{e&&C()},s);return()=>{e=!1,clearInterval(t)}},[s,C]);let S=e=>{let s="ascending";x.key===e&&"ascending"===x.direction&&(s="descending"),j({key:e,direction:s})},L=e=>x.key===e?"ascending"===x.direction?" ↑":" ↓":"",E=r.useMemo(()=>x.key?[...n].sort((e,s)=>e[x.key]<s[x.key]?"ascending"===x.direction?-1:1:e[x.key]>s[x.key]?"ascending"===x.direction?1:-1:0):n,[n,x]),R=Math.ceil(E.length/y),D=(w-1)*y,F=D+y,M=E.slice(D,F),I=e=>{if(!e||!e.replica_info||0===e.replica_info.length)return"0 (target: 0)";let s=e.replica_info.filter(e=>"READY"===e.status).length,t=e.target_num_replicas||0;return"".concat(s," (target: ").concat(t,")")},A=e=>{let{jobCounts:s}=e;return(0,a.jsx)(h.x9,{jobCounts:s,getStatusStyle:_.Cl})},z=e=>{let{replicaInfo:s}=e;return(0,a.jsx)(h.Kl,{replicaInfo:s})};return(0,a.jsxs)(d.Zb,{children:[(0,a.jsx)("div",{className:"overflow-x-auto rounded-lg",children:(0,a.jsxs)(u.iA,{className:"min-w-full table-fixed",children:[(0,a.jsx)(u.xD,{children:(0,a.jsxs)(u.SC,{children:[(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap w-32",onClick:()=>S("name"),children:["Pool",L("name")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap w-40",onClick:()=>S("job_counts"),children:["Jobs",L("job_counts")]}),(0,a.jsx)(u.ss,{className:"whitespace-nowrap w-20",children:"Workers"}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap w-36",onClick:()=>S("requested_resources_str"),children:["Worker Details",L("requested_resources_str")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap w-40",onClick:()=>S("requested_resources_str"),children:["Worker Resources",L("requested_resources_str")]})]})}),(0,a.jsx)(u.RM,{children:f&&b?(0,a.jsx)(u.SC,{children:(0,a.jsx)(u.pj,{colSpan:5,className:"text-center py-6 text-gray-500",children:(0,a.jsxs)("div",{className:"flex justify-center items-center",children:[(0,a.jsx)(c.Z,{size:20,className:"mr-2"}),(0,a.jsx)("span",{children:"Loading..."})]})})}):M.length>0?M.map(e=>(0,a.jsxs)(u.SC,{children:[(0,a.jsx)(u.pj,{children:(0,a.jsx)(i(),{href:"/jobs/pools/".concat(e.name),className:"text-blue-600 hover:text-blue-800",children:e.name})}),(0,a.jsx)(u.pj,{children:(0,a.jsx)(A,{jobCounts:e.jobCounts})}),(0,a.jsx)(u.pj,{children:I(e)}),(0,a.jsx)(u.pj,{children:(0,a.jsx)(z,{replicaInfo:e.replica_info})}),(0,a.jsx)(u.pj,{children:e.requested_resources_str||"-"})]},e.name)):(0,a.jsx)(u.SC,{children:(0,a.jsx)(u.pj,{colSpan:5,className:"text-center py-6 text-gray-500",children:"No pools found"})})})]})}),M.length>0&&R>1&&(0,a.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-t border-gray-200",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)("span",{className:"text-sm text-gray-700",children:"Rows per page:"}),(0,a.jsxs)("select",{value:y,onChange:e=>{k(parseInt(e.target.value,10)),N(1)},className:"border border-gray-300 rounded px-2 py-1 text-sm",children:[(0,a.jsx)("option",{value:5,children:"5"}),(0,a.jsx)("option",{value:10,children:"10"}),(0,a.jsx)("option",{value:25,children:"25"}),(0,a.jsx)("option",{value:50,children:"50"})]})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsxs)("span",{className:"text-sm text-gray-700",children:[D+1,"-",Math.min(F,E.length)," of"," ",E.length]}),(0,a.jsx)("button",{onClick:()=>{N(e=>Math.max(e-1,1))},disabled:1===w,className:"px-2 py-1 text-sm border border-gray-300 rounded disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-50",children:"Previous"}),(0,a.jsx)("button",{onClick:()=>{N(e=>Math.min(e+1,R))},disabled:w===R,className:"px-2 py-1 text-sm border border-gray-300 rounded disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-50",children:"Next"})]})]})]})}}}]);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5339,7325],{27325:function(e,s,t){t.d(s,{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,t(60998).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"}]])},16826:function(e,s,t){t.d(s,{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,t(60998).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"}]])},6521:function(e,s,t){t.d(s,{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,t(60998).Z)("FileSearch",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4.268 21a2 2 0 0 0 1.727 1H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"ms7g94"}],["path",{d:"m9 18-1.5-1.5",key:"1j6qii"}],["circle",{cx:"5",cy:"14",r:"3",key:"ufru5t"}]])},88507:function(e,s,t){t.d(s,{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,t(60998).Z)("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]])},81260:function(e,s,t){t.d(s,{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,t(60998).Z)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},23293:function(e,s,t){t.d(s,{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,t(60998).Z)("RefreshCcw",[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]])},47603:function(e,s,t){t.d(s,{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,t(60998).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"}]])},28586:function(e,s,t){t.d(s,{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,t(60998).Z)("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]])},43767:function(e,s,t){t.d(s,{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,t(60998).Z)("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},1812:function(e,s,t){t.d(s,{X:function(){return l}});var r=t(85893),a=t(67294);let n=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,[o,c]=(0,a.useState)(!1);if((0,a.useEffect)(()=>{s&&c(!1)},[s]),!s||o)return null;let i="string"==typeof s?s:n(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,":"]})," ",i]})})]}),(0,r.jsx)("button",{onClick:()=>{c(!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"})})})]})})}},82077:function(e,s,t){t.r(s),t.d(s,{Workspaces:function(){return _},getWorkspaceClusters:function(){return S},getWorkspaceManagedJobs:function(){return L}});var r=t(85893),a=t(67294),n=t(11163);t(23266),t(68969);var l=t(17324),o=t(37673),c=t(68764),i=t(30803),d=t(55739),u=t(1272),h=t(50326);t(53850);var m=t(1812),x=t(13626),p=t(81260);/**
|
|
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 f=(0,t(60998).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 g=t(47603),j=t(23001),k=t(23015),v=t(6378),w=t(51214),y=t(36856),b=t(47145),N=t(94545),C=t(93225),E=t(41664),Z=t.n(E);async function S(e){try{return(await b.x.fetch("/status",{cluster_names:null,all_users:!0,include_credentials:!1,override_skypilot_config:{active_workspace:e}})).map(e=>({status:"UP"===e.status?"RUNNING":"STOPPED"===e.status?"STOPPED":"INIT"===e.status?"LAUNCHING":"TERMINATED",cluster:e.name,user:e.user_name,user_hash:e.user_hash,cluster_hash:e.cluster_hash,cloud:e.cloud,region:e.region,zone:e.zone,launched_at:e.launched_at,handle:e.handle,last_use:e.last_use,autostop:e.autostop,to_down:e.to_down,metadata:e.metadata,resources_str:e.resources_str,workspace:e.workspace||"default"})).filter(s=>s.workspace===e)}catch(s){return console.error("Error fetching clusters for workspace ".concat(e,":"),s),[]}}async function L(e){try{let s=(await b.x.post("/jobs/queue/v2",{all_users:!0,verbose:!0,override_skypilot_config:{active_workspace:e}})).headers.get("X-Skypilot-Request-ID"),t=await b.x.get("/api/get?request_id=".concat(s)),r=await t.json(),a=r.return_value?JSON.parse(r.return_value):{jobs:[]};return a.jobs&&(a.jobs=a.jobs.map(e=>({...e,workspace:e.workspace||"default"})),a.jobs=a.jobs.filter(s=>s.workspace===e)),a}catch(s){return console.error("Error fetching managed jobs for workspace ".concat(e,":"),s),{jobs:[]}}}let M=e=>{let{isPrivate:s}=e;return s?(0,r.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,r.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"})};function _(){let[e,s]=(0,a.useState)([]),[t,E]=(0,a.useState)({runningClusters:0,totalClusters:0,managedJobs:0}),[_,z]=(0,a.useState)(!0),[R,D]=(0,a.useState)(null),[T,F]=(0,a.useState)({key:"name",direction:"asc"}),[P,W]=(0,a.useState)(""),[q,O]=(0,a.useState)(!1),[J,A]=(0,a.useState)({confirmOpen:!1,workspaceToDelete:null,deleting:!1,error:null}),[I,H]=(0,a.useState)({open:!1,message:"",userName:""}),[V,B]=(0,a.useState)(null),[X,U]=(0,a.useState)(!1),[G,K]=(0,a.useState)(null),[$,Q]=(0,a.useState)(null),Y=(0,n.useRouter)(),ee=(0,j.X)(),es=async()=>{if(V&&Date.now()-V.timestamp<3e5)return V;U(!0);try{let e=await b.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,timestamp:Date.now()};return B(t),U(!1),t}catch(e){throw U(!1),e}},et=async(e,s)=>{try{let t=await es();if("admin"!==t.role)return H({open:!0,message:e,userName:t.name.toLowerCase()}),!1;return s(),!0}catch(e){return console.error("Failed to check user role:",e),H({open:!0,message:"Error: ".concat(e.message),userName:""}),!1}},er=async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];e&&z(!0);try{let e=await v.default.get(l.getWorkspaces);D(e);let t=Object.keys(e),r=t.map(async e=>{let[s,t,r]=await Promise.all([v.default.get(l.getEnabledClouds,[e]),v.default.get(S,[e]),v.default.get(L,[e])]);return{workspaceName:e,enabledClouds:s,clusters:t||[],managedJobs:r||{jobs:[]}}}),a=await Promise.all(r),n=[],o=[],c={};a.forEach(e=>{let{workspaceName:s,enabledClouds:t,clusters:r,managedJobs:a}=e;r.forEach(e=>{n.push(e)}),a.jobs.forEach(e=>{o.push(e)}),c[s]=t}),Object.fromEntries(n.map(e=>[e.cluster,e.workspace||"default"]));let i={};t.forEach(e=>{i[e]={name:e,totalClusterCount:0,runningClusterCount:0,managedJobsCount:0,clouds:new Set}});let d=0;n.forEach(e=>{let s=e.workspace||"default";i[s]||(i[s]={name:s,totalClusterCount:0,runningClusterCount:0,managedJobsCount:0,clouds:new Set}),i[s].totalClusterCount++,("RUNNING"===e.status||"LAUNCHING"===e.status)&&(i[s].runningClusterCount++,d++),e.cloud&&i[s].clouds.add(e.cloud)});let u=new Set(k.statusGroups.active),h=0;(o||[]).forEach(e=>{let s=e.workspace||"default";i[s]&&u.has(e.status)&&i[s].managedJobsCount++,u.has(e.status)&&h++});let m=Object.values(i).filter(e=>t.includes(e.name)).map(e=>{let s=Array.isArray(c[e.name])?c[e.name]:[];return{...e,clouds:s}}).sort((e,s)=>e.name.localeCompare(s.name));s(m),E({runningClusters:d,totalClusters:n.length,managedJobs:h})}catch(e){console.error("Error fetching workspace data:",e),s([]),E({runningClusters:0,totalClusters:0,managedJobs:0})}e&&z(!1)};(0,a.useEffect)(()=>{(async()=>{await y.ZP.preloadForPage("workspaces"),er(!0)})();let e=setInterval(()=>{er(!1)},w.nb.REFRESH_INTERVAL);return()=>clearInterval(e)},[]);let ea=e=>{let s="asc";T.key===e&&"asc"===T.direction&&(s="desc"),F({key:e,direction:s})},en=e=>T.key===e?"asc"===T.direction?" ↑":" ↓":"",el=a.useMemo(()=>{if(!e)return[];let s=e;if(P&&""!==P.trim()){let t=P.toLowerCase().trim();s=e.filter(e=>!!(e.name.toLowerCase().includes(t)||e.clouds.some(e=>{let s=C.Z2[e.toLowerCase()]||e;return e.toLowerCase().includes(t)||s.toLowerCase().includes(t)}))||!!(!0===((null==R?void 0:R[e.name])||{}).private?"private":"public").includes(t))}return(0,N.R0)(s,T.key,T.direction)},[e,T,P,R]),eo=e=>{et("cannot delete workspace",()=>{A({confirmOpen:!0,workspaceToDelete:e,deleting:!1,error:null})})},ec=async()=>{if(J.workspaceToDelete){A(e=>({...e,deleting:!0,error:null}));try{await (0,l.zl)(J.workspaceToDelete),Q('Workspace "'.concat(J.workspaceToDelete,'" deleted successfully!')),A({confirmOpen:!1,workspaceToDelete:null,deleting:!1,error:null}),v.default.invalidate(l.getWorkspaces),v.default.invalidateFunction(S),v.default.invalidateFunction(L),await er(!0)}catch(e){console.error("Error deleting workspace:",e),A(e=>({...e,deleting:!1,error:null})),K(e)}}},ei=()=>{A({confirmOpen:!1,workspaceToDelete:null,deleting:!1,error:null})},ed=e=>{et("cannot edit workspace",()=>{Y.push("/workspaces/".concat(e))})};return _&&0===e.length?(0,r.jsxs)("div",{className:"flex justify-center items-center h-64",children:[(0,r.jsx)(d.Z,{}),(0,r.jsx)("span",{className:"ml-2 text-gray-500",children:"Loading workspaces..."})]}):(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"fixed top-20 right-4 z-[9999] max-w-md",children:[$&&(0,r.jsx)("div",{className:"bg-green-50 border border-green-200 rounded p-4 mb-4",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:$})})]}),(0,r.jsx)("div",{className:"ml-auto pl-3",children:(0,r.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,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"})})]})})]})}),(0,r.jsx)(m.X,{error:G,title:"Error",onDismiss:()=>K(null)})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2 h-5",children:[(0,r.jsx)("div",{className:"text-base flex items-center",children:(0,r.jsx)("span",{className:"text-sky-blue leading-none",children:"Workspaces"})}),(0,r.jsxs)("div",{className:"flex items-center",children:[_&&(0,r.jsxs)("div",{className:"flex items-center mr-2",children:[(0,r.jsx)(d.Z,{size:15,className:"mt-0"}),(0,r.jsx)("span",{className:"ml-2 text-gray-500 text-xs",children:"Refreshing..."})]}),(0,r.jsxs)("button",{onClick:()=>{v.default.invalidate(l.getWorkspaces),v.default.invalidateFunction(l.getEnabledClouds),v.default.invalidateFunction(S),v.default.invalidateFunction(L),er(!0)},disabled:_,className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:[(0,r.jsx)(x.Z,{className:"h-4 w-4 mr-1.5"}),!ee&&(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:"Filter workspaces",value:P,onChange:e=>W(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,r.jsx)("button",{onClick:()=>W(""),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"})})})]}),(0,r.jsx)("button",{onClick:()=>{et("cannot create workspace",()=>{Y.push("/workspace/new")})},disabled:X,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:X?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(d.Z,{size:12,className:"mr-2"}),(0,r.jsx)("span",{children:"Create Workspace"})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(p.Z,{className:"h-4 w-4 mr-2"}),"Create Workspace"]})})]}),0!==e.length||_?(0,r.jsx)(o.Zb,{children:(0,r.jsx)("div",{className:"overflow-x-auto rounded-lg",children:(0,r.jsxs)(c.iA,{className:"min-w-full",children:[(0,r.jsx)(c.xD,{children:(0,r.jsxs)(c.SC,{children:[(0,r.jsxs)(c.ss,{className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50",onClick:()=>ea("name"),children:["Workspace",en("name")]}),(0,r.jsxs)(c.ss,{className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50",onClick:()=>ea("totalClusterCount"),children:["Clusters ",en("totalClusterCount")]}),(0,r.jsxs)(c.ss,{className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50",onClick:()=>ea("managedJobsCount"),children:["Jobs",en("managedJobsCount")]}),(0,r.jsx)(c.ss,{className:"whitespace-nowrap",children:"Enabled infra"}),(0,r.jsx)(c.ss,{className:"whitespace-nowrap",children:"Actions"})]})}),(0,r.jsx)(c.RM,{children:_&&0===el.length?(0,r.jsx)(c.SC,{children:(0,r.jsx)(c.pj,{colSpan:5,className:"text-center py-6 text-gray-500",children:(0,r.jsxs)("div",{className:"flex justify-center items-center",children:[(0,r.jsx)(d.Z,{size:20,className:"mr-2"}),(0,r.jsx)("span",{children:"Loading..."})]})})}):el.length>0?el.map(e=>{let s=!0===((null==R?void 0:R[e.name])||{}).private;return(0,r.jsxs)(c.SC,{className:"hover:bg-gray-50",children:[(0,r.jsxs)(c.pj,{className:"",children:[(0,r.jsx)("button",{onClick:()=>ed(e.name),disabled:X,className:"text-blue-600 hover:text-blue-600 hover:underline text-left",children:e.name}),(0,r.jsx)("span",{className:"ml-2",children:(0,r.jsx)(M,{isPrivate:s})})]}),(0,r.jsx)(c.pj,{children:(0,r.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,r.jsx)(c.pj,{children:(0,r.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,r.jsx)(c.pj,{children:e.clouds.length>0?[...e.clouds].sort().map((s,t)=>{let a=C.Z2[s.toLowerCase()]||s;return(0,r.jsxs)("span",{children:[(0,r.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:a}),t<e.clouds.length-1&&" "]},s)}):(0,r.jsx)("span",{className:"text-gray-500 text-sm",children:"-"})}),(0,r.jsxs)(c.pj,{children:[(0,r.jsx)(i.z,{variant:"ghost",size:"sm",onClick:()=>ed(e.name),disabled:X,className:"text-gray-600 hover:text-gray-800 mr-1",children:(0,r.jsx)(f,{className:"w-4 h-4"})}),(0,r.jsx)(i.z,{variant:"ghost",size:"sm",onClick:()=>eo(e.name),disabled:"default"===e.name||X,title:"default"===e.name?"Cannot delete default workspace":"Delete workspace",className:"text-red-600 hover:text-red-700 hover:bg-red-50",children:(0,r.jsx)(g.Z,{className:"w-4 h-4"})})]})]},e.name)}):(0,r.jsx)(c.SC,{children:(0,r.jsx)(c.pj,{colSpan:5,className:"text-center py-6 text-gray-500",children:"No workspaces found"})})})]})})}):(0,r.jsxs)("div",{className:"text-center py-10",children:[(0,r.jsx)("p",{className:"text-lg text-gray-600",children:"No workspaces found."}),(0,r.jsx)("p",{className:"text-sm text-gray-500 mt-2",children:"Create a cluster to see its workspace here."})]}),R&&(0,r.jsx)(h.Vq,{open:q,onOpenChange:O,children:(0,r.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,r.jsx)(h.fK,{children:(0,r.jsx)(h.$N,{className:"pr-10",children:"All Workspaces Configuration"})}),(0,r.jsx)("div",{className:"flex-grow overflow-y-auto py-4",children:(0,r.jsx)("pre",{style:{backgroundColor:"#f5f5f5",padding:"16px",borderRadius:"8px",overflowX:"auto",whiteSpace:"pre",wordBreak:"normal"},children:u.ZP.dump(R,{indent:2})})})]})}),(0,r.jsx)(h.Vq,{open:I.open,onOpenChange:e=>{H(s=>({...s,open:e})),e||K(null)},children:(0,r.jsxs)(h.cZ,{className:"sm:max-w-md transition-all duration-200 ease-in-out",children:[(0,r.jsxs)(h.fK,{children:[(0,r.jsx)(h.$N,{children:"Permission Denied"}),(0,r.jsx)(h.Be,{children:X?(0,r.jsxs)("div",{className:"flex items-center py-2",children:[(0,r.jsx)(d.Z,{size:16,className:"mr-2"}),(0,r.jsx)("span",{children:"Checking permissions..."})]}):(0,r.jsx)(r.Fragment,{children:I.userName?(0,r.jsxs)(r.Fragment,{children:[I.userName," is logged in as non-admin and ",I.message,"."]}):I.message})})]}),(0,r.jsx)(h.cN,{children:(0,r.jsx)(i.z,{variant:"outline",onClick:()=>H(e=>({...e,open:!1})),disabled:X,children:"OK"})})]})}),(0,r.jsx)(h.Vq,{open:J.confirmOpen,onOpenChange:e=>{e||(ei(),K(null))},children:(0,r.jsxs)(h.cZ,{className:"sm:max-w-md",children:[(0,r.jsxs)(h.fK,{children:[(0,r.jsx)(h.$N,{children:"Delete Workspace"}),(0,r.jsxs)(h.Be,{children:['Are you sure you want to delete workspace "',J.workspaceToDelete,'"? This action cannot be undone.']})]}),(0,r.jsxs)(h.cN,{children:[(0,r.jsx)(i.z,{variant:"outline",onClick:ei,disabled:J.deleting,children:"Cancel"}),(0,r.jsx)(i.z,{variant:"destructive",onClick:ec,disabled:J.deleting,children:J.deleting?"Deleting...":"Delete"})]})]})})]})}w.nb.REFRESH_INTERVAL},23001:function(e,s,t){t.d(s,{X:function(){return a}});var r=t(67294);function a(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:768,[s,t]=(0,r.useState)(!1);return(0,r.useEffect)(()=>{let s=()=>{t(window.innerWidth<e)};return s(),window.addEventListener("resize",s),()=>{window.removeEventListener("resize",s)}},[e]),s}}}]);
|