Skip to content

Commit

Permalink
fix(web): fix TPM check when using the legacy AutoYaST mode (#1927)
Browse files Browse the repository at this point in the history
## Problem

When using the legacy AutoYaST mode, the web UI crashes at the end of
the installation when trying
to find our whether it is using TPM or not.

- #1918

## Solution

Properly handle that case:

* `fetchConfig` now returns `null` instead of `undefined`. According to
[TanStack Query

documentation](https://tanstack.com/query/latest/docs/framework/react/reference/useQuery),
`queryFn`
*Must return a promise that will either resolve data or throw an error.
The data cannot be
undefined*.
* `usingTpm` function now handles the case where the configuration is
`null`.

## Testing

- *Tested manually*
  • Loading branch information
imobachgs authored Jan 21, 2025
2 parents 6901956 + c446500 commit fa72f8e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions web/package/agama-web-ui.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Tue Jan 21 09:44:08 UTC 2025 - Imobach Gonzalez Sosa <[email protected]>

- Do not crash at the end of the installation when using a legacy
AutoYaST mode (gh#agama-project/agama#1927).

-------------------------------------------------------------------
Mon Jan 20 16:45:18 UTC 2025 - Ladislav Slezák <[email protected]>

Expand Down
4 changes: 2 additions & 2 deletions web/src/api/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ import { config } from "~/api/storage/types";
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const probe = (): Promise<any> => post("/api/storage/probe");

const fetchConfig = (): Promise<config.Config | undefined> =>
get("/api/storage/config").then((config) => config.storage);
const fetchConfig = (): Promise<config.Config | null> =>
get("/api/storage/config").then((config) => config.storage ?? null);

/**
* Returns the list of jobs
Expand Down
4 changes: 4 additions & 0 deletions web/src/components/core/InstallationFinished.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ const SuccessIcon = () => <Icon name="check_circle" className="icon-xxxl color-s
// TODO: define some utility method to get the device used as root (drive, partition, logical volume).
// TODO: use type checking for config.
function usingTpm(config): boolean {
if (!config) {
return null;
}

const { guided, drives = [], volumeGroups = [] } = config;

if (guided !== undefined) {
Expand Down

0 comments on commit fa72f8e

Please sign in to comment.