-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add switches tab to system inventory (#2620)
* Add switches tab * Add basic test * Update path snapshots * Drop Rack ID for now * womp womp test update
- Loading branch information
1 parent
ada302c
commit 11486f8
Showing
11 changed files
with
110 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, you can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* Copyright Oxide Computer Company | ||
*/ | ||
import { createColumnHelper } from '@tanstack/react-table' | ||
|
||
import { getListQFn, queryClient, type Switch } from '@oxide/api' | ||
import { Servers24Icon } from '@oxide/design-system/icons/react' | ||
|
||
import { useQueryTable } from '~/table/QueryTable' | ||
import { EmptyMessage } from '~/ui/lib/EmptyMessage' | ||
|
||
const EmptyState = () => ( | ||
<EmptyMessage | ||
icon={<Servers24Icon />} | ||
title="Something went wrong" | ||
body="We expected some switches here, but none were found" | ||
/> | ||
) | ||
|
||
const switchList = getListQFn('switchList', {}) | ||
|
||
export async function loader() { | ||
await queryClient.prefetchQuery(switchList.optionsFn()) | ||
return null | ||
} | ||
|
||
const colHelper = createColumnHelper<Switch>() | ||
const staticCols = [ | ||
colHelper.accessor('id', {}), | ||
colHelper.accessor('baseboard.part', { header: 'part number' }), | ||
colHelper.accessor('baseboard.serial', { header: 'serial number' }), | ||
colHelper.accessor('baseboard.revision', { header: 'revision' }), | ||
] | ||
|
||
Component.displayName = 'SwitchesTab' | ||
export function Component() { | ||
const emptyState = <EmptyState /> | ||
const { table } = useQueryTable({ query: switchList, columns: staticCols, emptyState }) | ||
return table | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, you can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* Copyright Oxide Computer Company | ||
*/ | ||
import type { Switch } from '@oxide/api' | ||
|
||
import type { Json } from './json-type' | ||
import { rack } from './rack' | ||
|
||
export const switches: Json<Switch[]> = [ | ||
{ | ||
baseboard: { | ||
part: '832-0431906', | ||
serial: 'BDS02141689', | ||
revision: 1, | ||
}, | ||
id: 'ed66617e-4955-465e-b810-0d0dc55d4511', | ||
rack_id: rack.id, | ||
time_created: rack.time_created, | ||
time_modified: rack.time_modified, | ||
}, | ||
] |
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