Skip to content

Commit

Permalink
[web] Small code improvement at ProposalSettingsSection
Browse files Browse the repository at this point in the history
  • Loading branch information
ancorgs committed Mar 7, 2024
1 parent 9ab4bf1 commit 338b8e5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
31 changes: 13 additions & 18 deletions web/src/components/storage/ProposalSettingsSection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,29 +143,24 @@ const SnapshotsField = ({
onChange({ active: checked, settings });
};

const configurableSnapshots = rootVolume.outline.snapshotsConfigurable;
if (!rootVolume.outline.snapshotsConfigurable) return;

const explanation = _("Uses Btrfs for the root file system allowing to boot to a previous \
version of the system after configuration changes or software upgrades.");

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe("if snapshots are not configurable", () => {
props.settings = { volumes: [{ ...rootVolume, outline: { ...rootVolume.outline, snapshotsConfigurable: false } }] };
});

it("renders the snapshots switch", () => {
it("does not render the snapshots switch", () => {
plainRender(<ProposalSettingsSection {...props} />);

expect(screen.queryByRole("checkbox", { name: "Use Btrfs Snapshots" })).toBeNull();
Expand Down

0 comments on commit 338b8e5

Please sign in to comment.