/*
* Copyright (C) 2025 Red Hat, Inc.
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
import cockpit from "cockpit";
import React from "react";
import { Card, CardBody } from "@patternfly/react-core/dist/esm/components/Card/index.js";
import { Content } from "@patternfly/react-core/dist/esm/components/Content/index.js";
import { List, ListItem } from "@patternfly/react-core/dist/esm/components/List/index.js";
import { PageSection } from "@patternfly/react-core/dist/esm/components/Page/index.js";
import { Title } from "@patternfly/react-core/dist/esm/components/Title/index.js";
import { Flex, FlexItem } from "@patternfly/react-core/dist/esm/layouts/Flex/index.js";
import {
useMountPointConstraints,
useRequiredSize,
} from "../../../hooks/Storage.jsx";
const _ = cockpit.gettext;
const idPrefix = "cockpit-storage-integration";
export const ModifyStorageSideBar = () => {
const mountPointConstraints = useMountPointConstraints();
const requiredSize = useRequiredSize();
if (mountPointConstraints === undefined) {
return null;
}
const requiredConstraints = (
mountPointConstraints.filter(constraint => constraint.required.v)
);
const recommendedConstraints = (
mountPointConstraints.filter(constraint => !constraint.required.v && constraint.recommended.v)
);
const getConstraints = constraints => (
{constraints.map(constraint => {
const item = [
constraint["mount-point"].v,
constraint["required-filesystem-type"].v
]
.filter(c => !!c)
.join(" ");
return {item};
})}
);
const requiredConstraintsSection = (
requiredConstraints.length > 0 &&
<>
{_("If you are configuring partitions the following are required:")}
{getConstraints(requiredConstraints)}
>
);
const recommendedConstraintsSection = (
recommendedConstraints.length > 0 &&
<>
{_("Recommended partitions:")}
{getConstraints(recommendedConstraints)}
>
);
return (
{_("Requirements")}
{cockpit.format(_("Fedora linux requires at least $0 of disk space."), cockpit.format_bytes(requiredSize))}
{_("You can either free up enough space here and let the installer handle the rest or manually set up partitions.")}
{_("Partitions (advanced)")}
{requiredConstraintsSection}
{recommendedConstraintsSection}
);
};