/******************************************************************************** * Copyright (c) 2026 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at * https://www.eclipse.org/legal/epl-2.0 * * SPDX-License-Identifier: EPL-2.0 ********************************************************************************/ import type { ChangeEvent } from 'react'; import { FunctionComponent } from 'react'; import { Box, Typography, TextField, InputAdornment, Button, Checkbox, FormControlLabel, useTheme } from '@mui/material'; import { CheckCircle as CheckCircleIcon, RadioButtonUnchecked as RadioButtonUncheckedIcon, PersonOutlined as PersonIcon, AccountTreeOutlined as AccountTreeIcon, ExtensionOutlined as ExtensionIcon } from '@mui/icons-material'; interface FilterItem { label: string; value: string; checked: boolean; onChange: (value: string) => void; disabled?: boolean; } interface ActionButton { label: string; color: string; disabled: boolean; onClick: () => void; } interface SearchToolbarProps { publisherQuery: string; namespaceQuery: string; nameQuery: string; onPublisherChange: (event: ChangeEvent) => void; onNamespaceChange: (event: ChangeEvent) => void; onNameChange: (event: ChangeEvent) => void; // Optional inline filters filters?: FilterItem[]; // Optional select all checkbox showSelectAll?: boolean; allSelected?: boolean; onSelectAllChange?: (checked: boolean) => void; // Optional action buttons actionButtons?: ActionButton[]; // Optional selected count display selectedCount?: number; } export const SearchToolbar: FunctionComponent = ({ publisherQuery, namespaceQuery, nameQuery, onPublisherChange, onNamespaceChange, onNameChange, filters = [], showSelectAll = false, allSelected = false, onSelectAllChange, actionButtons = [], selectedCount = 0, }) => { const theme = useTheme(); return ( ), }} sx={{ flex: 1, minWidth: 100, maxWidth: '16.67%', '& .MuiOutlinedInput-root': { backgroundColor: theme.palette.scanBackground.dark, '&.Mui-focused fieldset': { borderColor: theme.palette.secondary.main, }, }, }} /> ), }} sx={{ flex: 1, minWidth: 100, maxWidth: '16.67%', '& .MuiOutlinedInput-root': { backgroundColor: theme.palette.scanBackground.dark, '&.Mui-focused fieldset': { borderColor: theme.palette.secondary.main, }, }, }} /> ), }} sx={{ flex: 1, minWidth: 100, maxWidth: '16.67%', '& .MuiOutlinedInput-root': { backgroundColor: theme.palette.scanBackground.dark, '&.Mui-focused fieldset': { borderColor: theme.palette.secondary.main, }, }, }} /> {/* Inline Filter Checkboxes */} {filters.length > 0 && ( {filters.map((filter) => ( filter.onChange(filter.value)} disabled={filter.disabled} size='small' sx={{ color: theme.palette.checkboxUnchecked, '&.Mui-checked': { color: theme.palette.secondary.main, }, }} /> } label={ {filter.label} } sx={{ mr: 0 }} disabled={filter.disabled} /> ))} )} {/* Select All and Action Buttons */} {showSelectAll && onSelectAllChange && ( )} {/* Action Buttons */} {actionButtons.length > 0 && ( {actionButtons.map((button, index) => ( ))} {selectedCount > 0 && ( {selectedCount} selected )} )} ); };