// Copyright (C) The Arvados Authors. All rights reserved. // // SPDX-License-Identifier: AGPL-3.0 import React from 'react'; import { Field, InjectedFormProps } from "redux-form"; import { TextField } from "components/text-field/text-field"; import { DataExplorer } from "views-components/data-explorer/data-explorer"; import { NativeSelectField } from "components/select-field/select-field"; import { StyleRulesCallback, WithStyles, withStyles, Card, CardContent, Button, Typography, Grid, InputLabel, Tabs, Tab, Paper } from '@material-ui/core'; import { ArvadosTheme } from 'common/custom-theme'; import { User } from "models/user"; import { DataTableDefaultView } from 'components/data-table-default-view/data-table-default-view'; import { MY_ACCOUNT_VALIDATION } from "validators/validators"; import { USER_PROFILE_PANEL_ID } from 'store/user-profile/user-profile-actions'; import { noop } from 'lodash'; import { GroupsIcon } from 'components/icon/icon'; import { DataColumns } from 'components/data-table/data-table'; import { ResourceLinkHeadUuid, ResourceLinkHeadPermissionLevel, ResourceLinkHead, ResourceLinkDelete, ResourceLinkTailIsVisible } from 'views-components/data-explorer/renderers'; import { createTree } from 'models/tree'; type CssRules = 'root' | 'adminRoot' | 'gridItem' | 'label' | 'readOnlyValue' | 'title' | 'description' | 'actions' | 'content'; const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ root: { width: '100%', overflow: 'auto' }, adminRoot: { // ...theme.mixins.gutters() }, gridItem: { height: 45, marginBottom: 20 }, label: { fontSize: '0.675rem', color: theme.palette.grey['600'] }, readOnlyValue: { fontSize: '0.875rem', }, title: { fontSize: '1.1rem', }, description: { color: theme.palette.grey["600"] }, actions: { display: 'flex', justifyContent: 'flex-end' }, content: { // reserve space for the tab bar height: `calc(100% - ${theme.spacing.unit * 7}px)`, } }); export interface UserProfilePanelRootActionProps { openSetupShellAccount: (uuid: string) => void; loginAs: (uuid: string) => void; openDeactivateDialog: (uuid: string) => void; } export interface UserProfilePanelRootDataProps { isAdmin: boolean; isSelf: boolean; isPristine: boolean; isValid: boolean; initialValues?: User; localCluster: string; } const RoleTypes = [ { key: '', value: '' }, { key: 'Bio-informatician', value: 'Bio-informatician' }, { key: 'Data Scientist', value: 'Data Scientist' }, { key: 'Analyst', value: 'Analyst' }, { key: 'Researcher', value: 'Researcher' }, { key: 'Software Developer', value: 'Software Developer' }, { key: 'System Administrator', value: 'System Administrator' }, { key: 'Other', value: 'Other' } ]; type UserProfilePanelRootProps = InjectedFormProps<{}> & UserProfilePanelRootActionProps & UserProfilePanelRootDataProps & WithStyles; export enum UserProfileGroupsColumnNames { NAME = "Name", PERMISSION = "Permission", VISIBLE = "Visible to other members", UUID = "UUID", REMOVE = "Remove", } enum TABS { PROFILE = "PROFILE", GROUPS = "GROUPS", ADMIN = "ADMIN", } export const userProfileGroupsColumns: DataColumns = [ { name: UserProfileGroupsColumnNames.NAME, selected: true, configurable: true, filters: createTree(), render: uuid => }, { name: UserProfileGroupsColumnNames.PERMISSION, selected: true, configurable: true, filters: createTree(), render: uuid => }, { name: UserProfileGroupsColumnNames.VISIBLE, selected: true, configurable: true, filters: createTree(), render: uuid => }, { name: UserProfileGroupsColumnNames.UUID, selected: true, configurable: true, filters: createTree(), render: uuid => }, { name: UserProfileGroupsColumnNames.REMOVE, selected: true, configurable: true, filters: createTree(), render: uuid => }, ]; const ReadOnlyField = withStyles(styles)( (props: ({ label: string, input: {value: string} }) & WithStyles ) => ( {props.label} {props.input.value} ) ); export const UserProfilePanelRoot = withStyles(styles)( class extends React.Component { state = { value: TABS.PROFILE, }; componentDidMount() { this.setState({ value: TABS.PROFILE}); } render() { return {this.props.isAdmin && } {this.state.value === TABS.PROFILE &&
Role
} {this.state.value === TABS.GROUPS &&
} />
} {this.props.isAdmin && this.state.value === TABS.ADMIN && Setup Account This button sets up a user. After setup, they will be able use Arvados. This dialog box also allows you to optionally set up a shell account for this user. The login name is automatically generated from the user's e-mail address. Deactivate As an admin, you can deactivate and reset this user. This will remove all repository/VM permissions for the user. If you "setup" the user again, the user will have to sign the user agreement again. You may also want to reassign data ownership. Log In As an admin, you can log in as this user. When you’ve finished, you will need to log out and log in again with your own account. }
; } handleChange = (event: React.MouseEvent, value: number) => { this.setState({ value }); } } );