Skip to content

Commit 0aac15f

Browse files
committed
feat(FR-2680): add DeploymentAutoScalingTab wrapping AutoScalingRuleList
1 parent 7871bdb commit 0aac15f

1 file changed

Lines changed: 79 additions & 0 deletions

File tree

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/**
2+
@license
3+
Copyright (c) 2015-2026 Lablup Inc. All rights reserved.
4+
*/
5+
import { DeploymentAutoScalingTab_deployment$key } from '../__generated__/DeploymentAutoScalingTab_deployment.graphql';
6+
import { useCurrentUserInfo } from '../hooks/backendai';
7+
import AutoScalingRuleList from './AutoScalingRuleList';
8+
import React from 'react';
9+
import { graphql, useFragment } from 'react-relay';
10+
11+
interface DeploymentAutoScalingTabProps {
12+
deploymentFrgmt: DeploymentAutoScalingTab_deployment$key | null | undefined;
13+
fetchKey?: string;
14+
}
15+
16+
/**
17+
* DeploymentAutoScalingTab — tab shown on the Deployment detail page that
18+
* hosts the Auto-Scaling Rules management UI.
19+
*
20+
* This is a thin wrapper around `<AutoScalingRuleList />`. It extracts the
21+
* Relay global ID from the deployment fragment and derives the
22+
* `isEndpointDestroying` / `isOwnedByCurrentUser` flags that the underlying
23+
* list needs for permission gating. `AutoScalingRuleList` is already
24+
* Deployment-API based (its GraphQL query is rooted at `deployment(id: $id)`)
25+
* so no API migration is needed — we only need to surface it inside the new
26+
* Deployment detail page tabs.
27+
*/
28+
const DeploymentAutoScalingTab: React.FC<DeploymentAutoScalingTabProps> = ({
29+
deploymentFrgmt,
30+
fetchKey,
31+
}) => {
32+
'use memo';
33+
const [currentUser] = useCurrentUserInfo();
34+
35+
const deployment = useFragment(
36+
graphql`
37+
fragment DeploymentAutoScalingTab_deployment on ModelDeployment {
38+
id
39+
metadata {
40+
status
41+
}
42+
creator @since(version: "26.4.3") {
43+
basicInfo {
44+
email
45+
}
46+
}
47+
}
48+
`,
49+
deploymentFrgmt,
50+
);
51+
52+
if (!deployment?.id) {
53+
return null;
54+
}
55+
56+
const status = deployment.metadata?.status;
57+
// DeploymentStatus has no explicit DESTROYED state; STOPPING / STOPPED are
58+
// the terminal lifecycle states that should disable mutations, mirroring
59+
// `isEndpointInDestroyingCategory` from the legacy Endpoint API.
60+
const isEndpointDestroying = status === 'STOPPING' || status === 'STOPPED';
61+
62+
const creatorEmail = deployment.creator?.basicInfo?.email ?? null;
63+
// When the creator is unknown (e.g. on manager versions < 26.4.3 where the
64+
// `creator` field is not yet resolvable), fall back to "owned" so the UI
65+
// does not over-restrict.
66+
const isOwnedByCurrentUser =
67+
!creatorEmail || creatorEmail === currentUser.email;
68+
69+
return (
70+
<AutoScalingRuleList
71+
deploymentId={deployment.id}
72+
isEndpointDestroying={isEndpointDestroying}
73+
isOwnedByCurrentUser={isOwnedByCurrentUser}
74+
fetchKey={fetchKey}
75+
/>
76+
);
77+
};
78+
79+
export default DeploymentAutoScalingTab;

0 commit comments

Comments
 (0)