-
Notifications
You must be signed in to change notification settings - Fork 19
System Update #2915
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
System Update #2915
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
6b6a294
system update UI
david-crespo 6faa739
delete upload modal until we can make it work
david-crespo c34d037
e2e tests
david-crespo 72a2ca9
mock api rejects setting target to older version
david-crespo 4bc427e
explicitly sort releases by semver desc in mock API
david-crespo 7f88a39
You're absolutely right! Yes/No is better than True/False
david-crespo 4ba4c4c
gpt-5 review suggestions
david-crespo 67a24e6
Available releases -> Releases
david-crespo 0a9b052
test: fleet viewer can't set target release
david-crespo 62db149
merge main
david-crespo aeaec83
fix stuff
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,230 @@ | ||
| /* | ||
| * 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 { useMemo } from 'react' | ||
| import * as R from 'remeda' | ||
|
|
||
| import { | ||
| Images24Icon, | ||
| SoftwareUpdate16Icon, | ||
| SoftwareUpdate24Icon, | ||
| Time16Icon, | ||
| } from '@oxide/design-system/icons/react' | ||
| import { Badge } from '@oxide/design-system/ui' | ||
|
|
||
| import { | ||
| apiq, | ||
| queryClient, | ||
| useApiMutation, | ||
| usePrefetchedQuery, | ||
| type UpdateStatus, | ||
| } from '~/api' | ||
| import { DocsPopover } from '~/components/DocsPopover' | ||
| import { HL } from '~/components/HL' | ||
| import { MoreActionsMenu } from '~/components/MoreActionsMenu' | ||
| import { RefreshButton } from '~/components/RefreshButton' | ||
| import { makeCrumb } from '~/hooks/use-crumbs' | ||
| import { confirmAction } from '~/stores/confirm-action' | ||
| import { addToast } from '~/stores/toast' | ||
| import { EmptyCell } from '~/table/cells/EmptyCell' | ||
| import { CardBlock } from '~/ui/lib/CardBlock' | ||
| import { DateTime } from '~/ui/lib/DateTime' | ||
| import * as DropdownMenu from '~/ui/lib/DropdownMenu' | ||
| import { PageHeader, PageTitle } from '~/ui/lib/PageHeader' | ||
| import { PropertiesTable } from '~/ui/lib/PropertiesTable' | ||
| import { TipIcon } from '~/ui/lib/TipIcon' | ||
| import { ALL_ISH } from '~/util/consts' | ||
| import { docLinks } from '~/util/links' | ||
| import { percentage, round } from '~/util/math' | ||
|
|
||
| export const handle = makeCrumb('System Update') | ||
|
|
||
| const statusQuery = apiq('systemUpdateStatus', {}) | ||
| const reposQuery = apiq('systemUpdateRepositoryList', { query: { limit: ALL_ISH } }) | ||
|
|
||
| const refreshData = () => | ||
| Promise.all([ | ||
| queryClient.invalidateEndpoint('systemUpdateStatus'), | ||
| queryClient.invalidateEndpoint('systemUpdateRepositoryList'), | ||
| ]) | ||
|
|
||
| export async function clientLoader() { | ||
| await Promise.all([ | ||
| queryClient.prefetchQuery(statusQuery), | ||
| queryClient.prefetchQuery(reposQuery), | ||
| ]) | ||
| return null | ||
| } | ||
|
|
||
| function calcProgress(status: UpdateStatus) { | ||
| const targetVersion = status.targetRelease?.version | ||
| if (!targetVersion) return null | ||
|
|
||
| const total = R.sum(Object.values(status.componentsByReleaseVersion)) | ||
| const current = status.componentsByReleaseVersion[targetVersion] || 0 | ||
|
|
||
| if (!total) return null // avoid dividing by zero | ||
|
|
||
| return { | ||
| current, | ||
| total, | ||
| // trunc prevents, e.g., 999/1000 being reported as 100% | ||
| percentage: round(percentage(current, total), 0, 'trunc'), | ||
| } | ||
| } | ||
|
|
||
| export default function UpdatePage() { | ||
| const { data: status } = usePrefetchedQuery(statusQuery) | ||
| const { data: repos } = usePrefetchedQuery(reposQuery) | ||
|
|
||
| const { mutateAsync: setTargetRelease } = useApiMutation('targetReleaseUpdate', { | ||
| onSuccess() { | ||
| refreshData() | ||
| addToast({ content: 'Target release updated' }) | ||
| }, | ||
| // error handled by confirm modal | ||
| }) | ||
|
|
||
| const componentProgress = useMemo(() => calcProgress(status), [status]) | ||
|
|
||
| return ( | ||
| <> | ||
| <PageHeader> | ||
| <PageTitle icon={<SoftwareUpdate24Icon />}>System Update</PageTitle> | ||
| <div className="flex items-center gap-2"> | ||
| <RefreshButton onClick={refreshData} /> | ||
| <DocsPopover | ||
| heading="system update" | ||
| icon={<SoftwareUpdate16Icon />} | ||
| summary="The update system automatically updates components to the target release." | ||
| links={[docLinks.systemUpdate]} | ||
| /> | ||
| </div> | ||
| </PageHeader> | ||
| <PropertiesTable className="-mt-8 mb-8"> | ||
| {/* targetRelease will never be null on a customer system after the | ||
| first time it is set. */} | ||
| <PropertiesTable.Row label="Target release"> | ||
| {status.targetRelease?.version ?? <EmptyCell />} | ||
| </PropertiesTable.Row> | ||
| <PropertiesTable.Row label="Target set"> | ||
| {status.targetRelease?.timeRequested ? ( | ||
| <DateTime date={status.targetRelease.timeRequested} /> | ||
| ) : ( | ||
| <EmptyCell /> | ||
| )} | ||
| </PropertiesTable.Row> | ||
| <PropertiesTable.Row | ||
| label={ | ||
| <> | ||
| Progress | ||
| <TipIcon className="ml-1.5"> | ||
| Number of components updated to the target release | ||
| </TipIcon> | ||
| </> | ||
| } | ||
| > | ||
| {componentProgress ? ( | ||
| <> | ||
| <div className="mr-1.5">{componentProgress.percentage}%</div> | ||
| <div className="text-secondary"> | ||
| ({componentProgress.current} of {componentProgress.total}) | ||
| </div> | ||
| </> | ||
| ) : ( | ||
| <EmptyCell /> | ||
| )} | ||
| </PropertiesTable.Row> | ||
| <PropertiesTable.Row | ||
| label={ | ||
| <> | ||
| Last step planned{' '} | ||
| <TipIcon className="ml-1.5"> | ||
| A rough indicator of the last time the update planner did something | ||
| </TipIcon> | ||
| </> | ||
| } | ||
| > | ||
| <DateTime date={status.timeLastStepPlanned} /> | ||
| </PropertiesTable.Row> | ||
| <PropertiesTable.Row | ||
| label={ | ||
| <> | ||
| Suspended{' '} | ||
| <TipIcon className="ml-1.5"> | ||
| Whether automatic update is suspended due to manual update activity | ||
| </TipIcon> | ||
| </> | ||
| } | ||
| > | ||
| {status.suspended ? 'Yes' : 'No'} | ||
| </PropertiesTable.Row> | ||
| </PropertiesTable> | ||
|
|
||
| <CardBlock> | ||
| <CardBlock.Header title="Releases" /> | ||
| <CardBlock.Body> | ||
| <ul className="space-y-3"> | ||
| {repos.items.map((repo) => { | ||
| const isTarget = repo.systemVersion === status.targetRelease?.version | ||
| return ( | ||
| <li | ||
| key={repo.hash} | ||
| className="border-secondary flex items-center gap-4 rounded border p-4" | ||
| > | ||
| <Images24Icon className="text-secondary shrink-0" aria-hidden /> | ||
| <div className="flex-1"> | ||
| <div className="flex items-center gap-2"> | ||
| <span className="text-sans-semi-lg text-raise"> | ||
| {repo.systemVersion} | ||
| </span> | ||
| {isTarget && <Badge color="default">Target</Badge>} | ||
| </div> | ||
| <div className="text-secondary">{repo.fileName}</div> | ||
| </div> | ||
| <div className="flex items-center gap-4"> | ||
| <div className="flex items-center gap-1"> | ||
| <Time16Icon aria-hidden /> | ||
| <DateTime date={repo.timeCreated} /> | ||
| </div> | ||
| </div> | ||
| <MoreActionsMenu label={`${repo.systemVersion} actions`} isSmall> | ||
| <DropdownMenu.Item | ||
| label="Set as target release" | ||
| onSelect={() => { | ||
| confirmAction({ | ||
| actionType: 'primary', | ||
| doAction: () => | ||
| setTargetRelease({ | ||
| body: { systemVersion: repo.systemVersion }, | ||
| }), | ||
| modalTitle: 'Confirm set target release', | ||
| modalContent: ( | ||
| <p> | ||
| Are you sure you want to set <HL>{repo.systemVersion}</HL> as | ||
| the target release? | ||
| </p> | ||
| ), | ||
| errorTitle: `Error setting target release to ${repo.systemVersion}`, | ||
| }) | ||
| }} | ||
| // TODO: follow API logic, disabling for older releases. | ||
| // Or maybe just have the API tell us by adding a field to | ||
| // the TufRepo response type. | ||
| disabled={isTarget && 'Already set as target'} | ||
| /> | ||
| </MoreActionsMenu> | ||
| </li> | ||
| ) | ||
| })} | ||
| </ul> | ||
| </CardBlock.Body> | ||
| </CardBlock> | ||
| </> | ||
| ) | ||
| } |
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
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
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.
Doc added in https://github.com/oxidecomputer/docs/pull/658