Added a way to clear filters for non custom search (#2194)

This commit is contained in:
Erik Jan de Wit 2022-03-07 15:25:59 +01:00 committed by GitHub
parent 5dc2450b01
commit 663e96d000
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View file

@ -20,6 +20,7 @@ export default {
value: "Value", value: "Value",
noSearchResults: "No search results", noSearchResults: "No search results",
noSearchResultsInstructions: "Click on the search bar above to search", noSearchResultsInstructions: "Click on the search bar above to search",
clearAllFilters: "Clear all filters",
next: "Next", next: "Next",
back: "Back", back: "Back",
finish: "Finish", finish: "Finish",

View file

@ -25,6 +25,7 @@ import { ListEmptyState } from "../list-empty-state/ListEmptyState";
import { KeycloakSpinner } from "../keycloak-spinner/KeycloakSpinner"; import { KeycloakSpinner } from "../keycloak-spinner/KeycloakSpinner";
import { useFetch } from "../../context/auth/AdminClient"; import { useFetch } from "../../context/auth/AdminClient";
import type { SVGIconProps } from "@patternfly/react-icons/dist/js/createIcon"; import type { SVGIconProps } from "@patternfly/react-icons/dist/js/createIcon";
import { ButtonVariant } from "@patternfly/react-core";
type TitleCell = { title: JSX.Element }; type TitleCell = { title: JSX.Element };
type Cell<T> = keyof T | JSX.Element | TitleCell; type Cell<T> = keyof T | JSX.Element | TitleCell;
@ -412,6 +413,17 @@ export function KeycloakDataTable<T>({
isSearchVariant={true} isSearchVariant={true}
message={t("noSearchResults")} message={t("noSearchResults")}
instructions={t("noSearchResultsInstructions")} instructions={t("noSearchResultsInstructions")}
secondaryActions={
!isSearching
? [
{
text: t("clearAllFilters"),
onClick: () => setSearch(""),
type: ButtonVariant.link,
},
]
: []
}
/> />
)} )}
{loading && <Loading />} {loading && <Loading />}