X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/8b6f5c68fa40ad59092e1290dfd4261f0dfe643f..b238c5cec390860b3265238e07b41d62349f70ce:/src/views/groups-panel/groups-panel.tsx

diff --git a/src/views/groups-panel/groups-panel.tsx b/src/views/groups-panel/groups-panel.tsx
index f3f3701b..f50a344b 100644
--- a/src/views/groups-panel/groups-panel.tsx
+++ b/src/views/groups-panel/groups-panel.tsx
@@ -4,8 +4,7 @@
 
 import * as React from 'react';
 import { connect } from 'react-redux';
-import { Grid, Button } from "@material-ui/core";
-
+import { Grid, Button, Typography } from "@material-ui/core";
 import { DataExplorer } from "~/views-components/data-explorer/data-explorer";
 import { DataColumns } from '~/components/data-table/data-table';
 import { SortDirection } from '~/components/data-table/data-column';
@@ -16,11 +15,13 @@ import { createTree } from '~/models/tree';
 import { GROUPS_PANEL_ID, openCreateGroupDialog } from '~/store/groups-panel/groups-panel-actions';
 import { noop } from 'lodash/fp';
 import { ContextMenuKind } from '~/views-components/context-menu/context-menu';
-import { getResource, ResourcesState } from '~/store/resources/resources';
+import { getResource, ResourcesState, filterResources } from '~/store/resources/resources';
 import { GroupResource } from '~/models/group';
 import { RootState } from '~/store/store';
-import { Dispatch } from 'redux';
 import { openContextMenu } from '~/store/context-menu/context-menu-actions';
+import { ResourceKind } from '~/models/resource';
+import { LinkClass, LinkResource } from '~/models/link';
+import { navigateToGroupDetails } from '~/store/navigation/navigation-action';
 
 export enum GroupsPanelColumnNames {
     GROUP = "Name",
@@ -49,7 +50,7 @@ export const groupsPanelColumns: DataColumns<string> = [
         selected: true,
         configurable: true,
         filters: createTree(),
-        render: uuid => <span>0</span>,
+        render: uuid => <GroupMembersCount uuid={uuid} />,
     },
 ];
 
@@ -59,14 +60,17 @@ const mapStateToProps = (state: RootState) => {
     };
 };
 
-const mapDispatchToProps = (dispatch: Dispatch) => ({
-    onContextMenu: (event: React.MouseEvent<HTMLElement>, item: any) => dispatch<any>(openContextMenu(event, item)),
-    onNewGroup: openCreateGroupDialog
-});
+const mapDispatchToProps = {
+    onContextMenu: openContextMenu,
+    onRowDoubleClick: (uuid: string) =>
+        navigateToGroupDetails(uuid),
+    onNewGroup: openCreateGroupDialog,
+};
 
 export interface GroupsPanelProps {
     onNewGroup: () => void;
     onContextMenu: (event: React.MouseEvent<HTMLElement>, item: any) => void;
+    onRowDoubleClick: (item: string) => void;
     resources: ResourcesState;
 }
 
@@ -80,7 +84,7 @@ export const GroupsPanel = connect(
                 <DataExplorer
                     id={GROUPS_PANEL_ID}
                     onRowClick={noop}
-                    onRowDoubleClick={noop}
+                    onRowDoubleClick={this.props.onRowDoubleClick}
                     onContextMenu={this.handleContextMenu}
                     contextMenuColumn={true}
                     hideColumnSelector
@@ -96,7 +100,7 @@ export const GroupsPanel = connect(
                     } />
             );
         }
-        
+
         handleContextMenu = (event: React.MouseEvent<HTMLElement>, resourceUuid: string) => {
             const resource = getResource<GroupResource>(resourceUuid)(this.props.resources);
             if (resource) {
@@ -110,3 +114,20 @@ export const GroupsPanel = connect(
             }
         }
     });
+
+
+const GroupMembersCount = connect(
+    (state: RootState, props: { uuid: string }) => {
+
+        const permissions = filterResources((resource: LinkResource) =>
+            resource.kind === ResourceKind.LINK &&
+            resource.linkClass === LinkClass.PERMISSION &&
+            resource.tailUuid === props.uuid
+        )(state.resources);
+
+        return {
+            children: permissions.length,
+        };
+
+    }
+)(Typography);
