-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): adding status color mapping for k8s (#264)
Co-authored-by: Tristan Holaday <40547442+TristanHoladay@users.noreply.github.com>
- Loading branch information
1 parent
8ecf8c0
commit 15fc75f
Showing
4 changed files
with
112 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import type { K8StatusMapping } from './types' | ||
|
||
const statusColors = { | ||
success: 'text-green-400', | ||
info: 'text-blue-400', | ||
warning: 'text-orange-300', | ||
error: 'text-red-400', | ||
disabled: 'text-grey-400', | ||
} as const | ||
|
||
// Mapping between sections, statuses, and colors | ||
const k8StatusMapping: K8StatusMapping = { | ||
Pod: { | ||
Pending: { color: statusColors.warning }, | ||
Running: { color: statusColors.success }, | ||
Succeeded: { color: statusColors.success }, | ||
Failed: { color: statusColors.error }, | ||
Unknown: { color: statusColors.warning }, | ||
Completed: { color: statusColors.disabled }, | ||
}, | ||
Deployments: { | ||
Available: { color: statusColors.success }, | ||
Progressing: { color: statusColors.info }, | ||
Unavailable: { color: statusColors.error }, | ||
}, | ||
ReplicaSets: { | ||
Available: { color: statusColors.success }, | ||
Progressing: { color: statusColors.info }, | ||
Unavailable: { color: statusColors.error }, | ||
}, | ||
StatefulSets: { | ||
Available: { color: statusColors.success }, | ||
Progressing: { color: statusColors.info }, | ||
Unavailable: { color: statusColors.error }, | ||
}, | ||
Services: { | ||
Pending: { color: statusColors.warning }, | ||
Active: { color: statusColors.success }, | ||
Terminating: { color: statusColors.warning }, | ||
}, | ||
PersistentVolumeClaims: { | ||
Pending: { color: statusColors.warning }, | ||
Bound: { color: statusColors.success }, | ||
Lost: { color: statusColors.error }, | ||
}, | ||
Nodes: { | ||
Ready: { color: statusColors.success }, | ||
NotReady: { color: statusColors.warning }, | ||
SchedulingDisabled: { color: statusColors.disabled }, | ||
}, | ||
Jobs: { | ||
Complete: { color: statusColors.success }, | ||
Failed: { color: statusColors.error }, | ||
Running: { color: statusColors.success }, | ||
}, | ||
CronJobs: { | ||
Active: { color: statusColors.success }, | ||
Suspended: { color: statusColors.disabled }, | ||
}, | ||
ConfigMaps: { | ||
Active: { color: statusColors.success }, | ||
}, | ||
Secrets: { | ||
Active: { color: statusColors.success }, | ||
}, | ||
Namespaces: { | ||
Active: { color: statusColors.success }, | ||
Terminating: { color: statusColors.warning }, | ||
}, | ||
} | ||
|
||
// Function to get the color and status for a specific type and status | ||
export const getColorAndStatus = <T extends keyof K8StatusMapping>(type: T, status: keyof K8StatusMapping[T]) => { | ||
return (k8StatusMapping[type][status] as { color: string }).color || 'Unknown' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 4 additions & 8 deletions
12
ui/src/lib/features/k8s/workloads/pods/status/component.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters