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

[web] Fix inconsistencies in storage volumes #1109

Merged
merged 2 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions web/src/components/storage/ProposalPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ export default function ProposalPage() {
<ProposalSettingsSection
availableDevices={state.availableDevices}
encryptionMethods={state.encryptionMethods}
volumeTemplates={state.volumeTemplates}
Copy link
Contributor

@dgdavid dgdavid Mar 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a talk with @imobachgs, we concluded that this kind of errors could be avoid with the type checking. To do so, the volumeTemplates prop should be required and not have a default value. The consumer (ProposalPage in this case) is the responsible of giving the empty array if it's the case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a comment for bearing it in mind when activating the ts-check for the whole .jsx files.

settings={state.settings}
onChange={changeSettings}
isLoading={state.loading}
Expand Down
6 changes: 2 additions & 4 deletions web/src/components/storage/ProposalSettingsSection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,14 @@ const SnapshotsField = ({
}) => {
const rootVolume = (settings.volumes || []).find((i) => i.mountPath === "/");

const initialChecked = rootVolume !== undefined && hasFS(rootVolume, "Btrfs") && rootVolume.snapshots;
const [isChecked, setIsChecked] = useState(initialChecked);

// no root volume is probably some error or still loading
if (rootVolume === undefined) {
return <Skeleton width="25%" />;
}

const isChecked = rootVolume !== undefined && hasFS(rootVolume, "Btrfs") && rootVolume.snapshots;

const switchState = (_, checked) => {
setIsChecked(checked);
onChange({ active: checked, settings });
};

Expand Down
Loading