import React, { useRef, useState } from 'react'; import { Popover, TextContent, Text, Button, Alert, TextInput, } from '@patternfly/react-core'; import { Select, SelectOption } from '@patternfly/react-core/deprecated'; import { HelpIcon, MinusCircleIcon } from '@patternfly/react-icons'; import styles from '@patternfly/react-styles/css/components/Table/table'; import { Table, Th, Thead, Tbody, Tr, TrProps, TbodyProps, Td, } from '@patternfly/react-table'; import { UNIT_GIB, UNIT_KIB, UNIT_MIB } from '../../../../constants'; import { useAppDispatch, useAppSelector } from '../../../../store/hooks'; import { changePartitionMinSize, changePartitionMountpoint, changePartitionOrder, changePartitionUnit, removePartition, selectPartitions, } from '../../../../store/wizardSlice'; import { useFilesystemValidation } from '../../utilities/useValidation'; import { HookValidatedInput } from '../../ValidatedTextInput'; export const FileSystemContext = React.createContext(true); export const MinimumSizePopover = () => { return ( Image Builder may extend this size based on requirements, selected packages, and configurations. } > ); }; export type Partition = { id: string; mountpoint: string; min_size: string; unit: Units; }; type RowPropTypes = { partition: Partition; onDrop?: (event: React.DragEvent) => void; onDragEnd?: (event: React.DragEvent) => void; onDragStart?: (event: React.DragEvent) => void; }; const normalizeSuffix = (rawSuffix: string) => { const suffix = rawSuffix.replace(/^\/+/g, ''); return suffix.length > 0 ? '/' + suffix : ''; }; const getPrefix = (mountpoint: string) => { return mountpoint.split('/')[1] ? '/' + mountpoint.split('/')[1] : '/'; }; const getSuffix = (mountpoint: string) => { const prefix = getPrefix(mountpoint); return normalizeSuffix(mountpoint.substring(prefix.length)); }; const Row = ({ partition, onDragEnd, onDragStart, onDrop }: RowPropTypes) => { const dispatch = useAppDispatch(); const handleRemovePartition = (id: string) => { dispatch(removePartition(id)); }; const stepValidation = useFilesystemValidation(); const isPristine = React.useContext(FileSystemContext); return ( {!isPristine && stepValidation.errors[`mountpoint-${partition.id}`] && ( )} {partition.mountpoint !== '/' && !partition.mountpoint.startsWith('/boot') && !partition.mountpoint.startsWith('/usr') ? ( ) : ( )} xfs