29a1d82c7f
* initial version of client scope tab for clients * initial version evaluate tab * changed to use new adminCliend and merged default and optional * added add dialog * removed "always" and "required" scopes * better seach types dropdown layout * added switch implementation
79 lines
1.9 KiB
TypeScript
79 lines
1.9 KiB
TypeScript
import React, {
|
|
FormEvent,
|
|
Fragment,
|
|
MouseEventHandler,
|
|
ReactNode,
|
|
} from "react";
|
|
import {
|
|
Toolbar,
|
|
ToolbarContent,
|
|
ToolbarItem,
|
|
InputGroup,
|
|
TextInput,
|
|
Button,
|
|
ButtonVariant,
|
|
} from "@patternfly/react-core";
|
|
import { SearchIcon } from "@patternfly/react-icons";
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
type TableToolbarProps = {
|
|
toolbarItem?: ReactNode;
|
|
toolbarItemFooter?: ReactNode;
|
|
children: ReactNode;
|
|
searchTypeComponent?: ReactNode;
|
|
inputGroupName?: string;
|
|
inputGroupPlaceholder?: string;
|
|
inputGroupOnChange?: (
|
|
newInput: string,
|
|
event: FormEvent<HTMLInputElement>
|
|
) => void;
|
|
inputGroupOnClick?: MouseEventHandler;
|
|
};
|
|
|
|
export const TableToolbar = ({
|
|
toolbarItem,
|
|
toolbarItemFooter,
|
|
children,
|
|
searchTypeComponent,
|
|
inputGroupName,
|
|
inputGroupPlaceholder,
|
|
inputGroupOnChange,
|
|
inputGroupOnClick,
|
|
}: TableToolbarProps) => {
|
|
const { t } = useTranslation();
|
|
return (
|
|
<>
|
|
<Toolbar>
|
|
<ToolbarContent>
|
|
<Fragment>
|
|
{inputGroupName && (
|
|
<ToolbarItem>
|
|
<InputGroup>
|
|
{searchTypeComponent}
|
|
<TextInput
|
|
name={inputGroupName}
|
|
id={inputGroupName}
|
|
type="search"
|
|
aria-label={t("search")}
|
|
placeholder={inputGroupPlaceholder}
|
|
onChange={inputGroupOnChange}
|
|
/>
|
|
<Button
|
|
variant={ButtonVariant.control}
|
|
aria-label={t("search")}
|
|
onClick={inputGroupOnClick}
|
|
>
|
|
<SearchIcon />
|
|
</Button>
|
|
</InputGroup>
|
|
</ToolbarItem>
|
|
)}
|
|
</Fragment>
|
|
{toolbarItem}
|
|
</ToolbarContent>
|
|
</Toolbar>
|
|
{children}
|
|
<Toolbar>{toolbarItemFooter}</Toolbar>
|
|
</>
|
|
);
|
|
};
|