Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2990e6f

Browse files
committedMar 13, 2024·
WIP: SpacePolicy as pop-up
1 parent 704b693 commit 2990e6f

11 files changed

+521
-471
lines changed
 

‎web/src/components/storage/ProposalFileSystemsSection.jsx

-80
This file was deleted.

‎web/src/components/storage/ProposalFileSystemsSection.test.jsx

-55
This file was deleted.

‎web/src/components/storage/ProposalPage.jsx

-12
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ import {
2929
ProposalActionsSection,
3030
ProposalPageMenu,
3131
ProposalSettingsSection,
32-
ProposalSpacePolicySection,
3332
ProposalDeviceSection,
34-
ProposalFileSystemsSection,
3533
ProposalTransactionalInfo
3634
} from "~/components/storage";
3735
import { IDLE } from "~/client/status";
@@ -214,17 +212,7 @@ export default function ProposalPage() {
214212
<ProposalSettingsSection
215213
availableDevices={state.availableDevices}
216214
encryptionMethods={state.encryptionMethods}
217-
settings={state.settings}
218-
onChange={changeSettings}
219-
isLoading={state.loading}
220-
/>
221-
<ProposalFileSystemsSection
222-
settings={state.settings}
223215
volumeTemplates={state.volumeTemplates}
224-
onChange={changeSettings}
225-
isLoading={state.loading}
226-
/>
227-
<ProposalSpacePolicySection
228216
settings={state.settings}
229217
onChange={changeSettings}
230218
isLoading={state.loading}

‎web/src/components/storage/ProposalPage.test.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,11 @@ it("loads the proposal data", async () => {
123123
await screen.findByText(/\/dev\/vda/);
124124
});
125125

126-
it("renders the settings, find space and actions sections", async () => {
126+
it("renders the device, settings and actions sections", async () => {
127127
installerRender(<ProposalPage />);
128128

129+
await screen.findByText(/Device/);
129130
await screen.findByText(/Settings/);
130-
await screen.findByText(/Find Space/);
131131
await screen.findByText(/Planned Actions/);
132132
});
133133

‎web/src/components/storage/ProposalSettingsSection.jsx

+35
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { Checkbox, Form, Skeleton, Switch, Tooltip } from "@patternfly/react-cor
2424

2525
import { _ } from "~/i18n";
2626
import { If, PasswordAndConfirmationInput, Section, Popup } from "~/components/core";
27+
import { ProposalVolumes, ProposalSpacePolicyField } from "~/components/storage";
2728
import { Icon } from "~/components/layout";
2829
import { noop } from "~/utils";
2930
import { hasFS } from "~/components/storage/utils";
@@ -283,6 +284,8 @@ const EncryptionField = ({
283284
export default function ProposalSettingsSection({
284285
settings,
285286
encryptionMethods = [],
287+
volumeTemplates = [],
288+
isLoading = false,
286289
onChange = noop
287290
}) {
288291
const changeEncryption = ({ password, method }) => {
@@ -302,8 +305,26 @@ export default function ProposalSettingsSection({
302305
onChange({ volumes: settings.volumes });
303306
};
304307

308+
const changeVolumes = (volumes) => {
309+
onChange({ volumes });
310+
};
311+
312+
const changeSpacePolicy = (policy, actions) => {
313+
onChange({ spacePolicy: policy, spaceActions: actions });
314+
};
315+
305316
const encryption = settings.encryptionPassword !== undefined && settings.encryptionPassword.length > 0;
306317

318+
const { volumes = [] } = settings;
319+
320+
// Templates for already existing mount points are filtered out
321+
const usefulTemplates = () => {
322+
const mountPaths = volumes.map(v => v.mountPath);
323+
return volumeTemplates.filter(t => (
324+
t.mountPath.length > 0 && !mountPaths.includes(t.mountPath)
325+
));
326+
};
327+
307328
return (
308329
<>
309330
<Section title={_("Settings")}>
@@ -319,6 +340,20 @@ export default function ProposalSettingsSection({
319340
isLoading={settings.encryptionPassword === undefined}
320341
onChange={changeEncryption}
321342
/>
343+
<ProposalVolumes
344+
volumes={volumes}
345+
templates={usefulTemplates()}
346+
options={{ lvm: settings.lvm, encryption }}
347+
isLoading={isLoading && settings.volumes === undefined}
348+
onChange={changeVolumes}
349+
/>
350+
<ProposalSpacePolicyField
351+
policy={settings.spacePolicy}
352+
actions={settings.spaceActions}
353+
devices={settings.installationDevices}
354+
isLoading={isLoading}
355+
onChange={changeSpacePolicy}
356+
/>
322357
</Section>
323358
</>
324359
);

‎web/src/components/storage/ProposalSettingsSection.test.jsx

+26-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ jest.mock("@patternfly/react-core", () => {
3636
let props;
3737

3838
beforeEach(() => {
39-
props = {};
39+
props = {
40+
settings: {},
41+
onChange: jest.fn()
42+
};
4043
});
4144

4245
const rootVolume = { mountPath: "/", fsType: "Btrfs", outline: { snapshotsConfigurable: true } };
@@ -65,6 +68,28 @@ describe("if snapshots are not configurable", () => {
6568
});
6669
});
6770

71+
it("renders a section holding file systems related stuff", () => {
72+
plainRender(<ProposalSettingsSection {...props} />);
73+
screen.getByRole("grid", { name: "Table with mount points" });
74+
screen.getByRole("grid", { name: /mount points/ });
75+
});
76+
77+
it("requests a volume change when onChange callback is triggered", async () => {
78+
const { user } = plainRender(<ProposalSettingsSection {...props } />);
79+
const button = screen.getByRole("button", { name: "Actions" });
80+
81+
await user.click(button);
82+
83+
const menu = screen.getByRole("menu");
84+
const reset = within(menu).getByRole("menuitem", { name: /Reset/ });
85+
86+
await user.click(reset);
87+
88+
expect(props.onChange).toHaveBeenCalledWith(
89+
{ volumes: expect.any(Array) }
90+
);
91+
});
92+
6893
describe("Encryption field", () => {
6994
describe("if encryption password setting is not set yet", () => {
7095
beforeEach(() => {

0 commit comments

Comments
 (0)
Please sign in to comment.