// Copyright (C) The Arvados Authors. All rights reserved. // // SPDX-License-Identifier: AGPL-3.0 import * as React from 'react'; import { WithStyles, withStyles, Typography, Tabs, Tab, Paper, Button } 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 { ResourceFirstName, ResourceLastName, ResourceUuid, ResourceEmail, ResourceIsActive, ResourceIsAdmin, ResourceUsername } from "~/views-components/data-explorer/renderers"; import { navigateTo } from "~/store/navigation/navigation-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, Dispatch } from 'redux'; import { UserResource } from '~/models/user'; import { ShareMeIcon, AddIcon } from '~/components/icon/icon'; import { USERS_PANEL_ID, openUserCreateDialog } from '~/store/users/users-actions'; type UserPanelRules = "button"; const styles = withStyles(theme => ({ button: { marginTop: theme.spacing.unit, marginRight: theme.spacing.unit * 2, textAlign: 'right', alignSelf: 'center' }, })); export enum UserPanelColumnNames { FIRST_NAME = "First Name", LAST_NAME = "Last Name", UUID = "Uuid", EMAIL = "Email", ACTIVE = "Active", ADMIN = "Admin", REDIRECT_TO_USER = "Redirect to user", USERNAME = "Username" } export const userPanelColumns: DataColumns = [ { name: UserPanelColumnNames.FIRST_NAME, selected: true, configurable: true, sortDirection: SortDirection.NONE, filters: createTree(), render: uuid => }, { name: UserPanelColumnNames.LAST_NAME, selected: true, configurable: true, sortDirection: SortDirection.NONE, filters: createTree(), render: uuid => }, { name: UserPanelColumnNames.UUID, selected: true, configurable: true, sortDirection: SortDirection.NONE, filters: createTree(), render: uuid => }, { name: UserPanelColumnNames.EMAIL, selected: true, configurable: true, sortDirection: SortDirection.NONE, filters: createTree(), render: uuid => }, { name: UserPanelColumnNames.ACTIVE, selected: true, configurable: true, sortDirection: SortDirection.NONE, filters: createTree(), render: uuid => }, { name: UserPanelColumnNames.ADMIN, selected: true, configurable: false, sortDirection: SortDirection.NONE, filters: createTree(), render: uuid => }, { name: UserPanelColumnNames.REDIRECT_TO_USER, selected: true, configurable: false, sortDirection: SortDirection.NONE, filters: createTree(), render: () => (none) }, { name: UserPanelColumnNames.USERNAME, selected: true, configurable: false, sortDirection: SortDirection.NONE, filters: createTree(), render: uuid => } ]; interface UserPanelDataProps { resources: ResourcesState; } interface UserPanelActionProps { openUserCreateDialog: () => void; handleRowDoubleClick: (uuid: string) => void; onContextMenu: (event: React.MouseEvent, item: any) => void; } const mapStateToProps = (state: RootState) => { return { resources: state.resources }; }; const mapDispatchToProps = (dispatch: Dispatch) => ({ openUserCreateDialog: () => dispatch(openUserCreateDialog()), handleRowDoubleClick: (uuid: string) => dispatch(navigateTo(uuid)), onContextMenu: (event: React.MouseEvent, item: any) => dispatch(openContextMenu(event, item)) }); type UserPanelProps = UserPanelDataProps & UserPanelActionProps & DispatchProp & WithStyles; export const UserPanel = compose( styles, connect(mapStateToProps, mapDispatchToProps))( class extends React.Component { state = { value: 0, }; componentDidMount() { this.setState({ value: 0 }); } render() { const { value } = this.state; return {value === 0 &&
} />
}
; } handleChange = (event: React.MouseEvent, value: number) => { this.setState({ value }); } handleContextMenu = (event: React.MouseEvent, resourceUuid: string) => { const resource = getResource(resourceUuid)(this.props.resources); if (resource) { this.props.onContextMenu(event, { name: '', uuid: resource.uuid, ownerUuid: resource.ownerUuid, kind: resource.kind, menuKind: ContextMenuKind.USER }); } } handleRowDoubleClick = (uuid: string) => { this.props.handleRowDoubleClick(uuid); } handleRowClick = () => { return; } } );