Skip to content

Commit f35dac3

Browse files
committed
web: introduce a dedicated dashboard for workloads
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
1 parent 502a5e7 commit f35dac3

16 files changed

Lines changed: 4386 additions & 34 deletions

web/src/app.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { ClusterPage } from './components/dashboards/cluster/ClusterPage'
1616
import { EventList } from './components/search/EventList'
1717
import { ResourceList } from './components/search/ResourceList'
1818
import { ResourcePage } from './components/dashboards/resource/ResourcePage'
19+
import { WorkloadPage } from './components/dashboards/workload/WorkloadPage'
1920
import { FavoritesPage } from './components/favorites/FavoritesPage'
2021
import { ProfilePage } from './components/user/ProfilePage'
2122
import { NotFoundPage } from './components/layout/NotFoundPage'
@@ -311,6 +312,7 @@ function AppContent({ spec, namespace }) {
311312
<Route path="/events" component={EventList} />
312313
<Route path="/resources" component={ResourceList} />
313314
<Route path="/resource/:kind/:namespace/:name" component={ResourcePage} />
315+
<Route path="/workload/:kind/:namespace/:name" component={WorkloadPage} />
314316
<Route path="/user/profile" component={ProfilePage} />
315317
<Route default component={NotFoundPage} />
316318
</Router>

web/src/app.test.jsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ vi.mock('./components/dashboards/resource/ResourcePage', () => ({
5555
ResourcePage: () => <div data-testid="resource-page">ResourcePage</div>
5656
}))
5757

58+
vi.mock('./components/dashboards/workload/WorkloadPage', () => ({
59+
WorkloadPage: () => <div data-testid="workload-page">WorkloadPage</div>
60+
}))
61+
5862
vi.mock('./components/common/NotFoundPage', () => ({
5963
NotFoundPage: () => <div data-testid="not-found-page">NotFoundPage</div>
6064
}))

web/src/components/dashboards/resource/InventoryPanel.jsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,18 @@ export function InventoryPanel({ resourceData, onNavigate }) {
116116
return resourceData.status.inventory.filter(item => isWorkloadInventoryItem(item))
117117
}, [resourceData, hasInventory])
118118

119-
// Build URL for a resource
119+
// Build URL for a Flux resource
120120
const getResourceUrl = (item) => {
121121
const ns = item.namespace || resourceData.metadata.namespace
122122
return `/resource/${encodeURIComponent(item.kind)}/${encodeURIComponent(ns)}/${encodeURIComponent(item.name)}`
123123
}
124124

125+
// Build URL for a workload
126+
const getWorkloadUrl = (item) => {
127+
const ns = item.namespace || resourceData.metadata.namespace
128+
return `/workload/${encodeURIComponent(item.kind)}/${encodeURIComponent(ns)}/${encodeURIComponent(item.name)}`
129+
}
130+
125131
return (
126132
<DashboardPanel title="Managed Objects" id="inventory-panel">
127133
{/* Tab Navigation */}
@@ -252,6 +258,7 @@ export function InventoryPanel({ resourceData, onNavigate }) {
252258
<tbody class="divide-y divide-gray-200 dark:divide-gray-700">
253259
{sortedInventory.map((item, idx) => {
254260
const isFluxResource = isFluxInventoryItem(item)
261+
const isWorkload = !isFluxResource && isWorkloadInventoryItem(item)
255262
return (
256263
<tr key={idx} class="hover:bg-gray-50 dark:hover:bg-gray-800">
257264
<td class="px-3 py-2 text-sm">
@@ -262,6 +269,13 @@ export function InventoryPanel({ resourceData, onNavigate }) {
262269
>
263270
{item.name}
264271
</a>
272+
) : isWorkload ? (
273+
<a
274+
href={getWorkloadUrl(item)}
275+
class="text-flux-blue dark:text-blue-400 hover:underline"
276+
>
277+
{item.name}
278+
</a>
265279
) : (
266280
<span class="text-gray-900 dark:text-gray-100">{item.name}</span>
267281
)}

0 commit comments

Comments
 (0)