Add a 'Reset' button the the events search form (#2732)

This commit is contained in:
Jon Koops 2022-06-02 09:27:57 +02:00 committed by GitHub
parent b6d71a25cc
commit d6edaa1ee1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 3 deletions

View file

@ -31,5 +31,6 @@
"attribute": "Attribute",
"value": "Value",
"representation": "Representation",
"noUserDetails": "No user details"
"noUserDetails": "No user details",
"resetBtn": "Reset"
}

View file

@ -147,6 +147,11 @@ export const AdminEvents = () => {
commitFilters();
}
function resetSearch() {
reset();
commitFilters();
}
function removeFilter(key: keyof AdminEventSearchForm) {
const formValues: AdminEventSearchForm = { ...getValues() };
delete formValues[key];
@ -437,7 +442,6 @@ export const AdminEvents = () => {
</FormGroup>
<ActionGroup>
<Button
className="keycloak__user_events_search__form_btn"
variant={"primary"}
onClick={submitSearch}
data-testid="search-events-btn"
@ -445,6 +449,13 @@ export const AdminEvents = () => {
>
{t("searchAdminEventsBtn")}
</Button>
<Button
variant="secondary"
onClick={resetSearch}
isDisabled={!isDirty}
>
{t("resetBtn")}
</Button>
</ActionGroup>
</Form>
</Dropdown>

View file

@ -138,6 +138,11 @@ export default function EventsSection() {
commitFilters();
}
function resetSearch() {
reset();
commitFilters();
}
function removeFilter(key: keyof UserEventSearchForm) {
const formValues: UserEventSearchForm = { ...getValues() };
delete formValues[key];
@ -342,7 +347,6 @@ export default function EventsSection() {
</FormGroup>
<ActionGroup>
<Button
className="keycloak__user_events_search__form_btn"
variant={"primary"}
onClick={submitSearch}
data-testid="search-events-btn"
@ -350,6 +354,13 @@ export default function EventsSection() {
>
{t("searchUserEventsBtn")}
</Button>
<Button
variant="secondary"
onClick={resetSearch}
isDisabled={!isDirty}
>
{t("resetBtn")}
</Button>
</ActionGroup>
</Form>
</Dropdown>