From a405dc9e1337e9443fe06422d1f83c4db602306e Mon Sep 17 00:00:00 2001 From: Christie Molloy Date: Thu, 1 Oct 2020 15:15:23 -0400 Subject: [PATCH] fix formatting --- src/groups/GroupsCreateModal.tsx | 25 ++++++++++++++++--------- src/groups/GroupsList.tsx | 14 +++++--------- src/groups/GroupsSection.tsx | 14 +++----------- 3 files changed, 24 insertions(+), 29 deletions(-) diff --git a/src/groups/GroupsCreateModal.tsx b/src/groups/GroupsCreateModal.tsx index b1d569250c..1a0c127fae 100644 --- a/src/groups/GroupsCreateModal.tsx +++ b/src/groups/GroupsCreateModal.tsx @@ -1,4 +1,4 @@ -import React, {useContext} from "react"; +import React, { useContext } from "react"; import { AlertVariant, Button, @@ -6,7 +6,7 @@ import { FormGroup, Modal, ModalVariant, - TextInput + TextInput, } from "@patternfly/react-core"; import { useTranslation } from "react-i18next"; import { HttpClientContext } from "../http-service/HttpClientContext"; @@ -22,8 +22,13 @@ type GroupsCreateModalProps = { setCreateGroupName: (createGroupName: string) => void; }; -export const GroupsCreateModal = ({handleModalToggle, isCreateModalOpen, setIsCreateModalOpen, createGroupName, setCreateGroupName}: GroupsCreateModalProps) => { - +export const GroupsCreateModal = ({ + handleModalToggle, + isCreateModalOpen, + setIsCreateModalOpen, + createGroupName, + setCreateGroupName, +}: GroupsCreateModalProps) => { const { t } = useTranslation("groups"); const httpClient = useContext(HttpClientContext)!; const { realm } = useContext(RealmContext); @@ -32,19 +37,21 @@ export const GroupsCreateModal = ({handleModalToggle, isCreateModalOpen, setIsCr const { register, errors } = form; const valueChange = (createGroupName: string) => { - setCreateGroupName(createGroupName) - } + setCreateGroupName(createGroupName); + }; const submitForm = async () => { try { - await httpClient.doPost(`/admin/realms/${realm}/groups`, {name: createGroupName}); + await httpClient.doPost(`/admin/realms/${realm}/groups`, { + name: createGroupName, + }); setIsCreateModalOpen(false); setCreateGroupName(""); add(t("groupCreated"), AlertVariant.success); } catch (error) { add(`${t("couldNotCreateGroup")} ': '${error}'`, AlertVariant.danger); } - } + }; return ( @@ -57,7 +64,7 @@ export const GroupsCreateModal = ({handleModalToggle, isCreateModalOpen, setIsCr actions={[ + , ]} >
diff --git a/src/groups/GroupsList.tsx b/src/groups/GroupsList.tsx index efcf6b71b0..7ded8edaa2 100644 --- a/src/groups/GroupsList.tsx +++ b/src/groups/GroupsList.tsx @@ -5,10 +5,7 @@ import { TableBody, TableVariant, } from "@patternfly/react-table"; -import { - Button, - AlertVariant -} from "@patternfly/react-core"; +import { Button, AlertVariant } from "@patternfly/react-core"; import { useTranslation } from "react-i18next"; import { GroupRepresentation } from "./models/groups"; import { UsersIcon } from "@patternfly/react-icons"; @@ -31,7 +28,6 @@ export const GroupsList = ({ list }: GroupsListProps) => { { cells: [], selected: false }, ]); - const formatData = (data: GroupRepresentation[]) => data.map((group: { [key: string]: any }, index) => { const groupName = group[columnGroupName]; @@ -81,21 +77,21 @@ export const GroupsList = ({ list }: GroupsListProps) => { { title: t("common:Delete"), onClick: (_: React.MouseEvent, rowId: number) => { - try { httpClient.doDelete( + try { + httpClient.doDelete( `/admin/realms/${realm}/groups/${list![rowId].id}` ); add(t("Group deleted"), AlertVariant.success); } catch (error) { add(`${t("clientDeleteError")} ${error}`, AlertVariant.danger); } - - } + }, }, ]; return ( - + {formattedData && ( { const { t } = useTranslation("groups"); const httpClient = useContext(HttpClientContext)!; @@ -37,8 +36,6 @@ export const GroupsSection = () => { const [isCreateModalOpen, setIsCreateModalOpen] = useState(false); - - const loader = async () => { const groups = await httpClient.doGet( "/admin/realms/master/groups", @@ -97,15 +94,12 @@ export const GroupsSection = () => { }; const handleModalToggle = () => { - setIsCreateModalOpen(!isCreateModalOpen) + setIsCreateModalOpen(!isCreateModalOpen); }; return ( - + { } > {rawData && filteredData && ( - + )}