From 669c8d737795b6445678ffe7803438c0aac8c5ff Mon Sep 17 00:00:00 2001 From: jenny-s51 Date: Wed, 3 Mar 2021 13:56:03 -0500 Subject: [PATCH] add create user page --- src/components/view-header/ViewHeader.tsx | 4 +- src/user/UserForm.tsx | 228 +++++++++++++++++----- src/user/UsersTabs.tsx | 167 ++++++++-------- src/user/messages.json | 13 +- 4 files changed, 278 insertions(+), 134 deletions(-) diff --git a/src/components/view-header/ViewHeader.tsx b/src/components/view-header/ViewHeader.tsx index 4f25de5a8c..7e74fa2d8d 100644 --- a/src/components/view-header/ViewHeader.tsx +++ b/src/components/view-header/ViewHeader.tsx @@ -27,6 +27,7 @@ export type ViewHeaderProps = { badge?: string; badgeId?: string; badgeIsRead?: boolean; + dividerComponent?: "div" | "hr" | "li" | undefined; subKey: string; actionsDropdownId?: string; subKeyLinkProps?: FormattedLinkProps; @@ -43,6 +44,7 @@ export const ViewHeader = ({ badge, badgeId, badgeIsRead, + dividerComponent, subKey, subKeyLinkProps, dropdownItems, @@ -157,7 +159,7 @@ export const ViewHeader = ({ /> )} - + ); }; diff --git a/src/user/UserForm.tsx b/src/user/UserForm.tsx index 349365197a..4945fa5a1e 100644 --- a/src/user/UserForm.tsx +++ b/src/user/UserForm.tsx @@ -1,88 +1,226 @@ -import React from "react"; +import React, { useState } from "react"; import { ActionGroup, Button, FormGroup, + Select, + SelectOption, + Switch, TextArea, TextInput, -// ValidatedOptions, } from "@patternfly/react-core"; import { useTranslation } from "react-i18next"; -import { UseFormMethods } from "react-hook-form"; - +import { Controller, UseFormMethods } from "react-hook-form"; +import { useHistory } from "react-router-dom"; import { FormAccess } from "../components/form-access/FormAccess"; import UserRepresentation from "keycloak-admin/lib/defs/userRepresentation"; -// import { RoleFormType } from "./RealmRoleTabs"; +import { HelpItem } from "../components/help-enabler/HelpItem"; +import { useRealm } from "../context/realm-context/RealmContext"; export type UserFormProps = { form: UseFormMethods; save: (user: UserRepresentation) => void; - editMode: boolean; - reset: () => void; }; -export const UserForm = ({ - form, - save, - editMode, - reset, -}: UserFormProps) => { +export const UserForm = ({ form, save }: UserFormProps) => { const { t } = useTranslation("users"); + const { realm } = useRealm(); + + const [ + isRequiredUserActionsDropdownOpen, + setRequiredUserActionsDropdownOpen, + ] = useState(false); + const [selected, setSelected] = useState([]); + const history = useHistory(); + + const requiredUserActionsOptions = [ + + {t("configureOTP")} + , + + {t("updatePassword")} + , + + {t("updateProfile")} + , + + {t("verifyEmail")} + , + + {t("updateUserLocale")} + , + ]; + + const clearSelection = () => { + setSelected([]); + setRequiredUserActionsDropdownOpen(false); + }; + return ( -