Skip to content

Commit

Permalink
Merge pull request #5008 from adamkankovsky/webui-mount-point-mapping…
Browse files Browse the repository at this point in the history
…-switchers

webui: Changing of checkbox for switch
  • Loading branch information
KKoukiou authored Aug 7, 2023
2 parents c44677e + d3fd3e9 commit 0ec408e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
38 changes: 21 additions & 17 deletions ui/webui/src/components/storage/MountPointMapping.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,18 @@ import React, { useState, useRef, useEffect, useMemo, useCallback } from "react"
import {
Alert,
Button,
Checkbox,
Switch,
Flex,
FlexItem,
HelperText,
HelperTextItem,
Label,
Popover,
Select,
SelectOption,
SelectVariant,
TextInput,
TextInput, Tooltip,
} from "@patternfly/react-core";
import { HelpIcon, TrashIcon } from "@patternfly/react-icons";
import { TrashIcon } from "@patternfly/react-icons";

import { ListingTable } from "cockpit-components-table.jsx";
import { EmptyStatePanel } from "cockpit-components-empty-state.jsx";
Expand Down Expand Up @@ -201,25 +200,30 @@ const DeviceColumn = ({ deviceData, devices, idPrefix, handleRequestChange, lock
);
};

const FormatColumn = ({ deviceData, handleRequestChange, idPrefix, request }) => {
const FormatColumn = ({ handleRequestChange, idPrefix, request }) => {
const mountpoint = request["mount-point"];
const isRootMountPoint = mountpoint === "/";

return (
<Flex>
<Checkbox
id={idPrefix + "-checkbox"}
isChecked={request.reformat}
const FormatSwitch = () => {
return (
<Switch
id={idPrefix + "-switch"}
isChecked={!!request.reformat}
isDisabled={isRootMountPoint}
label={_("Reformat")}
aria-label={_("Reformat")}
onChange={checked => handleRequestChange(request["mount-point"], request["device-spec"], request["request-id"], checked)}
/>
);
};

return (
<Flex>
{!isRootMountPoint &&
<FormatSwitch />}
{isRootMountPoint &&
<Popover
bodyContent={_("The root partition is always re-formatted by the installer.")}
showClose={false}>
<HelpIcon />
</Popover>}
<Tooltip
content={_("The root partition is always re-formatted by the installer.")}>
<FormatSwitch />
</Tooltip>}
</Flex>
);
};
Expand Down
2 changes: 1 addition & 1 deletion ui/webui/test/check-storage
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ class TestStorageMountPoints(anacondalib.VirtInstallMachineCase):
self.browser.wait_not_present("#unlock-device-dialog")

def select_reformat(self, row):
self.browser.set_checked(f"{self.table_row(row)} td[data-label='Reformat'] input", True)
self.browser.click(f"{self.table_row(row)} td[data-label='Reformat'] input")

def check_reformat(self, row, checked):
checked_selector = "input:checked" if checked else "input:not(:checked)"
Expand Down
2 changes: 1 addition & 1 deletion ui/webui/test/reference

0 comments on commit 0ec408e

Please sign in to comment.