diff --git a/portal-ui/src/common/SecureComponent/permissions.ts b/portal-ui/src/common/SecureComponent/permissions.ts index 37f836099..b26d286c9 100644 --- a/portal-ui/src/common/SecureComponent/permissions.ts +++ b/portal-ui/src/common/SecureComponent/permissions.ts @@ -449,11 +449,15 @@ export const permissionTooltipHelper = (scopes: string[], name: string) => { }; export const listUsersPermissions = [IAM_SCOPES.ADMIN_LIST_USERS]; -export const viewUserPermissions = [IAM_SCOPES.ADMIN_GET_USER]; + export const addUserToGroupPermissions = [IAM_SCOPES.ADMIN_ADD_USER_TO_GROUP]; + export const deleteUserPermissions = [IAM_SCOPES.ADMIN_DELETE_USER]; + export const enableUserPermissions = [IAM_SCOPES.ADMIN_ENABLE_USER]; + export const disableUserPermissions = [IAM_SCOPES.ADMIN_DISABLE_USER]; + export const assignIAMPolicyPermissions = [ IAM_SCOPES.ADMIN_ATTACH_USER_OR_GROUP_POLICY, IAM_SCOPES.ADMIN_LIST_USER_POLICIES, @@ -479,3 +483,35 @@ export const editServiceAccountPermissions = [ IAM_SCOPES.ADMIN_UPDATE_SERVICEACCOUNT, IAM_SCOPES.ADMIN_REMOVE_SERVICEACCOUNT, ]; + +export const applyPolicyPermissions = [ + IAM_SCOPES.ADMIN_ATTACH_USER_OR_GROUP_POLICY, + IAM_SCOPES.ADMIN_LIST_USER_POLICIES, +]; + +export const deleteGroupPermissions = [IAM_SCOPES.ADMIN_REMOVE_USER_FROM_GROUP]; + +export const displayGroupsPermissions = [IAM_SCOPES.ADMIN_LIST_GROUPS]; + +export const createGroupPermissions = [ + IAM_SCOPES.ADMIN_ADD_USER_TO_GROUP, + IAM_SCOPES.ADMIN_LIST_USERS, +]; + +export const viewUserPermissions = [ + IAM_SCOPES.ADMIN_GET_USER, + IAM_SCOPES.ADMIN_LIST_USERS, +]; +export const editGroupMembersPermissions = [ + IAM_SCOPES.ADMIN_ADD_USER_TO_GROUP, + IAM_SCOPES.ADMIN_LIST_USERS, +]; +export const setGroupPoliciesPermissions = [ + IAM_SCOPES.ADMIN_ATTACH_USER_OR_GROUP_POLICY, + IAM_SCOPES.ADMIN_LIST_USER_POLICIES, +]; +export const viewPolicyPermissions = [IAM_SCOPES.ADMIN_GET_POLICY]; +export const enableDisableGroupPermissions = [ + IAM_SCOPES.ADMIN_ENABLE_GROUP, + IAM_SCOPES.ADMIN_DISABLE_GROUP, +]; diff --git a/portal-ui/src/screens/Console/Common/TableWrapper/TableWrapper.tsx b/portal-ui/src/screens/Console/Common/TableWrapper/TableWrapper.tsx index 7168e5d55..d91ba4d1a 100644 --- a/portal-ui/src/screens/Console/Common/TableWrapper/TableWrapper.tsx +++ b/portal-ui/src/screens/Console/Common/TableWrapper/TableWrapper.tsx @@ -40,6 +40,7 @@ import { TableRowPredefStyles, } from "../FormComponents/common/styleLibrary"; import Loader from "../Loader/Loader"; +import TooltipWrapper from "../TooltipWrapper/TooltipWrapper"; //Interfaces for table Items @@ -111,6 +112,7 @@ interface TableWrapperProps { index: number; }) => "deleted" | "" | React.CSSProperties; parentClassName?: string; + tooltip?: any; } const borderColor = "#9c9c9c80"; @@ -465,6 +467,7 @@ const TableWrapper = ({ onSelectAll, rowStyle, parentClassName = "", + tooltip, }: TableWrapperProps) => { const navigate = useNavigate(); @@ -558,235 +561,249 @@ const TableWrapper = ({ return ( - + - {isLoading && ( - - - {loadingMessage} + > + {isLoading && ( + + + {loadingMessage} + + + + - - - - - )} - {columnsSelector && !isLoading && records.length > 0 && ( -
- {columnsSelection(columns)} -
- )} - {records && !isLoading && records.length > 0 ? ( - // @ts-ignore - !!records[index]} - loadMoreRows={ - infiniteScrollConfig - ? infiniteScrollConfig.loadMoreRecords - : () => new Promise(() => true) - } - rowCount={ - infiniteScrollConfig - ? infiniteScrollConfig.recordsCount - : records.length - } - > - {({ onRowsRendered, registerChild }) => ( - // @ts-ignore - - {({ width, height }: any) => { - const optionsWidth = calculateOptionsSize( - width, - itemActions - ? itemActions.filter((el) => el.type !== "view").length - : 0 - ); - const hasSelect: boolean = !!(onSelect && selectedItems); - const hasOptions: boolean = !!( - (itemActions && itemActions.length > 1) || - (itemActions && - itemActions.length === 1 && - itemActions[0].type !== "view") - ); - return ( - // @ts-ignore - ( - - {customEmptyMessage !== "" - ? customEmptyMessage - : `There are no ${entityName} yet.`} - - )} - overscanRowCount={10} - rowHeight={40} - width={width} - rowCount={records.length} - rowGetter={({ index }) => records[index]} - onRowClick={({ rowData }) => { - clickAction(rowData); - }} - rowClassName={`rowLine ${findView ? "canClick" : ""} ${ - !findView && textSelectable ? "canSelectText" : "" - }`} - onRowsRendered={onRowsRendered} - sort={sortConfig ? sortConfig.triggerSort : undefined} - sortBy={sortConfig ? sortConfig.currentSort : undefined} - sortDirection={ - sortConfig ? sortConfig.currentDirection : undefined - } - scrollToIndex={ - autoScrollToBottom ? records.length - 1 : -1 - } - rowStyle={(r) => { - if (rowStyle) { - const returnElement = rowStyle(r); + )} + {columnsSelector && !isLoading && records.length > 0 && ( +
+ {columnsSelection(columns)} +
+ )} + {records && !isLoading && records.length > 0 ? ( + // @ts-ignore + !!records[index]} + loadMoreRows={ + infiniteScrollConfig + ? infiniteScrollConfig.loadMoreRecords + : () => new Promise(() => true) + } + rowCount={ + infiniteScrollConfig + ? infiniteScrollConfig.recordsCount + : records.length + } + > + {({ onRowsRendered, registerChild }) => ( + // @ts-ignore + + {({ width, height }: any) => { + const optionsWidth = calculateOptionsSize( + width, + itemActions + ? itemActions.filter((el) => el.type !== "view").length + : 0 + ); + const hasSelect: boolean = !!(onSelect && selectedItems); + const hasOptions: boolean = !!( + (itemActions && itemActions.length > 1) || + (itemActions && + itemActions.length === 1 && + itemActions[0].type !== "view") + ); + return ( + // @ts-ignore +
( + + {customEmptyMessage !== "" + ? customEmptyMessage + : `There are no ${entityName} yet.`} + + )} + overscanRowCount={10} + rowHeight={40} + width={width} + rowCount={records.length} + rowGetter={({ index }) => records[index]} + onRowClick={({ rowData }) => { + clickAction(rowData); + }} + rowClassName={`rowLine ${findView ? "canClick" : ""} ${ + !findView && textSelectable ? "canSelectText" : "" + }`} + onRowsRendered={onRowsRendered} + sort={sortConfig ? sortConfig.triggerSort : undefined} + sortBy={sortConfig ? sortConfig.currentSort : undefined} + sortDirection={ + sortConfig ? sortConfig.currentDirection : undefined + } + scrollToIndex={ + autoScrollToBottom ? records.length - 1 : -1 + } + rowStyle={(r) => { + if (rowStyle) { + const returnElement = rowStyle(r); - if (typeof returnElement === "string") { - return get(TableRowPredefStyles, returnElement, {}); + if (typeof returnElement === "string") { + return get( + TableRowPredefStyles, + returnElement, + {} + ); + } + + return returnElement; } - return returnElement; - } + return {}; + }} + > + {hasSelect && ( + // @ts-ignore + ( + + {onSelectAll ? ( +
+ +
+ ) : ( + Select + )} +
+ )} + dataKey={`select-${idField}`} + width={selectWidth} + disableSort + cellRenderer={({ rowData }) => { + const isSelected = selectedItems + ? selectedItems.includes( + isString(rowData) + ? rowData + : rowData[idField] + ) + : false; - return {}; - }} - > - {hasSelect && ( - // @ts-ignore - ( - - {onSelectAll ? ( -
- -
- ) : ( - Select - )} -
- )} - dataKey={`select-${idField}`} - width={selectWidth} - disableSort - cellRenderer={({ rowData }) => { - const isSelected = selectedItems - ? selectedItems.includes( - isString(rowData) ? rowData : rowData[idField] - ) - : false; - - return ( - { - e.stopPropagation(); - }} - checkedIcon={ - - } - icon={ - - } - /> - ); - }} - /> - )} - {generateColumnsMap( - columns, - width, - optionsWidth, - hasSelect, - hasOptions, - selectedItems || [], - idField, - columnsSelector, - columnsShown, - sortConfig ? sortConfig.currentSort : "", - sortConfig ? sortConfig.currentDirection : undefined - )} - {hasOptions && ( - // @ts-ignore - { - const isSelected = selectedItems - ? selectedItems.includes( - isString(rowData) ? rowData : rowData[idField] - ) - : false; - return elementActions( - itemActions || [], - rowData, - isSelected, - idField - ); - }} - /> - )} -
- ); - }} -
- )} -
- ) : ( - - {!isLoading && ( -
- {customEmptyMessage !== "" - ? customEmptyMessage - : `There are no ${entityName} yet.`} -
- )} -
- )} -
+ return ( + { + e.stopPropagation(); + }} + checkedIcon={ + + } + icon={ + + } + /> + ); + }} + /> + )} + {generateColumnsMap( + columns, + width, + optionsWidth, + hasSelect, + hasOptions, + selectedItems || [], + idField, + columnsSelector, + columnsShown, + sortConfig ? sortConfig.currentSort : "", + sortConfig ? sortConfig.currentDirection : undefined + )} + {hasOptions && ( + // @ts-ignore + { + const isSelected = selectedItems + ? selectedItems.includes( + isString(rowData) + ? rowData + : rowData[idField] + ) + : false; + return elementActions( + itemActions || [], + rowData, + isSelected, + idField + ); + }} + /> + )} + + ); + }} + + )} + + ) : ( + + {!isLoading && ( +
+ {customEmptyMessage !== "" + ? customEmptyMessage + : `There are no ${entityName} yet.`} +
+ )} +
+ )} +
+
); }; diff --git a/portal-ui/src/screens/Console/Groups/Groups.tsx b/portal-ui/src/screens/Console/Groups/Groups.tsx index 0046a420c..b11d19012 100644 --- a/portal-ui/src/screens/Console/Groups/Groups.tsx +++ b/portal-ui/src/screens/Console/Groups/Groups.tsx @@ -49,7 +49,12 @@ import SearchBox from "../Common/SearchBox"; import { CONSOLE_UI_RESOURCE, IAM_PAGES, - IAM_SCOPES, + permissionTooltipHelper, + applyPolicyPermissions, + displayGroupsPermissions, + deleteGroupPermissions, + getGroupPermissions, + createGroupPermissions, } from "../../../common/SecureComponent/permissions"; import { hasPermission, @@ -107,17 +112,23 @@ const Groups = ({ classes }: IGroupsProps) => { isLoading(true); }, []); - const displayGroups = hasPermission(CONSOLE_UI_RESOURCE, [ - IAM_SCOPES.ADMIN_LIST_GROUPS, - ]); + const displayGroups = hasPermission( + CONSOLE_UI_RESOURCE, + displayGroupsPermissions + ); - const deleteGroup = hasPermission(CONSOLE_UI_RESOURCE, [ - IAM_SCOPES.ADMIN_REMOVE_USER_FROM_GROUP, - ]); + const deleteGroup = hasPermission( + CONSOLE_UI_RESOURCE, + deleteGroupPermissions + ); - const getGroup = hasPermission(CONSOLE_UI_RESOURCE, [ - IAM_SCOPES.ADMIN_GET_GROUP, - ]); + const getGroup = hasPermission(CONSOLE_UI_RESOURCE, getGroupPermissions); + + const applyPolicy = hasPermission( + CONSOLE_UI_RESOURCE, + applyPolicyPermissions, + true + ); const selectionChanged = (e: React.ChangeEvent) => { const { target: { value = "", checked = false } = {} } = e; @@ -217,7 +228,7 @@ const Groups = ({ classes }: IGroupsProps) => { { > - +