Skip to content

Commit fcb06c6

Browse files
committed
Update EnvironmentCard to handle deployment errors and improve DonutIcon's percent safety checks
1 parent d3a761b commit fcb06c6

6 files changed

Lines changed: 29 additions & 18 deletions

File tree

console/workspaces/libs/api-client/src/hooks/traces.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,8 @@ export function useTraceList(
380380
// replacing the whole list. Falls back to a full refetch when the list is
381381
// empty (e.g. on initial load or after the user clears filters).
382382
useEffect(() => {
383-
if (hasCustomRange || !scopeParams) return;
383+
if (hasCustomRange || !scopeParams || options?.enabled === false
384+
|| !options?.enableAutoRefresh) return;
384385
const timer = setInterval(() => {
385386
if (traceListRef.current?.traces?.length) {
386387
loadNewerRef.current();
@@ -389,7 +390,7 @@ export function useTraceList(
389390
}
390391
}, 30000);
391392
return () => clearInterval(timer);
392-
}, [hasCustomRange, scopeParams]);
393+
}, [hasCustomRange, scopeParams, options?.enabled, options?.enableAutoRefresh]);
393394

394395
return {
395396
...queryResult,

console/workspaces/libs/shared-component/src/components/EnvironmentCard/EnvironmentCard.tsx

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ import {
4242
CheckCircle as CheckCircleRounded,
4343
Circle as CircleOutlined,
4444
Clock,
45-
XCircle as ErrorOutlineRounded,
4645
Rocket as RocketLaunchOutlined,
4746
FlaskConical as TryOutlined,
4847
Workflow,
@@ -351,17 +350,28 @@ export const EnvironmentCard = (props: EnvironmentCardProps) => {
351350
icon={<CircularProgress size={32} />}
352351
/>
353352
)}
354-
{currentDiployment.status === DeploymentStatus.ERROR && (
355-
<NoDataFound
356-
disableBackground
357-
message="Deployment Failed"
358-
icon={
359-
<ErrorOutlineRounded
360-
color={theme.vars?.palette?.error?.main}
361-
size={32}
362-
/>
353+
{(currentDiployment.status === DeploymentStatus.ERROR ||
354+
currentDiployment.status === DeploymentStatus.FAILED) && (
355+
<Alert
356+
severity="error"
357+
sx={{ width: "100%" }}
358+
action={
359+
<Button
360+
component={Link}
361+
to={generatePath(
362+
absoluteRouteMap.children.org.children.projects.children
363+
.agents.children.deployment.path,
364+
{ orgId, projectId, agentId }
365+
)}
366+
color="inherit"
367+
size="small"
368+
>
369+
View Deployment
370+
</Button>
363371
}
364-
/>
372+
>
373+
Deployment failed. Check the deployment page for more details.
374+
</Alert>
365375
)}
366376
{currentDiployment.status === DeploymentStatus.ACTIVE && (
367377
<Box

console/workspaces/pages/metrics/src/Metrics.Component.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export const MetricsComponent: React.FC = () => {
6565
const { data: deployments } = useListAgentDeployments(
6666
{ orgName: orgId, projName: projectId, agentName: agentId },
6767
);
68-
const isSuspended = deployments?.[envId ?? ""]?.status === "suspended";
68+
const isSuspended = deployments === undefined ? undefined : deployments[envId ?? ""]?.status === "suspended";
6969

7070
const metricsFilterRequest = useMemo(
7171
() => ({
@@ -85,7 +85,7 @@ export const MetricsComponent: React.FC = () => {
8585
{ agentName: agentId, orgName: orgId, projName: projectId },
8686
metricsFilterRequest,
8787
{
88-
enabled: !isSuspended && !!agentId && !!orgId && !!projectId && !!envId && (hasCustomRange || !!timeRange),
88+
enabled: isSuspended === false && !!agentId && !!orgId && !!projectId && !!envId && (hasCustomRange || !!timeRange),
8989
enableAutoRefresh: !hasCustomRange,
9090
timeRange: hasCustomRange ? undefined : timeRange,
9191
}

console/workspaces/pages/overview/src/AgentOverview/DonutIcon.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ export const DonutIcon: React.FC<DonutIconProps> = ({ percent, color, size = 30
3333
const r = size * 0.43;
3434
const sw = size * 0.117;
3535
const circumference = 2 * Math.PI * r;
36-
const offset = circumference * (1 - Math.min(percent, 100) / 100);
36+
const safePercent = Number.isFinite(percent) ? Math.min(Math.max(percent, 0), 100) : 0;
37+
const offset = circumference * (1 - safePercent / 100);
3738
return (
3839
<svg width={size} height={size} viewBox={`0 0 ${size} ${size}`} style={{ display: "block" }}>
3940
<circle cx={cx} cy={cx} r={r} fill="none"

console/workspaces/pages/overview/src/AgentOverview/ExternalAgentOverview.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ export const ExternalAgentOverview = () => {
128128
sortedEnvironmentList?.find((env: Environment) => env.id === selectedEnvironmentId)?.name
129129
}
130130
instrumentationUrl={agentInstrumentationUrl}
131-
apiKey="ey***"
132131
componentUid={agent?.uuid}
133132
environmentUid={selectedEnvironmentId}
134133
/>

console/workspaces/pages/overview/src/AgentOverview/InstrumentationDrawer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ interface InstrumentationDrawerProps {
3838
agentName: string;
3939
environment?: string;
4040
instrumentationUrl: string;
41-
apiKey: string;
41+
apiKey?: string;
4242
componentUid?: string;
4343
environmentUid?: string;
4444
}

0 commit comments

Comments
 (0)