X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/ba9a587ab628caea44d923b34d285a29e83e3456..5e9c2244747eff9fc02ff3c0d140bdde5e0b6845:/src/views/user-panel/user-panel.tsx

diff --git a/src/views/user-panel/user-panel.tsx b/src/views/user-panel/user-panel.tsx
index ceaba8cbf7..8849c12633 100644
--- a/src/views/user-panel/user-panel.tsx
+++ b/src/views/user-panel/user-panel.tsx
@@ -2,52 +2,50 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import * as React from 'react';
-import { WithStyles, withStyles, Typography } from '@material-ui/core';
-import { DataExplorer } from "~/views-components/data-explorer/data-explorer";
+import React from 'react';
+import { WithStyles, withStyles, Paper, Typography } from '@material-ui/core';
+import { DataExplorer } from "views-components/data-explorer/data-explorer";
 import { connect, DispatchProp } from 'react-redux';
-import { DataColumns } from '~/components/data-table/data-table';
-import { RootState } from '~/store/store';
-import { SortDirection } from '~/components/data-table/data-column';
-import { openContextMenu } from "~/store/context-menu/context-menu-actions";
-import { getResource, ResourcesState } from "~/store/resources/resources";
+import { DataColumns } from 'components/data-table/data-table';
+import { RootState } from 'store/store';
+import { SortDirection } from 'components/data-table/data-column';
+import { openUserContextMenu } from "store/context-menu/context-menu-actions";
+import { getResource, ResourcesState } from "store/resources/resources";
 import {
-    ResourceFirstName,
-    ResourceLastName,
+    UserResourceFullName,
     ResourceUuid,
     ResourceEmail,
-    ResourceIsActive,
     ResourceIsAdmin,
-    ResourceUsername
-} from "~/views-components/data-explorer/renderers";
-import { navigateTo } from "~/store/navigation/navigation-action";
-import { loadDetailsPanel } from "~/store/details-panel/details-panel-action";
-import { ContextMenuKind } from "~/views-components/context-menu/context-menu";
-import { DataTableDefaultView } from '~/components/data-table-default-view/data-table-default-view';
-import { createTree } from '~/models/tree';
-import { compose } from 'redux';
-import { UserResource } from '~/models/user';
-import { ShareMeIcon } from '~/components/icon/icon';
-import { USERS_PANEL_ID } from '~/store/users/users-actions';
+    ResourceUsername,
+    UserResourceAccountStatus,
+} from "views-components/data-explorer/renderers";
+import { navigateToUserProfile } from "store/navigation/navigation-action";
+import { createTree } from 'models/tree';
+import { compose, Dispatch } from 'redux';
+import { UserResource } from 'models/user';
+import { ShareMeIcon } from 'components/icon/icon';
+import { USERS_PANEL_ID, openUserCreateDialog } from 'store/users/users-actions';
+import { noop } from 'lodash';
 
-type UserPanelRules = "toolbar" | "button";
+type UserPanelRules = "button" | 'root';
 
 const styles = withStyles<UserPanelRules>(theme => ({
-    toolbar: {
-        paddingBottom: theme.spacing.unit * 3,
-        textAlign: "right"
-    },
     button: {
-        marginLeft: theme.spacing.unit
+        marginTop: theme.spacing.unit,
+        marginRight: theme.spacing.unit * 2,
+        textAlign: 'right',
+        alignSelf: 'center'
+    },
+    root: {
+        width: '100%',
     },
 }));
 
 export enum UserPanelColumnNames {
-    FIRST_NAME = "First Name",
-    LAST_NAME = "Last Name",
+    NAME = "Name",
     UUID = "Uuid",
     EMAIL = "Email",
-    ACTIVE = "Active",
+    STATUS = "Account Status",
     ADMIN = "Admin",
     REDIRECT_TO_USER = "Redirect to user",
     USERNAME = "Username"
@@ -55,20 +53,12 @@ export enum UserPanelColumnNames {
 
 export const userPanelColumns: DataColumns<string> = [
     {
-        name: UserPanelColumnNames.FIRST_NAME,
+        name: UserPanelColumnNames.NAME,
         selected: true,
         configurable: true,
         sortDirection: SortDirection.NONE,
         filters: createTree(),
-        render: uuid => <ResourceFirstName uuid={uuid} />
-    },
-    {
-        name: UserPanelColumnNames.LAST_NAME,
-        selected: true,
-        configurable: true,
-        sortDirection: SortDirection.NONE,
-        filters: createTree(),
-        render: uuid => <ResourceLastName uuid={uuid} />
+        render: uuid => <UserResourceFullName uuid={uuid} link={true} />
     },
     {
         name: UserPanelColumnNames.UUID,
@@ -87,29 +77,19 @@ export const userPanelColumns: DataColumns<string> = [
         render: uuid => <ResourceEmail uuid={uuid} />
     },
     {
-        name: UserPanelColumnNames.ACTIVE,
+        name: UserPanelColumnNames.STATUS,
         selected: true,
         configurable: true,
-        sortDirection: SortDirection.NONE,
         filters: createTree(),
-        render: uuid => <ResourceIsActive uuid={uuid} />
+        render: uuid => <UserResourceAccountStatus uuid={uuid} />
     },
     {
         name: UserPanelColumnNames.ADMIN,
         selected: true,
         configurable: false,
-        sortDirection: SortDirection.NONE,
         filters: createTree(),
         render: uuid => <ResourceIsAdmin uuid={uuid} />
     },
-    {
-        name: UserPanelColumnNames.REDIRECT_TO_USER,
-        selected: true,
-        configurable: false,
-        sortDirection: SortDirection.NONE,
-        filters: createTree(),
-        render: () => <Typography noWrap>(none)</Typography>
-    },
     {
         name: UserPanelColumnNames.USERNAME,
         selected: true,
@@ -124,48 +104,62 @@ interface UserPanelDataProps {
     resources: ResourcesState;
 }
 
-type UserPanelProps = UserPanelDataProps & DispatchProp & WithStyles<UserPanelRules>;
+interface UserPanelActionProps {
+    openUserCreateDialog: () => void;
+    handleRowClick: (uuid: string) => void;
+    handleContextMenu: (event, resource: UserResource) => void;
+}
+
+const mapStateToProps = (state: RootState) => {
+    return {
+        resources: state.resources
+    };
+};
+
+const mapDispatchToProps = (dispatch: Dispatch) => ({
+    openUserCreateDialog: () => dispatch<any>(openUserCreateDialog()),
+    handleRowClick: (uuid: string) => dispatch<any>(navigateToUserProfile(uuid)),
+    handleContextMenu: (event, resource: UserResource) => dispatch<any>(openUserContextMenu(event, resource)),
+});
+
+type UserPanelProps = UserPanelDataProps & UserPanelActionProps & DispatchProp & WithStyles<UserPanelRules>;
 
 export const UserPanel = compose(
     styles,
-    connect((state: RootState) => ({
-        resources: state.resources
-    })))(
+    connect(mapStateToProps, mapDispatchToProps))(
         class extends React.Component<UserPanelProps> {
             render() {
-                return <DataExplorer
-                    id={USERS_PANEL_ID}
-                    onRowClick={this.handleRowClick}
-                    onRowDoubleClick={this.handleRowDoubleClick}
-                    onContextMenu={this.handleContextMenu}
-                    contextMenuColumn={true}
-                    isColumnSelectorHidden={true}
-                    dataTableDefaultView={
-                        <DataTableDefaultView
-                            icon={ShareMeIcon}
-                            messages={['Your user list is empty.']} />
-                    } />;
+                return <Paper className={this.props.classes.root}>
+                    <DataExplorer
+                        id={USERS_PANEL_ID}
+                        title={
+                            <>
+                                <Typography>
+                                    User records are created automatically on first log in.
+                                </Typography>
+                                <Typography>
+                                    To add a new user, add them to your configured log in provider.
+                                </Typography>
+                            </>}
+                        onRowClick={noop}
+                        onRowDoubleClick={noop}
+                        onContextMenu={this.handleContextMenu}
+                        contextMenuColumn={true}
+                        hideColumnSelector
+                        paperProps={{
+                            elevation: 0,
+                        }}
+                        defaultViewIcon={ShareMeIcon}
+                        defaultViewMessages={['Your user list is empty.']} />
+                </Paper>;
             }
 
             handleContextMenu = (event: React.MouseEvent<HTMLElement>, resourceUuid: string) => {
+                event.stopPropagation();
                 const resource = getResource<UserResource>(resourceUuid)(this.props.resources);
                 if (resource) {
-                    this.props.dispatch<any>(openContextMenu(event, {
-                        name: '',
-                        uuid: resource.uuid,
-                        ownerUuid: resource.ownerUuid,
-                        kind: resource.kind,
-                        menuKind: ContextMenuKind.USER
-                    }));
+                    this.props.handleContextMenu(event, resource);
                 }
             }
-
-            handleRowDoubleClick = (uuid: string) => {
-                this.props.dispatch<any>(navigateTo(uuid));
-            }
-
-            handleRowClick = (uuid: string) => {
-                this.props.dispatch(loadDetailsPanel(uuid));
-            }
         }
     );
