19049: Make participant select read only when editing vm logins
[arvados-workbench2.git] / src / views-components / virtual-machines-dialog / add-login-dialog.tsx
index d9547d7c609a93e3a1e4797e2c9c9cc62c28d733..517734182bb3f037349707b9f37b620eda0d6700 100644 (file)
@@ -35,7 +35,7 @@ const AddLoginFormFields = (props) => {
     return <>
         <ParticipantField
             name={VIRTUAL_MACHINE_ADD_LOGIN_USER_FIELD}
-            component={UserSelect}
+            component={props.data.updating ? ReadOnlyUserSelect : UserSelect}
             excludedParticipants={props.data.excludedParticipants}
         />
         <GroupArrayInput
@@ -46,7 +46,6 @@ const AddLoginFormFields = (props) => {
     </>;
 }
 
-
 interface UserFieldProps {
     excludedParticipants: string[];
 }
@@ -61,3 +60,10 @@ const UserSelect = (props) =>
         excludedParticipants={props.excludedParticipants}
         onSelect={props.input.onChange}
         onDelete={() => (props.input.onChange(''))} />;
+
+const ReadOnlyUserSelect = (props) =>
+        <ParticipantSelect
+            onlyPeople
+            label='User'
+            items={props.input.value ? [props.input.value] : []}
+            disabled={true} />;