refactor: use semantic metric types instead of conditional logic in HostsOverview

Changed MetricBar type prop from conditional (value > 80 ? 'danger' : 'primary')
to semantic types ('cpu', 'memory', 'disk') for better maintainability and
consistency with the component's design system.

This allows MetricBar to handle threshold logic internally based on metric
type, rather than duplicating threshold conditions at each call site.
This commit is contained in:
rcourtman 2025-10-23 22:38:44 +00:00
parent 8fb9ef2e8f
commit 9925a0d78f

View file

@ -261,7 +261,7 @@ export const HostsOverview: Component<HostsOverviewProps> = (props) => {
<MetricBar
label={`${cpuPercent().toFixed(1)}%`}
value={cpuPercent()}
type={cpuPercent() > 80 ? 'danger' : 'primary'}
type="cpu"
/>
</Show>
</td>
@ -273,7 +273,7 @@ export const HostsOverview: Component<HostsOverviewProps> = (props) => {
<MetricBar
label={`${memUsed()} / ${memTotal()}`}
value={memPercent()}
type={memPercent() > 80 ? 'danger' : 'primary'}
type="memory"
/>
</Show>
</td>
@ -379,7 +379,7 @@ export const HostsOverview: Component<HostsOverviewProps> = (props) => {
<MetricBar
value={diskPercent()}
label={`${diskPercent().toFixed(1)}%`}
type={diskPercent() > 80 ? 'danger' : 'primary'}
type="disk"
/>
</div>
</Show>