-
Notifications
You must be signed in to change notification settings - Fork 19
Disk details side modal #2992
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Disk details side modal #2992
Changes from 5 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b15a06c
clean up AGENTS.md
david-crespo d79acd7
disk details side modal
david-crespo 1e58ec2
use ButtonCell for disk name on instance storage tab
david-crespo 97867b1
make disk name a link on snapshots table
david-crespo dd39405
fix test flake due to clicking a disk link accidentally
david-crespo 78e749b
add footer with close button so ben can sleep
david-crespo fa2ec30
make image edit and idp edit work the same way
david-crespo d6142ec
add ReadOnlySideModalForm, use it for the others
david-crespo b9c4ca2
open disk detail right on snapshots page, don't nav
david-crespo 1667e8b
put back my smart quote
david-crespo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,109 @@ | ||
| /* | ||
| * 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 { | ||
| NavigationType, | ||
| useNavigate, | ||
| useNavigationType, | ||
| type LoaderFunctionArgs, | ||
| } from 'react-router' | ||
|
|
||
| import { api, q, queryClient, usePrefetchedQuery, type Disk } from '@oxide/api' | ||
| import { Storage16Icon } from '@oxide/design-system/icons/react' | ||
|
|
||
| import { DiskStateBadge } from '~/components/StateBadge' | ||
| import { titleCrumb } from '~/hooks/use-crumbs' | ||
| import { getDiskSelector, useDiskSelector } from '~/hooks/use-params' | ||
| import { EmptyCell } from '~/table/cells/EmptyCell' | ||
| import { PropertiesTable } from '~/ui/lib/PropertiesTable' | ||
| import { ResourceLabel, SideModal } from '~/ui/lib/SideModal' | ||
| import { pb } from '~/util/path-builder' | ||
| import type * as PP from '~/util/path-params' | ||
| import { bytesToGiB } from '~/util/units' | ||
|
|
||
| const diskView = ({ disk, project }: PP.Disk) => | ||
| q(api.diskView, { path: { disk }, query: { project } }) | ||
|
|
||
| export async function clientLoader({ params }: LoaderFunctionArgs) { | ||
| const { project, disk } = getDiskSelector(params) | ||
| await queryClient.prefetchQuery(diskView({ project, disk })) | ||
| return null | ||
| } | ||
|
|
||
| export const handle = titleCrumb('Disk') | ||
|
|
||
| export default function DiskDetailSideModalRoute() { | ||
| const { project, disk } = useDiskSelector() | ||
| const navigate = useNavigate() | ||
| const { data } = usePrefetchedQuery(diskView({ project, disk })) | ||
| const animate = useNavigationType() === NavigationType.Push | ||
|
|
||
| return ( | ||
| <DiskDetailSideModal | ||
| disk={data} | ||
| onDismiss={() => navigate(pb.disks({ project }))} | ||
| animate={animate} | ||
| /> | ||
| ) | ||
| } | ||
|
|
||
| /** | ||
| * The inner content of the disk detail modal, separated so it can be used | ||
| * either as a standalone page/route or embedded in another page via query params. | ||
| */ | ||
|
|
||
| type DiskDetailSideModalProps = { | ||
| disk: Disk | ||
| onDismiss: () => void | ||
| /** Default true because when used outside a route (e.g., StorageTab), it's always a click action */ | ||
| animate?: boolean | ||
| } | ||
|
|
||
| export function DiskDetailSideModal({ | ||
| disk, | ||
| onDismiss, | ||
| animate = true, | ||
| }: DiskDetailSideModalProps) { | ||
| return ( | ||
| <SideModal | ||
| isOpen | ||
| onDismiss={onDismiss} | ||
| animate={animate} | ||
| title="Disk details" | ||
| subtitle={ | ||
| <ResourceLabel> | ||
| <Storage16Icon /> {disk.name} | ||
| </ResourceLabel> | ||
| } | ||
| > | ||
| <SideModal.Body> | ||
| <PropertiesTable> | ||
| <PropertiesTable.IdRow id={disk.id} /> | ||
| <PropertiesTable.DescriptionRow description={disk.description} /> | ||
| <PropertiesTable.Row label="Size"> | ||
| {bytesToGiB(disk.size)} GiB | ||
| </PropertiesTable.Row> | ||
| <PropertiesTable.Row label="State"> | ||
| <DiskStateBadge state={disk.state.state} /> | ||
| </PropertiesTable.Row> | ||
| {/* TODO: show attached instance by name like the table does? */} | ||
| <PropertiesTable.Row label="Block size"> | ||
| {disk.blockSize.toLocaleString()} bytes | ||
| </PropertiesTable.Row> | ||
| <PropertiesTable.Row label="Image ID"> | ||
| {disk.imageId ?? <EmptyCell />} | ||
| </PropertiesTable.Row> | ||
| <PropertiesTable.Row label="Snapshot ID"> | ||
| {disk.snapshotId ?? <EmptyCell />} | ||
| </PropertiesTable.Row> | ||
| <PropertiesTable.DateRow label="Created" date={disk.timeCreated} /> | ||
| <PropertiesTable.DateRow label="Last Modified" date={disk.timeModified} /> | ||
| </PropertiesTable> | ||
| </SideModal.Body> | ||
| </SideModal> | ||
| ) | ||
| } | ||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to call this
Disk, but it looks stupid. The other modals like this (project image, silo image, identity provider) are all naturally two-word titles. @benjaminleonard @charliepark if you think it looks fine asDisk, I'm fine changing it.