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

initial global btrfs option #1039

Merged
merged 13 commits into from
Feb 28, 2024
50 changes: 50 additions & 0 deletions web/src/components/storage/ProposalSettingsSection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,50 @@ const EncryptionSettingsForm = ({
);
};

/**
* Allows to define snapshots enablement
* @component
*
* @param {object} props
* @param {boolean} [props.isChecked=false] - Whether system snapshots are selected
* @param {boolean} [props.isLoading=false] - Whether to show the selector as loading
* @param {onChangeFn} [props.onChange=noop] - On change callback
*
* @callback onChangeFn
* @param {object} settings
*/
const SnapshotsField = ({
isChecked: isCheckedProp = false,
isLoading = false,
onChange = noop
}) => {
const [isChecked, setIsChecked] = useState(isCheckedProp);

const switchState = (checked) => {
setIsChecked(checked);
onChange(checked);
};

if (isLoading) return <Skeleton width="25%" />;

const explanation = _("Btrfs snapshots for root partition enforce root volume to use btrfs with snapshots enabled. It is useful for returning to previous snapshot of system e.g. after software upgrade.");
dgdavid marked this conversation as resolved.
Show resolved Hide resolved

return (
<>
<div className="split">
<Switch
id="snapshots"
label={_("Use Btrfs Snapshots")}
isReversed
isChecked={isChecked}
onChange={switchState}
/>
{explanation}
</div>
</>
);
};

/**
* Allows to define encryption
* @component
Expand Down Expand Up @@ -714,6 +758,12 @@ export default function ProposalSettingsSection({
isLoading={settings.lvm === undefined}
onChange={changeLVM}
/>
<SnapshotsField
settings={settings}
isChecked={false} // TODO
isLoading={false} // TODO
onChange={noop} // TODO
/>
<EncryptionField
password={settings.encryptionPassword || ""}
method={settings.encryptionMethod}
Expand Down
Loading