X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/1dcbe2d0ec3fdc613edca3a490d0adfce023a803..7e1669d2263cdf8e9066057fd126007b755ba7f5:/src/views/group-details-panel/group-details-panel.tsx

diff --git a/src/views/group-details-panel/group-details-panel.tsx b/src/views/group-details-panel/group-details-panel.tsx
index b4a8c6d3..9f2d3f41 100644
--- a/src/views/group-details-panel/group-details-panel.tsx
+++ b/src/views/group-details-panel/group-details-panel.tsx
@@ -7,23 +7,23 @@ import { connect } from 'react-redux';
 
 import { DataExplorer } from "views-components/data-explorer/data-explorer";
 import { DataColumns } from 'components/data-table/data-table';
-import { ResourceLinkHeadUuid, ResourceLinkTailUuid, ResourceLinkTailEmail, ResourceLinkTailUsername, ResourceLinkHeadPermissionLevel, ResourceLinkTailPermissionLevel, ResourceLinkHead, ResourceLinkTail, ResourceLinkDelete } from 'views-components/data-explorer/renderers';
+import { ResourceLinkHeadUuid, ResourceLinkTailUsername, ResourceLinkHeadPermissionLevel, ResourceLinkTailPermissionLevel, ResourceLinkHead, ResourceLinkTail, ResourceLinkDelete, ResourceLinkTailIsActive, ResourceLinkTailIsVisible } from 'views-components/data-explorer/renderers';
 import { createTree } from 'models/tree';
 import { noop } from 'lodash/fp';
 import { RootState } from 'store/store';
-import { GROUP_DETAILS_MEMBERS_PANEL_ID, GROUP_DETAILS_PERMISSIONS_PANEL_ID, openAddGroupMembersDialog } from 'store/group-details-panel/group-details-panel-actions';
+import { GROUP_DETAILS_MEMBERS_PANEL_ID, GROUP_DETAILS_PERMISSIONS_PANEL_ID, openAddGroupMembersDialog, getCurrentGroupDetailsPanelUuid } from 'store/group-details-panel/group-details-panel-actions';
 import { openContextMenu } from 'store/context-menu/context-menu-actions';
 import { ResourcesState, getResource } from 'store/resources/resources';
-import { ContextMenuKind } from 'views-components/context-menu/context-menu';
-import { PermissionResource } from 'models/permission';
 import { Grid, Button, Tabs, Tab, Paper } from '@material-ui/core';
 import { AddIcon } from 'components/icon/icon';
+import { getUserUuid } from 'common/getuser';
+import { GroupResource, isBuiltinGroup } from 'models/group';
 
 export enum GroupDetailsPanelMembersColumnNames {
     FULL_NAME = "Name",
-    UUID = "UUID",
-    EMAIL = "Email",
     USERNAME = "Username",
+    ACTIVE = "User Active",
+    VISIBLE = "Visible to other members",
     PERMISSION = "Permission",
     REMOVE = "Remove",
 }
@@ -51,25 +51,25 @@ export const groupDetailsMembersPanelColumns: DataColumns<string> = [
         render: uuid => <ResourceLinkTailUsername uuid={uuid} />
     },
     {
-        name: GroupDetailsPanelMembersColumnNames.EMAIL,
+        name: GroupDetailsPanelMembersColumnNames.ACTIVE,
         selected: true,
         configurable: true,
         filters: createTree(),
-        render: uuid => <ResourceLinkTailEmail uuid={uuid} />
+        render: uuid => <ResourceLinkTailIsActive uuid={uuid} />
     },
     {
-        name: GroupDetailsPanelMembersColumnNames.PERMISSION,
+        name: GroupDetailsPanelMembersColumnNames.VISIBLE,
         selected: true,
         configurable: true,
         filters: createTree(),
-        render: uuid => <ResourceLinkTailPermissionLevel uuid={uuid} />
+        render: uuid => <ResourceLinkTailIsVisible uuid={uuid} />
     },
     {
-        name: GroupDetailsPanelMembersColumnNames.UUID,
+        name: GroupDetailsPanelMembersColumnNames.PERMISSION,
         selected: true,
         configurable: true,
         filters: createTree(),
-        render: uuid => <ResourceLinkTailUuid uuid={uuid} />
+        render: uuid => <ResourceLinkTailPermissionLevel uuid={uuid} />
     },
     {
         name: GroupDetailsPanelMembersColumnNames.REMOVE,
@@ -112,8 +112,15 @@ export const groupDetailsPermissionsPanelColumns: DataColumns<string> = [
 ];
 
 const mapStateToProps = (state: RootState) => {
+    const groupUuid = getCurrentGroupDetailsPanelUuid(state.properties);
+    const group = getResource<GroupResource>(groupUuid || '')(state.resources);
+    const userUuid = getUserUuid(state);
+
     return {
-        resources: state.resources
+        resources: state.resources,
+        groupCanManage: userUuid && !isBuiltinGroup(group?.uuid || '')
+                            ? group?.writableBy?.includes(userUuid)
+                            : false,
     };
 };
 
@@ -126,6 +133,7 @@ export interface GroupDetailsPanelProps {
     onContextMenu: (event: React.MouseEvent<HTMLElement>, item: any) => void;
     onAddUser: () => void;
     resources: ResourcesState;
+    groupCanManage: boolean;
 }
 
 export const GroupDetailsPanel = connect(
@@ -145,12 +153,13 @@ export const GroupDetailsPanel = connect(
             return (
                 <Paper>
                   <Tabs value={value} onChange={this.handleChange} variant="fullWidth">
-                      <Tab label="MEMBERS" />
-                      <Tab label="PERMISSIONS" />
+                      <Tab data-cy="group-details-members-tab" label="MEMBERS" />
+                      <Tab data-cy="group-details-permissions-tab" label="PERMISSIONS" />
                   </Tabs>
                   {value === 0 &&
                       <DataExplorer
                           id={GROUP_DETAILS_MEMBERS_PANEL_ID}
+                          data-cy="group-members-data-explorer"
                           onRowClick={noop}
                           onRowDoubleClick={noop}
                           onContextMenu={noop}
@@ -158,14 +167,16 @@ export const GroupDetailsPanel = connect(
                           hideColumnSelector
                           hideSearchInput
                           actions={
-                              <Grid container justify='flex-end'>
-                                  <Button
+                                this.props.groupCanManage &&
+                                <Grid container justify='flex-end'>
+                                    <Button
+                                      data-cy="group-member-add"
                                       variant="contained"
                                       color="primary"
                                       onClick={this.props.onAddUser}>
                                       <AddIcon /> Add user
-                              </Button>
-                              </Grid>
+                                    </Button>
+                                </Grid>
                           }
                           paperProps={{
                               elevation: 0,
@@ -174,6 +185,7 @@ export const GroupDetailsPanel = connect(
                   {value === 1 &&
                       <DataExplorer
                           id={GROUP_DETAILS_PERMISSIONS_PANEL_ID}
+                          data-cy="group-permissions-data-explorer"
                           onRowClick={noop}
                           onRowDoubleClick={noop}
                           onContextMenu={noop}
@@ -188,19 +200,6 @@ export const GroupDetailsPanel = connect(
             );
         }
 
-        handleContextMenu = (event: React.MouseEvent<HTMLElement>, resourceUuid: string) => {
-            const resource = getResource<PermissionResource>(resourceUuid)(this.props.resources);
-            if (resource) {
-                this.props.onContextMenu(event, {
-                    name: '',
-                    uuid: resource.uuid,
-                    ownerUuid: resource.ownerUuid,
-                    kind: resource.kind,
-                    menuKind: ContextMenuKind.GROUP_MEMBER
-                });
-            }
-        }
-
         handleChange = (event: React.MouseEvent<HTMLElement>, value: number) => {
             this.setState({ value });
         }
