import React from "react"; // PatternFly import { EmptyState, EmptyStateActions, EmptyStateBody, EmptyStateVariant, Flex, FlexItem, SearchInput, } from "@patternfly/react-core"; import { TableVariant } from "@patternfly/react-table"; // Layout import SecondaryButton from "../SecondaryButton"; import TableLayout from "../TableLayout"; import PaginationLayout from "../PaginationLayout"; interface PropsToSettingsTableLayout { // Table ariaLabel: string; name?: string; variant: TableVariant | "compact"; hasBorders: boolean; tableClasses?: string; tableId: string; isStickyHeader: boolean; tableHeader?: JSX.Element; tableBody: JSX.Element[] | JSX.Element; onDeleteModal: () => void; isDeleteDisabled?: boolean; onAddModal: () => void; isAddDisabled?: boolean; onSearchChange?: (value: string) => void; searchValue?: string; // pagination paginationData: PaginationData; // eslint-disable-next-line @typescript-eslint/no-explicit-any list: any[]; entryCount?: number; entryType: string; extraID?: string; } interface PaginationData { page: number; perPage: number; updatePage: (newPage: number) => void; updatePerPage: (newSetPerPage: number) => void; updateSelectedPerPage: (selected: number) => void; // eslint-disable-next-line @typescript-eslint/no-explicit-any updateShownElementsList: (newShownElementsList: any[]) => void; totalCount: number; } // The settings table is meant to be used in the "settings" page for users, // hosts, etc. We need smaller sized pagination, and other differences that // are ideal in a crowded page where space is limited const SettingsTableLayout = (props: PropsToSettingsTableLayout) => { const extraId = props.extraID ? props.extraID : ""; const entryCount = props.entryCount ?? props.list.length; // Prepare ID for the Add buttons // - Should contain the entry type in lowercase and spaces replaced by dashes const addButtonId = extraId ? "add-" + extraId + "-" + props.entryType.toLowerCase().replace(" ", "-") : "add-" + props.entryType.toLowerCase().replace(" ", "-"); return ( <> {entryCount > 0 && props.onSearchChange !== undefined && ( props.onSearchChange && props.onSearchChange(value) } onClear={() => props.onSearchChange && props.onSearchChange("")} /> )} {props.paginationData.totalCount > 0 && ( <> Delete Add {props.entryType.toLowerCase()}s )} {props.paginationData.totalCount > 0 ? ( <> ) : ( 0 ? " found" : "") } variant={EmptyStateVariant.xs} > Add {props.entryType.toLowerCase()}s )} ); }; export default SettingsTableLayout;