// Copyright (C) The Arvados Authors. All rights reserved.
//
// SPDX-License-Identifier: AGPL-3.0
-import * as React from 'react';
+import React from 'react';
import { compose } from "redux";
import { reduxForm, InjectedFormProps, Field } from 'redux-form';
-import { withDialog, WithDialogProps } from "~/store/dialog/with-dialog";
-import { FormDialog } from '~/components/form-dialog/form-dialog';
-import { TextField } from '~/components/text-field/text-field';
-import { VirtualMachinesResource } from '~/models/virtual-machines';
-import { USER_LENGTH_VALIDATION } from '~/validators/validators';
+import { withDialog, WithDialogProps } from "store/dialog/with-dialog";
+import { FormDialog } from 'components/form-dialog/form-dialog';
+import { TextField } from 'components/text-field/text-field';
+import { VirtualMachinesResource } from 'models/virtual-machines';
+import { USER_LENGTH_VALIDATION, CHOOSE_VM_VALIDATION } from 'validators/validators';
import { InputLabel } from '@material-ui/core';
-import { NativeSelectField } from '~/components/select-field/select-field';
-import { SETUP_SHELL_ACCOUNT_DIALOG, createUser } from '~/store/users/users-actions';
-import { UserResource } from '~/models/user';
-
-interface SetupShellAccountFormDialogData {
- email: string;
- virtualMachineName: string;
- groupVirtualMachine: string;
-}
+import { NativeSelectField } from 'components/select-field/select-field';
+import { SetupShellAccountFormDialogData, SETUP_SHELL_ACCOUNT_DIALOG, setupUserVM } from 'store/users/users-actions';
+import { UserResource } from 'models/user';
export const SetupShellAccountDialog = compose(
withDialog(SETUP_SHELL_ACCOUNT_DIALOG),
reduxForm<SetupShellAccountFormDialogData>({
form: SETUP_SHELL_ACCOUNT_DIALOG,
onSubmit: (data, dispatch) => {
- dispatch(createUser(data));
+ dispatch(setupUserVM(data));
}
})
)(
<span>
<Field
name='email'
- component={TextField}
+ component={TextField as any}
disabled
label={data.user.email} /></span>;
<InputLabel>Virtual Machine</InputLabel>
<Field
name='virtualMachine'
- component={NativeSelectField}
- validate={USER_LENGTH_VALIDATION}
+ component={NativeSelectField as any}
+ validate={CHOOSE_VM_VALIDATION}
items={getVirtualMachinesList(data.items)} />
</div>;
const UserGroupsVirtualMachineField = () =>
<Field
name='groups'
- component={TextField}
+ component={TextField as any}
validate={USER_LENGTH_VALIDATION}
label="Groups for virtual machine (comma separated list)" />;
const getVirtualMachinesList = (virtualMachines: VirtualMachinesResource[]) =>
- virtualMachines.map(it => ({ key: it.hostname, value: it.hostname }));
+ [{ key: "", value: "" }].concat(virtualMachines.map(it => ({ key: it.hostname, value: it.hostname })));
type SetupShellAccountDialogComponentProps = WithDialogProps<{}> & InjectedFormProps<SetupShellAccountFormDialogData>;
<UserVirtualMachineField data={props.data as DataProps} />
<UserGroupsVirtualMachineField />
</>;
-
-
-