Skip to content
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

feat(web): adapt to HTTP API of DASD operations #1549

Merged
merged 62 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
9e8cc77
start with new web API for DASD
jreidinger Aug 21, 2024
daf6124
[WIP] Try to add a supported check to DASD API
teclator Aug 22, 2024
e05a7cc
try to have working dasd#supported
jreidinger Aug 22, 2024
5e246d1
Replaced DASD is supported check
teclator Aug 22, 2024
c772472
[WIP] Start adapting DASDPage
teclator Aug 22, 2024
7e4b34d
Temporal fix for showing dasds
teclator Aug 22, 2024
d866bd8
adapt ids
jreidinger Aug 22, 2024
8788502
Merge branch 'http-dasd' into web-dasd
teclator Aug 22, 2024
08edd00
Start moving DASD pages to Typescript
teclator Aug 22, 2024
e796206
add dasd probe
jreidinger Aug 22, 2024
2b40f73
add more api and queries for dasd
jreidinger Aug 22, 2024
455fa66
add format api call
jreidinger Aug 23, 2024
fa7ac90
fix sort types
jreidinger Aug 23, 2024
b2d7f6c
add backspace icon
jreidinger Aug 23, 2024
6251f72
Move DASD actions to queries
teclator Aug 23, 2024
6e8e581
add jobs api
jreidinger Aug 23, 2024
d4be0c8
Merge remote-tracking branch 'origin/http-dasd' into web-dasd
jreidinger Aug 23, 2024
fc3497f
Moved DASD filters to queries
teclator Aug 23, 2024
41251bf
Move DASD selection to queries
teclator Aug 23, 2024
b7ab21c
Merge remote-tracking branch 'origin/http-dasd' into web-dasd
jreidinger Aug 23, 2024
897bbf4
first attempt to implement proper format with storage jobs
jreidinger Aug 23, 2024
fc8f79c
optimize dasd devices query to not use invalidate
jreidinger Aug 27, 2024
f7530fd
Merge branch 'http-dasd' into web-dasd
teclator Aug 27, 2024
87e4e13
Fix jobs url
teclator Aug 27, 2024
fa3eae7
Getting rid of the DASD initial state
teclator Aug 27, 2024
e2da06a
Use the DASD id for notifing format job changes
teclator Aug 27, 2024
8991d01
Small fixes for the DASD Format progress dialog
teclator Aug 27, 2024
d67205d
Fix jobs summary test
teclator Aug 27, 2024
d7033e5
Merge remote-tracking branch 'origin/master' into web-dasd
jreidinger Aug 28, 2024
94f92fa
add non-working test for component with mutating queries
jreidinger Aug 28, 2024
23405eb
add test for dasd format progress together with fix it reveals
jreidinger Aug 28, 2024
5dba41c
transform DASDFormatProgress component to typescript
jreidinger Aug 29, 2024
40baceb
Update web/src/api/dasd.ts
jreidinger Aug 29, 2024
4e8e129
Removing dasd client
teclator Aug 29, 2024
eeba75f
Removing leftovers
teclator Aug 29, 2024
ad92d01
use connsistent name in API
jreidinger Aug 29, 2024
6b97d1d
Remove not needed code from DASD Page
teclator Aug 29, 2024
c13bfbf
Merge branch 'master' into web-dasd
teclator Aug 29, 2024
debcfb7
Merge remote-tracking branch 'origin/web-dasd' into dasd_failing_test
jreidinger Aug 29, 2024
1a3d485
fix dasd table test
jreidinger Aug 29, 2024
a6cb882
Improve DASDFormat progress dialog
teclator Aug 29, 2024
df7ca94
Notify id in Jobs events
teclator Aug 29, 2024
7ddbba5
Handle JobAdded event
teclator Aug 29, 2024
f585806
Remove running jobs when finish
teclator Aug 29, 2024
b028a3b
Fix DASDFormatProgress unit test
teclator Sep 2, 2024
9fd4544
Removed leftover Deviceinfo
teclator Sep 2, 2024
dbdf722
Changes based on CR
teclator Sep 2, 2024
8bbf57b
Changes based on code review
teclator Sep 3, 2024
918a5e3
Use mutations instead of API direct calls
teclator Sep 3, 2024
4405715
More changes based on code review
teclator Sep 4, 2024
6d140be
Replace dasd filter queries by component state
teclator Sep 4, 2024
8fc01b9
Replace dasd selection queries by component state
teclator Sep 4, 2024
50e76ad
Do not set any info about formatting.
teclator Sep 4, 2024
a75354f
Added DASD route only if supported
teclator Sep 4, 2024
669f102
Removed selected DASD leftover queries
teclator Sep 4, 2024
76d295b
Use only one mutation for modifying DASD state
teclator Sep 4, 2024
a705ac6
Do not modify existent cache but return new object
teclator Sep 4, 2024
d0bf495
Another inmutability fix
teclator Sep 4, 2024
3c9c319
Merge branch 'master' into web-dasd
teclator Sep 4, 2024
1c9dfdd
Added changelog
teclator Sep 4, 2024
9b96a93
Apply suggestions from CR
teclator Sep 5, 2024
e896085
Redirect to storage page in case DASD is not supported
teclator Sep 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 18 additions & 43 deletions web/src/components/storage/DASDPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import DASDFormatProgress from "~/components/storage/DASDFormatProgress";
import { _ } from "~/i18n";
import { useCancellablePromise } from "~/utils";
import { useInstallerClient } from "~/context/installer";
import { Page } from "~/components/core";
import { useDASDDevices, useDASDDevicesChanges } from "~/queries/dasd";

const reducer = (state, action) => {
const { type, payload } = action;
Expand Down Expand Up @@ -128,63 +130,36 @@ const initialState = {
};

export default function DASDPage() {
useDASDDevicesChanges();
const devices = useDASDDevices();
initialState.devices = devices;
const { storage: client } = useInstallerClient();
const { cancellablePromise } = useCancellablePromise();
const [state, dispatch] = useReducer(reducer, initialState);

useEffect(() => {
const loadDevices = async () => {
dispatch({ type: "START_LOADING" });
const devices = await cancellablePromise(client.dasd.getDevices());
dispatch({ type: "SET_DEVICES", payload: { devices } });
dispatch({ type: "STOP_LOADING" });
};

const loadJobs = async () => {
const jobs = await cancellablePromise(client.dasd.getJobs());
if (jobs.length > 0) {
dispatch({ type: "START_FORMAT_JOB", payload: { data: jobs[0] } });
}
};

loadDevices().catch(console.error);
loadJobs().catch(console.error);
}, [client.dasd, cancellablePromise]);

useEffect(() => {
const subscriptions = [];

const subscribe = async () => {
const action = (type, device) => dispatch({ type, payload: { device } });

subscriptions.push(
await client.dasd.deviceEventListener("added", (d) => action("ADD_DEVICE", d)),
await client.dasd.deviceEventListener("removed", (d) => action("REMOVE_DEVICE", d)),
await client.dasd.deviceEventListener("changed", (d) => action("UPDATE_DEVICE", d)),
);

await client.dasd.onJobAdded((data) =>
dispatch({ type: "START_FORMAT_JOB", payload: { data } }),
);
await client.dasd.onJobChanged((data) =>
dispatch({ type: "UPDATE_FORMAT_JOB", payload: { data } }),
);
};

const unsubscribe = () => {
subscriptions.forEach((fn) => fn());
};

subscribe();
return unsubscribe;
}, [client.dasd]);
}, [client.dasd, cancellablePromise, devices]);

return (
<>
<DASDTable state={state} dispatch={dispatch} />
{state.formatJob.running && (
<DASDFormatProgress job={state.formatJob} devices={state.devices} />
)}
</>
<Page>
<Page.Header>
<h2>{_("DASD")}</h2>
</Page.Header>

<Page.MainContent>
<DASDTable state={state} dispatch={dispatch} />
{state.formatJob.running && (
<DASDFormatProgress job={state.formatJob} devices={state.devices} />
)}
</Page.MainContent>
</Page>
);
}
8 changes: 7 additions & 1 deletion web/src/routes/storage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import React from "react";
import BootSelection from "~/components/storage/BootSelection";
import DeviceSelection from "~/components/storage/DeviceSelection";
import SpacePolicySelection from "~/components/storage/SpacePolicySelection";
import ISCSIPage from "~/components/storage/ISCSIPage";
import { DASDPage, ISCSIPage } from "~/components/storage";
import ProposalPage from "~/components/storage/ProposalPage";
import { Route } from "~/types/routes";
import { N_ } from "~/i18n";
Expand All @@ -34,6 +34,7 @@ const PATHS = {
bootingPartition: "/storage/booting-partition",
spacePolicy: "/storage/space-policy",
iscsi: "/storage/iscsi",
dasd: "/storage/dasd"
};

const routes = (): Route => ({
Expand Down Expand Up @@ -61,6 +62,11 @@ const routes = (): Route => ({
element: <ISCSIPage />,
handle: { name: N_("iSCSI") },
},
{
teclator marked this conversation as resolved.
Show resolved Hide resolved
path: PATHS.dasd,
element: <DASDPage />,
handle: { name: N_("DASD") },
},
],
});

Expand Down
Loading