-
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 cluster ops priority classes view (#62)
## Description Adding Priority Classes view ##### UDS <img width="1589" alt="Screenshot 2024-07-24 at 2 55 42 PM" src="https://github.com/user-attachments/assets/66971667-ac68-4981-8bcd-71277b71ae2c"> ##### OpenLens <img width="1704" alt="Screenshot 2024-07-24 at 3 06 19 PM" src="https://github.com/user-attachments/assets/1a1a21f0-c730-4d5e-98bc-23562cfe35f6"> ## Related Issue - #32 --------- Co-authored-by: Jeff McCoy <code@jeffm.us>
- Loading branch information
1 parent
2995497
commit f52ea3d
Showing
8 changed files
with
78 additions
and
2 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
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
11 changes: 11 additions & 0 deletions
11
ui/src/lib/features/k8s/cluster-ops/priority-classes/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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!-- SPDX-License-Identifier: Apache-2.0 --> | ||
<!-- SPDX-FileCopyrightText: 2024-Present The UDS Authors --> | ||
|
||
<script lang="ts"> | ||
import { DataTable } from '$components' | ||
import { createStore, type Columns } from './store' | ||
export let columns: Columns = [['name', 'emphasize'], ['value'], ['global_default'], ['description'], ['age']] | ||
</script> | ||
|
||
<DataTable {columns} {createStore} /> |
21 changes: 21 additions & 0 deletions
21
ui/src/lib/features/k8s/cluster-ops/priority-classes/component.test.ts
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,21 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-FileCopyrightText: 2024-Present The UDS Authors | ||
|
||
import '@testing-library/jest-dom' | ||
|
||
import { testK8sTableWithCustomColumns, testK8sTableWithDefaults } from '$features/k8s/test-helper' | ||
import Component from './component.svelte' | ||
import { createStore } from './store' | ||
|
||
suite('PriorityClassesTable Component', () => { | ||
beforeEach(() => { | ||
vi.clearAllMocks() | ||
}) | ||
|
||
testK8sTableWithDefaults(Component, { | ||
createStore, | ||
columns: [['name', 'emphasize'], ['value'], ['global_default'], ['description'], ['age']], | ||
}) | ||
|
||
testK8sTableWithCustomColumns(Component, { createStore }) | ||
}) |
33 changes: 33 additions & 0 deletions
33
ui/src/lib/features/k8s/cluster-ops/priority-classes/store.ts
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,33 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-FileCopyrightText: 2024-Present The UDS Authors | ||
|
||
import type { V1PriorityClass as Resource } from '@kubernetes/client-node' | ||
|
||
import { ResourceStore, transformResource } from '$features/k8s/store' | ||
import { type ColumnWrapper, type CommonRow, type ResourceStoreInterface } from '$features/k8s/types' | ||
|
||
interface Row extends CommonRow { | ||
description: string | ||
global_default: boolean | ||
value: number | ||
} | ||
|
||
export type Columns = ColumnWrapper<Row> | ||
|
||
export function createStore(): ResourceStoreInterface<Resource, Row> { | ||
const url = `/api/v1/resources/cluster-ops/priority-classes` | ||
|
||
const transform = transformResource<Resource, Row>((r) => ({ | ||
description: r.description ?? '', | ||
global_default: r.globalDefault ?? false, | ||
value: r.value ?? 0, | ||
})) | ||
|
||
const store = new ResourceStore<Resource, Row>('name') | ||
|
||
return { | ||
...store, | ||
start: () => store.start(url, transform), | ||
sortByKey: store.sortByKey.bind(store), | ||
} | ||
} |
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
6 changes: 5 additions & 1 deletion
6
ui/src/routes/(resources)/cluster-ops/priority-classes/+page.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
<!-- SPDX-License-Identifier: Apache-2.0 --> | ||
<!-- SPDX-FileCopyrightText: 2024-Present The UDS Authors --> | ||
|
||
<h1 class="text-white text-5xl">Priority Classes</h1> | ||
<script> | ||
import { PriorityClassesTable } from '$features/k8s' | ||
</script> | ||
|
||
<PriorityClassesTable /> |