diff --git a/portal-ui/src/common/SecureComponent/permissions.ts b/portal-ui/src/common/SecureComponent/permissions.ts
index e8e79bbb7..c502d4d89 100644
--- a/portal-ui/src/common/SecureComponent/permissions.ts
+++ b/portal-ui/src/common/SecureComponent/permissions.ts
@@ -112,6 +112,11 @@ export const IAM_SCOPES = {
S3_GET_BUCKET_LOCATION: "s3:GetBucketLocation",
S3_DELETE_BUCKET_POLICY: "s3:DeleteBucketPolicy",
S3_ABORT_MULTIPART_UPLOAD: "s3:AbortMultipartUpload",
+ ADMIN_ADD_USER_TO_GROUP: "admin:AddUserToGroup",
+ ADMIN_REMOVE_USER_FROM_GROUP: "admin:RemoveUserFromGroup",
+ ADMIN_GET_GROUP: "admin:GetGroup",
+ ADMIN_ENABLE_GROUP: "admin:EnableGroup",
+ ADMIN_DISABLE_GROUP: "admin:DisableGroup",
S3_ALL_ACTIONS: "s3:*",
ADMIN_ALL_ACTIONS: "admin:*",
};
diff --git a/portal-ui/src/screens/Console/Groups/Groups.tsx b/portal-ui/src/screens/Console/Groups/Groups.tsx
index bfdadc9f1..54e3537e0 100644
--- a/portal-ui/src/screens/Console/Groups/Groups.tsx
+++ b/portal-ui/src/screens/Console/Groups/Groups.tsx
@@ -43,6 +43,13 @@ import history from "../../../history";
import AButton from "../Common/AButton/AButton";
import PageLayout from "../Common/Layout/PageLayout";
import SearchBox from "../Common/SearchBox";
+import {
+ CONSOLE_UI_RESOURCE,
+ IAM_SCOPES,
+} from "../../../common/SecureComponent/permissions";
+import SecureComponent, {
+ hasPermission,
+} from "../../../common/SecureComponent/SecureComponent";
interface IGroupsProps {
classes: any;
@@ -85,27 +92,43 @@ const Groups = ({ classes, setErrorSnackMessage }: IGroupsProps) => {
isLoading(true);
}, []);
+ const displayGroups = hasPermission(CONSOLE_UI_RESOURCE, [
+ IAM_SCOPES.ADMIN_LIST_GROUPS,
+ ]);
+
+ const deleteGroup = hasPermission(CONSOLE_UI_RESOURCE, [
+ IAM_SCOPES.ADMIN_REMOVE_USER_FROM_GROUP,
+ ]);
+
+ const getGroup = hasPermission(CONSOLE_UI_RESOURCE, [
+ IAM_SCOPES.ADMIN_GET_GROUP,
+ ]);
+
useEffect(() => {
if (loading) {
- const fetchRecords = () => {
- api
- .invoke("GET", `/api/v1/groups`)
- .then((res: GroupsList) => {
- let resGroups: string[] = [];
- if (res.groups !== null) {
- resGroups = res.groups.sort(stringSort);
- }
- setRecords(resGroups);
- isLoading(false);
- })
- .catch((err: ErrorResponseHandler) => {
- setErrorSnackMessage(err);
- isLoading(false);
- });
- };
- fetchRecords();
+ if (displayGroups) {
+ const fetchRecords = () => {
+ api
+ .invoke("GET", `/api/v1/groups`)
+ .then((res: GroupsList) => {
+ let resGroups: string[] = [];
+ if (res.groups !== null) {
+ resGroups = res.groups.sort(stringSort);
+ }
+ setRecords(resGroups);
+ isLoading(false);
+ })
+ .catch((err: ErrorResponseHandler) => {
+ setErrorSnackMessage(err);
+ isLoading(false);
+ });
+ };
+ fetchRecords();
+ } else {
+ isLoading(false);
+ }
}
- }, [loading, setErrorSnackMessage]);
+ }, [loading, setErrorSnackMessage, displayGroups]);
const closeAddModalAndRefresh = () => {
setGroupOpen(false);
@@ -134,8 +157,16 @@ const Groups = ({ classes, setErrorSnackMessage }: IGroupsProps) => {
};
const tableActions = [
- { type: "view", onClick: viewAction },
- { type: "delete", onClick: deleteAction },
+ {
+ type: "view",
+ onClick: viewAction,
+ disableButtonFunction: () => !getGroup,
+ },
+ {
+ type: "delete",
+ onClick: deleteAction,
+ disableButtonFunction: () => !deleteGroup,
+ },
];
return (
@@ -173,19 +204,27 @@ const Groups = ({ classes, setErrorSnackMessage }: IGroupsProps) => {
onChange={setFilter}
classes={classes}
/>
- }
- onClick={() => {
- setSelectedGroup(null);
- setGroupOpen(true);
- }}
+
-
- To get started,{" "}
-
+
+ To get started,{" "}
+