diff --git a/awx/ui_next/src/screens/User/shared/UserForm.jsx b/awx/ui_next/src/screens/User/shared/UserForm.jsx
index 002cb5c9d2..60ffd35d36 100644
--- a/awx/ui_next/src/screens/User/shared/UserForm.jsx
+++ b/awx/ui_next/src/screens/User/shared/UserForm.jsx
@@ -4,6 +4,7 @@ import PropTypes from 'prop-types';
import { t } from '@lingui/macro';
import { Formik, useField, useFormikContext } from 'formik';
import { Form, FormGroup } from '@patternfly/react-core';
+import { useConfig } from '../../../contexts/Config';
import AnsibleSelect from '../../../components/AnsibleSelect';
import FormActionGroup from '../../../components/FormActionGroup/FormActionGroup';
import FormField, {
@@ -16,7 +17,7 @@ import { FormColumnLayout } from '../../../components/FormLayout';
function UserFormFields({ user }) {
const { setFieldValue, setFieldTouched } = useFormikContext();
-
+ const { me = {} } = useConfig();
const ldapUser = user.ldap_dn;
const socialAuthUser = user.auth?.length > 0;
const externalAccount = user.external_account;
@@ -119,22 +120,24 @@ function UserFormFields({ user }) {
validate={required(t`Select a value for this field`)}
/>
)}
-
-
-
+ {me.is_superuser && (
+
+
+
+ )}
>
);
}
diff --git a/awx/ui_next/src/screens/User/shared/UserForm.test.jsx b/awx/ui_next/src/screens/User/shared/UserForm.test.jsx
index d2bb6e3764..69c777bc5b 100644
--- a/awx/ui_next/src/screens/User/shared/UserForm.test.jsx
+++ b/awx/ui_next/src/screens/User/shared/UserForm.test.jsx
@@ -230,4 +230,25 @@ describe('', () => {
wrapper.find('button[aria-label="Cancel"]').invoke('onClick')();
expect(handleCancel).toBeCalled();
});
+
+ test('should not show user type field', async () => {
+ const handleCancel = jest.fn();
+ await act(async () => {
+ wrapper = mountWithContexts(
+ ,
+ {
+ context: {
+ config: {
+ me: { is_superuser: false },
+ },
+ },
+ }
+ );
+ });
+ expect(wrapper.find('FormGroup[label="User Type"]')).toHaveLength(0);
+ });
});