From 62fa0e204368ea1286e01059395fb53bd71e90a5 Mon Sep 17 00:00:00 2001 From: Alex <33497058+bexsoft@users.noreply.github.com> Date: Fri, 31 Mar 2023 22:09:37 -0600 Subject: [PATCH] Updated Entities results panel styles (#2753) Signed-off-by: Benjamin Perez --- .../Console/IDP/LDAP/LDAPEntitiesQuery.tsx | 325 ++++++++---------- .../Console/IDP/LDAP/LDAPResultsBlock.tsx | 165 +++++++++ 2 files changed, 312 insertions(+), 178 deletions(-) create mode 100644 portal-ui/src/screens/Console/IDP/LDAP/LDAPResultsBlock.tsx diff --git a/portal-ui/src/screens/Console/IDP/LDAP/LDAPEntitiesQuery.tsx b/portal-ui/src/screens/Console/IDP/LDAP/LDAPEntitiesQuery.tsx index 0ecebb74f..508ae9fba 100644 --- a/portal-ui/src/screens/Console/IDP/LDAP/LDAPEntitiesQuery.tsx +++ b/portal-ui/src/screens/Console/IDP/LDAP/LDAPEntitiesQuery.tsx @@ -27,13 +27,15 @@ import { InputBox, Loader, RemoveIcon, + SearchIcon, SectionTitle, - UptimeIcon, + TimeIcon, } from "mds"; import PolicySelectors from "../../Policies/PolicySelectors"; import { useSelector } from "react-redux"; import { LDAPEntitiesResponse } from "./types"; import { DateTime } from "luxon"; +import LDAPResultsBlock from "./LDAPResultsBlock"; const LDAPEntitiesQuery = () => { const dispatch = useAppDispatch(); @@ -107,90 +109,128 @@ const LDAPEntitiesQuery = () => { }; return ( - + - Query Filters + Query Filters - -

Users

- div > div": { - width: "100%", - }, - }} - > - {users.map((userDat, index) => { - return ( - ) => { - const usersElements = [...users]; - usersElements[index] = e.target.value; - setUsers(usersElements); - }} - overlayIcon={ - users.length === index + 1 ? : - } - overlayAction={() => { - alterUsersList(users.length === index + 1, index); - }} - /> - ); - })} + + + +

+ Users +

+
+ div > div": { + width: "100%", + }, + }} + > + {users.map((userDat, index) => { + return ( + ) => { + const usersElements = [...users]; + usersElements[index] = e.target.value; + setUsers(usersElements); + }} + overlayIcon={ + users.length === index + 1 ? ( + + ) : ( + + ) + } + overlayAction={() => { + alterUsersList(users.length === index + 1, index); + }} + /> + ); + })} +
- -

Groups

- div > div": { - width: "100%", - }, - }} - > - {groups.map((groupDat, index) => { - return ( - ) => { - const groupsElements = [...groups]; - groupsElements[index] = e.target.value; - setGroups(groupsElements); - }} - overlayIcon={ - groups.length === index + 1 ? : - } - overlayAction={() => { - alterGroupsList(groups.length === index + 1, index); - }} - /> - ); - })} + +

+ Groups +

+ div > div": { + width: "100%", + }, + }} + > + {groups.map((groupDat, index) => { + return ( + ) => { + const groupsElements = [...groups]; + groupsElements[index] = e.target.value; + setGroups(groupsElements); + }} + overlayIcon={ + groups.length === index + 1 ? ( + + ) : ( + + ) + } + overlayAction={() => { + alterGroupsList(groups.length === index + 1, index); + }} + /> + ); + })} +
- -

Policies

- - + +

+ Policies +

+ + +
- + {loading ? ( @@ -198,8 +238,6 @@ const LDAPEntitiesQuery = () => { ) : ( { > {results?.timestamp ? ( - {DateTime.fromISO(results.timestamp).toFormat( "D HH:mm:ss" @@ -224,114 +267,30 @@ const LDAPEntitiesQuery = () => { } > - Results + Query Results {results ? ( - + {!results.groups && !results.users && !results.policies && (

No Results Available

)} {!!results.groups && ( - - - Group Mappings - - - {results.groups.map((groupData, index) => { - return ( - -

{groupData.group}

- {groupData.policies && ( - - Policies: -
    - {groupData.policies.map( - (policy, index2) => ( -
  • - {policy} -
  • - ) - )} -
-
- )} -
- ); - })} -
-
+ )} {!!results.users && ( - - - User Mappings - - - {results.users.map((groupData, index) => { - return ( - -

{groupData.user}

- {groupData.policies && ( - - Policies: -
    - {groupData.policies.map( - (policy, index2) => ( -
  • - {policy} -
  • - ) - )} -
-
- )} -
- ); - })} -
-
+ )} {!!results.policies && ( - - - Policy Mappings - - - {results.policies.map((groupData, index) => { - return ( - -

{groupData.policy}

- {groupData.groups && ( - - Groups: -
    - {groupData.groups.map((group, index2) => ( -
  • - {group} -
  • - ))} -
-
- )} - {groupData.users && ( - - Users: -
    - {groupData.users.map((user, index3) => ( -
  • - {user} -
  • - ))} -
-
- )} -
- ); - })} -
-
+ )}
) : ( @@ -342,12 +301,22 @@ const LDAPEntitiesQuery = () => {
- + diff --git a/portal-ui/src/screens/Console/IDP/LDAP/LDAPResultsBlock.tsx b/portal-ui/src/screens/Console/IDP/LDAP/LDAPResultsBlock.tsx new file mode 100644 index 000000000..95771e16a --- /dev/null +++ b/portal-ui/src/screens/Console/IDP/LDAP/LDAPResultsBlock.tsx @@ -0,0 +1,165 @@ +// This file is part of MinIO Console Server +// Copyright (c) 2023 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +import React, { Fragment } from "react"; +import { Box, CollapseCaret, GroupsMenuIcon, SectionTitle } from "mds"; +import { LDAPEntitiesResponse } from "./types"; + +interface IResultBlock { + entityName: "Group" | "User" | "Policy"; + results: LDAPEntitiesResponse; +} + +interface IEntityResultName { + name: string; +} + +interface IEntityResultItem { + blockName: "Policies" | "Groups" | "Users"; + results: string[]; +} + +const EntityResultTitle = ({ name }: IEntityResultName) => { + return ( +

+ + {name} +

+ ); +}; + +const EntityResultItems = ({ blockName, results }: IEntityResultItem) => { + return ( + + {blockName}: +
    + {results.map((res, index) => ( +
  • {res}
  • + ))} +
+
+ ); +}; + +const LDAPResultsBlock = ({ entityName, results }: IResultBlock) => { + let entityLength = 0; + + switch (entityName) { + case "Group": + entityLength = results.groups?.length || 0; + break; + case "Policy": + entityLength = results.policies?.length || 0; + break; + case "User": + entityLength = results.users?.length || 0; + break; + } + + return ( + + } + actions={ + + {entityLength} Entit + {entityLength === 1 ? "y" : "ies"} Found + + } + > + {entityName} Mappings + + + {entityName === "Group" && + results.groups?.map((groupData, index) => { + return ( + + + {groupData.policies && ( + + )} + + ); + })} + {entityName === "User" && + results.users?.map((groupData, index) => { + return ( + + + {groupData.policies && ( + + )} + + ); + })} + {entityName === "Policy" && + results.policies?.map((groupData, index) => { + return ( + + + {groupData.groups && ( + + )} + {groupData.users && ( + + )} + + ); + })} + + + ); +}; + +export default LDAPResultsBlock;