-
Notifications
You must be signed in to change notification settings - Fork 22
List and download Support Bundles #3311
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
Open
charliepark
wants to merge
7
commits into
main
Choose a base branch
from
support-bundles
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f527b62
First stab at support bundles in console
charliepark 382ed47
Dropped size column
charliepark aa89f60
Add ereports to mock data
charliepark c744fcf
Remove sidemodal; other UI improvements
charliepark a406be1
simplify e2e test
charliepark 6653f25
copy change
charliepark b6a34ee
pre-review tweaks
charliepark 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
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,76 @@ | ||
| /* | ||
| * 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 { useForm } from 'react-hook-form' | ||
| import { useNavigate } from 'react-router' | ||
|
|
||
| import { | ||
| api, | ||
| MAX_BUNDLE_COMMENT_BYTES, | ||
| queryClient, | ||
| useApiMutation, | ||
| utf8ByteLength, | ||
| } from '@oxide/api' | ||
|
|
||
| import { TextField } from '~/components/form/fields/TextField' | ||
| import { SideModalForm } from '~/components/form/SideModalForm' | ||
| import { titleCrumb } from '~/hooks/use-crumbs' | ||
| import { addToast } from '~/stores/toast' | ||
| import { Message } from '~/ui/lib/Message' | ||
| import { pb } from '~/util/path-builder' | ||
|
|
||
| const defaultValues = { userComment: '' } | ||
|
|
||
| export const handle = titleCrumb('New support bundle') | ||
|
|
||
| export default function CreateSupportBundleSideModalForm() { | ||
| const navigate = useNavigate() | ||
|
|
||
| const onDismiss = () => navigate(pb.supportBundles()) | ||
|
|
||
| const createBundle = useApiMutation(api.supportBundleCreate, { | ||
| onSuccess() { | ||
| queryClient.invalidateEndpoint('supportBundleList') | ||
| addToast('Support bundle created') | ||
| navigate(pb.supportBundles()) | ||
| }, | ||
| }) | ||
|
|
||
| const form = useForm({ defaultValues }) | ||
|
|
||
| return ( | ||
| <SideModalForm | ||
| form={form} | ||
| formType="create" | ||
| resourceName="support bundle" | ||
| onDismiss={onDismiss} | ||
| onSubmit={({ userComment }) => { | ||
| createBundle.mutate({ body: { userComment: userComment || null } }) | ||
| }} | ||
| loading={createBundle.isPending} | ||
| submitError={createBundle.error} | ||
| > | ||
| <Message | ||
| variant="info" | ||
| content="Bundle collection runs in the background and can take several minutes. The bundle can be downloaded once collection is complete." | ||
| /> | ||
| <TextField | ||
| as="textarea" | ||
| name="userComment" | ||
| label="Comment" | ||
| description="Note about why this bundle is being collected" | ||
| rows={4} | ||
| control={form.control} | ||
| validate={(value) => | ||
| utf8ByteLength(value) > MAX_BUNDLE_COMMENT_BYTES | ||
| ? `Comment cannot exceed ${MAX_BUNDLE_COMMENT_BYTES} bytes` | ||
| : true | ||
| } | ||
| /> | ||
| </SideModalForm> | ||
| ) | ||
| } |
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,89 @@ | ||
| /* | ||
| * 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 { useForm } from 'react-hook-form' | ||
| import { useNavigate, type LoaderFunctionArgs } from 'react-router' | ||
|
|
||
| import { | ||
| api, | ||
| MAX_BUNDLE_COMMENT_BYTES, | ||
| q, | ||
| queryClient, | ||
| useApiMutation, | ||
| usePrefetchedQuery, | ||
| utf8ByteLength, | ||
| } from '@oxide/api' | ||
|
|
||
| import { TextField } from '~/components/form/fields/TextField' | ||
| import { SideModalForm } from '~/components/form/SideModalForm' | ||
| import { titleCrumb } from '~/hooks/use-crumbs' | ||
| import { getSupportBundleSelector, useSupportBundleSelector } from '~/hooks/use-params' | ||
| import { addToast } from '~/stores/toast' | ||
| import { pb } from '~/util/path-builder' | ||
| import type * as PP from '~/util/path-params' | ||
|
|
||
| const bundleView = ({ bundleId }: PP.SupportBundle) => | ||
| q(api.supportBundleView, { path: { bundleId } }) | ||
|
|
||
| export async function clientLoader({ params }: LoaderFunctionArgs) { | ||
| const selector = getSupportBundleSelector(params) | ||
| await queryClient.prefetchQuery(bundleView(selector)) | ||
| return null | ||
| } | ||
|
|
||
| export const handle = titleCrumb('Edit support bundle') | ||
|
|
||
| export default function EditSupportBundleSideModalForm() { | ||
| const navigate = useNavigate() | ||
| const selector = useSupportBundleSelector() | ||
|
|
||
| const { data: bundle } = usePrefetchedQuery(bundleView(selector)) | ||
|
|
||
| const form = useForm({ defaultValues: { userComment: bundle.userComment || '' } }) | ||
|
|
||
| const onDismiss = () => navigate(pb.supportBundles()) | ||
|
|
||
| const editBundle = useApiMutation(api.supportBundleUpdate, { | ||
| onSuccess() { | ||
| queryClient.invalidateEndpoint('supportBundleList') | ||
| queryClient.invalidateEndpoint('supportBundleView') | ||
| addToast('Support bundle updated') | ||
| navigate(pb.supportBundles()) | ||
| }, | ||
| }) | ||
|
|
||
| return ( | ||
| <SideModalForm | ||
| form={form} | ||
| formType="edit" | ||
| resourceName="support bundle" | ||
| onDismiss={onDismiss} | ||
| onSubmit={({ userComment }) => { | ||
| editBundle.mutate({ | ||
| path: { bundleId: selector.bundleId }, | ||
| body: { userComment: userComment || null }, | ||
| }) | ||
| }} | ||
| loading={editBundle.isPending} | ||
| submitError={editBundle.error} | ||
| > | ||
| <TextField | ||
| as="textarea" | ||
| name="userComment" | ||
| label="Comment" | ||
| description="Note about why this bundle is being collected" | ||
| rows={4} | ||
| control={form.control} | ||
| validate={(value) => | ||
| utf8ByteLength(value) > MAX_BUNDLE_COMMENT_BYTES | ||
| ? `Comment cannot exceed ${MAX_BUNDLE_COMMENT_BYTES} bytes` | ||
| : true | ||
| } | ||
| /> | ||
| </SideModalForm> | ||
| ) | ||
| } |
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.
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.
really minor given the context, but i always like to use a match for this kind of thing, so the compiler can require our input if we add e.g. a
rebuildingstate in the future