diff --git a/js/apps/admin-ui/src/events/AdminEvents.tsx b/js/apps/admin-ui/src/events/AdminEvents.tsx index 1ce83da9d1..cb8e22a414 100644 --- a/js/apps/admin-ui/src/events/AdminEvents.tsx +++ b/js/apps/admin-ui/src/events/AdminEvents.tsx @@ -25,17 +25,17 @@ import { } from "@patternfly/react-table"; import { pickBy } from "lodash-es"; import { PropsWithChildren, useMemo, useState } from "react"; -import { Controller, useForm } from "react-hook-form"; +import { Controller, FormProvider, useForm } from "react-hook-form"; import { useTranslation } from "react-i18next"; +import { TextControl } from "ui-shared"; import { adminClient } from "../admin-client"; -import { KeycloakTextInput } from "../components/keycloak-text-input/KeycloakTextInput"; +import DropdownPanel from "../components/dropdown-panel/DropdownPanel"; import { ListEmptyState } from "../components/list-empty-state/ListEmptyState"; import { Action, KeycloakDataTable, } from "../components/table-toolbar/KeycloakDataTable"; -import DropdownPanel from "../components/dropdown-panel/DropdownPanel"; import { useRealm } from "../context/realm-context/RealmContext"; import { useServerInfo } from "../context/server-info/ServerInfoProvider"; import { prettyPrintJSON } from "../util"; @@ -124,16 +124,16 @@ export const AdminEvents = () => { authIpAddress: t("ipAddress"), }; - const { - getValues, - register, - reset, - formState: { isDirty }, - control, - } = useForm({ + const form = useForm({ mode: "onChange", defaultValues, }); + const { + getValues, + reset, + formState: { isDirty }, + control, + } = form; function loader(first?: number, max?: number) { return adminClient.realms.findAdminEvents({ @@ -187,304 +187,6 @@ export const AdminEvents = () => { setKey(key + 1); } - const adminEventSearchFormDisplay = () => { - return ( - - - -
- - ( - - )} - /> - - - ( - - )} - /> - - - - - - - - - - - - - - - - - - ( - field.onChange(value)} - inputProps={{ id: "kc-dateFrom" }} - /> - )} - /> - - - ( - field.onChange(value)} - inputProps={{ id: "kc-dateTo" }} - /> - )} - /> - - - - - -
-
-
- - {Object.entries(activeFilters).length > 0 && ( -
- {Object.entries(activeFilters).map((filter) => { - const [key, value] = filter as [ - keyof AdminEventSearchForm, - string | string[], - ]; - - return ( - removeFilter(key)} - > - {typeof value === "string" ? ( - {value} - ) : ( - value.map((entry) => ( - removeFilterValue(key, entry)} - > - {entry} - - )) - )} - - ); - })} -
- )} -
-
- ); - }; - - const rows = [ - [t("realm"), authEvent?.authDetails?.realmId], - [t("client"), authEvent?.authDetails?.clientId], - [t("user"), authEvent?.authDetails?.userId], - [t("ipAddress"), authEvent?.authDetails?.ipAddress], - ]; - const code = useMemo( () => representationEvent?.representation @@ -502,7 +204,12 @@ export const AdminEvents = () => { data-testid="auth-dialog" variant={TableVariant.compact} cells={[t("attribute"), t("value")]} - rows={rows} + rows={[ + [t("realm"), authEvent.authDetails?.realmId], + [t("client"), authEvent.authDetails?.clientId], + [t("user"), authEvent.authDetails?.userId], + [t("ipAddress"), authEvent.authDetails?.ipAddress], + ]} > @@ -529,7 +236,257 @@ export const AdminEvents = () => { loader={loader} isPaginated ariaLabelKey="adminEvents" - toolbarItem={adminEventSearchFormDisplay()} + toolbarItem={ + + + + +
+ + ( + + )} + /> + + + ( + + )} + /> + + + + + + + + ( + field.onChange(value)} + inputProps={{ id: "kc-dateFrom" }} + /> + )} + /> + + + ( + field.onChange(value)} + inputProps={{ id: "kc-dateTo" }} + /> + )} + /> + + + + + + +
+
+ + {Object.entries(activeFilters).length > 0 && ( +
+ {Object.entries(activeFilters).map((filter) => { + const [key, value] = filter as [ + keyof AdminEventSearchForm, + string | string[], + ]; + + return ( + removeFilter(key)} + > + {typeof value === "string" ? ( + {value} + ) : ( + value.map((entry) => ( + removeFilterValue(key, entry)} + > + {entry} + + )) + )} + + ); + })} +
+ )} +
+
+
+ } actions={ [ {